Go Down

Topic: Controlling an RC car Speed/Steering with Arduino (outputting various voltages) (Read 429 times) previous topic - next topic

Cumulus

Hello,

I'm in the process of building a Mega Liner crawler (think line crawler that goes much faster) and need some advice on controlling the motor. Currently, a Futaba R617FS receiver takes an input from the RC controller and outputs a signal between .272V and .206 to a TEU-101BK Motor Controller which then modulates the voltage into the Motor between 0V and 7V. I'm thinking the best way to interface with this is program the Arduino to output the .272-.206V depending on how fast the car needs to go (as everything will be preprogrammed and the Radio Controller won't be in use, it's fine to unplug the receiver from Motor Controller). My question is, what is the most effective way to output such fine changes in Voltage from an Arduino (when I want to be able to output the full range of voltages, not just .272 and .206)?

I first thought just using analogWrite(), but the difference between the Voltage is small enough that the only values I can write were 10, 11, 12, 13, and 14 and I need much finer speed control then that.

Any ideas?

Thanks

vaj4088

Cumulus wrote (in part):

Quote
I first thought just using analogWrite(), but the difference between the Voltage is small enough that the only values I can write were 10, 11, 12, 13, and 14 and I need much finer speed control then that.
What Arduino do you have?  The Arduinos that I know do not have a DAC and cannot output an analog voltage - at least not without a low pass filter and some buffering.  The Arduinos that I know put out Pulse Width Modulation which is not what was described.


Chagrin

Your TEU-101BK is just a typical ESC and takes PPM commands just like an RC servo. Use the Servo library to control it.

It probably looks like a ".272V" signal simply because it's a pulsed signal and your multimeter is averaging the voltage.

Cumulus


Cumulus

Great! so it I hooked up to the Radio receiver and used code similar to here: https://www.sparkfun.com/tutorials/348

The throttle maps from 1500-1100 for 0-full throttle. It seems like the Pulsein fucntion returns a value in milliseconds of how long the pulse lasts which leaves me with a couple questions:

1. How long do I wait in between pulses. If i'm trying to put the motor at a set speed, it seems like I need to send repeating pulses of a set length. But how long do I put in between these pulses. For example, for the below code, I assume A is the value pulseIn() returned, but what would B be? Are they the same?

digitalwrite (pin#, high)
delayMicroseconds(A)
digitalwrite (pin#, low)
delayMicroseconds(B)
digitalwrite (pin#, high)...


2.The motor controller for the RC car is powered by a 7V battery. If I pulse it with 5V (from the arduino), will it read that? I assume I have to make common grounds (The wires connecting the Radio Controller to the motor controller are 3 wires per information flow, V+, GND, and signal).

thanks!


Chagrin

1) Much simpler to use the Servo library which handles everything for you.

2) Yes, you need common GND, and yes it should work with the 5V signal without issue.

Cumulus

Thanks for all the help so far. I've been very successful in controlling motor speed so far, but seem to have trouble controlling the steering. Frustrating as they should be the exact same.


Something like this sets the speed to half throttle and it'll sit there happily.

Servo sspeed;
int SIG = 7;
int carspeed = 45;


void setup() {
  sspeed.attach(SIG);     //Attach the servo to pin SIG
  sspeed.write(carspeed); //write starting throttle position

}

void loop() {
 }


Yet something like this appears to have no effect on the steering:

Servo ssteer;
int SIG2 = 13;
int angle = 45;


void setup() {
  ssteer.attach(SIG2);
  ssteer.write(angle);

}

void loop() {
 
}

I tried using ssteer.writeMicroseconds(1750) and that has no effect. Using a program which reads output from the radio controller pulseIN(6, HIGH, 2500) I can see the steering signal outputs pulses in between 1000 and 2000 microseconds. When I ran the same program on my steering control program (that is, reading the pulses output from the arduino), I see something like this:
Channel 1:0
Channel 1:1727
Channel 1:0
Channel 1:1727
Channel 1:0
Channel 1:1727
Channel 1:0
Channel 1:1533
Channel 1:0
Channel 1:1733

Could this bouncing be the issue (Note, the bouncing could be an error on my part in the connections, but I doubt it).


Any ideas? It seems like Steering and Speed control should be the exact same to the point where if I just switch the speed header with the steering header and run the speed program, the steering should change, but it doesn't...


vaj4088

Your servo library which I cannot see may prohibit certain pins from being used due to the use of a timer.  Read the documentation and try other pins.


Cumulus

So the issue ended up being that the servo for steering is powered by the signal (and the GND, V+ wires) and the Arduino can't supply enough current for it. Once I added a 5V battery in parallel it all worked great.
Thanks for the all the help!

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy