BrushlessPower / SBUS2-Telemetry

Arduino Library for SBUS and SBUS2 with Futaba Telemetry
GNU General Public License v3.0
84 stars 23 forks source link

SBUS Channel data #54

Closed BRolandG closed 9 months ago

BRolandG commented 9 months ago

Hi I'm building a RC plane tween engine sync device based on UM TINYPICCO. Using the engine's RPM values to adjust the slave engine's throttle position via a PID. I need both channel data and sensor data. Trottel, rudder, gain, and a switch channel to operate it. Sensors nnede are RPM for the master engine and the slave engine.

My problem is that the channel data received via the SBUS channel ranges from 352 to 1695. I expected it to range from 1101us to 1942us. I measured the expected values with my oscilloscope.

Bernt

ericlangel commented 9 months ago

Hello,

it sounds ok to me

it should be 172 and 1811 for 1000µs and 2000µs

BRolandG commented 9 months ago

Hi

Thanks for Your quick reply. I assumed the values (172 to 1811) to be in us format so I could send them directly to the slave engine servo from my Tinypicco. There is something I don't understand here....

I´m using Futaba T32MZ transmitter and R7008SB recceiver. And I want to send a PWM signal in 1000us to 2000us intervall to my slave servo from one GPIO pin on Tinypicco.

Bernt

BRolandG commented 9 months ago

Hi

I think I get it, I will just map() the channel value. What confuses me is why my Futaba setup give me that range on sbus and the 1000-2000us range on the recceiver pin.

Bernt

ericlangel commented 9 months ago

Hello,

for a correct answer you have to ask Futaba.

but i guess that a Dual Rate of 150% in Transmitter will end in SBUS Values from 0 to 2000 (or 2048). and that would be around 900µs to 2100µs

As you said, the easiest way is map().

Could you try the 150% Servo in Transmitter and tell us the SBUS Values?

BRolandG commented 9 months ago

Hi, yes still struggling with this nonlinear conversion.

I have used T32MZ and R7008SB and Picoscope7 to measure pwm.

Bernt

Sbus value min 100% mid max 100% 1 352 1023 1695 2 354 1027 1695 3 352 1025 1695 4 352 1023 1695 Pwm values 1 1100 1520 1940 2 1100 1523 1940 3 1100 1522 1940 4 1100 1520 1940 3,125 1,486 1,145

Den tors 23 nov. 2023 kl 07:43 skrev ericlangel @.***>:

Hello,

for a correct answer you have to ask Futaba.

but i guess that a Dual Rate of 150% in Transmitter will end in SBUS Values from 0 to 2000 (or 2048). and that would be around 900µs to 2100µs

As you said, the easiest way is map().

Could you try the 150% Servo in Transmitter and tell us the SBUS Values?

— Reply to this email directly, view it on GitHub https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54#issuecomment-1823882432, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE7YBZRP5KWXYYC5JA7HA3YF3WCJAVCNFSM6AAAAAA7UWDRMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRTHA4DENBTGI . You are receiving this because you authored the thread.Message ID: @.***>

BRolandG commented 9 months ago

Hi again.

I was wrong it is linear.. sorry. Map works fine even with the transmitter endpoints set to 150%.

Bernt

Sbus min endpoint max endpoint 1 84 1963 2 89 1963 3 84 1963 4 84 1963 PWM 1 933 2108 2 937 2108 3 933 2108 4 935 2108

Den tors 23 nov. 2023 kl 16:39 skrev Bernt Glada @.***>:

Hi, yes still struggling with this nonlinear conversion.

I have used T32MZ and R7008SB and Picoscope7 to measure pwm.

Bernt

Sbus value min 100% mid max 100% 1 352 1023 1695 2 354 1027 1695 3 352 1025 1695 4 352 1023 1695 Pwm values 1 1100 1520 1940 2 1100 1523 1940 3 1100 1522 1940 4 1100 1520 1940 3,125 1,486 1,145

Den tors 23 nov. 2023 kl 07:43 skrev ericlangel @.***

:

Hello,

for a correct answer you have to ask Futaba.

but i guess that a Dual Rate of 150% in Transmitter will end in SBUS Values from 0 to 2000 (or 2048). and that would be around 900µs to 2100µs

As you said, the easiest way is map().

Could you try the 150% Servo in Transmitter and tell us the SBUS Values?

— Reply to this email directly, view it on GitHub https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54#issuecomment-1823882432, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE7YBZRP5KWXYYC5JA7HA3YF3WCJAVCNFSM6AAAAAA7UWDRMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRTHA4DENBTGI . You are receiving this because you authored the thread.Message ID: @.***>

ericlangel commented 9 months ago

Thank you for sharing your results.

I would close the Issue at this point, because i cant change anything. Its a Futaba/SBUS specific think.

BRolandG commented 9 months ago

Hi

Yes problem solved. It works perfekt as it is. It was my misstanke.

Thanks!

Bernt

fre 24 nov. 2023 kl. 08:31 skrev ericlangel @.***>:

Closed #54 https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54 as completed.

— Reply to this email directly, view it on GitHub https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54#event-11053589369, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE7YB723S4FIENC3JKGKY3YGBEONAVCNFSM6AAAAAA7UWDRMKVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRGA2TGNJYHEZTMOI . You are receiving this because you authored the thread.Message ID: @.*** com>

BRolandG commented 9 months ago

Hi

I have tested some more with Futaba T32MZ and R7008SB. I read in another SBUS thread that the sbus range should be 0-2047, that is correct. These values are with + - 150% and trim in max / min position. So this is the absolute range.

define SBUS_MIN 0

define SBUS_MAX 2047

define PWM_MIN 882

define PWM_MAX 2161

Bernt

Den fre 24 nov. 2023 kl 08:47 skrev Bernt Glada @.***>:

Hi

Yes problem solved. It works perfekt as it is. It was my misstanke.

Thanks!

Bernt

fre 24 nov. 2023 kl. 08:31 skrev ericlangel @.***>:

Closed #54 https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54 as completed.

— Reply to this email directly, view it on GitHub https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54#event-11053589369, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE7YB723S4FIENC3JKGKY3YGBEONAVCNFSM6AAAAAA7UWDRMKVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRGA2TGNJYHEZTMOI . You are receiving this because you authored the thread.Message ID: @.*** com>

ericlangel commented 9 months ago

Nice to Know

BRolandG commented 8 months ago

Hi

Thanks for your nice code, it works like a charm.. I do have one question for you.

I run this code in my loop and poll for new data. I want the fresh frames as soon as they are available, but I don't want to use that data unless it is fresh. As i works with this code the slots is ok but the SBUS_Ready function is true for any frame. So I reuse the channel data as if it was fresh.

The purpose of my code is to synchronize two engines RPM with a PID and I want to feed the PID ony with new data.

Bernt

Den mån 27 nov. 2023 kl 11:41 skrev ericlangel @.***>:

Nice to Know

— Reply to this email directly, view it on GitHub https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54#issuecomment-1827579969, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE7YB2U56XDZRSLTENOVX3YGRU6JAVCNFSM6AAAAAA7UWDRMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRXGU3TSOJWHE . You are receiving this because you authored the thread.Message ID: @.***>

ericlangel commented 8 months ago

24

already discovered but never uploaded

ericlangel commented 8 months ago

in the Master Branch its already fixed, but not uploaded in arduino Lib Manager

BRolandG commented 8 months ago

Hi Yes I tested that, thanks.

However what I'm looking for is a way to poll for just new frames. I guess that works fine for telemetry slots since the SBUS2_Ready() is true every 56ms. But SBUS_Ready() is true every 14ms.

Bernt

Den mån 11 dec. 2023 kl 07:49 skrev ericlangel @.***>:

in the Master Branch its already fixed, but not uploaded in arduino Lib Manager

— Reply to this email directly, view it on GitHub https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54#issuecomment-1849424328, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE7YB65PYMDO5MLDI3WP7LYI2UHPAVCNFSM6AAAAAA7UWDRMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBZGQZDIMZSHA . You are receiving this because you authored the thread.Message ID: @.***>

ericlangel commented 8 months ago

normally sbus2_ready should also trigger every 14ms

every SBUS(2) Frame contains complete Servo Channel data with an Update interval of 14ms.

but complete Telemetry Data needs 4 SBUS(2) Frames. So Telemetry can be updated 4 x 12ms = 56ms.

If i understand you correctly: you have two Motors and want to sync them. So you need RPM Value and Throttle Value very fast.

What you could do: Make 4 RPM Sensor Slots with the same actual RPM Value

Slot 1 (SBUS Frame 1) Slot 8 (SBUS Frame 2) Slot 16 (SBUS Frame 3) Slot 24 (SBUS Frame 4)

So your actual RPM Value is send every 14ms. now you "just" have to read the SBUS2 Frame every 14ms

BRolandG commented 8 months ago

Hi thanks.

That is creative.. Good idea, I will try that.

Bernt

Den mån 11 dec. 2023 kl 10:02 skrev ericlangel @.***>:

normally sbus2_ready should also trigger every 14ms

every SBUS(2) Frame contains complete Servo Channel data with an Update interval of 14ms.

but complete Telemetry Data needs 4 SBUS(2) Frames. So Telemetry can be updated 4 x 12ms = 56ms.

If i understand you correctly: you have two Motors and want to sync them. So you need RPM Value and Throttle Value very fast.

What you could do: Make 4 RPM Sensor Slots with the same actual RPM Value

Slot 1 (SBUS Frame 1) Slot 8 (SBUS Frame 2) Slot 16 (SBUS Frame 3) Slot 24 (SBUS Frame 4)

So your actual RPM Value is send every 14ms. now you "just" have to read the SBUS2 Frame every 14ms

— Reply to this email directly, view it on GitHub https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54#issuecomment-1849596124, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE7YBZLTVWYFN6JH4Y7H5TYI3DZFAVCNFSM6AAAAAA7UWDRMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBZGU4TMMJSGQ . You are receiving this because you authored the thread.Message ID: @.***>

BRolandG commented 8 months ago

Hi

No, it did not work! TX will only accept a sensor Id ones, so I can not register the same sensor in TX 4 times. Did I understand your idea right?

Bernt

Den mån 11 dec. 2023 kl 10:12 skrev Bernt Glada @.***>:

Hi thanks.

That is creative.. Good idea, I will try that.

Bernt

Den mån 11 dec. 2023 kl 10:02 skrev ericlangel @.***>:

normally sbus2_ready should also trigger every 14ms

every SBUS(2) Frame contains complete Servo Channel data with an Update interval of 14ms.

but complete Telemetry Data needs 4 SBUS(2) Frames. So Telemetry can be updated 4 x 12ms = 56ms.

If i understand you correctly: you have two Motors and want to sync them. So you need RPM Value and Throttle Value very fast.

What you could do: Make 4 RPM Sensor Slots with the same actual RPM Value

Slot 1 (SBUS Frame 1) Slot 8 (SBUS Frame 2) Slot 16 (SBUS Frame 3) Slot 24 (SBUS Frame 4)

So your actual RPM Value is send every 14ms. now you "just" have to read the SBUS2 Frame every 14ms

— Reply to this email directly, view it on GitHub https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54#issuecomment-1849596124, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE7YBZLTVWYFN6JH4Y7H5TYI3DZFAVCNFSM6AAAAAA7UWDRMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBZGU4TMMJSGQ . You are receiving this because you authored the thread.Message ID: @.***>

ericlangel commented 8 months ago

not sure i think you dont need your TX.

how is you setup? one ESP for one engine? so Engine 1 is master and engine 2 is slave?

and the Slave sends RPM Value to the Master via SBUS?

BRolandG commented 8 months ago

My setup is

One airframe 2 engines.

Master engine trottel servo runs directly from RX. Slave engine trottel servo runs directly from ESP.

I also need data from 4 channels in ESP. Master trottel Mode Gain Rudder

During startup I control slave trottel pwm with master trottel pwm. Rudder is used to set an RPM offset to PID setpoint, based on mode and gain channels.

The ESP is running the PID. The PID setpoint is master RPM, actual value is slave RPM. The PID then deliver output as PWM trottelposition for the slave engine. I PWM write that directly to the slave engines servo from the ESP.

Bernt

mån 11 dec. 2023 kl. 15:27 skrev ericlangel @.***>:

not sure i think you dont need your TX.

how is you setup? one ESP for one engine? so Engine 1 is master and engine 2 is slave?

and the Slave sends RPM Value to the Master via SBUS?

— Reply to this email directly, view it on GitHub https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54#issuecomment-1850188307, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE7YB7HKWNCYUEAK7WZGALYI4J3PAVCNFSM6AAAAAA7UWDRMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJQGE4DQMZQG4 . You are receiving this because you authored the thread.Message ID: @.***>

ericlangel commented 8 months ago

so you are having just one esp in your plane? or two?

i dont understand what is connectet to SBUS?

p.s. a little bit offtopic: watch out with PWM generated by ESP -> if the ESP have a firmwareissue the PWM is generated with the last value all the time, you cant stop that engine.

i'am doing somthing similar. i get the throttle value from RX and modify that value and send it to the ESC. two years ago i had the isuue that i couldnt stop because the esp was blocked somewere.

BRolandG commented 8 months ago

Hi thanks.

They say that a picture/drawing is more clear than a 1000 words. Perhaps my code will explain what I'm trying to do....

Bernt

Den tis 12 dec. 2023 kl 07:45 skrev ericlangel @.***>:

so you are having just one esp in your plane? or two?

i dont understand what is connectet to SBUS?

p.s. a little bit offtopic: watch out with PWM generated by ESP -> if the ESP have a firmwareissue the PWM is generated with the last value all the time, you cant stop that engine.

i'am doing somthing similar. i get the throttle value from RX and modify that value and send it to the ESC. two years ago i had the isuue that i couldnt stop because the esp was blocked somewere.

— Reply to this email directly, view it on GitHub https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54#issuecomment-1851395307, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE7YBYU4BEYSXVHFUE5DI3YI74P7AVCNFSM6AAAAAA7UWDRMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJRGM4TKMZQG4 . You are receiving this because you authored the thread.Message ID: @.***>

ericlangel commented 8 months ago

so you have one ESP and 2 Futaba RPM Sensors?

BRolandG commented 8 months ago

Yes that is correct.

Bernt

tis 12 dec. 2023 kl. 12:02 skrev ericlangel @.***>:

so you have one ESP and 2 Futaba RPM Sensors?

— Reply to this email directly, view it on GitHub https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54#issuecomment-1851815105, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE7YB2L4SPDIV3P5TKTEZLYJA2TFAVCNFSM6AAAAAA7UWDRMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJRHAYTKMJQGU . You are receiving this because you authored the thread.Message ID: @.***>

ericlangel commented 8 months ago

ok now i understand your hardware.

so with the Futaba RPM Sensor you will just receive the RPM Value every 56ms. You cant get it faster.

BRolandG commented 8 months ago

Yes that is right.

I would really like to have a more frequent RPM update. The sensor detect a signal every 6ms @ 10000 rpm.

Bernt

tis 12 dec. 2023 kl. 12:56 skrev ericlangel @.***>:

ok now i understand your hardware.

so with the Futaba RPM Sensor you will just receive the RPM Value every 56ms. You cant get it faster.

— Reply to this email directly, view it on GitHub https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54#issuecomment-1851895734, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE7YBZ4ZZB5Z6NSXL2GSNLYJBBABAVCNFSM6AAAAAA7UWDRMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJRHA4TKNZTGQ . You are receiving this because you authored the thread.Message ID: @.***>

ericlangel commented 8 months ago

if price doesnt matter, you could use 4 Futaba RPM Sensors per Engine Each sensor with its own Slot

Engine 1 Slot 1 (SBUS Frame 1) Slot 8 (SBUS Frame 2) Slot 16 (SBUS Frame 3) Slot 24 (SBUS Frame 4)

Engine 2 Slot 2 (SBUS Frame 1) Slot 9 (SBUS Frame 2) Slot 17 (SBUS Frame 3) Slot 25 (SBUS Frame 4)

or building your own RPM sensor

BRolandG commented 8 months ago

Hi

Yes that would work I guess, but not neat…

Perhaps 56ms is frequent enough for my purpose. If not I have one version using interrupt that works.

Bernt

tis 12 dec. 2023 kl. 13:43 skrev ericlangel @.***>:

if price doesnt matter, you could use 4 Futaba RPM Sensors. Each sensor with its own Slot

Engine 1 Slot 1 (SBUS Frame 1) Slot 8 (SBUS Frame 2) Slot 16 (SBUS Frame 3) Slot 24 (SBUS Frame 4)

Engine 2 Slot 2 (SBUS Frame 1) Slot 9 (SBUS Frame 2) Slot 17 (SBUS Frame 3) Slot 25 (SBUS Frame 4)

or building your own RPM sensor

— Reply to this email directly, view it on GitHub https://github.com/BrushlessPower/SBUS2-Telemetry/issues/54#issuecomment-1851964772, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEE7YB55LQYQVHNKCJCAU2LYJBGPBAVCNFSM6AAAAAA7UWDRMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJRHE3DINZXGI . You are receiving this because you authored the thread.Message ID: @.***>