No video

Reading PWM Values from an RC Receiver using Arduino

  Рет қаралды 52,927

The Bored Robot

The Bored Robot

Күн бұрын

Пікірлер: 84
@lnz5660
@lnz5660 2 жыл бұрын
Its always the smallest youtubers who have the best tutorials.
@TheBoredRobotLLC
@TheBoredRobotLLC 2 жыл бұрын
Thank you! I'm glad you like the videos.
@novisfpv
@novisfpv Жыл бұрын
Very true
@israelpurdum9470
@israelpurdum9470 Жыл бұрын
amen
@tirtowijarso7189
@tirtowijarso7189 7 ай бұрын
You are right
@willyr5981
@willyr5981 Жыл бұрын
Thank you for making small videos on a single subject, it's alot easier to digest. Good Job!
@TheBoredRobotLLC
@TheBoredRobotLLC Жыл бұрын
Thank you! I'm glad it helped with your understanding of the topic.
@elektron2kim666
@elektron2kim666 11 ай бұрын
I'm doing the opposite as I wait for money or objects in the mail and it's a bit mind blowing. I already have a Pico W running code for PWM out like a throttle and the ESC/Brushless motor with BEC connectors. On an oscilloscope I get a square wave from the Pico pin. In stage 2 I want to hook in to "something" for auto throttle control which can be a heat sensor or the other servo. An RC car with a propeller is the original idea. Also removing the need for 2 hand controllers.
@TheBoredRobotLLC
@TheBoredRobotLLC 11 ай бұрын
That sounds like a fun project. I usually take that approach as well. I start with a controller and then I use sensors or some other input to create autonomous motion.
@umar07823
@umar07823 17 күн бұрын
Banger of a tutorial !
@TheBoredRobotLLC
@TheBoredRobotLLC 6 күн бұрын
Thanks!
@noicthebrave
@noicthebrave 4 ай бұрын
Much appreciated - Needed something like this for a lil project of mine :) Very helpful
@TheBoredRobotLLC
@TheBoredRobotLLC 4 ай бұрын
Glad I could help!
@lorenzothepasta2820
@lorenzothepasta2820 2 жыл бұрын
Thank you so much, now I can FINALLY read pwm signals from my reciever. Thank you, thank you, thank you!!!!!! I used your code from your blog/website.
@TheBoredRobotLLC
@TheBoredRobotLLC 2 жыл бұрын
I'm happy it worked for you.
@lorenzothepasta2820
@lorenzothepasta2820 2 жыл бұрын
@@TheBoredRobotLLC :D Good to see you back.
@williamzhang6197
@williamzhang6197 2 жыл бұрын
Thank you so much. It's really great to see these videos in such quality!
@TheBoredRobotLLC
@TheBoredRobotLLC 2 жыл бұрын
Thanks! I'm glad you enjoyed the video.
@JakeRobb
@JakeRobb 8 ай бұрын
Thanks, nice video! Keep up the good work! FYI, "baud" rhymes with "clawed," not "cloud." It might be nice if you occasionally dipped into the "why" behind some of your decisions. For example, why 9600 baud? As far as I can tell, it just controls the maximum rate at which you can write new values to the serial output port, and just needs to be fast enough keep up with the 50Hz input rate -- but that's not obvious, and it would be good if you said so (and perhaps even showed what happens if you pick a different value). I'm not sure how big an int is in Arduino land; guessing 32 bits. So that's 50 * 32 = 1600 bits per second, which means that any rate higher than that would be sufficient here, and anything faster would make no difference (except, I suppose, the _tiny_ change in latency between input and output). Google says the Arduino can go up to 115,200 baud (12x faster than 9600), so you'd be looking at a potential latency change from ~100µs down to ~8µs. At first I thought that the _input_ was 9600 baud, but I did the math on that and determined that it would only give you enough resolution to differentiate about ten levels of pulse width. Your output graph clearly shows at least an order of magnitude more resolution than that!
@TheBoredRobotLLC
@TheBoredRobotLLC 8 ай бұрын
Thank you for this! My apologies on the mispronunciation. The "why" is something that I could have delved into more. Generally speaking, I try to focus more on how to do something, but in this example, you're right in that the "why" could provide more insight in some other specific applications.
@brandonsprojects3294
@brandonsprojects3294 Жыл бұрын
Fantastic tutorial Informative and concise
@TheBoredRobotLLC
@TheBoredRobotLLC Жыл бұрын
Glad you liked it!
@DaveFer
@DaveFer Жыл бұрын
This is a great video -- very well-done and educational about interrupts. But ... the way this is constructed, won't this have the interrupt handler routine called with each pulse of the PWM signal? Even if the duty cycle hasn't changed? Won't this swamp the processor? ALSO, what is the point of a PWM port if it doesn't convert the PWM duty cycle into some value for us? Aren't you treating the PWM port like any other digital port?
@TheBoredRobotLLC
@TheBoredRobotLLC Жыл бұрын
You are correct that an interrupt happens at each pulse, but I haven't had any issues with simple projects so far. I was able to use this to read an RC signal and control a stepper motors without a problem. Yes, I am using this PWM port simply as a digital port. I could use the "pulseIn" command to measure the PWM signal, but I didn't have great performance with it.
@DaveFer
@DaveFer Жыл бұрын
@@TheBoredRobotLLC Very interesting. I had the opposite result with my Arduino Mega 2560 ... the interrupt method absolutely swamped my board and it basically prevented any other processing. Here's another consideration: You're calculating the pulse width using an interrupt (which ties up the proc for the duration of your algorithm, no?). Is that any different from pulseIn()? I'm guessing there may be a slight difference but ... is your algorithm more efficient than the Arduino pulseIn() function? If so, congrats. But by how much? I suspect both methods take up approx. the same proc cycles per iteration. BUT, you're video is a stellar tutorial on how to implement hardware interrupt handlers. Sincere congratulations. It's well-done in every way and highly valuable. I'm just contesting this usage context ... or rather hoping someone will suggest a trick so that the interrupt isn't called on every pulse cycle. Best wishes!
@TheBoredRobotLLC
@TheBoredRobotLLC Жыл бұрын
@@DaveFer Thanks for the feedback. Perhaps there is a better approach for this application. It's strange that your Arduino Mega is struggling with this. Generally speaking, interrupts are faster than pulsIn(), but I think it could be a cool experiment to quantify that.
@andreweberjavorski2231
@andreweberjavorski2231 3 ай бұрын
thanks code works
@TheBoredRobotLLC
@TheBoredRobotLLC 3 ай бұрын
Glad to hear it!
@Anselm1115
@Anselm1115 6 ай бұрын
thank you so much, excatly what i needed!
@TheBoredRobotLLC
@TheBoredRobotLLC 6 ай бұрын
Glad it helped!
@paulopmt1
@paulopmt1 10 ай бұрын
Saved my day, thank you so much!
@TheBoredRobotLLC
@TheBoredRobotLLC 10 ай бұрын
Glad it helped!
@frasermossman8467
@frasermossman8467 2 жыл бұрын
Could you show how to do this with (multiple) switches on your transmitter?
@TheBoredRobotLLC
@TheBoredRobotLLC 2 жыл бұрын
Sure, I can do that for my next video.
@K055ma
@K055ma 27 күн бұрын
Thx bro
@TheBoredRobotLLC
@TheBoredRobotLLC 26 күн бұрын
You're welcome!
@Okay1
@Okay1 Ай бұрын
Ok
@billysallerlei
@billysallerlei 6 ай бұрын
I playing around with this stuff for a fuew weeks. I have the problem thatt at the 0 position, the arduino reports values between 1505 and 1490, it ist'nt stable. At a stable position with an switch at the radio, defined 40% , isn't stable too. Is woobling around 20 digits. Is this an issue on arduinohardware or the used library?
@TheBoredRobotLLC
@TheBoredRobotLLC 6 ай бұрын
That seems normal. The value is going to bounce around a bit. You can implement some sort of smoothing function or filter if it doesn't work for your application.
@pendramoon
@pendramoon 6 ай бұрын
how can I find out the same thing but from a Bluetooth remote controller app?
@TheBoredRobotLLC
@TheBoredRobotLLC 6 ай бұрын
Do you have any documentation on the type of the signal coming from the Bluetooth module? If it's the same PWM signal as an RC receiver, the process should be the same.
@user-ho8nq9ol1r
@user-ho8nq9ol1r Жыл бұрын
Thank you for this nice video, very instructive. It is a nice start for a RC project. I am however experiencing soms troubles. When using this sketch on a Nano, it stalls after about 35 minutes. Do you have any idea what might cause this?
@TheBoredRobotLLC
@TheBoredRobotLLC Жыл бұрын
To be honest, I have never let it run for that long. I'm not quite sure what the answer is here, but there could be some sort of overflow issue here. I would have to do a bit of research on that.
@jeffreyharpen6772
@jeffreyharpen6772 11 ай бұрын
The micros() value is 32 bit unsigned integer which overflows after ~70 minutes (see the arduino language documentation). The reason you got 35 minutes is probably because you had signed int in your code.
@9e05cherianpadipurackalvar6
@9e05cherianpadipurackalvar6 5 ай бұрын
i didn't understand why just using the pulseIn command wasn't enough. (im new to this stuff)
@TheBoredRobotLLC
@TheBoredRobotLLC 5 ай бұрын
The pulseIn command can be too slow depending on the application. It stops all other parts of the programming while it waits for the pulse.
@ivanravaglioli
@ivanravaglioli 2 ай бұрын
Avrei bisogno di leggere 6 canali da un ricevitore RC, come devo modificare la Sketch?
@TheBoredRobotLLC
@TheBoredRobotLLC 2 ай бұрын
I have a video update on this: kzfaq.info/get/bejne/g9mFf5CDvp6-oo0.htmlsi=A3ninmmYJwcJUuIB
@matzetech
@matzetech 9 ай бұрын
I want to do the same but with an Raspberry Pi Pico. Should I wire Servo Anode to ADC Ground and Servo Signal to ADC0? The Servo Signal and Servo Anode Pin give a low Voltage between 0.2V and 0.5V which is fine for the Pico's max Voltage of 3.3V
@TheBoredRobotLLC
@TheBoredRobotLLC 9 ай бұрын
Sorry, to be completely honest, I don't have any experience working with Raspberry Pi yet.
@matzetech
@matzetech 9 ай бұрын
@@TheBoredRobotLLC No problem, I found out there are RC switches that can measure the length of the signal and switch something when the signal is low or high
@zl2961
@zl2961 7 ай бұрын
how would you do it fot a switch on the transmitter? Im trying to use arduino to control lights on an RC plane.
@TheBoredRobotLLC
@TheBoredRobotLLC 7 ай бұрын
It would work in the same way. Instead of a continuous set of pulse lengths, it would just be two discrete pulse lengths when you flip the switch. You would just have to measure what those two values are when the switch is flipped back and forth.
@ToyTechMachines
@ToyTechMachines 2 жыл бұрын
Nice tutorial
@TheBoredRobotLLC
@TheBoredRobotLLC 2 жыл бұрын
Thank you!
@user-sj7ej4yq9c
@user-sj7ej4yq9c 11 ай бұрын
Excellent and succinct video! If I used a receiver with a 2.4 GHz signal, would it still work with the pwm stuff?
@TheBoredRobotLLC
@TheBoredRobotLLC 11 ай бұрын
Yes this should still work. The Arduino is reading the PWM signal and not the 2.4GHz signal.
@JakeRobb
@JakeRobb 8 ай бұрын
2.4GHz is the carrier frequency, not the signal rate. So long as your transmitter and receiver are on the same carrier frequency (aka channel), you should be good to go -- and I'd expect that you'd still see 50Hz signal rate.
@user-nb1oq5fu6t
@user-nb1oq5fu6t 5 ай бұрын
I can only read up to 50% of the duty cycle and then the readings begin to invert, not entirely sure why. Thank you
@TheBoredRobotLLC
@TheBoredRobotLLC 5 ай бұрын
This can be a number of things. My first thought would be to check the output settings on your transmitter. I do have an update to this video to make things easier. kzfaq.info/get/bejne/g9mFf5CDvp6-oo0.html
@user-nb1oq5fu6t
@user-nb1oq5fu6t 5 ай бұрын
Hi, thanks so much for your response I managed to write a working programme with help from your videos
@matthewjensen6380
@matthewjensen6380 6 ай бұрын
@TheBoredRobot how can I control a mosfet using this technique to drive coreless motors? Thanks For Your Help.
@TheBoredRobotLLC
@TheBoredRobotLLC 6 ай бұрын
Assuming you have everything wired up correctly, you might be able to get away with just using the analogWrite() command. This pin sending the command could be sent to the gate with a resistor to protect the Arduino.
@matthewjensen6380
@matthewjensen6380 6 ай бұрын
I will try. Thanks
@rufo
@rufo Жыл бұрын
Thanks for the tutorial! Could one use a brushed ESC plugged into the RC receiver, and just measure the analog voltage it delivers? Would that work?
@TheBoredRobotLLC
@TheBoredRobotLLC Жыл бұрын
You're talking about reading the motor output for a brushed ESC? Yes it's possible with the Arduino, assuming that the output isn't greater than 5V.
@JakeRobb
@JakeRobb 8 ай бұрын
The ESC in that scenario would be acting as a digital-to-analog converter, taking the digital PWM signal and outputting an analog voltage signal. And then you want the arduino to take that analog signal and convert it back to digital? It'd work (given that you stay within the voltage limitations), but it seems kinda silly.
@undyinglegends3973
@undyinglegends3973 Жыл бұрын
I have a question, I am currently using this technique to try and controll a servo, but everytime when i pull on the elevator, the servo starts twitching
@TheBoredRobotLLC
@TheBoredRobotLLC Жыл бұрын
The first thing I would check is how smooth the signal to your servo is. If there is a lot of noise, then you might want to use a smoothing technique for the signal being sent to your servo. If that's not the case, I've had issues in the past if I am powering the servo directly from the 5V output from the Arduino.
@youssefmohammed6126
@youssefmohammed6126 2 жыл бұрын
how can i use this to control a stepper motor like a dc motor
@TheBoredRobotLLC
@TheBoredRobotLLC 2 жыл бұрын
You'll have to map the values you read from remote control to some sort of value that relates to the time between steps for the stepper motor. I'm working on a video to do this.
@finewoodworkingbyJJ
@finewoodworkingbyJJ Жыл бұрын
produces an overflow after 35mins cause youre using long instead of unsinged long... will be 70mins with unsigned
@TheBoredRobotLLC
@TheBoredRobotLLC Жыл бұрын
That makes sense. Thank you!
@finewoodworkingbyJJ
@finewoodworkingbyJJ Жыл бұрын
Thank You for the Idea 🙂checking old time < new time will eaven make it easy to reset the variables. I am doing it in your interrupt @@TheBoredRobotLLC
@albon4038
@albon4038 2 жыл бұрын
Hi do you have any contact platform for pm. Email?
@TheBoredRobotLLC
@TheBoredRobotLLC 2 жыл бұрын
You can leave a message for me here: www.theboredrobot.com/contact
@levinoshow9139
@levinoshow9139 Жыл бұрын
oops! friend to control the position of the stepper motor and the speed
@TheBoredRobotLLC
@TheBoredRobotLLC Жыл бұрын
To control speed and position at the same time, you might have to try out using the AccelStepper Library. I have another video on this as well.
@drinski6720
@drinski6720 8 ай бұрын
When could CurrentTime be less or equal than StartTime? I think never. CurrentTime will be greather than StartTime always.
@TheBoredRobotLLC
@TheBoredRobotLLC 8 ай бұрын
Yes, that's true! That's an oversight on my end. The inequality is not necessary in the code.
@NightEagle816
@NightEagle816 2 ай бұрын
volatile long StartTime = 0; volatile long CurrentTime = 0; volatile long Pulses = 0; int PulseWidth void setup() { Serial.begin(9600); pinMode(RCPin, INPUT_PULLUP); attachInterrupt(digtalPinToInterrupt(RCPin),PulseTimer,CHANGE); } void loop() { if (Pulses < 2000){ PulseWidth = Pulses; } Serial.println(PulseWidth); } void PulseTimer(){ CurrentTime = micros(); if (CurrentTime > StartTime){ Pulses = CurrentTime - StartTime; StartTime = CurrentTime; } }
@TheBoredRobotLLC
@TheBoredRobotLLC 2 ай бұрын
I have an update to this video to make things easier: kzfaq.info/get/bejne/g9mFf5CDvp6-oo0.htmlsi=HysbnLop4zBKpxot
@arduinomaquinas
@arduinomaquinas 8 ай бұрын
Like 660, great, awesome project, 🇧🇷😊👍 subscribed, @arduinomaquinas thank you bro, 😉👍👍
@TheBoredRobotLLC
@TheBoredRobotLLC 8 ай бұрын
Thank you!
STM32 for Arduino - Connecting an RC receiver should be easy, right?
16:52
Whoa
01:00
Justin Flom
Рет қаралды 22 МЛН
Вы чего бл….🤣🤣🙏🏽🙏🏽🙏🏽
00:18
Little brothers couldn't stay calm when they noticed a bin lorry #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 20 МЛН
How I Did The SELF BENDING Spoon 😱🥄 #shorts
00:19
Wian
Рет қаралды 36 МЛН
Adventures in Science: Using an RC Hobby Controller with Arduino
9:42
SparkFun Electronics
Рет қаралды 81 М.
Building a DSM2 R/C Transmitter with Arduino
14:16
James Bruton
Рет қаралды 182 М.
Using an RC Controller with an Arduino [With code and wiring]
13:31
Analog output from PWM and a low-pass filter
14:13
nLab
Рет қаралды 10 М.
The AMA Club Model is Failing. Here's Why.
16:10
Tail Heavy Productions
Рет қаралды 36 М.
It's time for change, it's time for Linux.
10:53
DankPods
Рет қаралды 259 М.
An Easy Way to Read All RC Channels at Once with Arduino
4:21
The Bored Robot
Рет қаралды 4 М.
RC Robot Car - RC Controls and Arduino
47:53
DroneBot Workshop
Рет қаралды 211 М.
Reading PWM Receiver Signal Using Arduino
15:34
Kamran Ahmad
Рет қаралды 68 М.
Arduino DRONE II   Part 1 receiver PWM read
10:22
Electronoobs
Рет қаралды 57 М.
Whoa
01:00
Justin Flom
Рет қаралды 22 МЛН