Go Down

Topic: Erratic Behavior Without USB Connection (Read 621 times) previous topic - next topic

ba47

Following my post on " How To Start A Random Task On Power Up", now I'm faced with a new problem.

My setup is a panel with Arduino Uno R3 + two 16 channel PWM servo controllers + 25 servos. Powered by a switching power supply adapter AC 110-240v to DC 5v - 6A - 30W.
The panel has both a switch for complete shut down of power and a PIR sensor which detects motion
when the power switch is on and powers up the panel.

It all works fine when the panel is connected to the USB port of my computer but without the USB connection, the 10 servos connected to the first PWM controller just shake and no task is performed.

I'm stuck and would appreciate your help.



Peterd51

Hi,

People will need a diagram and the sketch to start with.

Peter

ballscrewbob



Please
READ THIS POST to help you get the best out of the forum.

SIMPLE TROUBLESHOOTING.

These steps may also save you some unnecessary time and effort in the forum.

  • Always provide as much detail as possible to your issue it may be important.
  • If applicable provide your SKETCH inside CODE TAGS ( </> ) or a CREATE share link.
  • If applicable provide a schematic even if hand drawn.
  • How to insert a picture into your post
  • If applicable provide a proper LINK to the hardware / sensors etc. you are using.


Bob.

[/list]
It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

sterretje

@ba47, please check the subtitle of this forum section (I've added the emphasis).
Quote
Installation & Troubleshooting -

For problems with Arduino itself, NOT your project
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

UKHeliBob

I am not sure of the best place to deal with such a question but it will get more exposure here than its original location
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

ba47

Ty all for your answers.

Peterd51, ok, I'm attaching wiring diagram and code.

Bob, right, I should have included more info, srry.

streteetje, I thought my problem was with Arduino itself, not just my project.  Pls correct me if I'm wrong.

UKHellBob, I hope you are right and I get some help here.

Please take a look at the attachment to see my wiring diagram. 
I tried following this wiring and have no servo movement without USB connection.
Then I tried (maybe a mistake, but a try) feeding Arduino directly with 5v. through the barrel connector.
Now, running the below sketch on power up, I get 10 shaky servos connected to PWM0 (the first control card) and nothing else.

Here is the simple "sweep" code I'm trying to run :

Code: [Select]



#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40);   // Initiates library.
Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x41);   // Initiates library.

#define SERVOMIN  110  // Minimum pulse length count out of 4096.
#define SERVOMAX  588 // Maximum pulse length count out of 4096.

int servoNo = 0; // Defines a counter for servos.

void setup()
{
  Serial.begin(9600);       // Starts serial connecton at 9600 baud rate.
  pwm.begin();         // Sends PWM signals.
  pwm.setPWMFreq(60);  // Makes servos run at 60 Hz rate.
  pwm2.begin();         // Sends PWM signals.
  pwm2.setPWMFreq(60);
  delay(20);

  for (int myservo = 0; myservo < 11; myservo++)
    pwm.setPWM(myservo, 0, SERVOMIN);
  delay(20);

  for (int myservo = 0; myservo < 16; myservo++)
    pwm2.setPWM(myservo, 0, SERVOMIN);
  delay(20);


}

void loop()
{
  for (int pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++)
  {
    for (servoNo = 0; servoNo < 11; servoNo++)
      pwm.setPWM(servoNo, 0, pulselen);
    delay(1);

    for (servoNo = 0; servoNo < 16; servoNo++)
      pwm2.setPWM(servoNo, 0, pulselen);
    delay(1);
  }

  for (int pulselen = SERVOMAX; pulselen > SERVOMIN; pulselen--)
  {
    for (servoNo = 0; servoNo < 11; servoNo++)
      pwm.setPWM(servoNo, 0, pulselen);
    delay(1);
    for (servoNo = 0; servoNo < 16; servoNo++)
      pwm2.setPWM(servoNo, 0, pulselen);
    delay(1);

  }

}








Wawa

My setup is a panel with Arduino Uno R3 + two 16 channel PWM servo controllers + 25 servos.
Your Fritzing art shows a Mega.

Powered by a switching power supply adapter AC 110-240v to DC 5v - 6A - 30W.
25 tiny SG-90 servos (~650mA stall) already need a >=16.25Amp supply.
So what are the servos you're using.

The panel has both a switch for complete shut down of power and a PIR sensor which detects motion
when the power switch is on and powers up the panel.
Not in your art diagram, so can't comment on that.

It all works fine when the panel is connected to the USB port of my computer but without the USB connection, the 10 servos connected to the first PWM controller just shake and no task is performed.
Your diagram shows external power only connected to the servos.
The PCA9685 does not pass that 5volt servo power on to the Arduino, so you must always power the Arduino separately when not on USB power.
Leo..

ba47

#7
Dec 06, 2019, 08:22 am Last Edit: Dec 06, 2019, 08:34 am by ballscrewbob
Wawa,

I'm using 25 SG90's.

I left out the switch and PIR for simplicity.

My panel is a copy of the following panel (Pls see link) and he's using the same power supply for 36 servos.
So, I thought I'd not have any problem using it for 25 servos.

In his diagram he does not power Arduino separately .  
I tried powering the Arduino, as mentioned in my post.

https://create.arduino.cc/projecthub/doug-domke/servo-motor-artwork-79e2d3?f=1 (mod edit)

ballscrewbob

Although not totally clear in his schematic I think the Arduino must be powered but NOT from the PWM boards.
Just going by the write up HERE

Bob.

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Wawa

Yes, the screw connector is only connected to the row of servo supply pins, nothing else.
The official PCA9685 board has a(n ideal) reverse protection diode (the mosfet), the ebay clones do not.

The Arduino must be powered separately, and the Arduino does (must) also power the PCA9685.
Leo..

ba47

Thank you both for the replies.

I'm not using the Adafruit board but this one from Amazon :

https://www.amazon.com/KeeYees-PCA9685-Raspberry-Helicopter-Airplane/dp/B07KR2651B/ref=sr_1_fkmr0_1?keywords=KeeYees+10pcs+SG90+9G+Micro+Servomotore+con+PCA9685+Modulo+16+Canali+12+Bit+PWM+Servomotore+Driver+IIC+per+Arduino+Raspberry+Pi&qid=1575622845&sr=8-1-fkmr0

Here's what happens exactly :

1.  Following the wiring diagram from the link I mentioned, i.e. no power to Arduino, I get no movement
     without USB connection.  I guess that's due to what Leo says " The official PCA9685 board has a(n
     ideal) reverse protection diode (the mosfet), the ebay clones do not.


2. If I power the Arduino through it's barrel connector, I can run the sketch by first connecting the USB.
     Now if I disconnect the USB the sketch keeps running.
     But, if I power down the panel with the 220v switch, then power it back up, I get the 10 shaky servos
     on PWM0 (the first board) and nothing else, unless I connect the USB cable. Then all is ok.

I've excluded the PIR sensor but there's no difference.

This is a Christmas gift to a school and I must get it done on time.

Wawa

Just power the Arduino with a 5volt cellphone charger connected to the USB socket.
Leo..

ballscrewbob

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

ba47

Thanks guys, but I AM powering Arduino with 5v through it's barrel connector.

Is there a difference between powering it from the USB socket and the barrel connector ?

I need the USB connector to upload sketches.

ballscrewbob

You may want to increase the power to the barrel connector as the voltage regulator has a DROPOUT factor so will be giving less than 5 volts.
I Normally run from 7 to 10 volts if I need to use that connector.

You may have inadvertently stumbled onto the solution by adding that extra detail.

Bob.
It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Go Up