Name Stepper; Partno SC0001; Date 11/04/06; Revision 01; Designer Zachary Blair; Company Zachary Blair; Assembly None; Location None; Device g16v8a; /****************************************************************/ /* This is a controller for a stepper motor */ /****************************************************************/ /** Inputs **/ Pin 1 = clk; /* Step advance */ Pin 2 = motor; /* Select which motor to step */ Pin 3 = dir; /* Step direction input */ /* Pin 11 = !oe;*/ /* Register output enable */ /** Outputs **/ Pin [19..16] = [A3..0]; /* Stepper A outputs */ Pin [15..12] = [B3..0]; /* Stepper B outputs */ /** Declarations and Intermediate Variable Definitions **/ field stepA = [A3..0]; /* declare stepper bit field */ field stepB = [B3..0]; $define S0 'b'0011 /* define stepper excitation states */ $define S1 'b'0010 $define S2 'b'0110 $define S3 'b'0100 $define S4 'b'1100 $define S5 'b'1000 $define S6 'b'1001 $define S7 'b'0001 $define SI 'b'1111 /* the power-on state */ field mode = [motor,dir]; /* declare mode control field */ upA = mode:1; downA = mode:0; upB = mode:3; downB = mode:2; /** Logic Equations **/ Sequenced stepA { /* stepper A counter */ present SI default next S0; present S0 if upA next S1; if downA next S7; default next S0; present S1 if upA next S2; if downA next S0; default next S1; present S2 if upA next S3; if downA next S1; default next S2; present S3 if upA next S4; if downA next S2; default next S3; present S4 if upA next S5; if downA next S3; default next S4; present S5 if upA next S6; if downA next S4; default next S5; present S6 if upA next S7; if downA next S5; default next S6; present S7 if upA next S0; if downA next S6; default next S7; } Sequenced stepB { /* stepper B counter */ present SI default next S0; present S0 if upB next S1; if downB next S7; default next S0; present S1 if upB next S2; if downB next S0; default next S1; present S2 if upB next S3; if downB next S1; default next S2; present S3 if upB next S4; if downB next S2; default next S3; present S4 if upB next S5; if downB next S3; default next S4; present S5 if upB next S6; if downB next S4; default next S5; present S6 if upB next S7; if downB next S5; default next S6; present S7 if upB next S0; if downB next S6; default next S7; }