I'm not sure the calculation of norm1..5 (should these be in an array?) should be in the interrupt handler.
I would probably read (and possibly discard ?) the first two blocks received in main - then calculate the values of norm (again in main or (better) a separate macro) - then display values received thereafter (though I'm assuming you really want to do something with the values received - turn rudder left etc) - how often are message packets received?
Do you have details of the RC system - with a datasheet (link) if possible.
Martin
UART Transmission with atmega328p
-
- Valued Contributor
- Posts: 1628
- http://meble-kuchenne.info.pl
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 142 times
- Been thanked: 761 times
-
- Valued Contributor
- Posts: 1628
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 142 times
- Been thanked: 761 times
Re: UART Transmission with atmega328p
Something like this maybe?
Martin
Martin
- Attachments
-
- IBUS3.fcfx
- (27.11 KiB) Downloaded 121 times
Re: UART Transmission with atmega328p
Oh great, thank you.
I use Flysky transmitters and receivers and their IBUS to control my camera for macro shots (focus, macro sliders, lighting etc.).
Unfortunately there is very little information about the Flysky IBUS. However, there are some c libraries for decoding. Maybe we can integrate them here? Of course a suitable comms component in Flowcode would be nice
.
Something is not quite working in your last chart, again only ‘wild’ numbers come out. I'll have to look for the reason...
I use Flysky transmitters and receivers and their IBUS to control my camera for macro shots (focus, macro sliders, lighting etc.).
Unfortunately there is very little information about the Flysky IBUS. However, there are some c libraries for decoding. Maybe we can integrate them here? Of course a suitable comms component in Flowcode would be nice

Something is not quite working in your last chart, again only ‘wild’ numbers come out. I'll have to look for the reason...
Re: UART Transmission with atmega328p
It was just a little something in the GetNormalisation macro... works great!
I forgot to add that the data set is updated every 7ms. I actually only need the updated data in my main loop every few hundred microseconds. Maybe the frequent interrupt slows down my main program too much, I'll have to test that.
I forgot to add that the data set is updated every 7ms. I actually only need the updated data in my main loop every few hundred microseconds. Maybe the frequent interrupt slows down my main program too much, I'll have to test that.
Re: UART Transmission with atmega328p
Oh yes, one more thing, I don't have to display the data in the application. I only needed it to see if the values are correct. I also only have to process the first 5 channels sent, i.e. 12 bytes with the header.
-
- Valued Contributor
- Posts: 1628
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 142 times
- Been thanked: 761 times
Re: UART Transmission with atmega328p
That's good - please post the modification in case anyone else is playing along...
The interrupt shouldn't cause issues (it's short and should be quick enough for 115200 baud - there are several paths but each is short) - but main needs to process the data and set state back to 0 to capture the next data packet. What needs to be done with data received? Can speed up processing (a bit)by reducing the loops to just handle the first 5 channels. 7ms is quite a while for an MCU
Still need to receive all 30 bytes though.
Martin
The interrupt shouldn't cause issues (it's short and should be quick enough for 115200 baud - there are several paths but each is short) - but main needs to process the data and set state back to 0 to capture the next data packet. What needs to be done with data received? Can speed up processing (a bit)by reducing the loops to just handle the first 5 channels. 7ms is quite a while for an MCU

Martin
-
- Valued Contributor
- Posts: 1628
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 142 times
- Been thanked: 761 times
Re: UART Transmission with atmega328p
Another idea - main could process data as it is received.
Once the header (0x2040) is received - it just needs to wait for 2 byte blocks of data (for each channel) then ignore the postamble.
However - there might be a checksum at the end of the data and it might be good to check this if possible - to stop a data error causing bad things to happen?
Martin
Once the header (0x2040) is received - it just needs to wait for 2 byte blocks of data (for each channel) then ignore the postamble.
However - there might be a checksum at the end of the data and it might be good to check this if possible - to stop a data error causing bad things to happen?
Martin
-
- Valued Contributor
- Posts: 1065
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 201 times
- Been thanked: 225 times
Re: UART Transmission with atmega328p
Hoi Chris, Hi Martin
I have similar problems with the uart with the STM32.
If I receive two characters (bytes) for example “AB” then the result was “BB”.
But with the PIC32 and ESP32 it was easy to send and receive data arrays.
Also in connection with the PC app. This was also never problem via Bluetooth.
One more question Chris, do you have a little more info about your setup with the ATMEGA328 , Ibus and camera?
Maybe I can use that too.
I only need two characters for my connection. Here is my example.
Need a counter to get both:
I have similar problems with the uart with the STM32.
If I receive two characters (bytes) for example “AB” then the result was “BB”.
But with the PIC32 and ESP32 it was easy to send and receive data arrays.
Also in connection with the PC app. This was also never problem via Bluetooth.
One more question Chris, do you have a little more info about your setup with the ATMEGA328 , Ibus and camera?
Maybe I can use that too.
I only need two characters for my connection. Here is my example.
Need a counter to get both:
- Attachments
-
- FC10_STM32_F469_1_post.fcfx
- (23.75 KiB) Downloaded 121 times
Re: UART Transmission with atmega328p
I process the received 5 channels to control a stepper motor and mosfets which then activate lights and one to focus. All slow processes in themselves. Therefore you could certainly also read in the data individually in the main routine.
Attached is the corrected ibus3 chart. Thanks again to Martin!
Certainly very useful for all those who want to transfer data via the IBUS. Especially in the rc area.
Attached is the corrected ibus3 chart. Thanks again to Martin!
Certainly very useful for all those who want to transfer data via the IBUS. Especially in the rc area.
- Attachments
-
- IBUS3.fcfx
- (26.47 KiB) Downloaded 130 times
Re: UART Transmission with atmega328p
Hi stefan.erni,
I have made myself a small electronics board. I almost always use the ATMEGA328P or the ATMEGA328PB (would have a few more ports, but unfortunately it is not fully supported in Flowcode). The controller is cheap at JLCPCB and small with enough PWM ports that I need for e.g. brightness control.
Years ago I built a macro rail that I now want to automate even further, including remote control via an rc transmitter and receiver.
If everything works so far I can post something here.
I have made myself a small electronics board. I almost always use the ATMEGA328P or the ATMEGA328PB (would have a few more ports, but unfortunately it is not fully supported in Flowcode). The controller is cheap at JLCPCB and small with enough PWM ports that I need for e.g. brightness control.
Years ago I built a macro rail that I now want to automate even further, including remote control via an rc transmitter and receiver.
If everything works so far I can post something here.