Go Down

Topic: code for servo works in tinkercad but not when I load to Uno. (Read 610 times) previous topic - next topic

UKHeliBob

to add more info to my situation. I am trying to use a 20kg servo. When I plug in a 9kg servo everything works as it should. The 20kg servo have a working voltage range of 4.8v-6.8v. Again, everything works with a micro servo.
Can you please provide links to the two servo that you are using ?

Quote
I ran a sweep and the servo works
Which servo and how was it powered ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

TomGeorge

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?


Can you please post some pictures of your project so we can see your component layout, including the power supply for the servo?


Thanks.. Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

kwatts1000

So I found a solution. I looks like I can't just use the servo.write() function. that only works with small servos. I had to use a math function and use the PWM and step the servo down. I changed the code to this and it now works:
#include <Servo.h>

int pos = 0;

Servo servo_3;

void setup()
{
  pinMode(2, INPUT);
  servo_3.attach(3);

}

void loop()
{
  // Start Race
  if (digitalRead(2) == 1) {
    for (pos = 0; pos <= 35; pos += 1) {
      // tell servo to go to position in variable 'pos'
      servo_3.write(pos);
      // wait 10 ms for servo to reach the position
      delay(10); // Wait for 10 millisecond(s)
    }
    delay(1500); // Wait for 1500 millisecond(s)
    for (pos = 35; pos >= 0; pos -= 1) {
      // tell servo to go to position in variable 'pos'
      servo_3.write(pos);
      // wait 10 ms for servo to reach the position
      delay(10); // Wait for 10 millisecond(s)
    }

thank you all for your help. If you have any other input in will be glad to listen.
  } else {
    servo_3.write(0);
  }
}

AWOL

Quote
I looks like I can't just use the servo.write() function. that only works with small servos. I had to use a math function and use the PWM and step the servo down.
You need to expand on that.

It still sounds like a power supply problem to me.

Consider: in my attic is my kids slot-car gear. The cars have 12 V motors.
Outside my front door is a two litre diesel car.
It has a 12 V starter motor.
See the issue?

Please remember to use code tags when posting code

TomGeorge

Hi,
It looks like it is still a power supply problem.

In your original code you are signalling the servo to go from 0 straight to 35deg as fast as possible.

In you final code you are signalling the servo to go from 0 to 35deg in small steps, that is slower than in the previous code.

In moving in 1deg  steps you need less current to drive the servo motor as you are not asking for the fastest response from 0 to 35deg.

Tom..... :)
PS. Can you please post a link to specs/data or where you purchased the servos please?
Everything runs on smoke, let the smoke out, it stops running....

kwatts1000

this is the specs of the servo I got:

Item: DS3218 20KG Large Torque Digital Servo
Stall Torque (5V): 19 kg/cm (263.8oz/in)
Stall Torque (6.8V): 21.5 kg/cm (298.5 oz/in)
Speed : 0.16 sec/60°(5V) / 0.14 sec/60°(6.8V)
Operating Voltage: 4.8 ~ 6.8 DC Volts
Dead brand: 3μs
Weight: 60 g (2.12 oz)
Motor Type: DC Motor
Gear Type: Copper & Aluminum
Working frequence: 1520μs / 333hz
Size: 40 x 20 x 40.5 mm ( 1.58 x 0.79 x 1.60 in)
Features: -
High performance digital standard servo
High-precision metal gears with hard anodizing
CNC aluminium middle Shell
Dual ball bearings
Package Included: 1 x DS3218 20KG Large Torque Digital Servo
1 x 25T Adjustable metal servo arm

If you think its still a power problem then maybe I should try using a RC car battery to power the servo. I mean that is what the servo is really meant to be used for.

slipstick

For some reason despite being asked many times you still haven't told us how you are powering your servo.

And as everyone has been saying the power is still the problem. So how are you connecting and powering the servo?

Steve

PaulS

Quote
then maybe definitely I should try using a RC car battery to power the servo.
I fixed your statement for you
The art of getting good answers lies in asking good questions.

kwatts1000

I am currently using 4 AA batteries to provide 6v. I have a 7.2v RC battery that I cant try with a servo I have that can take up to 7.4v.

vinceherman

I am currently using 4 AA batteries to provide 6v. I have a 7.2v RC battery that I cant try with a servo I have that can take up to 7.4v.
Do you have a pencil or pen?  Does your phone have a camera?
Draw a wiring diagram.
Take a picture of that drawing.
Post the picture here.

This has been requested multiple times.

IanCrowe

this is the specs of the servo I got:

Item: DS3218 20KG Large Torque Digital Servo
Stall Torque (5V): 19 kg/cm (263.8oz/in)
Stall Torque (6.8V): 21.5 kg/cm (298.5 oz/in)
Speed : 0.16 sec/60°(5V) / 0.14 sec/60°(6.8V)
Operating Voltage: 4.8 ~ 6.8 DC Volts
Dead brand: 3μs
Weight: 60 g (2.12 oz)
Motor Type: DC Motor
Gear Type: Copper & Aluminum
Working frequence: 1520μs / 333hz
Size: 40 x 20 x 40.5 mm ( 1.58 x 0.79 x 1.60 in)
Features: -
High performance digital standard servo
High-precision metal gears with hard anodizing
CNC aluminium middle Shell
Dual ball bearings
Package Included: 1 x DS3218 20KG Large Torque Digital Servo
1 x 25T Adjustable metal servo arm

If you think its still a power problem then maybe I should try using a RC car battery to power the servo. I mean that is what the servo is really meant to be used for.
This could well be the source of your problem. The standard arduino servo library produces a 50Hz signal with a pulse width varying between 1 and 2ms.

Try goggling for "Arduino 333Hz servo library".

Ian

UKHeliBob

Quote
The standard arduino servo library produces a 50Hz signal with a pulse width varying between 1 and 2ms.
So does an RC receiver.  So if that is the cause of the problem it implies that this servo would not work with such as receiver, which I find unlikely
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up