Trying to move from USB to battery power for Nano 33 BLE and Fitec FS90 servo

We are making a parachute-release for a model rocket. We have an Arduino Nano 33 BLE and a Fitec Micro Servo 9g FS90 as well as various battery options including a HJ 852540 3.7V LiPo (giving 4V) and 4 AA batteries in series.

We are attempting to initiate the servo 4 seconds after the onboard accelerometer detects an acceleration on the x axis of more than 2g. We have so far been able to achieve this (though with the x acceleration set to 0.5g and without the delay to facilitate testing) but as soon as we detach from the USB the system stops working.

We have tested using the layout in the attached image but with power supplied by USB from a laptop, and we're using pin 9 for the PWM signal to the servo. We've tested various battery combinations, including both the LiPo and the 6V from 4 AA batteries in at Vin, and we've also supplied power to the USB socket from a power source (instead of the laptop). In each case the function ceases to work once the laptop connection is removed.

Our code is:

*/
int servoPin=9;
int servoPos=0; 
int LEDpin=13;

#include <Arduino_LSM9DS1.h>
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

void setup() {
  myservo.attach(servoPin);  // attaches the servo on pin 9 to the servo object
  Serial.begin(9600);
  while (!Serial);
  Serial.println("Started");

  if (!IMU.begin()) {
    Serial.println("Failed to initialize IMU!");
    while (1);
  }

  Serial.print("Accelerometer sample rate = ");
  Serial.print(IMU.accelerationSampleRate());
  Serial.println(" Hz");
  Serial.println();
  Serial.println("Acceleration in G's");
  Serial.println("X\tY\tZ");
}

void loop() {
  
  float x, y, z;

  if (IMU.accelerationAvailable()) {
    IMU.readAcceleration(x, y, z);

    Serial.print(x);
    Serial.print('\t');
    Serial.print(y);
    Serial.print('\t');
    Serial.println(z);

if (x > .5) for (servoPos = 5; servoPos <= 90; servoPos += 3) { // goes from 0 degrees to 110 degrees
    // in steps of 3 degree
    myservo.write(servoPos);              // tell servo to go to position in variable 'pos'
   delay(15);                       // waits 15ms for the servo to reach the position
  }
  if (x > .5) for (servoPos = 90; servoPos >= 5; servoPos -= 3) { // goes from 90 degrees to 0 degrees
    myservo.write(servoPos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position;


}}}

Many thanks for your insights! This is our first Arduino project and we have scoured tutorials and the forum but realise we may be missing material that's already published, so grateful for your patience too!

1 Like

Please post a real wiring diagram for the failing attemt.

Hello
take a look here and read the section
Powering the board

paulpaulson:
Hello
take a look here and read the section
Powering the board

Thank you Paul - we have followed these instructions and tested both 4.0V and 6.0V at Vin (we also cut the SJ4) to test with unregulated power and then reconnected in order to be able to return to USB power when that didn't work. Since, I think, Vin should regulate down from 6V, we cannot figure out why we are not getting the servo activated (and since we cannot plug in the USB we are not able to see the activity of the accelerometer via the serial monitor).

Railroader:
Please post a real wiring diagram for the failing attemt.

Thanks Railroader - we haven't yet figured out how to produce diagrams - sorry! We have tested several configurations to try to provide the right power to the servo, and the best appears to be to power the servo in parallel with the arduino with both grounded and the battery providing either 4V (LiPo) or 6V (4xAA) via Vin. The only other pin in use is pin 9 for the PWM to the servo. We have also experimented with using the 5V out for the servo power, but found this only gives 5V when on USB power (dropping to less than 0.5V when the board is on battery power).

Try pen and paprt! No need for royal stamps in the corner. Preferably use black colour.

What is the Ah rating of the battery in use?

The servo could require up to 800mA and that requirement may cause a power failure.

Oh, 650mA is the battery rating from the pic. Talk to Scottie, he may be able to help you get more power.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.