Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Stepper controller CPLD based..

Status
Not open for further replies.

henrik2000

Advanced Member level 4
Joined
Jul 6, 2001
Messages
106
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,296
Activity points
1,123
cpld controller stepper motor uses

Using CPLD to control your steppers is an alternative to trying to use the PC to do so.. If your PC goes away for 150 milliseconds to check if you inserted (or not) a DVD.. It is not taking good care of your steppers. (Under windows I meant of course).. So as an idea, why not use a small cpld to control each of your stepper..? The controller can then just receive low level order and insure that everything goes smoothly..

To show how small this can be, here is an example of the code required for one stepper (driving P & N power FETS). This in turns let you choose whatever stepper you want, from very rough 7.5 degrees per step to exotic 0.5 degree.. And whatever voltage / current required..

If you need more details, PM me.. Cheers..

----------------------------------
module StepperMotorPorts (StepDrive, clock, Direction, StepEnable, ProvideStaticHolding);

output[3:0] StepDrive; // the 4 output to drive the MOSFETS driving the coils in the motor.
reg[3:0] StepDrive;
input clock; // clock input to logic device
input Direction; // spin clockwise or counter-clockwise? (actual direction depends on correct hookup/pin assignements)
input StepEnable; // move a single step on next clock divider rollover. leave high for a single clock to get a single step.
// If high across rollover, may get two steps

input ProvideStaticHolding;

reg[1:0] state; // simple state machine, 4 states
reg[31:0] StepCounter;
// most motors won't spin extrordinarially fast, so this slows the clock input way down
parameter[31:0] StepLockOut = 32'b00000000000000110000110101000000;
//rollover for the counter, to get a non-binary delay time divider
reg InternalStepEnable; // used to capture a step enable even when we are in the wait loop for the clock divider.

always @(posedge clock)
begin
//on clock
StepCounter <= StepCounter + 31'b0000000000000000000000000000001 ; //move the delay counter
if (StepEnable == 1'b1)
begin
InternalStepEnable <= 1'b1 ; // capture any requests for a step, even while we are waiting...
end
if (StepCounter >= StepLockOut)
begin
StepCounter <= 32'b00000000000000000000000000000000 ; // if we just roll-ed over, then it's time to do something
if (ProvideStaticHolding == 1'b1)
begin
//should we leave coils in energized state by defaul or not?
StepDrive <= 4'b0000 ;
end
else
begin
StepDrive <= 4'b1111 ;
end
if (InternalStepEnable == 1'b1)
begin
// are we supposed to step on this clock?
InternalStepEnable <= StepEnable ;
// InternalStepEnable togles at the speed of the clock divider rollover, trailing the
// external StepEnable by less than or equal to one rollover.
// Putting this inside the \"if internal=1\" makes us wait until after move to turn off,
// so we move at least once for each pulse of external step enable line.
if (Direction == 1'b1)
begin
state <= state + 2'b01 ;
end // to change the direction of a stepper motor, you energize
if (Direction == 1'b0)
begin
state <= state - 2'b01 ;
end // the coils in the opposite pattern, so just run states backwards
// this also allows a change of direction at any arbitrary point
case (state)
2'b00 :
begin
StepDrive <= 4'b1010 ; // these states follow proper pattern of coil energizing for turning steppers
end
2'b01 :
begin
StepDrive <= 4'b1001 ;
end
2'b10 :
begin
StepDrive <= 4'b0101 ;
end
2'b11 :
begin
StepDrive <= 4'b0110 ;
end
default :
begin
end
endcase //state
end
end
end
endmodule
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top