SBUS icon indicating copy to clipboard operation
SBUS copied to clipboard

NANO V3

Open ghost opened this issue 7 years ago • 7 comments

Hy, it uses fine on Mega, on UNO but seems stucked on NANO V3 (ATmega328p), is it not possible ? I have add Softawre serial to be able to readsome debugs which work on UNO but no possibility to see anything on Arduino Nano. On a program I am making for rc model lighting using SBUS from channel 9, I get running on UNO but not on Nano. Nothing happens. I am trying since a week now and a good advice if NANO yes or no would be nice. Otherwise it is a perfect library. Thanks for reply, André

ghost avatar Oct 28 '17 22:10 ghost

Doesn't work reliably on Pro Mini as well. Initializes once in 50 resets.

voroshkov avatar Oct 05 '18 07:10 voroshkov

Found a workaround which seems to work reliably on Pro Mini: It merely reboots Arduino until it starts capturing valid packets. Surprisingly enough this code works pretty good and fast.

#define SBUS_WARM_UP_TIME_MS 100

void(* resetArduino) (void) = 0; //declare reset function at address 0

void setup() {
    sbus.begin(false);

    uint32_t ms = millis();
    while(millis() - ms < SBUS_WARM_UP_TIME_MS) {
        sbus.process();
    }

    if (sbus.getGoodFrames() == 0) {
        resetArduino();
    }
    ...

voroshkov avatar Oct 05 '18 19:10 voroshkov

How do you get it to work on nano? @voroshkov did it not work at all for you at first ? when you used pro mini

eskaflon avatar Oct 26 '18 05:10 eskaflon

@eskaflon, yes - didn't work on Pro Mini until I implemented the "hack" described above. Tried 2 ProMinis with the same result. At the same time didn't notice an issue on Uno board. That's weird because both have ATMega328p chip, 16MHz oscillator and 5V voltage

voroshkov avatar Oct 26 '18 06:10 voroshkov

@voroshkov Weird how it doesnt work on these boards, thanks for the hack. Is this how you used it ?

#include <SBUS.h>
#define SBUS_WARM_UP_TIME_MS 100
SBUS sbus(Serial);

void(* resetArduino) (void) = 0; //declare reset function at address 0


void setup()
{
  sbus.begin(false);

  uint32_t ms = millis();
  while(millis() - ms < SBUS_WARM_UP_TIME_MS) {
      sbus.process();
  }

  if (sbus.getGoodFrames() == 0) {
      resetArduino();
  }
  sbus.begin();
  Serial.begin(115200);
  Serial.println("SBUS Status");
}

// this is timer2, which triggers ever 1ms and processes the incoming SBUS datastream
ISR(TIMER2_COMPA_vect)
{
  sbus.process();
}
...

eskaflon avatar Oct 26 '18 07:10 eskaflon

@eskaflon, no. On proMini you cannot use sbus & Serial, because Serial is used for sbus. Not sure about timer ISR - didn't try that.

My code is as follows:

...
void setup() {
    sbus.begin(false);
    uint32_t ms = millis();
    while(millis() - ms < SBUS_WARM_UP_TIME_MS) {
        sbus.process();
    }
    if (sbus.getGoodFrames() == 0) {
        resetArduino();
    }
    // also setup pins and other stuff as usual...
    ...
}

void loop() {
    sbus.process();
    ...
    // and the loop should not be long to avoid sbus losing packets
}

voroshkov avatar Oct 26 '18 07:10 voroshkov

What about Arduino micro?

jasin755 avatar Aug 15 '19 06:08 jasin755