Tilburg, Noord Brabant
Offline
Newbie
Karma: 0
Posts: 46
|
 |
« on: November 21, 2011, 03:25:08 pm » |
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
Tesla Member
Karma: 96
Posts: 6364
|
 |
« Reply #1 on: November 21, 2011, 05:31:12 pm » |
Use 'pulseIn()' to measure the pulse width in microseconds. You should get a value from about 1000 to about 2000.
|
|
|
|
|
Logged
|
|
|
|
|
Tilburg, Noord Brabant
Offline
Newbie
Karma: 0
Posts: 46
|
 |
« Reply #2 on: December 03, 2011, 10:42:01 am » |
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
Tesla Member
Karma: 96
Posts: 6364
|
 |
« Reply #3 on: December 03, 2011, 11:17:44 am » |
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
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 137
Posts: 19016
I don't think you connected the grounds, Dave.
|
 |
« Reply #4 on: December 03, 2011, 11:48:22 am » |
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.
|
|
|
|
Tilburg, Noord Brabant
Offline
Newbie
Karma: 0
Posts: 46
|
 |
« Reply #5 on: December 03, 2011, 12:04:40 pm » |
@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
Brattain Member
Karma: 137
Posts: 19016
I don't think you connected the grounds, Dave.
|
 |
« Reply #6 on: December 03, 2011, 12:15:55 pm » |
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.
|
|
|
|
Tilburg, Noord Brabant
Offline
Newbie
Karma: 0
Posts: 46
|
 |
« Reply #7 on: December 03, 2011, 04:53:39 pm » |
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.htmNow 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
Brattain Member
Karma: 137
Posts: 19016
I don't think you connected the grounds, Dave.
|
 |
« Reply #8 on: December 03, 2011, 05:45:49 pm » |
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.
|
|
|
|
|