Prop Boe Bot with Ping problem
I am just starting to play with the Parallax Prop BOE board. I am using a program using a ping as a stand alone sensor for roaming. The program I got from the Parallax site some time ago. I changed the pin numbers using the header outputs and no resistors. The ping sensor and peizo speaker work, but the servos not responsive. Tried everything I know. What am I doing wrong. I did notice the letter E (green) before the servo in the PUB inet section. I am also planning to revise the PEK code to work on theProp BOE. by the way, I am using high speed servos. I also have to learn how to post example programs better. Thanks in advance.
{{ Prop-PingBot.spin revised for Prop BOE 3-2014 Crazy Rabbit's Home Robotics This program and its objects are all under construction. INSTRUCTIONS ‣ Press F8 to compile this application. ‣ Double-click the Propeller PingBot Schematic object in the object browser window for the various schematics. ‣ Compare the schematic to the comments in this object's init code block (below). ‣ Adjust the schematic, constants section for your particular wiring. ‣ Load the code into the Propeller chip with F11, and let it roam. MORE INFO ‣ Open each of the objects (PiezoSpeaker, PING, etc), and view them in documentation mode. Their instructions should match the commands in this object's init section. ┌────────────────────────┬────────────────────────┬───────────────┬────────────┐ │ Propeller PING))) Bot │ (C)2009 James Ronald │ Version 0.10 │ Jan. 2009 │ ├────────────────────────┴────────────────────────┴───────────────┴────────────┤ │ │ │ Base on work of Andy Lindsay (C)2008 Parallax, Inc. ( PID Following PEKbot ) │ │ │ │ │ The PEKbot package is available for download from the PEKbot thread on the │ │ Propeller Chip forum: │ │ │ │ http://forums.parallax.com/forums/default.aspx?f=25&m=174962 │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ }} CON _xinfreq = 5_000_000 _clkmode = xtal1 | pll16x L = 14 ' I/O Pin for Left Wheel Servo R = 15 ' I/O Pin for Right Wheel Servo P = 16 ' I/O Pin for Ping Sensor Servo PING_Pin = 19 ' I/O Pin For PING))) PIEZO_Pin = 4 ' I/O Pin for Piezo Speaker VAR long servo[3] long range OBJ schematic : "Propeller Ping-Bot Schematic" piezo : "Piezospeaker" s : "Servos" ping : "Ping" PUB init ' Piezospeaker connected to PIEZO_Pin, beeps at a frequency of 2637 for ' 1 second (2637 cycles). piezo.beep(PIEZO_Pin, 2637, 2637) ' Variables will be monitored by servos object. All are initialized ' to stop (range is -1000 to 1000 with 0 = stop). servo[L] := 0 servo[R] := 0 servo[P] := 0 ' Servo range must be contiguous ordered from low to high. Left servo ' connected to P0, right servo connected to P1, and ping servo to P2. s.start(14, 16, @servo) ' Call the main method (otherwise, the program would stop here). main PUB main ' PingBot starts out looking forward and moving straight ahead. When an object ' is sensed he will look for a clear path to the left and then to the right. If ' these paths are all blocked he will then let out a cry and turn about which ' will hopefully free him from his boxed in situation. It's amazing that just ' this little bit of code can create such an interesting personality. repeat servo[P] := 0 if ping.Inches(PING_Pin) < 10 servo[L] := 0 servo[R] := 0 servo[P] := 500 waitcnt(clkfreq/2 + cnt) if ping.Inches(PING_Pin) < 10 servo[P] := -500 waitcnt(clkfreq/2 + cnt) if ping.Inches(PING_Pin) < 10 servo[L] := 1000 servo[R] := 1000 piezo.beep(PIEZO_Pin, 2637, 2637) else servo[L] := 1000 servo[R] := 1000 else servo[L] := -1000 servo[R] := -1000 else servo[L] := -1000 servo[R] := 1000 waitcnt(clkfreq/4 + cnt) ' wait 250ms
{{ Prop-PingBot.spin revised for Prop BOE 3-2014 Crazy Rabbit's Home Robotics This program and its objects are all under construction. INSTRUCTIONS ‣ Press F8 to compile this application. ‣ Double-click the Propeller PingBot Schematic object in the object browser window for the various schematics. ‣ Compare the schematic to the comments in this object's init code block (below). ‣ Adjust the schematic, constants section for your particular wiring. ‣ Load the code into the Propeller chip with F11, and let it roam. MORE INFO ‣ Open each of the objects (PiezoSpeaker, PING, etc), and view them in documentation mode. Their instructions should match the commands in this object's init section. ┌────────────────────────┬────────────────────────┬───────────────┬────────────┐ │ Propeller PING))) Bot │ (C)2009 James Ronald │ Version 0.10 │ Jan. 2009 │ ├────────────────────────┴────────────────────────┴───────────────┴────────────┤ │ │ │ Base on work of Andy Lindsay (C)2008 Parallax, Inc. ( PID Following PEKbot ) │ │ │ │ │ The PEKbot package is available for download from the PEKbot thread on the │ │ Propeller Chip forum: │ │ │ │ http://forums.parallax.com/forums/default.aspx?f=25&m=174962 │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ }} CON _xinfreq = 5_000_000 _clkmode = xtal1 | pll16x L = 14 ' I/O Pin for Left Wheel Servo R = 15 ' I/O Pin for Right Wheel Servo P = 16 ' I/O Pin for Ping Sensor Servo PING_Pin = 19 ' I/O Pin For PING))) PIEZO_Pin = 4 ' I/O Pin for Piezo Speaker VAR long servo[3] long range OBJ schematic : "Propeller Ping-Bot Schematic" piezo : "Piezospeaker" s : "Servos" ping : "Ping" PUB init ' Piezospeaker connected to PIEZO_Pin, beeps at a frequency of 2637 for ' 1 second (2637 cycles). piezo.beep(PIEZO_Pin, 2637, 2637) ' Variables will be monitored by servos object. All are initialized ' to stop (range is -1000 to 1000 with 0 = stop). servo[L] := 0 servo[R] := 0 servo[P] := 0 ' Servo range must be contiguous ordered from low to high. Left servo ' connected to P0, right servo connected to P1, and ping servo to P2. s.start(14, 16, @servo) ' Call the main method (otherwise, the program would stop here). main PUB main ' PingBot starts out looking forward and moving straight ahead. When an object ' is sensed he will look for a clear path to the left and then to the right. If ' these paths are all blocked he will then let out a cry and turn about which ' will hopefully free him from his boxed in situation. It's amazing that just ' this little bit of code can create such an interesting personality. repeat servo[P] := 0 if ping.Inches(PING_Pin) < 10 servo[L] := 0 servo[R] := 0 servo[P] := 500 waitcnt(clkfreq/2 + cnt) if ping.Inches(PING_Pin) < 10 servo[P] := -500 waitcnt(clkfreq/2 + cnt) if ping.Inches(PING_Pin) < 10 servo[L] := 1000 servo[R] := 1000 piezo.beep(PIEZO_Pin, 2637, 2637) else servo[L] := 1000 servo[R] := 1000 else servo[L] := -1000 servo[R] := -1000 else servo[L] := -1000 servo[R] := 1000 waitcnt(clkfreq/4 + cnt) ' wait 250ms
Comments
Maybe this will help clear things up...:)
-Tommy
[code]
{{ Prop-PingBot.spin revised for Prop BOE 3-2014 Crazy Rabbit's Home Robotics
This program and its objects are all under construction.
INSTRUCTIONS
‣ Press F8 to compile this application.
‣ Double-click the Propeller PingBot Schematic object in the object
browser window for the various schematics.
‣ Compare the schematic to the comments in this object's init code
block (below).
‣ Adjust the schematic, constants section for your particular wiring.
‣ Load the code into the Propeller chip with F11, and let it roam.
MORE INFO
‣ Open each of the objects (PiezoSpeaker, PING, etc), and view
them in documentation mode. Their instructions should match
the commands in this object's init section.
┌────────────────────────┬────────────────────────┬───────────────┬────────────┐
│ Propeller PING))) Bot │ (C)2009 James Ronald │ Version 0.10 │ Jan. 2009 │
├────────────────────────┴────────────────────────┴───────────────┴────────────┤
│ │
│ Base on work of Andy Lindsay (C)2008 Parallax, Inc. ( PID Following PEKbot ) │ │
│ │
│ The PEKbot package is available for download from the PEKbot thread on the │
│ Propeller Chip forum: │
│ │
│ http://forums.parallax.com/forums/default.aspx?f=25&m=174962 │
│ │
└──────────────────────────────────────────────────────────────────────────────┘
}}
CON
_xinfreq = 5_000_000
_clkmode = xtal1 | pll16x
L = 14 ' I/O Pin for Left Wheel Servo
R = 15 ' I/O Pin for Right Wheel Servo
P = 16 ' I/O Pin for Ping Sensor Servo
PING_Pin = 19 ' I/O Pin For PING)))
PIEZO_Pin = 4 ' I/O Pin for Piezo Speaker
VAR
long servo[3]
long range
OBJ
schematic : "Propeller Ping-Bot Schematic"
piezo : "Piezospeaker"
s : "Servos"
ping : "Ping"
PUB init
' Piezospeaker connected to PIEZO_Pin, beeps at a frequency of 2637 for
' 1 second (2637 cycles).
piezo.beep(PIEZO_Pin, 2637, 2637)
' Variables will be monitored by servos object. All are initialized
' to stop (range is -1000 to 1000 with 0 = stop).
servo[L] := 0
servo[R] := 0
servo[P] := 0
' Servo range must be contiguous ordered from low to high. Left servo
' connected to P0, right servo connected to P1, and ping servo to P2.
s.start(14, 16, @servo)
' Call the main method (otherwise, the program would stop here).
main
PUB main
' PingBot starts out looking forward and moving straight ahead. When an object
' is sensed he will look for a clear path to the left and then to the right. If
' these paths are all blocked he will then let out a cry and turn about which
' will hopefully free him from his boxed in situation. It's amazing that just
' this little bit of code can create such an interesting personality.
repeat
servo[P] := 0
if ping.Inches(PING_Pin) < 10
servo[L] := 0
servo[R] := 0
servo[P] := 500
waitcnt(clkfreq/2 + cnt)
if ping.Inches(PING_Pin) < 10
servo[P] := -500
waitcnt(clkfreq/2 + cnt)
if ping.Inches(PING_Pin) < 10
servo[L] := 1000
servo[R] := 1000
piezo.beep(PIEZO_Pin, 2637, 2637)
else
servo[L] := 1000
servo[R] := 1000
else
servo[L] := -1000
servo[R] := -1000
else
servo[L] := -1000
servo[R] := 1000
waitcnt(clkfreq/4 + cnt) ' wait 250ms
[code]
[c0de]
code here
[/c0de]
Except use an "o" instead of a zero.
Yes, much.
I'm pretty sure I can help you with this but I can't find all the objects you're using.
After pressing F9 to compile your code. You can select "Archive>Project" from the File menu. If you attach the zipped archive (by selecting "Go Advanced" and then "Manage Attachments"), we could all have the objects you used.
You might want to switch to a servo object that allows more than two servos.
I have an example of how to use this other servo object to control a robot in this post.
I tried to send the whole thing, but still don't know how. Is it possible to just send the whole page as attachment. I keep getting stuck in circles.
In case anyone else wants to look at the code, I've attached the archive of what I assume is the correct project.
If you use the Propeller Tool's archive feature, it will include all the objects used in the archive. As you can see, there's a big difference in size.
James, could you check to make sure this the correct code?
Was your main issue the power supply? It's not uncommon for an inadequate power supply to cause reset issues with the Propeller and the Basic Stamp when driving servos.
If you're interested in testing your code on the PropBOE, I'll load the code on my PropBOE-Bot so we could compare results.