Motor drive

Questions on other types of hardware and getting it talking to the ARM CPU
Post Reply
YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Motor drive

Post by YahooArchive »

The ARMmite pins are not designed to drive a motor directly (unless
its really really really small).

They can drive 0 to 3.3V at about 4mA, which is probably too little to
drive the motor. You will need a buffer of some sort either a
transistor like a 2N2222 or a driver like a UC1709, and then you
should also have some protection for the driver from the inductive
spikes the motor will produce.

There are some sample circuits in the documentation for the BASICnode
and BASIC-8 products at the Coridium website.



YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: Motor drive

Post by YahooArchive »

I've had a number of questions about sensing voltges greater than 5V.
So I added some notes on that in the BASIC Help Files, Hardware
Specs, TTL Interfacing /General Interfacing page. (check the Coridium
Support webpage)

I've show resistor divider circuits and a sample opto-isolator circuit.

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: Motor drive

Post by YahooArchive »

I was just doing some testing of a PID motor control loop on an
ARMmite written in basic and was concerned that it might be too slow
to get good control. It turned out to be WAY too fast. A control cycle
is running in 5 microseconds. I am going to have to put in a delay
loop to get me to 40 or 50. Its way better too fast than too slow.

I'm impressed.

Roger

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: Motor drive

Post by YahooArchive »

>from the info line
>Is the Armmite or any of your products capable of directly driving a
typical servo (model airplane, etc.)? Is this the same as \"PWM\" ?
Can you give examples of h/w and s/w to do this?

>Similarly, can any of your processors read (input) a servo signal and
turn it into a number? Can you give h/w and s/w examples to do this?

Hopefully we'll get some real world experienced answers to this.

Servos are normally driven with phased pulses, which can be done using
delays and direct output. HWPWM might be used for this, but may
require some alternative programming of the timer registers. (check
user guide for 2103/2138). In any case, the pins will have to be
buffered with Darlington transistors or MOSFETs as the IOs of our
products are simple 4mA drivers.

The ARM is fast enough to count most pulse trains, but there are now 2
pins which can generate interrupts, so counting can be done as a
background task.

PWM is a software bit-banged operation, more to be compatible with
older PBASIC code, and HWPWM should be used for 4-8 channels of
hardware driven PWM.

Details can be found in the Hardware Library section of the Helpfiles.

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: Motor drive

Post by YahooArchive »

You can run the servo control signal straight of the ARMmite boards
into the servo. Servos typically take any control signal from 2.5V up,
even when the servo power supply voltage is 6V.

The servo control logic expects pulses that are between 1ms and 2ms
long with 1.5ms meaning neutral position. Most servos will want a
pulse every 20ms. You can use HWPWM to achieve this, or you can
bitbang it like this:

servopulse=1500+10*angle
timer=0
io(servopin)=1
do
while timer<servopulse
io(servopin)=0

Hope that helps,
Peter

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: Motor drive

Post by YahooArchive »

Consistent with Peter's assertions, I too have successfully interfaced
several servos directly and concurrently with both an ARMexpress and
an ARMmite. The power and ground are ovbiously from a power source of
the correct level and polarity, that leaves the signal, which is
indeed a 1 to 2 ms wide pulse ever ~20-30ms. The servos I am using
(pretty old ones, I might add) have a high enough signal input
impedance where it doesn't load down the ARMmite/ARMexpress' outputs
much at all.

Regarding the pulse train, max throw in one direction will occur if
the pulsewidth is ~1ms, and max throw in the other direction will
occur with the pulsewidth is ~2ms. 1500us (1.5ms) will yield servo
mid-scale...

I have ran the servos with as much as 50ms between sending the pulses,
but if there is any appreciable loads on the servos, they will start
to move and when the next pulse comes, it gets bumped back. 20ms is
good (documented spec for many servos), 30ms is acceptable. Longer
than that and you're on your own. I haven't tested with updating them
at anything faster than 20ms. I've had discussions with folks
regarding the newer digital servos where the normal old rules don't
necessairly apply in all cases. If those are the target servos for
your code, then I can dig up some dialogue I had earlier this year
with Ben Sturgess and Joe "Max-VTOL" Davis (if they don't chime in
here soon by themselves... :-)

I have some pretty solid Servo Control Code in the UAV project files
in the Groups Files section. The project was put on hold to aid in
the beta testing functions, V7, life (professional and personal) gets
in the way, etc. and now I am working another project that will be
announced to the group later. But, I do plan on getting back to the
UAV project as some point later this year, and with all of the changes
that ARMbasic has gone through recently, it is sure to be a much more
efficient app, when I get it mature. I am excited and looking forward
to picking up where I left off at.!.

Regardless, take a peek at the UAV project files. You should note
that I tried to use as descriptive as possible variable names, and I
think I did a descent job at documenting the code. As always, if
there ARE questions when you get to reviewing is, please go ahead and
send me an email, or post herein, and I will holler back, when I am able.

Take care. I hope that you all have a great spring & summer.

-t

Post Reply