Code for RC Steering
Carol Hazlett
Posts: 312
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
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
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.
-Phil
-Phil
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.
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
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
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
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.
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?
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
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?
http://en.wikipedia.org/wiki/Electronic_speed_control#Brushless_ESC