Questions on Sonar from the Palo Verde MHS Engineering Dept

Hello, this is the new account for the PVHS group, we had been using one member’s account before and felt bad when we made posts in his name (we kinda had to at the time).

We are working on a sonar unit for our rover. We probably will not be the ones to finish this particular part, but we are responsible for the basic groundwork, such as making said sonar work with our 28-pin Basic Atom and Bot Board.

The sample code we found that is giving us problems for the moment is as follows.

[code]wDist var word
convfac var word

main
convfac = 74
gosub sr_sonar
debug DEC wDist, cr
pause 200
gotomain

sr_sonar:
pulsout P0, 5
pulsin P0, 1, wDist
wDist = wDist/convfac
pause 10
return

sr_sonar_2:
pulsout P0, 5
output P0
rctime P0, 1, wDist
wDist = wDist/convfac
pause 10
return
[/code]

The problem is in line 7, and no matter what I tried personally the error stayed there and merely changed faces. Usually the error is Unexpected Token type (DEC) or “Expected “.

I would link to the exact site where you can see the sonar unit but I can’t with this account yet, once it allows me to I will if I need to.

Looks like you’ve got the syntax for DEBUG incorrect.

I’m not a programmer, but I did a lot of reading while I put the information from the manual into wiki format. ;D

I believe you’re looking for something more like this:

debug [DEC wDist,cr]

Check out this page for more information:
basicmicro.wikia.com/wiki/MBasic … 1%29#DEBUG

If you have any questions, feel free to ask!

Hi, I’m part of the new year for this project. I have the orginal topic starter for this project sitting next to me.

He said he could never get it to work. Saying that reading he got were weird, and never read accurately (Get diffrent reading for the same distance of an object.)

I’m relitively new to the program and enginnering itself and I’m wondering if you guys could give me some pointers and helpful tips so I can get it working at least.

And by “it” I mean the sonar.

If you need anymore information, just ask and I’ll try to give it to you.

Well it might be a good place to start by actually connecting everything and downloading the program. Then you can tell us exactly what errors you are getting.

We would also need to know which version of the IDE are you using?

An image of the wiring would help.

This is not a complicated project. Sad to see it drag on for so long.

IDE number - Basic ATOM-pro 07.2.0.7
Copyright © 2003

We’ll probably get the image or the wiring this week or next week. It’ll Depending when we start the wiring.

We have all the stuff downloaded as well. I’m going to play with it for a bit and I’ll have more information for you then.

Ok the IDE you are using is old. Go the the Basic Micro website and DL the 8.0.1.7 file.

In the meantime this thread may help. It’s for the Ping not the SRF-04 though.
lynxmotion.net/viewtopic.php?p=17280#17280

Here it is. It took me a couple hours to get it sorted out. This is for the IDE ver 8.0.1.7. It will work with the Mini-ABB and the Bot Board.

I hope I get a good grade! :unamused:

[code]wdist var word
low p10 ;pin to initiate the sensor
low P11 ;pin to measure the return pulse

main:
pause 10
pulsout p10, 20
pulsin 11, 0, toolong, 40000, wdist
wdist = wdist / 148 ;convert for inches
serout s_out, i9600, "Distance: ", sdec wdist, 13, 10] ;display result in terminal
goto main

toolong: ; if the program gets here the sensor is not functioning, or wired wrong
serout s_out, i9600, “Timeout, sensor is not working”, 13]
goto main[/code]

Ah, Thank you for the codes, (and sorry for the late reply). We tried out the codes and they don’t seem to work.

The one you gave me didn’t compile properly and the sonar/basic atom didn’t seem to want to read it.

And the second one you gave me (the Hello World thing) didn’t want to work at all (error in line 16 it said).

So, we looked at the 8.0 manual and that wasn’t very helpful.

Soooo… We looked at the code our enemys used (AKA: Period 4), and their program worked (it printed out numbers), but it only printed out zeros.

What on earth are you talking about? :open_mouth: :unamused:

From reading above I have no idea who you are talking to… I wrote a program specifically for you. I have tested it and it works flawlessly. Why don’t you tell me what problems you are having with it. To make this SUPER easy I will paste it here so you don’t have to scroll up two posts.

[code]wdist var word
low p10 ;pin to initiate the sensor
low P11 ;pin to measure the return pulse

main:
pause 10
pulsout p10, 20
pulsin 11, 0, toolong, 40000, wdist
wdist = wdist / 148 ;convert for inches
serout s_out, i9600, "Distance: ", sdec wdist, 13, 10] ;display result in terminal
goto main

toolong: ; if the program gets here the sensor is not functioning, or wired wrong
serout s_out, i9600, “Timeout, sensor is not working”, 13]
goto main[/code]

Alrighty, this might help a bit Robot Dude.

We (my team) is working on getting the sonar 28015 Rev A to work so that it reads and prints out distances.

For some reason we conectedBot Board II to a bread board (If that makes sense) and then the Sonar to the Bread Board.

I’m sorry if this dosen’t make sense, i’m working on the information newbies and the people who worked on this last year gave me.

You do realize that a 28015 is a PING, not an SRF-04! Right? :smiling_imp:

People can only help you with an equivalent accuracy as the information they are provided by you. It’s no wonder that the code I wrote for you doesn’t work. You asked for code examples for a sensor you don’t have. :unamused:

We would love to help you fine tune your code. Go ahead and post what you have and we will try to help point you in the right direction… 8)

A photograph or two of what you have wired up wouldn’t hurt one bit at all either… as a matter of fact it probably would have saved a whole lot of time for a lot of people by now since had you posted one oh say 4 months ago then someone might have realized there were only 3 wires going to the sensor and not 4! :open_mouth:

No robot dude, I didn’t realize that at all o.o. That’s is actually very helpful to know that. Thanks =D.

I know, I’m being very…difficult., it’s just that I’m new to engineering and my teacher wants us to program something he never taught us how to program. Thanks for putting up with me =D.

EddieB: I’ll get pictures as soon as I can.

There are these things called cell phones… and I hear some of the newer ones have cameras… and the other day I heard a news story about the high percentage of kids in grade / high school who have these cell phone things these days… hmmm. :wink:

It’s understandable that you’re new and sort of out on a limb, so to speak, with your project. We’re all more than willing to help you out, but you’ve got to meet us in the middle.

Provide us with all of the information you have, in a clear, concise manner. Post pictures of your wiring and the electronics you’re using, diagrams and schematics, whatever you have or can do. Tell us what your project is, the goal and what you hope to accomplish along the way. Show us what you’ve done so far, provide us with code that you’ve written so far.

Like I said, we’re willing to help you out, but we’re not going to do the project for you. The more information you provide, the more we will be able to help! :smiley:

haha, very funny. That actually worked.

http://i163.photobucket.com/albums/t292/Dankscarver/Uberblargh.jpg

http://i163.photobucket.com/albums/t292/Dankscarver/Nya.jpg

http://i163.photobucket.com/albums/t292/Dankscarver/Desu.jpg

http://i163.photobucket.com/albums/t292/Dankscarver/Blargh.jpg

Thank you EddieB for the Idea =D

Correct me if I’m wrong, but according to your pictures, it looks like you have the GND, 5V, and SIG of the PING going to the Bot Board’s IO pins… :unamused:

If that’s true, then no wonder it’s not working, the PING has no power! Unless you’re setting the IO pins to HIGH/LOW in your code, which would work… unless it draws more than 25mA. Connect the 5V to 5V and the GND to GND header pins and that should help…
The header pins on the Bot Board are set up like this:

______ | ATOM | I P G | Pro | / W N | Chip | O R D | | | | o o o <-header pins | | o o o | | o o o | | o o o | |

PWR is dependent on the voltage jumper located above(towards the chip) each IO bus, be sure it’s on 5V.

It also seems that you have wires going into both VS and the VL inputs, and you have the VS=VL jumper installed… where are these wires going to/coming from?

Heh, even a blind squirel finds a nut every now and then. 8)

Color to signal assignment at the ping)) is BLK = GND, RED = +5V, and GRN = SIG… is that correct?

It also very much looks on the bap+abb end like all three of the clips are connected to port pins rather than the red to +5, blk to gnd, and grn to an i/o pin, is that also correct?

if it is correct, the question is then why isn’t it connected red to VL, blk to gnd, and grn to an i/o pin? this configuration is simpler, requires no code to setup power and gnd, and eliminates some other potential problem areas. pick an i/o port, say P4, connect the VS/VL jumper for it in the VL position, and wire the sensor to it. The ping)) is literally designed so you can use a servo extender cable to direct wire it to the 3-pin output header style of an abb. I’ll find some code I know works at home tonight from my rov project which uses all the same parts you have.

edit: aw phooey, Fish beat me to it. :frowning:

I thought maybe they used I/O pins to set up power ground and signal, but alas, looking at their code, there is no way on this earth it’s really working. Here is the code from their other post, sigh…

CmConver CON 2260 cmDistance VAR Word time VAR Word MAIN cmDistance = 5000 DEBUG [dec time] cmDistance = CmConver ** time DEBUG [dec cmDistance] PULSOUT 15, 1 PULSIN 15, 1, time PULSOUT 12, 1 PULSIN 12, 1, time PULSOUT 8, 1 PULSIN 8, 1, time PAUSE 1000 return

Perhaps it’s time to define the term “working”…

I also garuntee that the AtomPro will not source enough current thorugh an I/O if you did try to power it directly from the I/O pins. They may be able to sink it but even that is unlikely. Lighting an LED is one thing…

Also you could very well have fried the I/Os you had GND and VCC connected to if you ever set both the pins to outputs in order to try to power the sensor module that way.