Shop OBEX P1 Docs P2 Docs Learn Events
Prop Boe Bot with Ping problem — Parallax Forums

Prop Boe Bot with Ping problem

CrazyrabbitCrazyrabbit Posts: 116
edited 2014-04-01 16:30 in Robotics
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

Comments

  • TtailspinTtailspin Posts: 1,326
    edited 2014-03-24 07:33
    Hi Crazyrabbit, I tried and tried to read your code, but i can't make heads or tails of it as posted,

    Maybe this will help clear things up...:)
    attachment.php?attachmentid=78421&d=1297987572

    -Tommy
  • CrazyrabbitCrazyrabbit Posts: 116
    edited 2014-03-26 14:08
    Thanks. I wish I knew how to just list as attachment like before. Here is the slightly modified code

    [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]
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-03-26 14:40
    It looks like you forgot the slash in your closing code tag.

    [c0de]

    code here

    [/c0de]

    Except use an "o" instead of a zero.
  • CrazyrabbitCrazyrabbit Posts: 116
    edited 2014-03-26 15:56
    Better ?

    {{ Prop-PingBot.spin   revised for Prop BOE 3-2014  Crazy Rabbit's Home Robotics
    
    This program and its objects are all under construction.
    
    INSTRUCTIONS
      &#8227; Press F8 to compile this application.
      &#8227; Double-click the Propeller PingBot Schematic object in the object
        browser window for the various schematics.
      &#8227; Compare the schematic to the comments in this object's init code
        block (below).
      &#8227; Adjust the schematic, constants section for your particular wiring.
      &#8227; Load the code into the Propeller chip with F11, and let it roam.
    
    MORE INFO  
      &#8227; 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.
        
    &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;
    &#9474; Propeller PING))) Bot  &#9474; (C)2009 James Ronald   &#9474; Version 0.10  &#9474; Jan. 2009  &#9474;
    &#9500;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9524;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9524;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9524;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9508;
    &#9474;                                                                              &#9474;
    &#9474; Base on work of Andy Lindsay (C)2008 Parallax, Inc. ( PID Following PEKbot ) &#9474;                                                                          &#9474;
    &#9474;                                                                              &#9474;
    &#9474; The PEKbot package is available for download from the PEKbot thread on the   &#9474;
    &#9474; Propeller Chip forum:                                                        &#9474;
    &#9474;                                                                              &#9474;
    &#9474; http://forums.parallax.com/forums/default.aspx?f=25&m=174962                 &#9474;
    &#9474;                                                                              &#9474;
    &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;
    
    }}  
    
    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
    
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-03-26 16:56
    Better ?

    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.
  • CrazyrabbitCrazyrabbit Posts: 116
    edited 2014-03-29 09:27
    I have made some progress. I switched to using a Prop RPM board I modified a few years ago. I used the original program and it sort of worked. Had to reverse the motors and the ping would stop pinging after a few activations. I tried using caps across the power of the servos, same thing. I went the old way and added an extra battery pack for the servos and accessories. Works much better. The board is a little bigger then the standard 3" x 4" so it looks a little weird and is held by only one screw. I hope to use the Prop BOE someday when I learn more. Starting to hit the prop books. Basic stamp is much easier for sure. Here is the program I used complete. Seems the Prop is much more sensitive to noise then the basic stamp. I also tried to slow it down by changing the pulsecode numbers, but didn't work.
    {{ Prop-PingBot.spin   revised for Prop BOE 3-2014  Crazy Rabbit's Home Robotics
    
    This program and its objects are all under construction.
    
    INSTRUCTIONS
      &#8227; Press F8 to compile this application.
      &#8227; Double-click the Propeller PingBot Schematic object in the object
        browser window for the various schematics.
      &#8227; Compare the schematic to the comments in this object's init code
        block (below).
      &#8227; Adjust the schematic, constants section for your particular wiring.
      &#8227; Load the code into the Propeller chip with F11, and let it roam.
    
    MORE INFO  
      &#8227; 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.
        
    &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9516;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;
    &#9474; Propeller PING))) Bot  &#9474; (C)2009 James Ronald   &#9474; Version 0.10  &#9474; Jan. 2009  &#9474;
    &#9500;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9524;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9524;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9524;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9508;
    &#9474;                                                                              &#9474;
    &#9474; Base on work of Andy Lindsay (C)2008 Parallax, Inc. ( PID Following PEKbot ) &#9474;                                                                          &#9474;
    &#9474;                                                                              &#9474;
    &#9474; The PEKbot package is available for download from the PEKbot thread on the   &#9474;
    &#9474; Propeller Chip forum:                                                        &#9474;
    &#9474;                                                                              &#9474;
    &#9474; http://forums.parallax.com/forums/default.aspx?f=25&m=174962                 &#9474;
    &#9474;                                                                              &#9474;
    &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;
    
    }}  
    
    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
    


    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.
  • CrazyrabbitCrazyrabbit Posts: 116
    edited 2014-03-29 09:55
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-03-29 10:39
    I think you must have zipped up your Propeller directory.

    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.
  • CrazyrabbitCrazyrabbit Posts: 116
    edited 2014-04-01 16:30
    I am using a Parallax lipo pack for a power supply and a separate 7.4V lipo pack for the motors. Thanks for the code. I'll check it out. Prop is so different then Basic stamp for sure.
Sign In or Register to comment.