Newbie on Stepper motors needs help

craigcurtin

Senior Member
Guys,

I have never wired up a stepper motor before, so am getting a little lost.

What i have is a Peter Anderson supplied Kiwi Patch board with a 20m. All good - i can program that and talk to it etc.

I then have a SN754410 which is a higher current drop in (apparently) for the L293D. Spec sheet here

http://www.electroniq.net/other-projects/motor-control-circuits/sn754410-motor-driver.html

I then have this stepper motor. Which is a bipolar stepper motor with 4 wires.

http://www.sparkfun.com/datasheets/Robotics/SM-42BYG011-25.pdf

I wish to use the 20m to be able to drive this forwards and backwards - i have a couple of limit switches and an LDR.

I just do not have any idea of

1) How many pins on the 20m will i need to use - 1 assume 4 but not sure.
2) Which pins do i wire these to on the Controller
3) Which pins on the controller correspond with which coloured wires on the motor.

This is i assume all pretty basic for the old hands - but having never done it before i thought i would ask the brains trust.

regards

Craig
 
Same circuit

I was just about to post and ask some questions about this myself. I wont hijack your thread but will be watching this very closely. I want to use the same setup and was just looking at the sparkfun stepper for a model railroad turntable. The plan is to use one sensor for initial position. Then send x steps for each position. Not sure if this will work but as usual it sounds pretty striaght forward to start. I will post anything I get as soon as my motor gets here. Will order it tonight.
 

craigcurtin

Senior Member
If you are ordering from sparkfun

They have a driver board with the controller integrated etc - it is about $15 from what i can read on the net and others more knowledgeable than me this board is good value and will make you life easier

Craig
 

craigcurtin

Senior Member
Yes i have read the manual

I understand the basic theory (i think) but am haviing problems with the practical application in terms of what to connect to where

regards

Craig
 

pha555

Senior Member
See the Figure at

http://www.electroniq.net/other-projects/motor-control-circuits/sn754410-motor-driver.html

Note that the motor consists of two isolated coils. You should be able to use continuity to find the two coils. It really doesn't matter which is PHI1 and PHI2.

Consider the following sequence;

A B
0 0
0 1
1 1
1 0
and then repeat


To go the other way;

1 0
1 1
0 1
0 0

etc

In the schematic, they show +24 VDC. However, go with +12VDC for this motor.

Best.

Peter Anderson
http://www.phanderson.com/picaxe/
 

craigcurtin

Senior Member
thanks Peter - for taking the time

But as a newbie it does not make much sense to me, in particular

1) what do the 1,2en and 3,4 en do and how do i wire them up ?
2) I can see where they have a micro pin going to say pin 2 on the SN chip - but it also seems to be connected to pin 7 - is that correct ?
3) I have found the coil pairs for the motor (one of my previous posts has those) so i am guessing that i would connect

Motor SN754410
Red pin 3
Green pin 6
Yellow pin 11
blue pin 14

If that was correct i would then just connect four picaxe outputs to 1a,2a,3a,4a - but then what are the 1,2en and 3,4en connected to ?

Sorry for the stupid questions - but my head hurts from looking for answers on google

regards

Craig
 

premelec

Senior Member
The first link in your first post has a schematic of how to drive the motor - note TWO inputs from a driver - e.g. PICAXE - A & B . Peter has referred you to the logical input sequences on these two inputs to get rotation. You can determine the coil leads with an ohmeter. Study the schematic in that first post - wire it up - then drive the A & B inputs from the PICAXE - you'll need a common ground V- connection as well as the A & B logic drive. 3 leads to driver circuit.
 

craigcurtin

Senior Member
The Premelec

I think i already have the two coils identified from my first post and the diagram that was included.

What i need clarified is the pin assignment and what happens to the 1,2 en and 3,4en - from more reading on google it looks like i just tie them both the 5vcc ?

regards

Craig
 

craigcurtin

Senior Member
OK got it working thanks - one small problem

If i leave the 1,2 and 3,4 en connected to 5v permanently then my 7805 gets very hot.

If i try and move them to a picaxe output pin (pin 2 and pin 3) and enable them before i send any commands - they do not work.


Any ideas on this ?

regards

Craig
 

Pauldesign

Senior Member
Any ideas on this ?
Although i'ven't seen your code, I'll reckon to insert sort delays (and adjust the delays until the motors steps smoothly) in the start of your program and between successive steps to give the motor enough time to initialize and move from one step to another otherwise it will speed to max and/or stall and hence causes your reg (LM7805) to push too much current, thus getting very hot as you've notice. I believe you can even scent the hottest. Can't you?.:p

You may review electrical machines (DC motor in this case) operations and pay emphasis on torgue, speed and current.;)
 

SAborn

Senior Member
You need to use the EN pins as well as these are used to enable / disable each coil output.
So while one coil is energised the other is disabled or turned off via its EN pins, then you swap coils and toggle the EN pins.

Here is a schematic using a 08m and a 293D, there is many ways to do this and this is just one way as with the 08m i only had 4 outputs to work with.

I can do full stepping and 1/2 stepping with this setup.

If you get totally lost than PM me your number (landline only) and i will try to talk you through it.
 

Attachments

craigcurtin

Senior Member
thanks Saborn

OK this is my setup

use the KIWI patch board as supplied by Peter anderson assembled with a 20m -all good and works fine

I am using output 7,6,5,4 and to the SN chip

Pin 7 goes to SN pin 2
pin 6 goes to SN pin 7
Pin 5 goes to SN pin 10
Pin 4 goes to SN pin 15

to get things working i have wired the two enable pins to +5v however as stated the 7805 gets too hot to touch within 3 or 4 minutes

If instead i wire them to output pins 3 and 2 and then enable both prior to the motor running then nothing happens - i would have thought this would be equivalent to having them go to the live 5v rail ?

I have pasted my sample code below

for w1 =1 to 400

high 2
high 3


LOW 7
HIGH 6
HIGH 4
LOW 5

PAUSE 10

HIGH 7
LOW 6
LOW 5 ; redundant line
HIGH 4 ; redundant line
PAUSE 10

HIGH 7 ; redundant line
LOW 6 ; redundant line
HIGH 5
LOW 4
PAUSE 10

HIGH 6
LOW 7
HIGH 5 ; redundant line
LOW 4 ; redundant line
PAUSE 10

next w1
 

craigcurtin

Senior Member
I also tried this

I wanted to see if it was better faster and used the pins commands as below

for w1 = 1 to Rotations

let pins = %01010000
pause DelayTIme
let pins = %10010000
pause DelayTime

let pins = %10110000
pause DelayTime
let pins = %01110000
pause DelayTime

next w1

But i then thought that this would be resetting the enable pins to 0 each time ? How would i overcome this ?

Craig
 

SAborn

Senior Member
Try this, its untested but i changed the pin numbers to suit your above discription from a test routine i had for a previous project.

You did not quote what pin out of pin3 & pin2 went to which enable pin so i took a guess and they might be backwards.

Load it into your 20m and give it a go.
It should step 3000 steps one direction stop then step 3000 steps in the reverse direction, stop and then repeat.

Code:
'20m and SN754410 stepper driver


symbol steps = 3000
symbol counter = w3

symbol delay = 10


high 6,4,3
low 7,5,2
	
'setfreq m8


Start:
		
	toggle 6,7
	toggle 2,3
	inc counter
	pause delay
	gosub check
	
	
	toggle 4,5
	toggle 2,3
	inc counter
	pause delay
	gosub check
	
	goto start
	
Check:
	if counter >= steps and b2 = 0 then
	counter = 0
	b2 = 1
	toggle 4,5
	pause 1000
	endif
	
	
	if counter >= steps and b2 = 1 then
	counter = 0
	b2 = 0
	toggle 7,6
	pause 1000
	endif
	return

	end
 

hippy

Technical Support
Staff member
let pins = %10110000

But i then thought that this would be resetting the enable pins to 0 each time ? How would i overcome this ?
You can keep the desired levels of other pins in a separate variable and add those into the mix when you output them ...

let pins = %10110000 | b0

Or you could read and mask the actual output pin states you want to keep into b0 ( or other variable ) before re-outputting them.

If you know what the states of the enable pins will / should be, just add them into the bit pattern you are using.

Best solution is not to put other things on the output pins which will be zeroed so it doesn't matter if they are. This is a standard part of software engineering, designing to make the code easier ( and therefore usually faster and shorter ). One 'ease of use' decision may make something else more difficult and that's the 'art' over the science in deciding which of numerous possibilities is best to use.
 
Last edited:

craigcurtin

Senior Member
Saborn - tried and no luck

I have added a couple of debug steps in and tried it with the jumpers reversed for the two enables in case i did manage to get them wrong.

Still no go - however if i take your code and hard wire the two enable pins back to 5v+ everything runs. Still with the 7805 overheating badly though.

Any more ideas ?

regards

Craig
 

SAborn

Senior Member
How have you wired the chip with the Vs and Vss inputs?

Pm me your number and i will call to discuss it as i cant be bothered typing pages.
 

westaust55

Moderator
@Craig,

Can you upload :
1. a copy of your schematic/circuit diagram
2. a photo of your circuit showing both ends of all wires clearly so folks can trace through the wiring to look for any wiring errors.
 

craigcurtin

Senior Member
thanks for all the time guys

I have been on the phone with SABorn (Pete) for about an hour (very much appreciated mate !!) and we could not get a resolution.

Pete wants me to go away and add a bigger input car for the board from the 7805 and look at some protection diodes for each of the picaxe outputs.

Something screwy going on !

Anyway i am away for a week tomorrow so i will use the power of the net to do more research and play with this some more

Craig
 

SAborn

Senior Member
As per the phone conversation with Craig.

Through process of elimination a dry joint was found and repaired, this did not fix the problem.
The data sheet for the SN754410 implies internal diodes across the outputs, but also shows external diodes in circuit example.

We were able to get the motor to jitter under program control but not rotate, with the enable pins pulled high externally to 5v the motor would drive Fwd & Bwd, although the Vreg got hot quickly.

I suspect several things, mainly EMF from the coils feeding into the power rails and the vreg receiving a high ripple on its inputs.
The Kiwi board has a 220uf cap on the input to the vreg and from previous testing on a Cro this is far to low IMO, as the lowest i was able to go with minimal ripple was 330uf, and for this application would recommend 470 to 1000uf on the input.
Basically the Vreg is seeing AC and causing it to heat up.
This ripple is also filtering through to the picaxe and causing erratic behavior.

Past experience with motor drivers has also shown more stable results with a resistor (nominally 330 ohm) in all data lines to the driver chip.

Recommendations made to Craig for his circuit, Change the 220uf cap to 1000uf, place 330 ohm resistors in all data lines to the driver (6 resistors) and if the problem still exists, fit diodes across all outputs to the coils.(8 diodes)

The circuit apears to be wired correctly, as we traced each wire pin to pin.

Here is a schematic of the circuit as per traced over the phone.
Also attached a full data sheet for the SN754410 driver chip.
 

Attachments

SAborn

Senior Member
are the enable pins tied directly/hard to 5V or via 10 kOhm resistors?
what happens when resistors are used as per the app notes
Not sure Westie,
Think Craig had them tied direct to 5v, but looking at the test circuit in the data sheet i see they show 3v to the enable/input pins.
I suspect this was minmimal voltage required for reliable operation.
 

craigcurtin

Senior Member
Hey Westie thanks for chiming in

once again Pete thanks for the time.

After tracing through the circuit with Pete and modifying his test program that is positively known to work with bipolar steppers we could get nothing more than a jitter from the motor.

However simply taking the two enable pins and putting them onto the live 5v rail (no resistors etc) the motor would behave perfectly - although could only be run for about a minute or so before the LM7805 was too hot to touch (no heat sink at this point)

We substituted in a 2nd 20M with the same result.

Peter has suggested the changes he has outlined as well as the move of the 12 v input and ground (for the SN chip) from the kiwi patch board directly to the battery.

I am on a 1 week holiday now - so on my return home i will try each of the suggestions and see where we can get to.

regards

Craig
 

westaust55

Moderator
Just a thought . . .Is there anyway whatsoever that the SN754410 could be installed rotated through 180 degrees?

All Enables, controls, inputs and outputs, ground, etc would function and be conencted as normal.
Only the 5V and 12V supply connections would be rotated.

While one might think the excessive voltage on Vcc2 would "cook"/fry the circuit and stop it working maybe is has not.
 

craigcurtin

Senior Member
not a bad call - i will check for this as soon as i get home

It is possible but i think highly unlikely - and the reason i say that is i deliberately tried to install it the opposite way to the picaxe 20m,

Wiill check and advise

Craig
 
Top