Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NANO V3 #7

Open
ghost opened this issue Oct 28, 2017 · 7 comments
Open

NANO V3 #7

ghost opened this issue Oct 28, 2017 · 7 comments

Comments

@ghost
Copy link

ghost commented Oct 28, 2017

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é

@voroshkov
Copy link

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

@voroshkov
Copy link

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();
    }
    ...

@eskaflon
Copy link

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

@voroshkov
Copy link

voroshkov commented Oct 26, 2018

@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

@eskaflon
Copy link

eskaflon commented Oct 26, 2018

@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();
}
...

@voroshkov
Copy link

voroshkov commented Oct 26, 2018

@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
}

@jasin755
Copy link

What about Arduino micro?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants