I would like to have a more versatile PWM decoder to decode both the Duration and Frequency of PWM signals from 1 to 100kHz. Could you please show how that would be accomplished if capable using arduino. Thanks for your great work!
Excellent series of videos, very clear and concise!! Do you know how to use these inputs to switch an output pin on a UNO, to switch an LED array on and off based on the pulse width? Say,
Hi karan Very good, your tutorial! helped me a lot. Let me ask you 3 questions? The first, is it possible to use the other interrupt ports? I have the atmega 328p -AU, and in the datasheet informs that it has 23 interrupt ports. I changed the code, added more variables to store the timer values and port, for exemple B00010000 But the interruption occurs only in pins 12,13,14 and 15. For example, in the datasheet it says that pin 1 is also interrupt, but it does not work. I'll need to use 3 ports to read 3 channels from my receiver, But then I'll need to use two PWM ports for this. I wanted to use an interrupt port that did not have the PWM function. In my case I need the 6 PWM ports. Do you know how? The other question is, the pulsein command would help me solve this problem. But the problem is that when the signal is missing, it takes too long. But the advantage of pulsein is that you can use any port to read PPM signal. Do you know how the pulse in command works? Or just how to do a PWM via software? Thanks!
Hello! is it possible to control the speed of stepper motor (Nema17)? WITH this code? writing down the required code? I tried everything, but I didn't get it.
It`s absolutly stunning how well you teach me... but the code I write by my own does not show anything on serial monitor plz fix the download link of the code cuz it does not working now! thanks
PCINT15-8 are registered with interrupt enabler PCIE1 therefore you first need to run PCICR |= (1 PCINT15 can be used as interrupt pins but they are managed by PCMSK1 register, to enable each pin use PCMSK1 |= (1
That mistake is very common, PCINT16 has input register PINK not PIND. Using PINK & B00000001 should work. Depending on what you want the micro controller to do, try to avoid using digitalRead as it has many overheads and takes long to compute.
Thanks for the help! I'm wondering if you can help me fix another issue kind of related to this. I'm using this code you showed in the videos to read my RC receiver's 6 channels. Now I'm using the built in Servo library to actually control my servos, and they have a really bad jitter problem. The servos glitch a couple degrees every few seconds, I think the arduino library is not very good. I have no idea where to even begin to write my own servo control code.
Do you have a flysky fsi6? If yes, then you need ia6b receiver to use ppm option. the stock receiver cannot work with ppm. More on interfacing ppm here www.instructables.com/id/Reading-RC-Receiver-PPM-Signal-Using-Arduino/
something is not working good for my Leonardo pro micro for input[0] I get 6724 and for toher channels I get around: input[1] 13884 input[2] 11528 input[3] 12192 just by touching the analog pins by hand!
If the pins are open, they are likely to generate noise. Make sure they are connected to source if needed otherwise ground them or disable their interrupt.
Hi! Would it be possible to reupload the Link for the Final Code? I tried to copy it on the go and I think I almost did it, but its not quite working and I'm quite confused as to what I did wrong. Having the Final code would be a great help, thanks!
+Chris Pavey Sorry, I fixed it but the video probably got cut in post so it wasn't mentioned. The final code is actually using 5 timers which is correct. I'm trying to annotate that error but it wouldn't let me...
I follow the same procedure but the channel which I have selected as last always giving wrong values. But the other channels are working fine. Do you have any idea about this?
+Niloy Sarkar I would check if the board supports interrupt at that pin. Also verify that you are allocating correct variables. Finally could be a broken connection.
how to choos which pin for which channel? I have a Leonardo Pro Micro and want to hook my receiver as joystick, the joystick library is working now I need to know what pins are good and how to set them up for receiver inputs (4-5 channels enough for me) According to documentation: Micro, Leonardo, other 32u4-based, Digital Pins Usable For Interrupts: 0, 1, 2, 3, 7 But on the board pin numbers start from 2..10 then 14 15 16, no other pins like pin 1 or pin 0 media.apcmag.com/wp-content/uploads/sites/20/2014/01/apcnews2012apc-arduino-foot-switch-project-thumb_mainImage2.jpg2.jpg upd: oh I found it the RX0 and TX1 are used for it: External Interrupts: 0(RX), 1(TX), 2, 3 and 7. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details. Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the Micro, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class. So far I could get: docs.google.com/document/d/1ew2NMjswf7mPXAz_kwTeJL5NdgQKJrjOKzxiGQrffEU/edit?usp=sharing
You code seems good to me, in order to choose the pins you want to use, you need to cross reference PCINT0 -> PCINT3 from data sheet to arduino pinout. Then when you plug the pins in, they should read. If you think interrupts are not working correctly, try running one interrupt at a time to see if they all work on their own.
hi. you should write a program to get the values (input[0-3]) and convert them into PWM signals if you are using an ESC. I would use the servo library. search controlling a brushless motor with Arduino. and i would use the Map function in Arduino. Hope this helps
In Uno Board serial print of" interrupt" is also not responding. I'm giving to the pulses signal to the 8,9,10,11 pins but not responding. Can you please mention reason for that.
Superb Tutorial! The code is no nonsense and clean, Does the job wonderfully.. Thankyou so much
Hi Kamran, So how can I implement the Failsafe after switch off the Receiver, possible implement this?
I would like to have a more versatile PWM decoder to decode both the Duration and Frequency of PWM signals from 1 to 100kHz. Could you please show how that would be accomplished if capable using arduino. Thanks for your great work!
Excellent series of videos, very clear and concise!!
Do you know how to use these inputs to switch an output pin on a UNO, to switch an LED array on and off based on the pulse width? Say,
Does this work with a nano?
Hi karan
Very good, your tutorial!
helped me a lot.
Let me ask you 3 questions?
The first, is it possible to use the other interrupt ports?
I have the atmega 328p -AU, and in the datasheet informs that it has 23 interrupt ports.
I changed the code, added more variables to store the timer values and port, for exemple B00010000
But the interruption occurs only in pins 12,13,14 and 15.
For example, in the datasheet it says that pin 1 is also interrupt, but it does not work.
I'll need to use 3 ports to read 3 channels from my receiver,
But then I'll need to use two PWM ports for this.
I wanted to use an interrupt port that did not have the PWM function.
In my case I need the 6 PWM ports.
Do you know how?
The other question is, the pulsein command would help me solve this problem.
But the problem is that when the signal is missing, it takes too long.
But the advantage of pulsein is that you can use any port to read PPM signal.
Do you know how the pulse in command works?
Or just how to do a PWM via software?
Thanks!
Hello!
is it possible to control the speed of stepper motor (Nema17)?
WITH this code?
writing down the required code?
I tried everything, but I didn't get it.
It was nice video ..excellent very useful.
You great , thank you , please dont stop
It`s absolutly stunning how well you teach me...
but the code I write by my own does not show anything on serial monitor
plz fix the download link of the code cuz it does not working now!
thanks
Very good post, thanks a lot :-)
+Christoph Borst Thanks
OMG, thank you, it helps a lot
How would you use PCINT13-8 for this?
PCINT15-8 are registered with interrupt enabler PCIE1 therefore you first need to run
PCICR |= (1 PCINT15 can be used as interrupt pins but they are managed by PCMSK1 register, to enable each pin use
PCMSK1 |= (1
actually switched over to a MEGA board and I'm using
PCICR |= (1
That mistake is very common, PCINT16 has input register PINK not PIND. Using PINK & B00000001 should work.
Depending on what you want the micro controller to do, try to avoid using digitalRead as it has many overheads and takes long to compute.
Thanks for the help! I'm wondering if you can help me fix another issue kind of related to this. I'm using this code you showed in the videos to read my RC receiver's 6 channels. Now I'm using the built in Servo library to actually control my servos, and they have a really bad jitter problem. The servos glitch a couple degrees every few seconds, I think the arduino library is not very good. I have no idea where to even begin to write my own servo control code.
Nice Video, explained very well! Thanks
very good tutorial... can you tell me the difference between ppm on and off in rx settings on tx
Do you have a flysky fsi6? If yes, then you need ia6b receiver to use ppm option. the stock receiver cannot work with ppm. More on interfacing ppm here www.instructables.com/id/Reading-RC-Receiver-PPM-Signal-Using-Arduino/
thank, can you show how to use attachInterrupt this function to do the same thing
something is not working good for my Leonardo pro micro for input[0] I get 6724
and for toher channels I get around:
input[1] 13884
input[2] 11528
input[3] 12192
just by touching the analog pins by hand!
If the pins are open, they are likely to generate noise. Make sure they are connected to source if needed otherwise ground them or disable their interrupt.
Hi! Would it be possible to reupload the Link for the Final Code? I tried to copy it on the go and I think I almost did it, but its not quite working and I'm quite confused as to what I did wrong. Having the Final code would be a great help, thanks!
How would you add more than 8 channels?
Thank you. This is a good, clear explanation and demonstration.
a question... Is it possible to read 5 PWM signals on arduino uno?
Yes, you can
your final code link does not work, but good tutorial!!
curious if this is possible on an ESP32S?
got it to work on the ESP32S with a different method but using the same logic, thank you!
Quick question on the timer array. You've declared an array of 4 timers but then used timers 0 > 4. Why does this not throw an error?
+Chris Pavey Sorry, I fixed it but the video probably got cut in post so it wasn't mentioned. The final code is actually using 5 timers which is correct. I'm trying to annotate that error but it wouldn't let me...
its not working on my teensy..
Wonderful Tutorial! Thank you!
Stunning!!
Really good.
Thanks!
Your idea create.but i use attachInterrupt instead. Thank you.
I follow the same procedure but the channel which I have selected as last always giving wrong values. But the other channels are working fine. Do you have any idea about this?
+Niloy Sarkar I would check if the board supports interrupt at that pin. Also verify that you are allocating correct variables. Finally could be a broken connection.
how to choos which pin for which channel? I have a Leonardo Pro Micro and want to hook my receiver as joystick, the joystick library is working now I need to know what pins are good and how to set them up for receiver inputs (4-5 channels enough for me)
According to documentation:
Micro, Leonardo, other 32u4-based, Digital Pins Usable For Interrupts: 0, 1, 2, 3, 7
But on the board pin numbers start from 2..10 then 14 15 16, no other pins like pin 1 or pin 0
media.apcmag.com/wp-content/uploads/sites/20/2014/01/apcnews2012apc-arduino-foot-switch-project-thumb_mainImage2.jpg2.jpg
upd: oh I found it the RX0 and TX1 are used for it:
External Interrupts: 0(RX), 1(TX), 2, 3 and 7. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.
Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the Micro, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class.
So far I could get:
docs.google.com/document/d/1ew2NMjswf7mPXAz_kwTeJL5NdgQKJrjOKzxiGQrffEU/edit?usp=sharing
You code seems good to me, in order to choose the pins you want to use, you need to cross reference PCINT0 -> PCINT3 from data sheet to arduino pinout. Then when you plug the pins in, they should read. If you think interrupts are not working correctly, try running one interrupt at a time to see if they all work on their own.
Thanks man helped alot
hi,,how to controll brushless motor with this project ??
hi. you should write a program to get the values (input[0-3]) and convert them into PWM signals if you are using an ESC. I would use the servo library. search controlling a brushless motor with Arduino. and i would use the Map function in Arduino. Hope this helps
Bro its working on Mega board but it's not showing the values well.. I'm just getting 0 - 0 -0- 0
In Uno Board serial print of" interrupt" is also not responding. I'm giving to the pulses signal to the 8,9,10,11 pins but not responding. Can you please mention reason for that.
same here... all 0-0-0-0