Motorama_ServoStepperFun
The L293D h-bridge serves the same purpose as the ULN 2001.
Servo Control
Servos are typically centered using 1.5 ms (millisecond), or 1500 µs (microsecond) pulses. Other angles can be signalled using shorter or longer pulses, typically in the range of 1.0 ms to 2.0 ms wide. For continuous-rotation servos, the pulse signal controls direction and speed (instead of position), with 1.5 ms usually being the stop signal.The test signal was set such that a standard servo would be adjusted to its 90° center position.
Normally/Typically 1500 µs = center
Arduino code that I had been using.
#include // Servo myservo; void setup() { myservo.attach(3); // 3 is the output pin myservo.write(90); // set servo to mid-point (90°) } void loop() {}
Basically, this code takes the desired angle, 90°, and sends the servo the appropriate pulse.
I decided to try a different approach.
Instead of having the servo library interpret the input angle of 90° before sending a signal,
I would skip a step and send a signal for 1.5 ms.
#include Servo myservo; void setup() { myservo.attach(3); myservo.writeMicroseconds(1500); // set servo to mid-point } void loop() {}
Before now I hadn’t looked very closely at the Servo.h library.
Here are a few lines of code from that file.
Don’t worry if it doesn’t make sense – just look at the numbers.
attach(pin ) - Attaches a servo motor to an i/o pin. attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds default min is 544, max is 2400 write() - Sets the servo angle in degrees. #define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo #define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo #define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached
I still don’t really understand how Arduino’s servo.write(angle) command works,
but according to the Arduino reference, the angle should be from 0 to 180 degrees.
In the servo library, the minimum pulse width default is defined to be 544 µs,
and the maximum is defined to be 2400 µs.
These values are outside of the 1000 µs and 2000 µs parameters
I have used in the past for direct servo control.
Since I did not define the minimum and maximum pulse widths in the attach command, it seems that the program automatically fell back to the library defaults of
544 and 2400 microseconds – 544 for 0° and 2400 for 180°.
This wouldn’t have been as much an issue if the default minimum and maximum pulse width
were symmetrical around 1500 µs, but they’re not!
90° is right between 0° and 180°. 544 plus 2400 divided by 2? 1472, or 1.472 ms.
So that’s where the 1.472 ms comes from!
===================
standoffs/spacers (stacked in 4 can be used in battery pack to replace a btry)
3v motor
measure with 10amp plug on multimeter
230mA draw is normal motor operation with 3v
still current ...when motor cant spin is 800mA'ish (so much more)
1.5amps if using 6v (so much much more)
so dont use drive which peaks at 1.2 amps
also
if u use larger voltage than the motor is spec'ed for,
it may work, but will reduce the life of the motor
Powering
Motors
Motors need a lot of energy, especially cheap motors since
they're less efficient.
Voltage requirements:
The first important thing to figure out what voltage the motor is going to use.
If you're lucky your motor came with some sort of
specifications.
Some small hobby motors are only intended to run at 1.5V, but
its just as common to have 6-12V motors.
The motor controllers on this shield are designed to run
from 5V to 12V. MOST
1.5-3V MOTORS WILL NOT WORK
Current requirements:
The second
thing to figure out is how much current your motor will need.
The motor driver chips that come with the kit are designed to
provide up to 1.2 A per motor, with 3A peak current.
Note that once you head towards 2A you'll probably want to put a
heat-sink on the motor driver,
otherwise you will get thermal failure, possibly burning out the
chip.
You can't run motors off of a 9V battery so don't waste your
time/batteries!
Use a big Lead Acid or NiMH battery pack. Its also very much
suggested that you set up two power supplies (split supply)
one for the Arduino and
one for the motors.
99% of 'weird motor problems' are due to noise on the
power line from sharing power supplies
and/or not having a powerful enough supply!
Even small DC motors can draw up to 3 Amps when they stall.
Setting
up your shield for powering Hobby Servos
Servos are powered off of the same regulated 5V that the Arduino uses. This is OK for the small hobby servos suggested. Basically, power up your Arduino with the USB port or DC barrel jack and you're good to go. If you want something beefier, cut the trace going to the optional servo power terminal and wire up your own 5-6V supply!
Setting
up your shield for powering DC Motors
The DC motors are powered off of a 'high voltage supply' and NOT
the regulated 5V.
Don't connect the motor power supply to the Arduino's 5V power
pin.
This is a very very very bad idea unless you are sure you know
what you're doing!
You could damage your Arduino and/or USB port!
There are two places you can get your motor 'high voltage
supply' from.
- One is the DC
barrel jack on the Arduino board
- The other is the
2-terminal block on the shield that is labeled DC Motor Power
5-12VDC.
The DC Jack on the Arduino has a protection diode so you won't be able to mess things up too bad if you plug in the wrong kind of power. The terminal block as a protection FET so you will not damage the arduino/shield if you wire up your battery supply backwards, but it wont work either!
If you would like to have a single DC power supply for
the Arduino and motors
Say a wall adapter or a single battery pack with 6-12VDC output,
simply plug it into the DC jack on the Arduino or the 2-pin power terminal
block on the shield. Place the power jumper on the motor shield.
Note that you may have problems with Arduino resets if the battery supply is not able to provide constant power, so it is not a suggested way of powering your motor project. You cannot use a 9V battery for this, it must be 4 to 8 AA batteries or a single/double lead acid battery pack.
Note that you may have problems with Arduino resets if the battery supply is not able to provide constant power, so it is not a suggested way of powering your motor project. You cannot use a 9V battery for this, it must be 4 to 8 AA batteries or a single/double lead acid battery pack.
If you would like to have the Arduino powered off of USB and
themotors powered off of a DC power supply
Plug in the USB cable. Then connect the motor supply to the
power terminal block on the shield. Do not place the jumper on the shield.
This is a suggested method of powering your motor project as it
has a split supply, one power supply for logic, and one supply for motors
If you would like to have 2 separate DC power supplies for the Arduino and motors.
Plug in the supply for the Arduino into the DC jack, and connect
the motor supply to the power terminal block. Make sure the jumper is removed
from the motor shield.
No matter what, if you want to use the DC motor/Stepper system
the motor shield LED should be lit indicating good motor power
Comments
Post a Comment