Go Down

Topic: RC reciever to analog 0-5 voltage (Read 2 times) previous topic - next topic

shahar

Hi people.

OK. John's code works good
the only problem is that if I move the RC transmitter stick from full right to full left I get about two seconds respond time.
anyone knows how to improve that?

the code:


const int inputPinA = 2;  // The pin connected to the RC receiver's servo output A
const int outputPinA = 3;  // Output PWM pin A
const int inputPinB = 4;  // The pin connected to the RC receiver's servo output B
const int outputPinB = 5;  // Output PWM pin B

void setup() {
    pinMode(inputPinA, INPUT);
    pinMode(inputPinB, INPUT);
}

void loop() {
    unsigned long pulseLength;

    pulseLength = constrain(pulseIn(inputPinA, HIGH), 1000, 2000);
    analogWrite(outputPinA, map(pulseLength, 1000, 2000, 0, 255));

    pulseLength = constrain(pulseIn(inputPinB, HIGH), 1000, 2000);
    analogWrite(outputPinB, map(pulseLength, 1000, 2000, 0, 255));
}



johnwasser


the only problem is that if I move the RC transmitter stick from full right to full left I get about two seconds respond time.
anyone knows how to improve that?


Perhaps the low-pass filter you use for converting PWM to a voltage has too large a capacitor or too large a resistor.  Sounds like the frequency cut-off is closer to 0.5 HZ than, say, 100 Hz.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Go Up