dognaught47
New member
I have 2 questions regarding how best to use SBUS.h
Is it expected that PWMServo.h is required when using SBUS.h?
The following code using SBUS.h and PWMServo.h works as expected with a Teensy 4.1 receiving sbus signals from the TBS Crossfire 8ch diversity RX. If I switch to using Servo.h, I get very strange results where I essentially can't get reliable servo movement (in this example only the servo on channel 28 will work). I found a note at the bottom of this page describing known Interrupt Latency issues with some libraries. Is this a known issue with SBUS.h? Or am I doing something wrong?
Is the SBUS library that you can find through the Teensyduino Library Manager the most recent one?
While working on this project, I came across the SBUS git repository and that code seems to be different than what I get through the Teensyduino Library Manager. This got me to wondering if I should be trying to use that code instead. What's the best practice here? I tried to follow the installation instructions but I wasn't successful as it seems like there are dependancies on another library (core.h) and couldn't figure out how to put all those pieces together to produce a working library.
A big thank you to brtaylor for your excellent contribution. I'm super happy to be able to use this library and benefit from reduced latency and fewer wires in my project.
Is it expected that PWMServo.h is required when using SBUS.h?
The following code using SBUS.h and PWMServo.h works as expected with a Teensy 4.1 receiving sbus signals from the TBS Crossfire 8ch diversity RX. If I switch to using Servo.h, I get very strange results where I essentially can't get reliable servo movement (in this example only the servo on channel 28 will work). I found a note at the bottom of this page describing known Interrupt Latency issues with some libraries. Is this a known issue with SBUS.h? Or am I doing something wrong?
Code:
#include <PWMServo.h>
#include "SBUS.h"
#define NUM_OF_CHANNEL 8
SBUS x8r(Serial2);
uint16_t channels[NUM_OF_CHANNEL];
bool failSafe;
bool lostFrame;
PWMServo servoA;
PWMServo servoB;
void setup() {
// put your setup code here, to run once:
x8r.begin();
//using standard serial port for debugging
Serial.begin(9600);
servoA.attach( 28 );
servoB.attach( 29 );
}
void loop() {
if ( x8r.read(&channels[0], &failSafe, &lostFrame ) ) {
Serial.print("got data ch3:");
Serial.print( channels[3] );
int pos = channels[3] / 11;
servoA.write( pos );
servoB.write( pos );
Serial.println("");
} else {
Serial.println("no data");
}
}
Is the SBUS library that you can find through the Teensyduino Library Manager the most recent one?
While working on this project, I came across the SBUS git repository and that code seems to be different than what I get through the Teensyduino Library Manager. This got me to wondering if I should be trying to use that code instead. What's the best practice here? I tried to follow the installation instructions but I wasn't successful as it seems like there are dependancies on another library (core.h) and couldn't figure out how to put all those pieces together to produce a working library.
A big thank you to brtaylor for your excellent contribution. I'm super happy to be able to use this library and benefit from reduced latency and fewer wires in my project.