STM32 for Arduino - Connecting an RC receiver should be easy, right?

Поділитися
Вставка
  • Опубліковано 12 лип 2024
  • Let’s dive in the STM32 for Arduino code and learn more about the SysTick timer, millis(), micros() and interrupts. I mean, how hard can it be to measure a RC receiver pulse?
    Well, as always there are problems that need to be solved. And that’s great! Hopefully you can learn something from this video as I did while I was making it.
    My website: www.brokking.net/
    Video - Getting started with the STM32 microcontroller - STM32F103C8T6 via Arduino:
    • Getting started with t...
    Video - Getting started with the STM32 microcontroller - STM32F103C8T6 via Arduino:
    • Arduino for STM32 + MP...
    The Arduino STM32 project on GitHub:
    github.com/rogerclarkmelbourn...
    I bought the STM32F103C8T6 here:
    www.dx.com/p/stm32f103c8t6-arm...
    And also the FTDI programmer:
    www.dx.com/p/crius-ftdi-basic-...
    Download the example code here:
    www.brokking.net/UA-cam/STM32...
  • Наука та технологія

КОМЕНТАРІ • 120

  • @MrLimetto
    @MrLimetto 6 років тому +4

    That's what I call a great explanation. Keep up the nice animation / graphics! ;)

  • @EngineeringVignettes
    @EngineeringVignettes 6 років тому +1

    I like the way you progress though the problem, it is useful for the viewers to see how to work through these problems... life gets a bit trickier when you bring interrupt servicing into a previously simpler firmware design.
    I have been playing around with RC pulse (Tx and Rx) for a while now as well (going back to 1998!). If I could comment on that Interrupt Handler, I would highly recommend making the timer/tick interrupt the highest priority; this is the typical way it is done, especially when advancing to more complicated RTOS based firmware. As you have demonstrated, the tick is the literal heartbeat of the system and provides synchronization and timing for all other system, including other interrupts.
    Once again, thanks for the video. You constantly produce high quality content, well done.
    - Eddy

  • @divyanshu_harkhka
    @divyanshu_harkhka 6 років тому +1

    Great video as always.. From the past 5 days I'm literally checking your channel every hour to see if the next video is out or not.. Can't wait for the next video.. I have also ordered a STM32 for upgrading my drone.. :)

    • @Joop_Brokking
      @Joop_Brokking  6 років тому +2

      Please don't hold your breath for it. Making a video is very time consuming. It might even take two weeks or more :-(

    • @divyanshu_harkhka
      @divyanshu_harkhka 6 років тому

      Joop Brokking No problem sir.. Keep up your great work.. You are my motivation.. 👍👍

  • @MrRonychakraborty
    @MrRonychakraborty 6 років тому +2

    You are the boss :) carry on. Thanks for working on Stm32

  • @Tech2C
    @Tech2C 6 років тому +2

    Wow great presentation. Clear and detailed, thank you.
    For my RC projects I use Input Capture for PPM receiver inputs and Output Compare for PWM servo/motor outputs - this method is not CPU time sensitive and most importantly jitter-free.

  • @MrEdwardhartmann
    @MrEdwardhartmann 6 років тому

    Great video. I can't wait to see how you optimize this code.

  • @mrtmrf5007
    @mrtmrf5007 6 років тому +1

    Very good and easy tutorial ..keep the good work... thanks

  • @alk2345
    @alk2345 5 років тому +1

    Thank you that you explain this interesting things distinctly and not fast =)
    p.s. eng is not my lang =)

  • @fpvrcstuff
    @fpvrcstuff 6 років тому

    You Sir, are a genius ! Great video!

  • @Loopyengineeringco
    @Loopyengineeringco 6 років тому

    Fantastic explanation. Thank you!

  • @rodstartube
    @rodstartube 6 років тому

    as always, superb!

  • @RP6conrad
    @RP6conrad 6 років тому +1

    Excellent explanation what is going on in the Arduino code !! In my GPS-car, I use the sum-signal with a input capture function. Big advantage : only 1 pin is needed, and the Interrupt timing is not critical anymore because the timer value is stored by hardware. I dont know or this possible with Arduino, I use GCC-compiler.

  • @PhG1961
    @PhG1961 6 років тому +1

    Waw Joop, zeer goede video !

  • @Life-ze1no
    @Life-ze1no 6 років тому +1

    good videos...keep it going~!!! cheer

  • @judgeomega
    @judgeomega 3 роки тому +1

    is it possible to make interrupts only when the signal changes? then you can just have the interrupts toggle a variables, while the main loop uses the variables.

  • @silnangmarak
    @silnangmarak 2 роки тому +3

    can you use s-bus instead of using each channel to connect to stm?

  • @zhivebelarus560
    @zhivebelarus560 3 роки тому +2

    QQ: Could you just change the timer interrupt priority to highest to let the time function work correctly ? Instead of checking registers for overflow, seems simpler to me....

  • @sidaqbarw918
    @sidaqbarw918 2 роки тому +2

    Thank you very much but I have a problem error: 'Timer2' was not declared in this scope how do I solve this problem

  • @toddspeck9415
    @toddspeck9415 6 років тому

    Awesome!

  • @sergiourquijo4000
    @sergiourquijo4000 4 роки тому +1

    maybe a stupid question... What about using ibus instead of the pwm? I dont even know what ibus is but im about to inform me because i want to make something similar but with arduino so i only have two external interrupts

  • @berndeckenfels
    @berndeckenfels 5 років тому

    Could you only trigger one channel for the raising flank and only have the interrupts for each channel on the falling trigger?

  • @junuhunuproductions
    @junuhunuproductions 6 років тому

    Wow, this video is awesome! Thanks for sharing knowledge with the audience. I am, however curious why that problem of micros() reading being faulty DIDN'T occur at YMFC project series. Also, why is Arduino UNO much faster at finishing external interrupt functions?

  • @cue108
    @cue108 6 років тому

    you are awesome!

  • @browaruspierogus2182
    @browaruspierogus2182 6 років тому +1

    I think one core mcus are not very suitable for parallel tasks. I am getting esp32 family boards to experiment with different hardware. Also there is fast STM32F4 with Cortex-m4 and 168Mhz clock that could be good too.
    For advanced stuff more specific IDE/soft than Arduino is needed.
    I am waiting for cheap quad cortex mcu boards

  • @trarredbandit9734
    @trarredbandit9734 Рік тому +3

    Is it possible to do this with the esp32?

  • @tigransargsyan5835
    @tigransargsyan5835 6 років тому +1

    Hi Joop. I have a question regarding your code. The example modifies the variable receiver_input1 from the interrupt handler and displays (reads) it in the main loop. Given the fact that the variable receiver_input1 is 32-bits long, the execution of the function Serial.println() may be suspended in order for the interrupt handler to be executed first which could cause corrupted output of the function Serial.println(). May this be the cause of the spikes? Thank you!

    • @Joop_Brokking
      @Joop_Brokking  6 років тому +1

      The spikes are exactly 1ms long and are the result of the timer not updated due to the interrupt override.

  • @PeterK6502
    @PeterK6502 6 років тому

    Hoi, Ik heb ook effe een scoop op mijn futuba receiver (R617FS) gehangen, het pulse gedrag is gelijk aan wat je bij de fly sky receiver hebt getoond.

  • @hendmei7066
    @hendmei7066 2 роки тому +1

    hello, can you do it for the aircraft and specifically for the FSi A6B receiver!?

  • @raykent3211
    @raykent3211 6 років тому +3

    Excellent well-paced video, thanks! I'm left wondering whether anyone makes an rc receiver that just outputs digital information over I2C, for example. It seems absurd for it to be converted into the analogue domain (pwm) and back. I know that gives compatability with ordinary servos, but can you get I2C servos?

    • @Joop_Brokking
      @Joop_Brokking  6 років тому +4

      The PWM principle starts a long way back when the first transmitter/receivers where made. Most "digital" receivers mostly use the S.bus protocol. It's a serial data connection. You can get servo's that use the S.bus protocol.

    • @sriharivishnubhatla
      @sriharivishnubhatla 5 років тому +2

      How can we interface the STM32 or the arduino UNO to read the S.Bus signal?
      That would make the circuitry a lot simpler when it comes to wiring up the quad, doesn't it?

  • @roycas3
    @roycas3 5 років тому +1

    Can you please do a video for stm32 + NRF24 transceiver. ?

  • @adelashour3253
    @adelashour3253 4 роки тому +1

    Was there such problem in arduino uno? That didnt appeared in ymfc al

  • @noamkoren1839
    @noamkoren1839 6 років тому

    Hey Joop great work!! I was wandering where do you find the info about using direct pin manipulations for STM32f1?

    • @Joop_Brokking
      @Joop_Brokking  6 років тому +2

      In the datasheet and in the STM32 for Arduino core files.

  • @minseokkim6144
    @minseokkim6144 6 років тому

    Awesome

  • @christianolivergalopo1189
    @christianolivergalopo1189 6 років тому +1

    Good Day Sir! :) We are planning to build a drone using Arduino ATX2, but we do not know how to connect an RC controller to the micro-controller. Would you mind helping us out? You're help is really a big deal! Thank you so much!

  • @crescenciolara2279
    @crescenciolara2279 5 років тому +3

    Help needed
    With sketch STM32_ICM-2 I am able to check receiver channels on serial monitor
    With correct readings.
    Now if I use YMFC-32_Auto_Test_program_ver_1a
    This is what appears
    Waiting for a valid receiver channel_ 0 input signal
    The input pulse should be between 1000 til 2000
    Current channel-3 receiver input value =0
    I have tried two different radios and two different receivers.
    Help will be appreciated.
    Thank you

    • @araferw9479
      @araferw9479 5 років тому

      i have the same question

  • @chrisleech1565
    @chrisleech1565 6 років тому

    Greetings from Canada Joop, I was fooling around with these STM32 F103 dev boards a couple of years ago and the goal at the time was to mount the Cleanflight FW on it. Designed originally for multirotors , and an offshoot from Baseflight which has its origins in Multiwii.
    We had no problems running the earlier versions that were almost 128K of code with Baro and 9DOF module, plus a piezo beeper. But I went thru at least three of these dev bds, they would just refuse to go into boot mode. There are two or three versions of these STM32 break out boards out there and I can say that it pays to have a selection/supply to choose from. Reply if you wish the links to RCGroups thread. Best regards

  • @ervinsalazar9026
    @ervinsalazar9026 5 років тому

    HI can you please help me configure systick interrupt on arduino ide so i can trigger a code at 1Khz, please i need your help

  • @omhobby9481
    @omhobby9481 4 роки тому +2

    please make tutorial with frsky SBUS

  • @donkelly36
    @donkelly36 6 років тому +1

    Joop, you mention that your goal is to get the YMFC-AL to fly with the STM controller. Sounds great! Just curious why you didn't just go to the faster Arduino Zero or Due? Is it because you're wanting the smaller size of the STM? It looks like the 48MHz Arduino Zero, for example, may run the YMFC-AL code with little to no mods perhaps, yet the STM seems to require a lot.

    • @donkelly36
      @donkelly36 6 років тому

      Think I see the issue. Some of these faster boards aren't truely compatible with the real\original Arduino IDE. It has to do with arduino.cc separating from arduino.org. Aaaarrggg.

    • @Joop_Brokking
      @Joop_Brokking  6 років тому +3

      I have now specific reason for the STM32. I just like to explore new microcontrollers and the STM32 is really cheap and easy to obtain.

  • @birendrakumar-gl5gq
    @birendrakumar-gl5gq 5 років тому +1

    I have a question if i want to use 10 channel flysky transmitter and receiver,do i need to chande the code?

    • @Eren-to7nx
      @Eren-to7nx 3 місяці тому

      Hello, did you find the answer to this question?

  • @AndrewR2130
    @AndrewR2130 5 років тому +1

    Would it be possible to toggle a piece of code by reading output from rc reciver example coustom lights and flash patterns toggled via remote

  • @GrahamStw
    @GrahamStw 6 років тому

    Regarding the code at @9:20 - those functions are all marked "inline" so, as long as the compiler respects that, they shouldn't generate any overhead compared to directly accessing SYSTICK_BASE->CNT

  • @garyprice3757
    @garyprice3757 6 років тому +1

    Got the same scope. Encoders are rubbish but apart from that, a fairly reasonable device.

  • @HAMZAHAHMED
    @HAMZAHAHMED 6 років тому

    great #

  • @john92648
    @john92648 4 роки тому +1

    Hi, after trying the first examples i'm now on the setup test and by compile the code I get error message YMFC-32_Setup_ver-1a:31:1: error: 'HardWire' does not name a type
    HardWire HWire(2, I2C_FAST_MODE);
    Any idea was is going wrong by me
    Regards

  • @vitaliyd193
    @vitaliyd193 6 років тому

    thanks! I messed my arduino to read these 60 month ago, and gave up. Cant wait for next video !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @davebenemerito310
    @davebenemerito310 5 років тому +2

    I am thinking what college degree I'm going to learn things just like this one and microcontrollers.. what would be the best fit?

    • @Joop_Brokking
      @Joop_Brokking  5 років тому +3

      I learned everything I know at home :-) I'm a high voltage engineer by trade.

    • @davebenemerito310
      @davebenemerito310 5 років тому +1

      Good to know, thanks for the reply :)

    • @alaksmcgregor3358
      @alaksmcgregor3358 5 років тому +1

      Try electrical engineering.

    • @davebenemerito310
      @davebenemerito310 5 років тому +1

      Would computer engineering be relevant?

    • @macieksoft
      @macieksoft 5 років тому +2

      Take some free time and reliable internet connection, no need for college. I learned microcontrollers at home when i was just 13, all using just information from internet. Don't be scared by digital, it won't bite you ;-)

  • @stevenlee1726
    @stevenlee1726 6 років тому

    Hi, Sir. I wonder whats the difference between using arduino IDE and using IDE like keil u vision to program stm32f103c8t6. Will arduino take up much more memory?

    • @Joop_Brokking
      @Joop_Brokking  6 років тому +1

      The Arduino IDE will give you a head start and setup all the base settings to get the board to run. This will consume some memory but not much.
      With Keil you might need to setup the microcontroller by hand. This means a very steep learning curve.

    • @pow9606
      @pow9606 3 роки тому

      @@Joop_Brokking Once you learn it you can do inline debugging which is a breath of fresh air. I'm going to start by using NUCLEO-F103RB board and Keil. Hopfully I will start have hair left afterwards.

  • @rich1051414
    @rich1051414 5 років тому +1

    Can someone explain how the STM32 is better than the various ATMega chips? It seems more difficult to work with.

    • @signalworks
      @signalworks 5 років тому +3

      And to summarize: Much, much faster, a lot cheaper, many more interrupts and better PWM as well as better ADC.

    • @macieksoft
      @macieksoft 5 років тому +9

      32bit architecture vs 8bit. 10*12bit ADC vs 8*10bit. 20kB SRAM vs 8kB or less. From 64 up to 256kB of FLASH (depends on particular chip) vs from 8 to 128kB. USB and CAN even in lower end chips. 3*UARTs vs 1 or 2. 2*I2C vs 1. 2*SPI vs 1. Build in bootloader trough UART, SPI and STLINK vs SPI/ISP only. 72MHz max rated clock (WO overclocking) vs about 16MHz or so. Battery back up for RAM. Far more advanced interrupts, timers. More hardware PWM.

    • @walidhanniche5545
      @walidhanniche5545 5 років тому +1

      Daft punk already did
      Harder better faster stronger

  • @aminezitouni8427
    @aminezitouni8427 6 років тому +1

    Joop you must please notice, in 5:46 "every 4 ms instead of every 4μs"

  • @zeshan2973
    @zeshan2973 5 років тому +4

    11:58 can anybody please explain this line....
    if (ob1 & SCB_BASE -> ICSR >> 26) ?

    • @Joop_Brokking
      @Joop_Brokking  5 років тому +6

      This line is true when the 26 bit of the ICSR register is set.
      ob1 is just a one
      & is the operator and
      SCB_BASE -> ICSR is the reference to the ICSR register
      >> 26 moves the bits 26 positions to the right

    • @timothysimonthomas3396
      @timothysimonthomas3396 3 роки тому +1

      @@Joop_Brokking could you please elaborate a bit more please, or suggest relevant material?

    • @waplet
      @waplet 3 роки тому +1

      @@timothysimonthomas3396
      >> is bitwise operator which shifts one bit right.
      0b11110000 >> 1 equals 0b1111000.
      And thus >> 26, means 26 shifts to the right.
      Then there is & operator (0b1 & (etc)) , after all execution just ANDs the whole expression
      if (0b1 & 0b1) then it's true.

  • @davide5137
    @davide5137 6 років тому +1

    Why not using arm mbed language?
    However great work joop, thisi is amazing!!

    • @Joop_Brokking
      @Joop_Brokking  6 років тому +3

      Because the STM32 for Arduino add-on has it's own specific functions. But working with registers will work on all platforms and IDE's.

    • @davide5137
      @davide5137 6 років тому

      and apart from the registers code, do you think mbed language could be faster than arduino language on an mbed enabled stm32 board?

  • @JoaoNelsonLima
    @JoaoNelsonLima 6 років тому +1

    enable captions

  • @siarheibartashevich2287
    @siarheibartashevich2287 4 роки тому +1

    What about Jittering?

  • @adityapachore366
    @adityapachore366 3 місяці тому +2

    Sir, the Example code links are not working!

  • @omhobby9481
    @omhobby9481 5 років тому +2

    My brain is smoking...but its very interesting

  • @MarcelOoms
    @MarcelOoms 6 років тому

    Great video! Maybe stupid; would it not be faster to handle 1 channel only as RISING interrupt (as they occur at the same time), and then only handle FALLING interrupts separately? That would probable almost half the total time spent on interrupts?

    • @RobertShaverOfAustin
      @RobertShaverOfAustin 6 років тому

      That's only true for the _Futaba_ receiver. (Timecode 13:34) The _Fly Sky_ receiver staggers the start pulses. (Timecode 13:18) I don't think you want your code to only work with certain brands of receivers. By the way, maybe _Fly Sky_ staggered the start of the pulses to make the code reading them to not cause all those interrupts at the same time. On the other hand, the end of the pulses could get synchronized at random times and still have the same problem. It would be a very rare occurrence, the hardest kind of issue to discover during testing.

    • @MarcelOoms
      @MarcelOoms 6 років тому

      O, clear.

  • @Kongfufrank
    @Kongfufrank 3 роки тому

    Ide arduino não funciona? Falta arquivos? Ensina instalar stm32 em aduino ide?

  • @tcurdt
    @tcurdt 6 років тому

    It's odd that the system timer does not use the highest priority. Is there no (easy) way to change that?

    • @Joop_Brokking
      @Joop_Brokking  6 років тому +2

      The I2C hardware needs the highest priority. So it's not possible to set the systick to the highest priority without problems. That's one of the downsides of the STM32. On the other hand the systick interrupt keeps pending so it stays accurate and only differs a few nanoseconds.

  • @sumit_kashyap..
    @sumit_kashyap.. 6 років тому +1

    What is different between 3 axis and 6 axis gyro ???

    • @Joop_Brokking
      @Joop_Brokking  6 років тому

      There is no 6-axis gyro. What you mean is 6 degrees of freedom. This is 3 gyro axis + 3 accelerometer axis.

  • @SKElectronics
    @SKElectronics 6 років тому +1

    I had a problem. I am using a ppm receiver and a mpu6050 but I'M able to read one thing at a time I you needed the code Then I can send you but please Solve that problem. Or make a dedicated video so that everyone can use ppm receiver.

  • @andybarnard4575
    @andybarnard4575 6 років тому

    My understanding is that in the Arduino version of the code with 4 channels the case of all state changes happening simultaneously will generate 4 interrupts each one interrupting each other, and the ISR routine will run 4 times. However the state change for all channels will be handled the first time the ISR routine is run, and the subsequent 3 times through the routine do nothing. A good approach for timing accuracy.So to compare apples with apples, my question is: is the 17uS (272 clock cycles) measured for the Arduino 4 times through its ISR routine or once? I'm hoping :-) the final goal of these new videos is to port YMFC-AL to STM32 leaving enough processing power to add compass, barometer and (perhaps) GPS.

    • @Joop_Brokking
      @Joop_Brokking  6 років тому

      The Arduino is measured with 4 channels all have a rising edge at the same time.

  • @noijze
    @noijze 6 років тому

    aren't there S-bus libraries available for arduino or so

    • @Joop_Brokking
      @Joop_Brokking  6 років тому +1

      The S.Bus is just an inverted 100kbps UART signal. You don't need an library for that.
      But not everybody has a S.Bus output. So to keep it useful for everybody I will use normal PWM.

  • @sukhee5
    @sukhee5 5 років тому +1

    Where did you bought FDTI. I need model number FDTI.

  • @gacherumburu9958
    @gacherumburu9958 6 років тому +1

    🤔🤔

  • @plazmax
    @plazmax 6 років тому

    Is it not programed via usb port ? Need ftdi?

    • @SKElectronics
      @SKElectronics 6 років тому

      plazma Yes it needed ftdi or stlink.

    • @JeanLucCoulon
      @JeanLucCoulon 6 років тому

      This is described in the previous video of the series: "Getting started with the STM32 microcontroller - STM32F103C8T6 via Arduino"
      I recommand you view it before this one (as it is told by Joop in this video).

    • @Loopyengineeringco
      @Loopyengineeringco 6 років тому

      You can program it via USB if you flash a different bootloader to it, i recommend doing it! github.com/rogerclarkmelbourne/STM32duino-bootloader

    • @sodichz
      @sodichz 6 років тому

      Many thanks for your effort. Kindly note that I did your YMFC Al. the. I tried to make the 32 one , but I faced same issue which you explained here.

    • @mikebrown7366
      @mikebrown7366 5 років тому

      @@Loopyengineeringco I think that doesn't always work. Different PC's running different versions of windows won't always detect the USB device correctly. It has something to do with the wrong resistor value pulling up one of the USB lines. It violates some plug and play specification, so some computers have trouble with it. I prefer using STLink device to program the STM32. They are very cheap and allow the ability to free up all flash (no bootloader) and hardware debugging using GDB.

  • @superdau
    @superdau 6 років тому

    It hurts a little to see how the STM32 is limited so much by trying to make it "arduino like". The STM32 hardware is so much more capable (not just in speed and memory but general functions) than the AVR. Using timer input capture will make this problem much easier (or at least easier to make glitch free while being efficient).

    • @Joop_Brokking
      @Joop_Brokking  6 років тому +2

      The STM32 for Arduino indeed limits the functionality of the STM32 with the core files. Luckily it's possible to use direct register access. This way it's still possible to use almost every function of the STM32.

    • @gatisozols
      @gatisozols 6 років тому +1

      I totaly agree about timer capture. I have made an STM32 HID joystick with ppm receiver, the PPM decoding took about 10 lines of code.

    • @dexop
      @dexop 6 років тому

      Gatis Ozols could you share your code?

    • @RobertShaverOfAustin
      @RobertShaverOfAustin 6 років тому +1

      I really appreciate how clearly you are describing your code and the issues. Your diagrams are very clear and helpful.
      I hope you will work on the core files and then submit a patch. That way you fix the problem for everyone, not just your projects. At the very least there could be a DEFINE that specifies which processor the code is intended for so that conditional compilation can add features for those processors that have them.

    • @gatisozols
      @gatisozols 6 років тому +1

      Sorry for the delay missed Your comment github.com/gatis-ozols/ppm_stick Beware that that is CubeMX generated code (meant for STM32 System Workbench IDE), it is NOT Arduino IDE compatible.

  • @TanishqIsHere
    @TanishqIsHere 6 років тому +1

    Joop, in your title there is a tiny grammatical error, use 'an' instead of 'a' before 'RC'

    • @Joop_Brokking
      @Joop_Brokking  6 років тому

      Thanks for the tip. I thought that 'an' should only be used with a vowel sound. And 'a' with a consonant sound. Please elaborate.... I'm Dutch ;-)

    • @TanishqIsHere
      @TanishqIsHere 6 років тому

      Exactly, just like there is _an hour_ not _a hour_ .
      Even though the words are starting with a consonant alphabet but their pronunciation produces a vowel sound.
      Similarly when pronouncing _R_ , there is a _Schwa_ sound, phonetic transcription : *_ɑ_* ,which is similar to a vowel sound.

    • @Joop_Brokking
      @Joop_Brokking  6 років тому

      Thank you for the explanation! I will change the title :-)

  • @wouter11234
    @wouter11234 6 років тому +1

    Isn't it an RC and not a RC?