Shop OBEX P1 Docs P2 Docs Learn Events
PING Mounting Bracket programming help ! ! — Parallax Forums

PING Mounting Bracket programming help ! !

Chris23Chris23 Posts: 16
edited 2008-04-30 20:28 in Robotics
Hello everyone !

·· I have recently bought from Parallax a Ping sensor with the mounting bracket. First i tested the Ping·sensor using the programs Ping_Demo and PingMeasureCmAndIn, provided from Parallax's website. Everything worked·fine. Then i used·RoamingWithPING-V1.0·just to see the Ping working with the·Mounting Bracket. I got a strange ·behaviour as regards the Mounting bracket. The servo was twisting rapidly 5 degrees·left and right like crazy. I thought i should make a code only for the servo, in order to·see its behaviour. With this code i just wanted the servo to keep·spinning 45 and 90 degrees left and right. The results were not·the expected ones.
The servo only turn left or right. If i use·only·the subroutine·GOSUB LEFT90·or only the subroutine GOSUB RIGHT90, eveything ok, but when i use them both, GOSUB LEFT90 and then·GOSUB RIGHT90, it turns left and then it does nothing, it stucks. I suppose that i don't use right the command PULSOUT...so i can control the polarity of the pulse and consequently control the servo's movement. In addition, i don't quite understand, why the number 1085 is used at this command ·''PULSOUT PingServo, 1085''. in order the servo to turn 90 degrees left and the·number 225·''PULSOUT PingServo, 225'', in order the servo to turn 90 degrees right. Please some help..........

Thank you,

Christofer

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2008-04-29 18:21
    Funny, that should have worked. Do you have a BS2 'plain'? Or some other 'flavor' of BS2, like a BS2p or BS2sx.

    And are you sure you plugged the Servo plug into the three-pin connection properly?

    And what are you using to power it? It's possible a low battery would cause these symptoms.
  • Chris23Chris23 Posts: 16
    edited 2008-04-29 18:54
    I use a BS2 plain. Yes i am sure that i have plugged the servo correctly. As regards the battery, i bought yesterday a 4.5V and i supply with it the BS2, the Ping and the servo. BS2 and Ping work fine... the servo doesn't !
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-04-29 19:47
    Chris,

    If you read the code comments you will see that every servo is different, therefore the code requires you to provide calibration values for the various sections, if you do not you will experience undesirable behavior. That code also requires the IR detectors to be connected. If you don’t want to use those and have to calibrate I would suggest using the simple code located at the following link. I hope this helps. Take care.

    http://www.parallax.com/Store/Robots/RoboticAccessories/tabid/145/CategoryID/51/List/0/Level/a/ProductID/248/Default.aspx?SortField=ProductName%2cProductName

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Chris23Chris23 Posts: 16
    edited 2008-04-29 21:19
    Chris,

    I know that the parameter of pulsout needs calibration. When i use only the subroutine LEFT90 and it turns 70 degrees instead of 90, but it moves. The same thing happens when i use only the subroutine RIGHT90. The problem is that when i use the subroutine LEFT90 and then RIGHT90, it turns left but then it does nothing, it stucks. I don't thing this behaviour comes because of the wrong parameters of the pulsout command. Could something else go wrong with the code i posted?

    Thank you in advance,

    Christofer
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-04-29 22:25
    I didn’t look at the code you posted. My replies were to the Roaming with PING))) issues you mentioned, since I did write that. The Turn Left and Turn Right routines are not calibrated by changing the PULSOUT values. They are calibrated by changing the number of iterations of the loop. Have you changed that value to compensate for the turn? If the turn is falling short you would increase the value. If it is overshooting the ark then the number should be reduced.
    Additionally you asked why it would keep scanning.· Do you have the IR sensors connected as per the code?· If not it will do that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support


    Post Edited (Chris Savage (Parallax)) : 4/30/2008 8:28:19 PM GMT
  • Chris23Chris23 Posts: 16
    edited 2008-04-30 00:50
    Chris,

    Thank you very much for your suggestions. I just want to clarify something...When i want the servo to turn 45,90...x degrees right or left, it does it pretty well by changing the number of iterations of the loop. The problem is when i want the servo to turn left and then right or the opposite. In other words scan 180 degrees. I suppose that this shouldn't happen, because when i am experimenting seperately to turn left or right, the servo works. Furthermore, i have not connected neither the IR sensor nor the servos of the Boe-bot with the Ping Mounting Bracket. I just want to work with the Ping and the Mounting Bracket at first and be sure that everything works. For that reason, i modulated the code RoamingWithPING-V1.0 for my needs. Did you see the code?? Is something wrong with it?
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-04-30 00:56
    No.

    The servo "control signal" is a 1 mSec to 2 mSec wide pulse, repeated every 20 to 50 mSecs. The 'position' of the Servo depends on the width of the pulse.

    So, "full left" would be a 1 mSec pulse (repeated every 20 to 50 mSec), "full right" a 2 mSec pulse (repeated every 20 mSec), and "mid-range" a 1.5 mSec pulse (repeated every 20 mSec).

    The pulse is repeated 20 times or so, to give the servo time to move to the 'commanded' position.
  • Chris23Chris23 Posts: 16
    edited 2008-04-30 16:33
    Thank you all for your suggestions...

    The problem was the power. I used a classic 4,5 V battery from a store to supply the BS2, PING and servo at first and the servo was not working correctly. Then i used a circuit and i made 4.5V to 5 V and everything is ok !!! allanlane5 you were right...
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-04-30 16:49
    Glad you got it working.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-04-30 20:28
    Sorry it seems there was some confusion about which left and right you were referring to…When you said Turn Left and Turn right, that refers to the wheels, but it seems you really meant the PING))) servo, which is typically straight in those routines. In any event it won’t work without the IR, however it seems you’re set now, so take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.