Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 3 > Sonar for Robot Navigation Issues

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Sonar for Robot Navigation Issues
Moderator:
RKRM

Post Reply
Follow this topic



Sonar for Robot Navigation Issues

RealChemist posted on 12 Mar 2012 2:03 PM PST
Member
9 Forum Posts

Hey all,

For the senior design project at my university, my group was assigned a robot that would serve as a wandering information kiosk for the campus.  I was placed in charge of sensor integration.  The sonars that our group decided to use can output an analog voltage level that corresponds to detected range or a pulse whose width corresponds to the detected range.  To get a handle on the PSoC 3 I created a quick proof of concept program that would take in the analog votlage level and convert it to a digital value.  To test it out I breadboarded the PSoC 3 and hooked it up to a power supply so I could easily and precisely change the voltage.  The problem is that no matter what I change the voltage level to, GetResult always returns a value that is approx 22,000 or 0x5850 in hex.

So far in my troubleshooting efforts I have assumed, from talking to friends on similar projects, that the ADC returns a value that is scaled so that the resolution matches the acceptable input voltage range IE 0-6.14 volt range divided by 2^16 (16 bits of resolution). 

 

Attached is my simple project so far,




Re: Sonar for Robot Navigation Issues

Gautam Das posted on 13 Mar 2012 10:07 PM PST
Cypress Employee
742 Forum Posts

Hi RealChemist,

 

You have made a mention that the sonars you have chosen can give output in the form of analog voltage level that corresponds to the detected range or a pulse whose width corresponds to detected range.

I presume that you are testing out the former method. Is that right?

 

After looking into the project, here are the following points that needs attention:

 

1) The Conversion Mode of ADC has to be "Continuous" in this case as a single channel ADC is used.

2) How are you measuring the ADC counts? You can use the character LCD while testing so that you can see visually the change in ADC counts when voltage is changed.

3) SInce you are ADC with 16-bit resolution, use ADC_DelSig_1_GetResult32() API to get the ADC value and the variable can be unsigned integer (uint32) rather than integer as the ADC is in single ended mode.

 



Re: Sonar for Robot Navigation Issues

RealChemist posted on 14 Mar 2012 01:41 PM PST
Member
9 Forum Posts

Yes the voltage level method is the one that I am using. 

After making the changes you suggested it seems to work to voltages up to 3V. 

Measurements:

0V   ~14 (decimal)

1V    ~11000 (decimal)

2V    ~23000 (decimal)

3V    ~32000 (decimal)

4V    ~35000 (decimal)

5V    ~36000 (decimal)

The acceptable input voltage is up to 6V so I do not know why it cannot detect anything much higher than 3V.  I uploaded the updated project.  Thanks for the help!



Re: Sonar for Robot Navigation Issues

Gautam Das posted on 15 Mar 2012 11:36 PM PST
Cypress Employee
742 Forum Posts

Hi RealChemist,

 

Which kit are you using?

If you are using CY8CKIT-001 kit, please make sure that the power supply of the board is set to 5V.

The input signal given to PSoC should never exceed the Vdda supply voltage. Hence, if you are powering up the device at 3.3V, then the maximum voltage which you can apply is 3.3V

When you have chosen the Vref as internal 1.024V reference, and set the input range to 6 times Vref (6.144V), it means that theoritically if the input analog voltage reaches 6.114V, the ADC will give its full scale reading.

However, you are limited by the power supply which is provided to PSoC. You can measure upto 5V, if you power up the device with 5V.



Re: Sonar for Robot Navigation Issues

RealChemist posted on 15 Mar 2012 09:19 AM PST
Member
9 Forum Posts

I was given the PSoC 3 first touch starter kit by a teacher to use.  I tried researching this morning but couldnt find what pins I needed to use to supply the board with an external voltage.  There are 28 external I/O pins which didnt match what I found.  I went into the system tab to make sure VDDA was set to 5V and it was.  Mind you I am currently running it off USB so that I am able to debug it.



Re: Sonar for Robot Navigation Issues

RealChemist posted on 15 Mar 2012 09:59 AM PST
Member
9 Forum Posts

I could just run it at 3.3V and power the sonar with 3.3V volts as well and the sonar output will only go up to 3V.



Re: Sonar for Robot Navigation Issues

Bob Marlowe posted on 15 Mar 2012 12:13 PM PST
Top Contributor
1768 Forum Posts

You may download the schematics for your first-touch-kit from the Cypress website at:  http://www.cypress.com/?docID=31295 

If possible, you ought to run your sonar with the same voltage as your PSoC runs.

In my opinion it is easier to measure a pulse-width than a voltage, especially when multiple sensors have to be attached.

 

Bob



Re: Sonar for Robot Navigation Issues

RealChemist posted on 16 Mar 2012 07:14 AM PST
Member
9 Forum Posts

 Im assuming you would use a timer for that?  I looked into doing that but it seemed more complicated to implement.



Re: Sonar for Robot Navigation Issues

Bob Marlowe posted on 16 Mar 2012 07:46 AM PST
Top Contributor
1768 Forum Posts

You may use a counter-module (UDB), Up-Counter, set the capture-input as needed (depends on the polarity of your signal to measure) enable(hardware only) the counter with your signal and set re-load on capture, TC and reset. Set the clock to Bus-Clock and the count input to a frequency giving a reasonable  resolution. Take care that the input-clock is synchron to bus-clock.

That's it

In the main-loop read the status of the timer and look for a captured value.

Very easy approach even when you need to handle multiple sensors which can be annoying with only one ADC

 

Bob



Re: Sonar for Robot Navigation Issues

RealChemist posted on 16 Mar 2012 10:19 AM PST
Member
9 Forum Posts

Here is the data sheet for the sonar we are using FYI

http://www.robotshop.com/PDF/LV-MaxSonar-WR1-Datasheet.pdf

 

According to the data sheet, is it safe to assume at the period of the output pulse is going to be 47ms + Pulse Width?  In the timing description it says that rangings are available every 47 ms.  Assuming this is correct, in order to use a counter I would have to be able to measure the period of measurement as well.  To clarify, I would have to  be able to determine how many clock periods went by while the counter was enabled (when the input signal is high)

 

Sorry for any silly questions.  Its been awhile since Ive programmed anything and I am far out of my comfort range considering my favorite courses in my curriculum were the semiconductor ones...



Re: Sonar for Robot Navigation Issues

Bob Marlowe posted on 16 Mar 2012 01:15 PM PST
Top Contributor
1768 Forum Posts

Use a count-frequency of 27,211Hz which will give a resolution of 1/4 inch. 

Max measure is 37.338 ms giving a max count of about 1000.

Period is 50ms, so period value should be 1360. Seems as if a 16-bit counter is enough, set period to 30000, then capturing will always reset the counter, when counter overflows (there is a status-bit for that) sonar doesn't work.

But there is something in your device making everything easier, it has a built-in UART with which you can communicate. Voltages are ok, just drop a UART module and configure it as a receiver with a buffer. 

 

Bob



Re: Sonar for Robot Navigation Issues

Eilrem posted on 21 Apr 2012 03:54 AM PST
Cypress Employee
17 Forum Posts

Why not use a resistor ladder in the input? Same resistor values will will allow you to double the input voltage range.






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20