12v dc motor control

tom955i

New Member
Apologies for what will seem like an obviuos question to many on here but I'm new and not making much progress trying to contol a 12v dc motor (forward, back, fast and slow) using a 28x1, and a L293d .

If i just use pin high and low, 'for power = 0 to 100' and 'for delay = 1 to 200'
I can get my model to speed up and stop and reverse direction and stop, but i can't get it to slow down gradually.

I've tried to do this using pwmout on the 28x1 but have confused myself about the connections needed between the 28x1 and the L293d and have very little understanding of the code to make this work.

Any advice would be gratefully received.

many thanks.


Tom.
 

tom955i

New Member
Hi eclectic thanks for the response.

yeah I've got the two linked as per the diagram and working fine for changing direction. However what I've tried is to sibstitute the 'output 4' pin on the 28x1, which feeds the 1,2 En input on the L293d, with the pwmout 1 pin with no results.

My problem is I'm ignorant as to whether this a connection or a coding problem. I've been trawling through the forum for hours now and keep seeing different versions of pwm code.

please see below the code I entered for getting the motor to start, stop, speed up and reverse.

'OPTIONS PICAXE-28X1
symbol motor = 4
symbol power = b0
symbol delay = b1
symbol offperiod =b2
low motor
high 7
low 6

main:
for power = 1 to 3
for delay = 1 to 200
high motor
pause power
low motor
offperiod = 10 - power
pause offperiod
next delay
next power
pause 5000
low motor
low 7
pause 1000
for power = 1 to 3
for delay = 1 to 200
high 6
high motor
pause power
low motor
offperiod = 10 - power
pause offperiod
next delay
next power
pause 5000
low motor
low 6
pause 1000
goto main


I'm unsure as to whether the 'SYMBOL' commands have to be used in conjunction with any pwmout commands I would enter for using the pwmout pin.

Thanks aagain,
tom
 

tom955i

New Member
Just one and yes all connections are correct and works ok accept whem trying to use pwmout control.

tom
 

eclectic

Moderator
I'm sorry to sound dumb, but I 'm confused by your code.

You are altering outputs 4 6 and 7

But, I'm assuming your motor is connected to pins 6 and 7.

Could you please say which pins the motor is connected to?

e.
 

tom955i

New Member
Currently output pin 7, forward, (leg 28) on the 28x1 is connected to the 2A (leg7) on the L293d, similarly output pin 6 ,back , (leg 27) is connected to 1A (leg2).
Output pin 4(leg 25, 28x1) which according to the explanatory comments I have "defines the symol for the motor output pin", is connected to leg 1 the 1,2EN pin on the L293d.
When running the simulator ,output pin 4 has a permanent pulsing supply and output pins six and 7 go alternately high and low to give direction.

When I remove the connection between output4 pin ( 28x1) and the L293d and replace it with a connection between pwmout pin ( leg 12, 28x1) and the 1,2En pin and change the code so that "symbol motor=4" is removed and a command " pwm1, 99, 80", in the main body of the programme, nothing happens.

Cheers, tom.
 

eclectic

Moderator
OK, let's start again

I've just breadboarded a circuit which works, but haven't had chance yet
to draw a diagram.

Look at the RIGHT side of the page 12 diagram

Instead of Pin 6, I connected to PWM 1 (physical leg 12)

Instead of Pin 7, I connected to PWM 2 (physical leg 13)

Code:
#PICAXE 28X1
main:

pwmout 1, 255,1000
pwmout 2 OFF
pause 2000

pwmout 2,255,1000
pwmout 1 OFF
pause 2000
goto main
e.

I'll sort out a diagram ASAP
 

eclectic

Moderator
Mark 2

Code:
#PICAXE 28X1

main:
' increase CW
pwmout 2 OFF
For w0 = 100 to 1000 step 100
pwmout 1, 255,w0
pause 500
next

'decrease CW
For w0 = 1000 to 100 step -100
pwmout 1, 255,w0
pause 500
next

'increase ACW
pwmout 1 OFF
For w0 = 100 to 1000 step 100
pwmout 2, 255,w0
pause 500
next

'decrease ACW
For w0 = 1000 to 100 step -100
pwmout 2, 255,w0
pause 500
next

goto main ' start again
 

Attachments

tom955i

New Member
eclectic that's brilliant, thanks very much.

I've worked with the first programe you gave me so that it starts and stops progressively and does the same in reverse, and have had a go at the second which is what I've being trying to achieve all along... all be it with a permanent ringing noise from the motor. Frequency resonance perhaps.

All the hours or reseaech and head scratching only to find somebody can crack it in minutes is all part of the fun I guess.

Again many thanks for your help with the control sequence and diagrams,

Cheers, tom.
 

eclectic

Moderator
Thanks for the thanks.
It wasn't ME who cracked it in minutes, but just accumulated knowledge
which I've gained from this forum.

A few bits and pieces.

1. The L293 datasheet, page 1 states 600mA per channel and up to 5kHz frequency.
You may be able to vary the PWM a little. See the Wizard.

2. What is the STALL rating of your motor?
Have a Forum-search for more info.

3. In future, you'll normally get a fast response by posting in the "Active" section.
The Sandbox is just for tests and is rarely visited.

Let us know how you get on with your project.

e.
 
Top