Library for STMicroelectronics dSPIN L6470 stepper driver. "daisy-chain" supported.
Dependents: L6470_daisy_chain l6470
Diff: L6470SDC.h
- Revision:
- 2:2af83d3ccd97
- Parent:
- 1:db64ad30b4b3
- Child:
- 3:486fb90dc7d5
diff -r db64ad30b4b3 -r 2af83d3ccd97 L6470SDC.h --- a/L6470SDC.h Fri Jun 05 08:48:29 2015 +0000 +++ b/L6470SDC.h Tue Jun 09 06:10:11 2015 +0000 @@ -116,7 +116,6 @@ * Example: * DigitalOut my_cs(D10); * L6470SDC stepper(USBTX, USBRX, SPI_MOSI, SPI_MISO, SPI_SCLK, &my_cs); - * ~~~~~~ */ L6470SDC(PinName tx, PinName rx, PinName mosi, PinName miso, PinName sclk, DigitalOut *csel); @@ -130,7 +129,6 @@ * Example: * Serial usb_serial(USBTX, USBRX); * L6470SDC stepper(&usb_serial, SPI_MOSI, SPI_MISO, SPI_SCLK, D10); - * ~~~~~~~~~~~ */ L6470SDC(Serial *serial, PinName mosi, PinName miso, PinName sclk, PinName csel); @@ -145,7 +143,6 @@ * Serial usb_serial(USBTX, USBRX); * DigitalOut my_cs(D10); * L6470SDC stepper(&usb_serial, SPI_MOSI, SPI_MISO, SPI_SCLK, &my_cs); - * ~~~~~~~~~~~ ~~~~~~ */ L6470SDC(Serial *serial, PinName mosi, PinName miso, PinName sclk, DigitalOut *csel); @@ -158,7 +155,6 @@ * Serial usb_serial(USBTX, USBRX); * SPI my_spi(SPI_MOSI, SPI_MISO, SPI_SCLK); * L6470SDC stepper(&usb_serial, &my_spi, D10); - * ~~~~~~~~~~~ ~~~~~~~ */ L6470SDC(Serial *serial, SPI *spi, PinName csel); @@ -172,7 +168,6 @@ * SPI my_spi(SPI_MOSI, SPI_MISO, SPI_SCLK); * DigitalOut my_cs(D10); * L6470SDC stepper(&usb_serial, &my_spi, &my_cs); - * ~~~~~~~~~~~ ~~~~~~~ ~~~~~~ */ L6470SDC(Serial *serial, SPI *spi, DigitalOut *csel); @@ -194,7 +189,6 @@ * Example: * DigitalOut cs1(D10); * L6470SDC stepper(SPI_MOSI, SPI_MISO, SPI_SCLK, &cs1); - * ~~~~ */ L6470SDC(PinName mosi, PinName miso, PinName sclk, DigitalOut *csel); @@ -205,7 +199,6 @@ * Example: * SPI spi1(SPI_MOSI, SPI_MISO, SPI_SCLK); * L6470SDC stepper(&spi1, D10); - * ~~~~~ */ L6470SDC(SPI *spi, PinName csel); @@ -217,7 +210,6 @@ * SPI spi1(SPI_MOSI, SPI_MISO, SPI_SCLK); * DigitalOut cs1(D10); * L6470SDC stepper(&spi1, &cs1); - * ~~~~~ ~~~~ */ L6470SDC(SPI *spi, DigitalOut *csel); @@ -247,36 +239,138 @@ */ int getMotorCount(); - /** Get motor Busy-flag status. + /** Get motor Busy-flag status * * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. * @returns Busy status.(false = Busy-flag 0, true = Busy-flag 1) */ bool isBusy(int motorNumber); - /** Get motor Busy-flag status. + /** Run motor rotate * * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. * @param hex_speed Motor rotate speed(hex_value Step/s). -> please use "calcSpd(stepPerSecond)" method. - * @param isClockwise clockwise = true. counter clockwise = false. + * @param isClockwise Rotate direction. true = clockwise. false = counter-clockwise. + * Example: + * unsigned long calculatedValue = motor.calcSpd(200); + * motor.run(1, calculatedValue, true); //200step/s, clockwise */ void run(int motorNumber, unsigned long hex_speed, bool isClockwise); + /** Run motor steps + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + * @param count Steps count. If using Microstep-mode, "count" must be multiplied by Microstep-value. + * @param isClockwise Rotate direction. true = clockwise. false = counter-clockwise. + * Example: + * motor.stop(1); + * motor.setStepMode(1, 0x07); //set microstep-mode 0x07 = 1/128 microstep. + * motor.step(1, 256, false); //(256/128)=2 step, counter cloclwise. + */ void step(int motorNumber, unsigned int count, bool isClockwise); + + /** Run motor move + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + * @param stepsCount Steps count. If using Microstep-mode, "stepsCount" must be multiplied by Microstep-value. + * @param isClockwise Rotate direction. true = clockwise. false = counter-clockwise. + * If less than 5step -> Please use the "step(int motorNumber, unsigned int count, bool isClockwise)". + * If greater than 5step -> Please use this method. + */ void move(int motorNumber, unsigned long stepsCount, bool isClockwise); + + /** Go to motor ABS position (shortest path) + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + * @param ABSPos Motor Absolute position. + * CAUTION: This method a motion to ABS position through the shortest path. Rotate direction is not constant. + */ void goto1(int motorNumber, unsigned long ABSPos); + + /** Go to motor ABS position (Specify the rotate direction) + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + * @param ABSPos Motor Absolute position. + * @param isClockwise Rotate direction. true = clockwise. false = counter-clockwise. + */ void goto2(int motorNumber, unsigned long ABSPos, bool isClockwise); + + /** ???Run motor rotate. Until external switch status change??? + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + * @param hex_speed Motor rotate speed(hex_value Step/s). -> please use "calcSpd(stepPerSecond)" method. + * @param isClockwise Rotate direction. true = clockwise. false = counter-clockwise. + * @param setMark External switch status?...??.. Sorry... I could not understand. Please see L6470 datasheet. + */ void goUntil(int motorNumber, unsigned long hex_speed, bool isClockwise, bool setMark); + + /** ???Release external switch??? + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + * @param isClockwise Rotate direction. true = clockwise. false = counter-clockwise. + * @param setMark External switch status?...??.. Sorry... I could not understand. Please see L6470 datasheet. + */ void releaseSwitch(int motorNumber, bool isClockwise, bool setMark); + + /** Go to motor home-position + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + */ void home(int motorNumber); + + /** Go to motor home-position [alias: home(int motorNumber)] + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + */ void zero(int motorNumber); + + /** Go to motor marked-position + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + * Mark Position: -> Please use setMarkPosition(int motorNumber, unsigned long value). + */ void gotoMark(int motorNumber); + + /** Reset the ABS_POS register to zero (ABS_POS zero = home-position) + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + */ void resetHome(int motorNumber); + + /** Reset the ABS_POS register to zero [alias: resetHome(int motorNumber)] + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + */ void resetZero(int motorNumber); + + /** Reset motor device.(software reset) + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + */ void motorReset(int motorNumber); + + /** Stop rotation (soft-stop) + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + */ void stop(int motorNumber); + + /** Stop rotation. Ignore deceleration (hard-stop) + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + */ void stopImmidiate(int motorNumber); + + /** Stop rotation (soft-stop) state sets HighImpedance. + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + */ void stop_HighImpedance(int motorNumber); + + /** Stop rotation. Ignore deceleration (hard-stop) state sets HighImpedance. + * + * @param motorNumber Chained motor-number. If not using daisy-chain, you must be motorNumber = 1. + */ void stopImmidiate_HighImpedance(int motorNumber); // calc method -----------------------------------------------------------------------------