demanding too much from arduino nano?

hi all,
I'm trying to build a telemetry system for a diy uav.
I have a ground station with an lcd and switches and a transiever.

The drone board does a few main things:
Reads in the drones battery voltage via a voltage divider.
Transmits the data via software serial using a 3dr radio module.
reads in the controller ppm signal from the rc reciever.
Outputs pwm signals to servos.

I am currently only experimenting with 1 servo and the issue is that the servo jitters quite a lot.

I commented out the ppm reader to see if that helped but it made no difference.

Is this too much for the arduino nano? should i use a mega (but quite large in size)?

I also considered the stm 32 but all the library's wont work and i have never done anything with the actual timers and hard coding all of the functionality.

here is the code for the drone controller:

//including the required librarys
#include <EasyTransfer.h> //communication protocol
#include <PPMReader.h>    //allows rc reciever to be read
#include <Servo.h>        //allows us to write to the servos
#include <SoftwareSerial.h>//allows communication with the 3dr module(s)

EasyTransfer ETin, ETout; //begins communication protocol

SoftwareSerial Radio(10,11);//begins serial communication with the 3dr radio

Servo servo1; //initialises servo 1

//initialising ppm readability
int interruptPin = 2;
int channelAmount = 6;
PPMReader ppm(interruptPin, channelAmount);

//voltage from the battery (1)
int vraw;

//communication prptocol setup
struct RECEIVE_DATA_STRUCTURE{//recieved data
  int16_t switch1; //switch 1
};

struct SEND_DATA_STRUCTURE{//sent data
  int16_t volts;  //battery voltage (raw)
  int16_t rollcmd;  //roll value read from the reciever
};


RECEIVE_DATA_STRUCTURE rxdata; //finalising the data structure
SEND_DATA_STRUCTURE txdata;

void setup() { //seting up 
  Radio.begin(57600); //initialises serial with radio
  ETin.begin(details(rxdata), &Radio); //begins recieve protocol
  ETout.begin(details(txdata), &Radio); //begins transmit protocol
  servo1.attach(3); //begins the servo
  rxdata.switch1 = 0; //beginning the switch value as off
  txdata.volts=0;     // starting voltage at 0
}

void loop() { //main processing loop
  
  txdata.rollcmd = ppm.latestValidChannelValue(1, 0); //reading in the roll value
  
  if(Radio.available())//recieving any new data
  {
    ETin.receiveData(); 
  }
  
  vraw = analogRead(A1);//reading in the battery voltage
  txdata.volts = vraw;  //writing it to vraw
  //writing servo value accordiung to switch position
  if(rxdata.switch1==1) 
  {
    servo1.write(60);
  }
  else if(rxdata.switch1==0)
  {
    servo1.write(10);
  }
  
  delay(10);//short delay
  
  ETout.sendData();//send the data
}

Any suggestions would be great!

I have not had to resolve this in my work but as I understand, there is a conflict between softwareserial.h and servo.h

I recall conversations that servotimer2 and/or AltSoftwareSerial

Ah, here is a discussion on the topic.

The Servo library and SoftwareSerial both use the same timer. There is a ServoTimer2 library that uses a different timer. There are several versions of this library out there - some of which may not be compatible with current versions of the IDE.

I am currently only experimenting with 1 servo and the issue is that the servo jitters quite a lot.

Probably caused by SoftwareSerial.

Is this too much for the arduino nano? should i use a mega (but quite large in size)?

Either that or use the hardware serial interface for your radio and do the debugging over the same channel.

georgegohl888:
reads in the controller ppm signal from the rc reciever.
Outputs pwm signals to servos.

Is it essential to use the RC transmitter and receiver?

If you use a pair of nRF24L01+ wireless transceivers the nano won't have the task of interpreting the pulse widths which requires a lot of computation.

The nRF24s would also provide a 2-way communication system.

...R
Simple nRF24L01+ Tutorial

pylon:
Probably caused by SoftwareSerial.

Either that or use the hardware serial interface for your radio and do the debugging over the same channel.

How can I debug and use the radio over the same channel? wont one block the other?

Robin2:
Is it essential to use the RC transmitter and receiver?

If you use a pair of nRF24L01+ wireless transceivers the nano won't have the task of interpreting the pulse widths which requires a lot of computation.

The nRF24s would also provide a 2-way communication system.

...R
Simple nRF24L01+ Tutorial

I use the rc transmitter and receiver as the primary method of control. It works over a longer range and works better than my sketchy at best system. I then use the 3dr modules (which work the same as the nrf24) to transmit and recieve other data. I want to read the reciever signal because in the future I will add fly by wire functionality.

Removing the ppm functionality didn't improve the issue either...

vinceherman:
I have not had to resolve this in my work but as I understand, there is a conflict between softwareserial.h and servo.h

I recall conversations that servotimer2 and/or AltSoftwareSerial

Ah, here is a discussion on the topic.

The Servo library and SoftwareSerial both use the same timer. There is a ServoTimer2 library that uses a different timer. There are several versions of this library out there - some of which may not be compatible with current versions of the IDE.

thanks ill have a look!

vinceherman:
I have not had to resolve this in my work but as I understand, there is a conflict between softwareserial.h and servo.h

I recall conversations that servotimer2 and/or AltSoftwareSerial

Ah, here is a discussion on the topic.

The Servo library and SoftwareSerial both use the same timer. There is a ServoTimer2 library that uses a different timer. There are several versions of this library out there - some of which may not be compatible with current versions of the IDE.

I tried servo timer 2 library but it yields no change. I'm suspecting software serial is the issue here. Would using a dedicated servo board help? or maybe using another arduino nano and using another software serial to combine them?

How can I debug and use the radio over the same channel? wont one block the other?

Not block but maybe disturb. That depends what instance is receiving the data. If that can handle to receive additional debugging data, you're fine.

The Servo library and SoftwareSerial both use the same timer.

Bullshit, SoftwareSerial don't use a timer. Newer versions of the IDE even include a version which don't block all interrupts anymore, so it's important to have a new IDE or at least an up-to-date AVR core. Which one do you use?

I've I changed to use altsoftserial. This initially clashed with the servo library but then i switched to use servo timer 2. Now it all works like a treat! thanks for the help :slight_smile: