Pages: [1]   Go Down
Author Topic: reading pwm  (Read 2782 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 0
Posts: 376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

HI

I have done a bit of googleing, and read a bit around the forum, trying to find out how i can read a pwm signal,
i would like to read the pwm output on an rc channel, and then control a fan when the output is lower than 1100 say, in order to stop a motor getting hot when there is no airflow,
it would be cool to use an arduino to do this based on the fact i have a few lying around, and that i could easily make up some funky throttle curves etc for an old rc handset that doenst have that ability.

I have found that pulseIn can be used, but i havent been able to find any example code or anything related to RC gear, does anyone have any pointers?

thanks,
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34532
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Generally this is not a thing people do. But the pulse in will work for you. Just do it, you don't need for some one to have done it first.
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you´re right about not needing someone to have done it first,
but being a rooky, it helps, heh heh ,

I assume i could do something like count the millis between the HIGH of the pulse in and work out the position of the RC stick from that,

i just dont know how
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34532
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just read the values and then print them out. Then you can see the range you get and you know what numbers to use in the map statement to convert it to the values you want.
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This -
http://rcarduino.blogspot.com/2012/01/how-to-read-rc-receiver-with.html

or this -
http://rcarduino.blogspot.com/2012/04/how-to-read-multiple-rc-channels-draft.html

or like mike says, if you want to keep it simple use pulse in

Duane B
rcarduino.blogspot.com
Logged


Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The better way to decode a R/C servo pulse is using an interrupt pin rather the pulsein.

Lefty
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

looks good,

going to do some reading , thanks
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

duane,

thanks a lot man , that first link prints out my rc ranges from approx 1000 to 1900 ,

now time to get fiddling to see how to make it react to those ranges without screwing it all up,

then i will check out reading more than one signal at a time,

i think this will be a fun project,
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well the led on pin 13 is now being successfully controlled by channel one on my RC set without noticebly slowing the code,
I think I have the bug, this is going to be one of those projects that will take a lot of sleepy time out of my nights,
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This car is controlled through Arduino, using more or less the same code. The arduino listens to what I want the car to do, then reads a gyroscope and decides whether to let me control the car or intervene if its rotating faster than the code thinks it should be i.e. spinning out. It does this about 100 times per second you should recognise most of the code from the other links.

http://rcarduino.blogspot.com/2012/07/rcarduino-yaw-control-part-2.html

Duane B

rcarduino.blogspot.com
Logged


Offline Offline
Sr. Member
****
Karma: 0
Posts: 376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i will take a look , thanks,

i have another question which might be resolved in your code,
but how can i control the servo via the arduino? i mean i have a led, with a 0-255 pwm signal based on stick position, so i have effectivly got a dimmer ,its all nice an all, but i want to know if i can manipulate the original servo pwm signal and then send it out to the servo, i know its possible with arduino because there are arduino based UAV´s all over the show,

Logged

Offline Offline
Sr. Member
****
Karma: 4
Posts: 327
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A little late may be,
  but thought, as you need only a is it above / below a speed signal,

convert the PWM to analog, with a R/C,
    and use an alog input to read the resultant voltage.
         
just a thought,
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You need the servo library, it does exactly what you want.

Here is a little intro - might be more complicated than you need, the library is very simple and easy to use -

http://rcarduino.blogspot.com/2012/01/can-i-control-more-than-x-servos-with.html

Duane B

Logged


Offline Offline
Sr. Member
****
Karma: 0
Posts: 376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well , i have read through the servo library notes, and it looks pretty easy to use,

Im assuming that with the last bit of code the prints out the pwm signal to serial, i cna just put that value onto the write statement and get direct control over the servo based on the stick position,

i think thats a good way to startout experimentation.

I was going to try and build some acceleration curves into the programming to allow less wheel spin in loose ground or rain, but i just ordered an Rx for my good handset, so that plan is probly not worth persuing anymore,

I am however incredibly interested in your example of the ESP for the rc car. did you get it working well ?
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 376
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well, I have the servo moving according to the stick position, and my pwm controlled led working at the same time, so that prooves that i can do more than just split the servo signal with a y cable and control other stuff accodringly, now i can try my hand at amking some crude throttle curves etc,

do you have a good link to how to use the gyro  ? i have a wii motion plus iic gyro sat around after taking it out of a cuad build, maybe i can use that,
Logged

Pages: [1]   Go Up
Jump to: