Shop OBEX P1 Docs P2 Docs Learn Events
Code for RC Steering — Parallax Forums

Code for RC Steering

Carol HazlettCarol Hazlett Posts: 312
edited 2012-10-25 13:45 in General Discussion
All the projects I have done had differential steering or were walking robots. I know alot about controlling motors and servos but find myself stumped on coding for ackerman steering. I am using a Basic Stamp 2 with a Minds-i RC rock crawler to make an autonomous rover for use outside. I have searched the internet for a while and see that many people have done this very thing but could not find a tutorial or explanation on how it is done. I am using an ESC/BEC to power the Stamp and provide motor control and the steering servo is plugged into one of the Servo ports. The set-up works fine in that I can program my motors and the steering servo also works fine. I am just not clear on how to get the steering and motors to work together to produce a specific turn. I realize that I need the steering servo to be turned at the same time as the motors are moving. It is really simple in theory but I am drawing a complete blank on how to code it! Can anybody point me in the right direction? Thank you, Carol

Comments

  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2012-10-24 18:23
    counter var word

    for counter = 1 to 500
    pulsout pin#, 1000
    pause 20
    next counter

    for vounter = 1 to 500
    pulsout pin#, 750
    pause 20
    next counter

    for counter = 1 to 500
    pulsout pin#, 500
    pause 20
    next counter

    that should turn your servo to 2, 12, 10 o clock. Pin # is the pin your servos data line is connected to on the bs2. That will make your wheels turn one way for 500ms then straight for 500ms and then the other way for 500ms
  • W9GFOW9GFO Posts: 4,010
    edited 2012-10-24 18:41
    All the projects I have done had differential steering or were walking robots. I know alot about controlling motors and servos but find myself stumped on coding for ackerman steering.

    I'm not quite sure what you need help with so I will guess. I think you are asking how to determine what speed to use for each of the two drive motors based upon the angle of the steering. For a right turn the left motor will turn faster than the left. You will have to measure the turn radius and calculate the difference that each wheel has to travel for a given turn setting, then drive the motors appropriately.

    You probably know but in a car one motor drives both drive wheels via a differential - which automatically divides the power between the wheels.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-10-24 18:53
    It really is a good tutorial on differentials;
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-10-24 18:59
    Here's a video from 1937 that explains the automobile differential in the simplest terms possible:

    -Phil
  • W9GFOW9GFO Posts: 4,010
    edited 2012-10-24 19:02
    I think that is the exact same video but with a different title. I agree that it is a very good explanation, I wish there were more videos like this.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-10-24 19:22
    Ah, you snuck that one in ahead of me! I was responding to #3. :)

    -Phil
  • xanaduxanadu Posts: 3,347
    edited 2012-10-24 19:51
    I thought he meant how to pulse the ESC and steering servo simultaneously using a BS2. Maybe a servoPAL?
  • Carol HazlettCarol Hazlett Posts: 312
    edited 2012-10-24 20:16
    Xanadu and rwgast_logicdesign had what I was looking for. I already understand the physical properties of differentials having built many of them on different robot projects.
    Physically my robot works fine, it was the software implimentation that I am fuzzy on. But the videos won't go to waste. As I am a mentor for the Girl Scouts FLL team I
    am going to use the video for a teaching aid. Thanks everybody.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-10-24 20:53
    All the projects I have done had differential steering or were walking robots. I know alot about controlling motors and servos but find myself stumped on coding for ackerman steering. I am using a Basic Stamp 2 with a Minds-i RC rock crawler to make an autonomous rover for use outside. I have searched the internet for a while and see that many people have done this very thing but could not find a tutorial or explanation on how it is done. I am using an ESC/BEC to power the Stamp and provide motor control and the steering servo is plugged into one of the Servo ports. The set-up works fine in that I can program my motors and the steering servo also works fine. I am just not clear on how to get the steering and motors to work together to produce a specific turn. I realize that I need the steering servo to be turned at the same time as the motors are moving. It is really simple in theory but I am drawing a complete blank on how to code it! Can anybody point me in the right direction? Thank you, Carol

    I just don't get it. rwgast_logicdesign gave a basic example of driving one servo at a time. Xanadu suggested a ServoPal.

    It sounds like your actual question was how to operate a servo and a motor at the same time. Do you now know how to do that?


    Here is rwgast's code modified to also operate the ESC. This code should make it drive one direction for ten seconds, then straight for ten seconds then the other direction for ten seconds.

    counter var word

    for counter = 1 to 500
    pulsout steeringPin, 1000
    pulsout ESC_Pin, 800
    pause 18
    next counter

    for counter = 1 to 500
    pulsout steeringPin, 750
    pulsout ESC_Pin, 800
    pause 18
    next counter

    for counter = 1 to 500
    pulsout steeringPin, 500
    pulsout ESC_Pin, 800
    pause 18
    next counter
  • Carol HazlettCarol Hazlett Posts: 312
    edited 2012-10-24 21:20
    You are exactly right and yes your code is more what I was looking for. But I appreciate that anybody answered at all. How come your are using PAUSE 18 instead of PAUSE 20? Is there any advantage to the shorter signal length?
  • W9GFOW9GFO Posts: 4,010
    edited 2012-10-24 21:32
    Servos and ESCs expect a pulse once every 20ms (50 Hz). Standard servos are not too demanding but some ESCs are. The For..Next loop, two pulses and other things also take time to execute. Just the two pulses alone take a minimum of 1.8ms, without taking the other things into account that would mean that the pulses are coming once every 21.8 ms. The reduced PAUSE is an attempt to bring the pulse train closer to once every 20ms.
  • Carol HazlettCarol Hazlett Posts: 312
    edited 2012-10-24 23:04
    Thank you W9GF0. I see you live in my area of the world. Have you ever been to one the Seattle Robotics Society meetings? They are the third Saturday of every month and we have lot's of interesting guest speakers at each meeting. The location and information is on seattlerobotics.org or Robothon on Facebook.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-10-24 23:21
    I haven't been to an SRS meeting in many years - and I missed the last RoboThon. I don't feel like I'm missing out though. I've been averaging about four robotics meetings each week lately with the two paying projects plus the HS robotics club. Also, it seems that each time I think of it, or am reminded, the meeting has just occurred.
  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2012-10-25 00:10
    Im sorry I was under the impression you had you back wheels spinning and just didnt know how to turn the servo my bad, I also dont know anything about RC speed controllers!

    Which is intresting I was at the RC shop today buying some belts and looked at a 6 way controller with a receiver. I was thinking this may be an upgrade from blue tooth for manual control. Unfourtantely the guy didnt know many detail about how ESC works and when I explained PWM and asked in if thats how the ESC worked in RC he told me no. I very briefly glansed at a page about ESC only to see it was PWM.

    Heres my question if I were to buy one of these hi end RC remote set ups, how does it work. When you pull an analog throttle stick what does the reciver output on the car? Can that directly be ran into the input of an motor driver chip like the l293/l28 etc etc, or would I need a micro to intercept the recivers out put and write a PWM ramp based on the value the reciver gives me.

    Is going to n RC radio setup even a good path for manual control in robotics, the range is much better than bluetooth but I can have as many functions on my controller as I want with BT or xbee or any of that jazz
  • Carol HazlettCarol Hazlett Posts: 312
    edited 2012-10-25 00:37
    Lots of people use RC radios for robot control, especially the combat robots. The radios are quick and responsive and easy to use since you are making physical movements instead of programming. They send PWM signals to the ESC which makes it easy to convert between microcontroller control or using an RC radio. My robot with the rock crawler chassis has to be completely autonomous, that is why I am using a microcontroller to run it. Just plug the steering servo and the motor connector from the ESC into your microcontroller to set it up. You have to send an arming signal to the ESC but more often than not that signal is the same value as center on a servo, PULSOUT pin, 750. When I want to test my physical setup I can just unplug from the microcontroller and plug into a receiver and use a radio to run the robot.
  • xanaduxanadu Posts: 3,347
    edited 2012-10-25 07:05
    Be careful when you plug an ESC into a microcontroller. Some ESCs output voltage on the throttle connector to power the receiver. Almost every airplane I've had worked that way. Keep your multimeter handy. Radio controllers are great for driving robots, just don't get sucked into spending a lot of money on them if it isn't your primary source of control. They can get quite expensive and most of those features you pay for are for helicopters. The newer Spektrum Radios have telemetry but on a robot you'll end up outgrowing it and wanting something more hackable anyway :)
  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2012-10-25 07:31
    ahh see thats ehere the difference lies. when controlling a servo you use pulsout to feed it the posistion and then pause 20ms. The parallax hb25 motor controlls also work this way. a servo/hb25 and ESC ot sounds like all want a signal thats hi or on, for .5 to 2ms then a 20ms pause, wich is kind of a funky PWM signal.

    if you were to ditch your RC ESC and use a plain old hbridge/driver chip (these allow you to run your motor forward and reverse and also amplify your pwm signal to an exceptable voltage/current for your dc motor) with your PWM or Speed signal for your rear motor generated by your uController you would need to use the standard method of pwm using pwm pin, duty cycle %, # of cycles. Although you are using esc you maye want to give this a quick read to see how ESC is done using a bs2 directly.

    http://www.emesystems.com/BS2PWM.htm

    i would really like to know how rc ESC and the HB25 control a brushless motor without feedback using servo style pulses
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-10-25 08:31
    i would really like to know how rc ESC and the HB25 control a brushless motor without feedback using servo style pulses

    The HB25 can't control brushless motors. It's used with brushed motors. Brushless ESCs are a mystery to me. Someone on the forum recently had a project of controlling a brushless motor with a Prop. Here's BLDC thread on rcgroups.
  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2012-10-25 11:28
    I was looking at some motor at the RC shop for rock crawlers and they were brushed, there are also a very exspensive brushed motor on robot shop. What exactly is the advantage of a brushed motor are there any power differences?

    The HB25 only does brushed motors oh my my, NWCCTV has quite a few extra HB-25s when he explained to me how they worked I was very impressed but I had no idea I couldnt just go ahaed and attach a drill motor to them. What makes brushed motor able to be controlled like a servo? I mean you could do all this with brushless motor and an encoder wheel right?
  • W9GFOW9GFO Posts: 4,010
    edited 2012-10-25 13:23
    What makes brushed motor able to be controlled like a servo?

    It has to do with the motor controller. If the brushless or brushed motor controller can accept RC control signals then it knows what you want it to do.

    Look here for a description of the differences;

    http://en.wikipedia.org/wiki/Electric_motor#Brushed_DC_motors
  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2012-10-25 13:38
    so if one wanted to build a brushless controler that worked via rc pulsing what kind of chips would you want? will any schematic for a brushless rc speed control do this?

    the thing is ive been very curious how this technology works with no posistion sensors or anything. most people like comtious servos or steppers becuase it eleminates the need for wheel encoder right?
  • W9GFOW9GFO Posts: 4,010
    edited 2012-10-25 13:45
    It does sense position using back EMF in "sensorless" motors or hall sensors in others. Sensorless are by far the most common in RC.

    http://en.wikipedia.org/wiki/Electronic_speed_control#Brushless_ESC
Sign In or Register to comment.