SBUS input

Status
Not open for further replies.

funwey

New member
I have been trying on the following code for reading SBUS input from a frsky receiver:
#include "Wire.h"
#include "SBUS.h"

// a SBUS object, which is on hardware
// serial port 1
SBUS x8r(Serial1);

// channel, fail safe, and lost frames data
uint16_t channels[16];
bool failSafe;
bool lostFrame;

void setup() {
Wire.begin();
Serial.begin(115200);
// begin the SBUS communication
x8r.begin();
}

void loop() {
int i = 1;
// look for a good SBUS packet from the receiver

Serial.println("h");
if(x8r.read(&channels[0], &failSafe, &lostFrame)){
Serial.println("h234 ");
// write the SBUS packet to an SBUS compatible servo
for (i=0; i < 8; i++) {
Serial.print(i);
Serial.print(" :");
Serial.print(channels);
Serial.print(" "); };
Serial.println();

x8r.write(&channels[0]);
}
}

I am using Pin0 (RX1) (and also tried RX5) on Teensy4 as input and the SBUS signal from the receiver passes through an inverter circuit. This code and setup works on an Arduino Mega 2560 board, but not on the teensy4. Please help.
 
I have tried using 3.3V or 5V, lowering the CPU speed to 24MHz, using #include <I2C_t3.h>. All not working on teensy4.
 
Bit of an old post, BUT.... With the Bolder library and Teensy 4.0 you do NOT need the inverter circuit. After trying a lot with an inverter (using 4049 chip) I found the comment deep in one of the fora (forums?) Cannot remember exactly where just yet. I connected an xmplus via a level shifter (very careful here, because the xmplus likes 5v, but the teeensy doesn't). The sbus wire goes straight to (rpt. via level shifter) the rx pin on Teensy.

This works:-
Code:
#include <elapsedMillis.h>
#include <SBUS.h>

// reads an SBUS packet from an
// SBUS receiver.

#include "SBUS.h"

SBUS xmplus(Serial1);
void setup() {
  xmplus.begin();
  Serial.begin(9600);
//  Joystick.useManualSend(true);
}

void loop() {
   float channels[16]; bool failSafe; bool lostFrame;
   while(xmplus.readCal(&channels[0], &failSafe, &lostFrame)){
    
      Joystick.Zrotate(int((channels[0] + 1.0) * 512.0));  // ailerons - roll
      Joystick.Z(int((channels[1] +1.0) * 512.0));        // Elevator - pitch
      Joystick.Y(int((channels[2] +1.0) * 512.0));        // Throttle
      Joystick.X(int((channels[3] +1.0) * 512.0));        // Rudder - Yaw
      Joystick.sliderLeft(0);
      Joystick.sliderRight(0);

      delay(5);
      }
}

Seems like a waste of the Teensy..... only 1% of memory used !! I tested with FPVFreerider Works ok.


Hmmmm! Found the thread - 'tis an answer to funway ......
 
Last edited:
Status
Not open for further replies.
Back
Top