Bi polar stepper motor circuit

nick12ab

Senior Member
When I run this code in the simulator, I get an errormessage "Stack error - return without gosub!"
What code? There is no code on page 17 and the code on page 18 should not cause this. Please copy and paste the code you are using (don't just say it's the code from page x).
 

eclectic

Moderator
Please alter the program slightly
Marked with ****

Code:
#picaxe 14M2
dirsB= %1111111  ; **********************


main: for b3 = 0 to 99 ‘ start a for...next loop
gosub lstep ‘ call left step sub-procedure
next b3 ‘ next loop

for b3 = 0 to 99 ‘ start a for...next loop
gosub rstep ‘ call left step sub-procedure
next b3 ‘ next loop

lstep: let b1 = b1 + 1 ‘ add 1 to variable b1

goto step2 ‘ goto the lookup table

rstep: let b1 = b1 - 1 ‘ subtract 1 from variable b1

step2: let b1 = b1 & %00000011 ‘ mask lower two bits of b1

lookup b1,(%1010,%1001,%0101,%0110),b2 ‘ lookup code into b2

let pinsB = b2 ‘ output b2 onto control lines ; ****************

return
e
 

westaust55

Moderator
Try adding a line
GOTO Main
or
DO : LOOP
Before the label LStep:
To stop the main code dropping through into the subroutines



EDIT:
(now at a PC)
Code:
#picaxe 14M2
dirsB= %1111111  ; **********************


main: 
	for b3 = 0 to 99 ‘ start a for...next loop
	    gosub lstep ‘ call left step sub-procedure
	next b3 ‘ next loop

	for b3 = 0 to 99 ‘ start a for...next loop
	    gosub rstep ‘ call left step sub-procedure
	next b3 ‘ next loop

	[B][COLOR="#FF0000"]GOTO Main [/COLOR][/B]; *-*-*-*-*-*-*-*-*

lstep: 
	let b1 = b1 + 1 ‘ add 1 to variable b1

	goto step2 ‘ goto the lookup table

rstep: 
	let b1 = b1 - 1 ‘ subtract 1 from variable b1

step2: 
	let b1 = b1 & %00000011 ‘ mask lower two bits of b1

	lookup b1,(%1010,%1001,%0101,%0110),b2 ‘ lookup code into b2

	let pinsB = b2 ‘ output b2 onto control lines ; ****************

	return
 
Last edited:

nerdegutta

Senior Member
Thanks.

I got it somehow working, but after a while the L293 gets really hot and the stepper stalls.

I've breadborded it, and I thought that the stalling came from no heatsink/fan and bad grounding.

- nerdegutta
 

boriz

Senior Member
"I got it somehow working, but after a while the L293 gets really hot and the stepper stalls."

Sound like you're using a regulator, something you didn't mention earlier, probably an L293, probably trying to operate it beyond spec, probably didn't read the datasheet?
 

westaust55

Moderator
To avoid confusion and guesswork can you please post:
1. A link to the Datasheet for the stepper motor or failing that the voltage and current details
2. A schematic of the circuit you have constructed
3. If possible a photo showing clearly the project preferrable taken perpendicular to the board with a clear background so folks here can trace/ check your wiring
4 the PiCAXE program code as you have to so far.

Overheating could be due to:
1. Excessive current draw -the now mentioned L293D is rated at 600 mA
2. Wrong control of the driver chip - in effect creating an internal short ?
3. Wrong wiring
 

nerdegutta

Senior Member
Hi.

1. Link to stepper motor.

2. A schematic is attached.14m2-bi-polar-sch.png

3. No camera available at the moment... :(

4. The code:

Code:
#picaxe 14m2
#no_data

symbol dir_pin = pinc.0
symbol step_pin = pinc.1

dirsB = %1111111

main:
if dir_pin = 0 and step_pin = 1 then
	let b1 = b1 + 1
	gosub step2

endif

if dir_pin = 1 and step_pin = 1 then
	let b1 = b1 - 1
	gosub step2
endif

'  	low b.0:low b.1:low b.2:low b.3 ; testing
' lookup b1, (%0000, %0000, %0000, %0000), b2 ; testing, turning all pins off
let pinsb = b2
goto main
	
	
step2:
	let b1 = b1 & %00000011
	'lookup b1, (%1010, %1001, %0101, %0110), b2 ; testing
	'lookup b1, (%1100, %0110, %0011, %1001), b2 ; testing
 	lookup b1, (%1010, %0110, %0101, %1001), b2
	let pinsb = b2
	return
Thanks for your time!

- nerdegutta.
 

westaust55

Moderator
The problem is the motor current.

From the techncial data for the motor:
Technische Daten:
- Betriebsspannung max. 5 V- = voltage rating
- Strangstrom max. 1 A = current rating
You are running the motor at 12 Volts DC but is only rated at 5 Volts so the current will in fact be roughly twice that stated.

The nameplate motor current rating is 1 Amp however the L293D is only rated for 0.6 Amps continuous with brief peak current to 1.2 Amps.
Yet because of the 12 Volt supply your pulses will be around 2 Amps so almost double the L293D peak rating.

As an experiment:
1. reduce the voltage on the L293D Vcc2 pin (pin8) from 12 V to 5 volts and the chips should not get as hot.
then if still warm try
2. add a 4.7 Ohm resistor in series with the 5 V supply to the Vcc2 pin to limit the motor current to around 0.5 Amps. The motor may operate a little slower and need more time delay between steps. The L293D should definitely not be hot now.

then to operate properly:
3. Find a 5 or 12 V motor with a current rating less than 0.6 amps (600 mA)
 
Last edited:

westaust55

Moderator
Certainly the website indicates 5 V rating.

Are there any marking on the motor?

If not and if you have a multimeter then measure the winding resistance.
Is it 5 Ohms?

Neglecting the motor reactance, the current (Amps) will be Volts / Ohms.
That will indicate the current at 5 V and 12 V? Anything greater than 0.6 Amps is going to add to the heating and possible failure of the L293D.
 

nerdegutta

Senior Member
Certainly the website indicates 5 V rating.
It certenly does.

Are there any marking on the motor?
AEG S026/48
253/0.4 4C 01

If not and if you have a multimeter then measure the winding resistance.
Is it 5 Ohms?
Yes, 5.3 and 5.4


I replaced the 12v with 5v, and then the motor stalls. I also tried with a Pause-command, from 10 to 100. After the lookup in Step2. Still stalling.

- nerdegutta
 

nerdegutta

Senior Member
Added a video

First part is with 5v on pin8, last part is with 12v.

[video=youtube_share;F3lEvAjwgVQ]http://youtu.be/F3lEvAjwgVQ[/video]

- nerdegutta
 

westaust55

Moderator
Looking at your video, the stepper motor is operating in one directionon 5 V but seems not to reverse.
As expected, the motor operates faster with the higher voltage and can reverse direction.

Some site I looked on a couple of days ago sugegsted that the AEG model you have is not a particularly good quality motor.
I also found some site indicating a rating of 10V and 0.65 Amps with 15 Ohm windings.

Seems it is not your program or the driver chip (L293D) but more likely the quality of the motor.
 
Top