I am currently working on a project to drive an RC car with an Arduino Uno. I’ve hacked the controller to accept inputs via a low pass filter.
However, when I try and pass in two separate PWM signals through different pins (pins 9 and 11), it seems to bleed out and the car turns and accelerates.
Side note: I’m a bit of a Noob when it comes to electronics as I’m more of a programmer rather than an Electrical engineer. I also apologize if this topic has been re-posted, but I couldn’t find it.
Any thoughts are welcome.
Thanks in advance.
Test code is below.
int lr = 120;
void setup()
{
Serial.begin(9600);
pinMode(9,OUTPUT); // controls the turning
pinMode(11,OUTPUT); // controls the acceleration.
}
void loop()
{
analogWrite(11,72); // The controller uses this as an idle mode of sorts
analogWrite(9, lr);
analogWrite(11,72);
if (millis()% 2000 >= 0 && millis()% 2000 < 1000) // So I can get some idea of how it's turning
lr = 255;
else if ( millis()% 2000 >= 1000 && millis()% 2000 <= 1999)
lr = 0;
Serial.print("Time mod 2000 = ");
Serial.print(millis() % 2000 );
Serial.print(" | lr = ");
Serial.println(lr);
delay(500);
}
The speed control would typically be done with PWM turning the drive transistors on and off. If you turn the PWM into a voltage it will likely just keep the transistors turned on all the time. Try eliminating the low-pass filter on Pin 11.
johnwasser:
The speed control would typically be done with PWM turning the drive transistors on and off. If you turn the PWM into a voltage it will likely just keep the transistors turned on all the time. Try eliminating the low-pass filter on Pin 11.
Ok, I can see how that could help, but I do need the two. One to control the voltage for the acceleration and turning. I need them both to accomplish my needs.
The ultimate goal of this is to allow the car to drive on a track an detect obstacles via sonar sensors. It should make course corrections as needed (and I'd rather not have to chase it for a long time).
This was allowing me for a left/right/straight... and the car would go Forward, backward, and remain still at the same time as the change in direction.