copyright, Peter H Anderson, Baltimore, MD, Nov, 11
Introduction
The note illustrates how to interface the Arduino and a PICAXE with a bipolar stepper motor using a Microchip TC4469 Quad FET Driver
In Figure #1, note that when input B is at a logic one current flows from terminal 13 to terminal 12. When at a logic zero, current flows from terminal 12 to terminal 13. The same is true for the A input in controlling the second coil. Note that using this arrangement, two coils are always energized.
Refer to this BiPolar Stepper Tutorial. Note that in the high torque two phase mode, two adjacent windings are always operated. This is implemented in the following routine by sequentially outputting 00, 01, 11 and 10 or the reverse. Note that the pause is implemented by constantly energizing the same two windings. The up side of this is that when in pause the motor is held. Of course, the down side is that power is always being dissipated in the motor.
Arduino - Stepper_TC4469_1
// Arduino - Stepper_TC4469_1 // // Push - Bipolar Stepper Control, Full step // // Interface of Arduino with Bipolar stepper using a Microchip // TC4469 Quad MOSFET. // // When Arduino Pin 8 is high, advances motor CW. Else, when Pin 9 is high // advances motor CCW. Otherwise holds motor in pause. // // Note that two windings are always energized. // // copyright, Peter H Anderson, Baltimore, MD, Oct 3, '11 #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) #define CW 0 #define CCW 1 #include <avr\io.h> void turn_step(byte dir); void setup() { pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(13, OUTPUT); } void loop() { byte tm=25; while(1) { if(digitalRead(8)==1) { turn_step(CW); delay(tm); } else if (digitalRead(9)==1) { turn_step(CCW); delay(tm); } else { delay(tm); } } } void turn_step(byte dir) { static byte n=0; byte patts[4] = {0x00, 0x02, 0x03, 0x01}; if (dir) // go down through patts[] { if (n == 0) // if index at bottom { n = 3; } else { --n; } } else // go up through patts[] { if (n == 3) // if index at top { n = 0; } else { ++n; } } if (patts[n] & 0x01) // CW { sbi(PORTD, 2); } else { cbi(PORTD, 2); } if (patts[n] & 0x02) // CCW { sbi(PORTD, 3); } else { cbi(PORTD, 3); } }
PICAXE. Stepper_TC4469_1.Bas
' Stepper_TC4469_1.Bas ' ' Push - Pull Bipolar Stepper Control ' ' Interface of PICAXE with Bipolar stepper using a Microchip ' TC4469. ' ' When PinB.2 is low, advances motor CW. Else, when PinB.3 is low ' advances motor CCW. Otherwise holds motor in pause. ' ' copyright, Peter H Anderson, Baltimore, MD, Oct 5, '11 #picaxe 20x2 #Terminal 9600 #No_Table #No_Data #freq m4 Symbol Tm = B2 Symbol Index = B3 Symbol Patt = B4 Symbol LSBit = B5 Symbol X = B6 Symbol Y = B7 Symbol CW = PinB.2 Symbol CCW = PinB.3 Symbol AAA = B.0 Symbol BBB = B.1 Main: Tm = 10 Index = 0 Do ' Continuous loop If CW = 0 Then If Index = 0 Then Index = 3 Else Index = Index - 1 End If GoSub OutPatt Else If CCW = 0 Then If Index = 3 Then Index = 0 Else Index = Index + 1 End If GoSub OutPatt End If Pause Tm Loop OutPatt: Lookup Index, ($0, $1, $3, $2), Patt LSBit = Patt AND $01 If LSBit = 1 Then High AAA 'SerTxD ("A1") Else Low AAA 'SerTxD ("A0") End If Patt = Patt / 2 LSBit = Patt AND $01 If LSBit = 1 Then High BBB 'SerTxD ("B1") Else Low BBB 'SerTxD ("B0") End If Return