paulrafu
Posts: 5
Joined: Tue Oct 09, 2012 8:35 pm
Location: Romania

Drive DC star(3.5 floppy) motor with ULN2003

Wed Oct 10, 2012 7:24 pm

Hi everibody!
I start a project with my R-pi and I want do drive a 3.5 floppy motor (5V DC star motor).
Here is schematic:
Image
GND to ground of R-pi and external source, +5v to external source.
I wrote some code in bash shell:

Code: Select all

#!/bin/bash

#motor
#porneste motor DC in stea miezul stelei +5V ;bobA pin 23; bobB pin24; bobC pin25


MOT1=23
MOT2=24
MOT3=25
OFF=0
ON=1

# Make sure we have root access
if [ $EUID -ne 0 ]; then
        echo "You must be root to run this. Try 'sudo $0'"
        exit
fi

# Clean up procedure--turn off the LED, unexport the GPIO, and exit
cleanup()
{
        for J in $MOT1 $MOT2 $MOT3
        do
        echo $OFF > /sys/class/gpio/gpio$J/value      # turn off
        echo $J > /sys/class/gpio/unexport
        done
        echo Interrupted.
        exit
}
# Set up--select the pin and direction. Catch Control-C SIGHUP SIGKILL

for I in $MOT1 $MOT2 $MOT3
do
echo $I > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio$I/direction
#trap 'cleanup $I' 1 2 15

done

trap 'cleanup' 1 2 15

while true
do
        echo $ON > /sys/class/gpio/gpio$MOT1/value    # turn on coil A
        echo $OFF > /sys/class/gpio/gpio$MOT2/value   #turn off coil B
        echo $OFF > /sys/class/gpio/gpio$MOT3/value   # turn off coil C
sleep 0.01
        echo $OFF > /sys/class/gpio/gpio$MOT1/value   # turn off coil A
        echo $ON > /sys/class/gpio/gpio$MOT2/value    # turn on coil B
        echo $OFF > /sys/class/gpio/gpio$MOT3/value   # turn off coil C
sleep 0.01
        echo $OFF > /sys/class/gpio/gpio$MOT1/value    # turn off coil A
        echo $OFF > /sys/class/gpio/gpio$MOT2/value   #turn off coil B
        echo $ON > /sys/class/gpio/gpio$MOT3/value   # turn on coil C
sleep 0.01
done
.... but my motor won't start up! just buzzing... soo I need some help!
Sorry for my bad english...!

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Drive DC star(3.5 floppy) motor with ULN2003

Thu Oct 11, 2012 10:57 am

Maybe if you drive the inputs more slowly. That is, use longer sleep times.

(If the rotor has a lot of inertia it may need to start slowly and ramp up.)

Hoagie
Posts: 119
Joined: Sun Sep 23, 2012 7:19 pm

Re: Drive DC star(3.5 floppy) motor with ULN2003

Thu Oct 11, 2012 11:57 am

You could also try adding some more steps to the sequence as follows...
Currently you have
a
b
c

but you could try
a
ab
b
bc
c
a c

Also, are you giving enough current to the coils?

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Drive DC star(3.5 floppy) motor with ULN2003

Thu Oct 11, 2012 4:50 pm

paulrafu wrote:Hi everibody!
I start a project with my R-pi and I want do drive a 3.5 floppy motor (5V DC star motor).
Here is schematic:
Image
GND to ground of R-pi and external source, +5v to external source.
You have basically what is known as a BrushLess DC Motor (BLDC)
paulrafu wrote:I wrote some code in bash shell:
You need a better method of programming and these sorts of devices are normally driven by dedictaed chips and FETs or timer sequences from Timing Process Units (TPU) in dedicated micros. These need continuous timing patterns any gaps doing to OS not giving resource time will cause all sorts of noises and uneven running.
paulrafu wrote:.... but my motor won't start up! just buzzing... soo I need some help!
Sorry for my bad english...!
You are stalling the motor and not energising the coils correctly basically you must energise the coils
in sequence -

Forward coil A, coil B, coil C and repeat
Reverse coil C, coil B, coil A and repeat

But you have to drive AB then BC then CA for forward, with first coil at 5V and second coil at GND.

Speed of switching determines speed of rotation, depending on number of magnet poles on the moving part.
I have attached an image of a typical timing pattern from a job I did in 2007, you need to drive each winding with a Half brdige configuration of FETs.
Attachments
BLDC.gif
Typical BLDC drive patterns for Half bridge drive
BLDC.gif (17.35 KiB) Viewed 1958 times
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

paulrafu
Posts: 5
Joined: Tue Oct 09, 2012 8:35 pm
Location: Romania

Re: Drive DC star(3.5 floppy) motor with ULN2003

Fri Oct 12, 2012 7:59 pm

Thank's for yours replys! just keep trying...
:oops:

Return to “Automation, sensing and robotics”