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!
[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]
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]
You do realize that a 28015 is a PING, not an SRF-04! Right?
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.
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!
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.
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.
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!
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…
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.
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
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.
Hello again, we have been away from here for some time as we tried to make sense of previous directions. Your information led to us working with the wiring, which we discovered may have caused our unit to fry (through no direct fault of our own, as we had to share the unit with another period in the same class). Unfortunately we are all very new to this particular set of equipment and several of us working on it directly are honestly not experts when it comes to the electrical wiring.
We have tried rewiring the sonar/bot board in an attempt to ratify the issues we found. We have reason to believe however, that the sonar unit is in fact dead. Now what I’m worried about is finding some form of proof to its inoperability. A much more pleasant solution would be proof otherwise however. In either case we would like some more help.
The other division’s design was set-up with all of the wire clips on the top pin of the board, with the pins closest to the user. We believe this could have led to them putting voltage into all of the sonar pins at once, with no designated ground. Now unless I’m completely incorrect, that could have destroyed it.
On the other hand, possible screw-ups on our end include not being able to store the Time(1-3) variables correctly. I have tried the various variable types in the ATOM manual on the off-chance that the problem was the stored value being rounded off to an effective zero.
While this should not have been a difficult project we are still having plenty of difficulty, we were, until recently, sharing the unit with another division among other things. The pictures provided show our current wiring. Red leads to the Ping’s 5v pin, black to GND and green to SIG. This set-up appeared to provide it with proper power, as the LED that according to the Ping manual “indicates sensor activity came on. Does this mean that it’s firing its pulse? Or receiving the echo perhaps?
CmConver CON 2260
cmDistance VAR WORD
time VAR WORD
MAIN
PULSOUT 4, 8
PULSIN 4, 1, time
cmDistance = CmConver ** time
DEBUG [dec cmDistance]
PAUSE 1000
return
The program above is currently set to take P4’s pulsout and pulsin to get the variable Time, which is multiplied by our constant. The debug runs a stream of zeroes at me currently. As you can see tise variables are multiplied by the constant (Which I believe is simply a value given by the code that was the basis for this) for the product variables which are then printed via debug. We have also tried running the original code this was based on, it had not worked any better.
main:
low p4
pulsout p4, 5
input p4
pulsin p4, 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]
Use the 8.0.1.7 IDE and run this program. At the bottom of the IDE you will see tabs. Click on Terminal1, change the baudrate (first one) to 9600, far right click connect. You should see “Distance: XX” where XX is the distance in inches. It should go from 133 (11’) down to 1 (1"). Go ahead and move your hand in front of the sensor real close to see it go down all the way to 1". This will tell you if the sensor is functional. Try it.
Thank all of you guys for your help; we have the sonar printing out relatively accurate distances in inches. Thanks to your help we are a good step closer to what the project is becoming.
Our next step will be mounting this onto our rover and preparing the program to keep our rover from ever running into objects. This will either be an automatic process or a warning for the driver; it has yet to been decided. Thanks to you we finally have the upper-hand on our competition.
You may well hear from us again in the near future. Thanks again.