Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Serial plotter and monitor don't work while using sbus

  1. #1
    Junior Member
    Join Date
    Jan 2021
    Posts
    5

    Serial plotter and monitor don't work while using sbus

    Hello,
    I am working on a basic drone project with teensy 3.6. Just started and try to read values from Radiolink at9s pro. I use futaba sbus example and want to see the values of first 4 channels of the transmitter. But according to a youtube channel, I should observe the values in serial monitor and plotter (https://www.youtube.com/watch?v=98MwXc7FuMk this is Turkish but you can see 17:20-19:20).He is using arduino mega and I am trying to do the exact same thing with using teensy 3.6. But when I open serial plotter or monitor nothing happens. Usb Type:Serial and Port: COM6 Serial (Teensy 3.6).
    Here is my code:

    Code:
    #include <FUTABA_SBUS.h>
    
    
    
    FUTABA_SBUS sBus;
    
    
    void setup(){
      sBus.begin();
      Serial.begin(115200);
    }
    
    void loop(){
      sBus.FeedLine();
      if (sBus.toChannels == 1){
        sBus.UpdateServos();
        sBus.UpdateChannels();
        sBus.toChannels = 0;
    
    Serial.print(sBus.channels[0]);
    Serial.print(",");
    Serial.print(sBus.channels[1]);
    Serial.print(",");
    Serial.print(sBus.channels[2]);
    Serial.print(",");
    Serial.print(sBus.channels[3]);
    Serial.println();
      }
    }
    Thank you and sorry for the language.

  2. #2
    Senior Member brtaylor's Avatar
    Join Date
    Mar 2016
    Location
    Portland, OR
    Posts
    708
    I'm guessing it's this library?
    https://github.com/mikeshub/FUTABA_SBUS

    The issue is that SBUS uses inverted serial. Based on the way the library opens the serial port, I'm guessing the intent is to use a hardware inverter. I'm partial to it, but I would recommend using the SBUS library I wrote, it was optimized for Teensy:
    https://github.com/bolderflight/SBUS

    My SBUS library correctly uses the inverted serial available to Teensy so you don't need any external hardware. Hope that helps.

  3. #3
    Junior Member
    Join Date
    Jan 2021
    Posts
    5
    Quote Originally Posted by brtaylor View Post
    I'm guessing it's this library?
    https://github.com/mikeshub/FUTABA_SBUS

    The issue is that SBUS uses inverted serial. Based on the way the library opens the serial port, I'm guessing the intent is to use a hardware inverter. I'm partial to it, but I would recommend using the SBUS library I wrote, it was optimized for Teensy:
    https://github.com/bolderflight/SBUS

    My SBUS library correctly uses the inverted serial available to Teensy so you don't need any external hardware. Hope that helps.
    Thank you for your answer,
    Yes I was using that library(mikeshub) and using with an external hardware as an inverter. I tried your library's examples without using any external hardware but in AIN_SBUS_example I got values of channels that randomly changes and can't controlled by my transmitter. I am undergraduate and don't know much of this topic but I will try to learn. But for now if you have any recomendations or ideas I would love to hear.
    Thank you again.

  4. #4
    Senior Member brtaylor's Avatar
    Join Date
    Mar 2016
    Location
    Portland, OR
    Posts
    708
    Well, the issue is that the AIN example is reading POT values and sending that to SBUS servos, which is not really what you're trying to do as far as I understand it. The below example, just reads all 16 channels from an SBUS receiver and prints the value along with failsafe and lost link information. Note that it assumes the SBUS receiver is connected to Teensy Serial 2, you might need to edit that to whatever UART the SBUS receiver is connected to.

    Code:
    /*
    * Brian R Taylor
    * brian.taylor@bolderflight.com
    * 
    * Copyright (c) 2018 Bolder Flight Systems
    * 
    * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
    * and associated documentation files (the "Software"), to deal in the Software without restriction, 
    * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
    * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
    * furnished to do so, subject to the following conditions:
    * 
    * The above copyright notice and this permission notice shall be included in all copies or 
    * substantial portions of the Software.
    * 
    * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
    * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
    * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
    * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    */
    
    /*
    * Description: this program will print all 16 SBUS channel values
    * plus lost frame and failsafe as read from an SBUS receiver. 
    */
    
    #include "SBUS.h"
    
    /* The Teensy SBUS interfaces on Serial2 */
    SBUS sbus(Serial2);
    /* 16 SBUS channels, reading */
    float SbusRead[16];
    /* Failsafe and lost frame status */
    bool Failsafe, LostFrame;
    
    void setup()
    {
      /* Serial for printing the command */
      Serial.begin(115200);
      while (!Serial) {}
      /* Starting SBUS communication */
      sbus.begin();
    }
    
    void loop()
    {
      /* print the received values */
      if (sbus.readCal(&SbusRead[0], &Failsafe, &LostFrame)) {
        for (unsigned int i = 0; i < sizeof(SbusRead) / sizeof(float); i++) {
          Serial.print(SbusRead[i]);
          Serial.print("\t");
        }
        Serial.print(LostFrame);
        Serial.print("\t");
        Serial.println(Failsafe);
      }
    }

  5. #5
    Also can recommend brtaylor's library. Have used it before on a build before and it was awesome!

  6. #6
    Junior Member
    Join Date
    Jan 2021
    Posts
    5
    Yes I realized that AIN example is not doing what I trying to do(felt very ignorant ). But this code worked perfectly the way I wanted to. Also no needed to use any external hardware. Thank you very much for all of you help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •