Go Down

Topic: how to read PWM signal from RC receiver (Read 1 time) previous topic - next topic

mechatron

Hi,

I would like to use PWM signals from my RC car receiver to steer some leds.

I would like to activate brake lights when the car is braking and flash a set of head lights for x times when I push the button on the 3rd channel. (like used at le mans when a prototype is getting close to a slower vehicle)
Also the voltage from the LiPo should be monitored and when it droppes below 6,6V a bright red led should be turned on in the cockpit. There are IC's readily available which switch at a certain voltage, I just have to look for them to make an input signal for the chip.

I intend to use a tiny45 chip and wonder how the chip can read the PWM signals from the receiver.

Can the chip "read" the PWM signal and know the pulse width or should I make an RC network to make an analog input and map it?

Thanks

to baldly code what no man has coded before

johnwasser

Use 'pulseIn()' to measure the pulse width in microseconds.  You should get a value from about 1000 to about 2000.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

mechatron

Thanks,

I'm afraid I cannot use PulseIn as it waits for the end of the pulse and I want to run 2 processes at the time (read out 2 channels from the receiver).

There is a function called millis which would be perfect if it would be in microseconds.
Is there a way to measure time in the background in microseconds?

Thanks
to baldly code what no man has coded before

johnwasser

There is the function "micros()".

You can use a Pin Change interrupt to record the time (in microseconds) on the rising edge and, at the falling edge, subtract the start time from that.

See: attachInterrupt() in the built-in Reference.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

AWOL

Your R/C receiver almost certainly outputs PPM, not PWM.
The distinction is a fine one, but searching for PPM instead of PWM could yield better results.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

mechatron

#5
Dec 03, 2011, 06:04 pm Last Edit: Dec 03, 2011, 06:09 pm by mechatron Reason: 1
@John,

Thanks for the micros function, but what if my second PWM changes while the interrupt on the other pins is executed?
(is it possible to monitor 2 PWM signals simultaneously with one attiny)

@AWOL,

I will look into it but I think PPM is the signal type used between the transmitter and receiver.

The receiver makes a PWM signal for each channel (receiver output to esc, servo's and my attiny) from the PPM signal (receiver input).
I'm 99% sure about this.
to baldly code what no man has coded before

AWOL

#6
Dec 03, 2011, 06:15 pm Last Edit: Dec 03, 2011, 06:18 pm by AWOL Reason: 1
Quote
The receiver makes a PWM signal for each channel (receiver output to esc, servo's and my attiny) from the PPM signal (receiver input).

Servos typically use PPM as their input, as do ESCs.
It simplifies the decoder in the receiver.
Your setup may be an exception.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

mechatron


Quote
The receiver makes a PWM signal for each channel (receiver output to esc, servo's and my attiny) from the PPM signal (receiver input).

Servos typically use PPM as their input, as do ESCs.
It simplifies the decoder in the receiver.
Your setup may be an exception.


http://www.brookshiresoftware.com/rd_how_servos_work.htm

Now I'm lost.

I have audio tester, maybe I'll measure it next week and know for sure.
to baldly code what no man has coded before

AWOL

#8
Dec 03, 2011, 11:45 pm Last Edit: Dec 03, 2011, 11:49 pm by AWOL Reason: 1
You may be lost, but brookshiresoftware doesn't know its PPM from its PWM.

Don't believe everything you read on the Web.
No, wait...

How's that 99% looking now?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up