Pages: [1]   Go Down
Author Topic: how to read PWM signal from RC receiver  (Read 1619 times)
0 Members and 1 Guest are viewing this topic.
Tilburg, Noord Brabant
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

to baldly code what no man has coded before

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8842
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use 'pulseIn()' to measure the pulse width in microseconds.  You should get a value from about 1000 to about 2000.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Tilburg, Noord Brabant
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

to baldly code what no man has coded before

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8842
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26274
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Tilburg, Noord Brabant
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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.
« Last Edit: December 03, 2011, 12:09:15 pm by mechatron » Logged

to baldly code what no man has coded before

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26274
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: December 03, 2011, 12:18:27 pm by AWOL » Logged

"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.

Tilburg, Noord Brabant
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

to baldly code what no man has coded before

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26274
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: December 03, 2011, 05:49:14 pm by AWOL » Logged

"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.

Pages: [1]   Go Up
Jump to: