Control up to 4 steppers axis with limit switch logic from serial port

Dependencies:   mbed

Committer:
jm
Date:
Sat Feb 12 16:49:03 2011 +0000
Revision:
0:3e676fcd9c71
jmStepperAxis Command Line Interface Module

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jm 0:3e676fcd9c71 1 /*************************************************************************
jm 0:3e676fcd9c71 2 * @file jmStepper.h
jm 0:3e676fcd9c71 3 * @brief Stepper Control Interface
jm 0:3e676fcd9c71 4 * You can use 4,5,6 and 8 wire steppers.
jm 0:3e676fcd9c71 5 * Each output pin must have two drivers.
jm 0:3e676fcd9c71 6 * One driver must be the inverted output pin.
jm 0:3e676fcd9c71 7 * The other driver is the non inverted output pin.
jm 0:3e676fcd9c71 8 * This way the steppers operate in full step, full torque mode.
jm 0:3e676fcd9c71 9 * .
jm 0:3e676fcd9c71 10 * @version 1.0
jm 0:3e676fcd9c71 11 * @date Feb 12, 2010
jm 0:3e676fcd9c71 12 */
jm 0:3e676fcd9c71 13
jm 0:3e676fcd9c71 14 /*
jm 0:3e676fcd9c71 15 * Module Command Line Interface
jm 0:3e676fcd9c71 16 Format: command name (arg info)min..max values [optional argument]
jm 0:3e676fcd9c71 17 stepper (Stepper number)0..3 (Pin CoilA)0..432 (Pin CoilB)0..432 (Direction)0..1 (Delay)1..255 [(Steps)1..65535]
jm 0:3e676fcd9c71 18 stepperStop (steppers value)1..15
jm 0:3e676fcd9c71 19
jm 0:3e676fcd9c71 20 Example for stepper on pins Port1.31 Port1.30 DIP20 DIP19
jm 0:3e676fcd9c71 21 stepper 0 131 130 1 1 shortest delays between steps (fastest speed) continuous mode
jm 0:3e676fcd9c71 22 stepper 0 131 130 0 1 1 one step in reverse direction
jm 0:3e676fcd9c71 23 stepper 0 131 130 1 10 5 5 steps in foward direction with 10 unit ticks between steps
jm 0:3e676fcd9c71 24
jm 0:3e676fcd9c71 25 * Module Events
jm 0:3e676fcd9c71 26 GPPST (stepper id)0..3
jm 0:3e676fcd9c71 27 On Ending steps, Send Message: GPPST id pinA pinB delay status
jm 0:3e676fcd9c71 28
jm 0:3e676fcd9c71 29 * Module Feedback and Help messages may be enabled/disabled by Command Lines.
jm 0:3e676fcd9c71 30 feedback (enable/disable)0..1
jm 0:3e676fcd9c71 31 help (enable/disable)0..1
jm 0:3e676fcd9c71 32
jm 0:3e676fcd9c71 33 */
jm 0:3e676fcd9c71 34
jm 0:3e676fcd9c71 35 #ifndef jmStepperdef
jm 0:3e676fcd9c71 36 #define jmStepperdef 1
jm 0:3e676fcd9c71 37
jm 0:3e676fcd9c71 38 #define stepperQty 4 // 4 steppers max
jm 0:3e676fcd9c71 39
jm 0:3e676fcd9c71 40 #include "LPC17xx.h"
jm 0:3e676fcd9c71 41
jm 0:3e676fcd9c71 42 // Module Data Structure
jm 0:3e676fcd9c71 43 extern struct StructStepper{
jm 0:3e676fcd9c71 44 uint8_t cw;
jm 0:3e676fcd9c71 45 uint8_t active;
jm 0:3e676fcd9c71 46 uint8_t seq;
jm 0:3e676fcd9c71 47 uint8_t delay;
jm 0:3e676fcd9c71 48 uint8_t eggTimer;
jm 0:3e676fcd9c71 49 uint16_t nSteps;
jm 0:3e676fcd9c71 50 uint16_t pinA;
jm 0:3e676fcd9c71 51 uint16_t pinB;
jm 0:3e676fcd9c71 52 uint32_t CoilA_bitValue;
jm 0:3e676fcd9c71 53 uint32_t CoilB_bitValue;
jm 0:3e676fcd9c71 54 LPC_GPIO_TypeDef *portCoilA;
jm 0:3e676fcd9c71 55 LPC_GPIO_TypeDef *portCoilB;
jm 0:3e676fcd9c71 56 }sStepper[stepperQty];
jm 0:3e676fcd9c71 57
jm 0:3e676fcd9c71 58 #endif
jm 0:3e676fcd9c71 59
jm 0:3e676fcd9c71 60 // Module Prototypes
jm 0:3e676fcd9c71 61 void StepperInit(void);
jm 0:3e676fcd9c71 62 void StepperSM(void);
jm 0:3e676fcd9c71 63 void cli_Stepper(void);
jm 0:3e676fcd9c71 64 void Step(int number, bool CW);
jm 0:3e676fcd9c71 65 void cli_StepperStop(void);
jm 0:3e676fcd9c71 66 void cli_GPPST(void);
jm 0:3e676fcd9c71 67 void rGPPST(unsigned int id);
jm 0:3e676fcd9c71 68 void cli_StepSpeed(void);
jm 0:3e676fcd9c71 69
jm 0:3e676fcd9c71 70 //-------------------------- CLIG PLUGS --------------------
jm 0:3e676fcd9c71 71 // CLIG-INCLUDE
jm 0:3e676fcd9c71 72 /*
jm 0:3e676fcd9c71 73 #include "jmStepper.h"
jm 0:3e676fcd9c71 74 */
jm 0:3e676fcd9c71 75
jm 0:3e676fcd9c71 76 // CLIG-INIT
jm 0:3e676fcd9c71 77 /*
jm 0:3e676fcd9c71 78 StepperInit();
jm 0:3e676fcd9c71 79 */
jm 0:3e676fcd9c71 80
jm 0:3e676fcd9c71 81 // CLIG-TIMER
jm 0:3e676fcd9c71 82 /*
jm 0:3e676fcd9c71 83 // Module jmStepper
jm 0:3e676fcd9c71 84 for(i=0;i<stepperQty;i++)if(sStepper[i].eggTimer>0)sStepper[i].eggTimer--;
jm 0:3e676fcd9c71 85 */
jm 0:3e676fcd9c71 86
jm 0:3e676fcd9c71 87 // CLIG-CMD
jm 0:3e676fcd9c71 88 /*
jm 0:3e676fcd9c71 89 stepper cli_Stepper();
jm 0:3e676fcd9c71 90 stepperStop cli_StepperStop();
jm 0:3e676fcd9c71 91 GPPST cli_GPPST();
jm 0:3e676fcd9c71 92 stepSpeed cli_StepSpeed();
jm 0:3e676fcd9c71 93 */
jm 0:3e676fcd9c71 94
jm 0:3e676fcd9c71 95 // CLIG-SM
jm 0:3e676fcd9c71 96 /*
jm 0:3e676fcd9c71 97 StepperSM();
jm 0:3e676fcd9c71 98 */
jm 0:3e676fcd9c71 99 //-------------------------- END CLIG PLUGS --------------------