ああ
2324L012CR.h@0:56bba8101e52, 2013-11-02 (annotated)
- Committer:
- e00nagog
- Date:
- Sat Nov 02 04:56:46 2013 +0000
- Revision:
- 0:56bba8101e52
????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
e00nagog | 0:56bba8101e52 | 1 | //This '2324L012CR' libraly maked by Brid |
e00nagog | 0:56bba8101e52 | 2 | //DC_12V_Moter |
e00nagog | 0:56bba8101e52 | 3 | //2013.11.02 |
e00nagog | 0:56bba8101e52 | 4 | //Ver 0.0.001 |
e00nagog | 0:56bba8101e52 | 5 | //m.saito |
e00nagog | 0:56bba8101e52 | 6 | |
e00nagog | 0:56bba8101e52 | 7 | |
e00nagog | 0:56bba8101e52 | 8 | #ifndef 2324L012CR_H |
e00nagog | 0:56bba8101e52 | 9 | #define 2324L012CR_H |
e00nagog | 0:56bba8101e52 | 10 | |
e00nagog | 0:56bba8101e52 | 11 | #include "mbed.h" |
e00nagog | 0:56bba8101e52 | 12 | |
e00nagog | 0:56bba8101e52 | 13 | #define FORWARD 1 |
e00nagog | 0:56bba8101e52 | 14 | #define REVERSE 0 |
e00nagog | 0:56bba8101e52 | 15 | |
e00nagog | 0:56bba8101e52 | 16 | // name (length<<8)+address |
e00nagog | 0:56bba8101e52 | 17 | #define ABS_POS ((22<<8)+0x01) //Current position |
e00nagog | 0:56bba8101e52 | 18 | #define EL_POS ((9<<8)+0x02) //Electrical position |
e00nagog | 0:56bba8101e52 | 19 | #define MARK ((22<<8)+0x03) //Mark position |
e00nagog | 0:56bba8101e52 | 20 | #define SPEED ((20<<8)+0x04) //Current speed |
e00nagog | 0:56bba8101e52 | 21 | #define ACC ((12<<8)+0x05) //Acceleration |
e00nagog | 0:56bba8101e52 | 22 | #define DEC ((12<<8)+0x06) //Deceleration |
e00nagog | 0:56bba8101e52 | 23 | #define MAX_SPEED ((10<<8)+0x07) //Maximum speed |
e00nagog | 0:56bba8101e52 | 24 | #define MIN_SPEED ((13<<8)+0x08) //Minimum speed |
e00nagog | 0:56bba8101e52 | 25 | #define KVAL_HOLD ((8<<8)+0x09) //Full step speed |
e00nagog | 0:56bba8101e52 | 26 | #define KVAL_RUN ((8<<8)+0x0A) // |
e00nagog | 0:56bba8101e52 | 27 | #define KVAL_ACC ((8<<8)+0x0B) // |
e00nagog | 0:56bba8101e52 | 28 | #define KVAL_DEC ((8<<8)+0x0C) // |
e00nagog | 0:56bba8101e52 | 29 | #define INT_SPD ((14<<8)+0x0D) // |
e00nagog | 0:56bba8101e52 | 30 | #define ST_SLP ((8<<8)+0x0E) // |
e00nagog | 0:56bba8101e52 | 31 | #define FN_SLP_ACC ((8<<8)+0x0F) // |
e00nagog | 0:56bba8101e52 | 32 | #define FN_SLP_DEC ((8<<8)+0x10) // |
e00nagog | 0:56bba8101e52 | 33 | #define K_THERA ((4<<8)+0x11) // |
e00nagog | 0:56bba8101e52 | 34 | #define ADC_OUT ((5<<8)+0x12) // |
e00nagog | 0:56bba8101e52 | 35 | #define OCR_TH ((4<<8)+0x13) // |
e00nagog | 0:56bba8101e52 | 36 | #define STALL_TH ((7<<8)+0x14) // |
e00nagog | 0:56bba8101e52 | 37 | #define FS_SPD ((10<<8)+0x15) // |
e00nagog | 0:56bba8101e52 | 38 | #define STEP_MODE ((8<<8)+0x16) // |
e00nagog | 0:56bba8101e52 | 39 | #define ARARM_FN ((8<<8)+0x17) // |
e00nagog | 0:56bba8101e52 | 40 | #define CONFIG ((16<<8)+0x18) // |
e00nagog | 0:56bba8101e52 | 41 | #define STATUS ((16<<8)+0x19) // |
e00nagog | 0:56bba8101e52 | 42 | |
e00nagog | 0:56bba8101e52 | 43 | |
e00nagog | 0:56bba8101e52 | 44 | |
e00nagog | 0:56bba8101e52 | 45 | //RH = ResetHex |
e00nagog | 0:56bba8101e52 | 46 | #define RH_ABS_POS 0 //Current position |
e00nagog | 0:56bba8101e52 | 47 | #define RH_EL_POS 0 //Electrical position |
e00nagog | 0:56bba8101e52 | 48 | #define RH_MARK 0 //Mark position |
e00nagog | 0:56bba8101e52 | 49 | #define RH_SPEED 0 //Current speed |
e00nagog | 0:56bba8101e52 | 50 | #define RH_ACC 0x8A //Acceleration |
e00nagog | 0:56bba8101e52 | 51 | #define RH_DEC 0x8A //Deceleration |
e00nagog | 0:56bba8101e52 | 52 | #define RH_MAX_SPEED 0x20 //Maximum speed |
e00nagog | 0:56bba8101e52 | 53 | #define RH_MIN_SPEED 0 //Minimum speed |
e00nagog | 0:56bba8101e52 | 54 | #define RH_KVAL_HOLD 0xFF //Full step speed |
e00nagog | 0:56bba8101e52 | 55 | #define RH_KVAL_RUN 0xFF // |
e00nagog | 0:56bba8101e52 | 56 | #define RH_KVAL_ACC 0xFF // |
e00nagog | 0:56bba8101e52 | 57 | #define RH_KVAL_DEC 0xFF // |
e00nagog | 0:56bba8101e52 | 58 | #define RH_INT_SPD 0x408 // |
e00nagog | 0:56bba8101e52 | 59 | #define RH_ST_SLP 0x19 // |
e00nagog | 0:56bba8101e52 | 60 | #define RH_FN_SLP_ACC 0x29 // |
e00nagog | 0:56bba8101e52 | 61 | #define RH_FN_SLP_DEC 0x29 // |
e00nagog | 0:56bba8101e52 | 62 | #define RH_K_THERA 0x0 // |
e00nagog | 0:56bba8101e52 | 63 | // ADC_OUT ReadOnly |
e00nagog | 0:56bba8101e52 | 64 | #define RH_OCR_TH 0xF |
e00nagog | 0:56bba8101e52 | 65 | #define RH_STALL_TH 0x7F |
e00nagog | 0:56bba8101e52 | 66 | #define RH_FS_SPD 0x27 |
e00nagog | 0:56bba8101e52 | 67 | #define RH_STEP_MODE 0x7 |
e00nagog | 0:56bba8101e52 | 68 | #define RH_ARARM_FN 0xFF |
e00nagog | 0:56bba8101e52 | 69 | #define RH_CONFIG 0x2E88 |
e00nagog | 0:56bba8101e52 | 70 | // RH_STATUS ReadOnly |
e00nagog | 0:56bba8101e52 | 71 | |
e00nagog | 0:56bba8101e52 | 72 | |
e00nagog | 0:56bba8101e52 | 73 | |
e00nagog | 0:56bba8101e52 | 74 | class 2324L012CR{ |
e00nagog | 0:56bba8101e52 | 75 | public: |
e00nagog | 0:56bba8101e52 | 76 | 2324L012CR(PinName pwm_R1, PinName pwm_R2, PinName pwm_L1, PinName pwm_L2); |
e00nagog | 0:56bba8101e52 | 77 | |
e00nagog | 0:56bba8101e52 | 78 | unsigned char send(unsigned char temp); |
e00nagog | 0:56bba8101e52 | 79 | void send_bytes(unsigned char temp[],int i); |
e00nagog | 0:56bba8101e52 | 80 | void NOP(); |
e00nagog | 0:56bba8101e52 | 81 | void SetParam(int param,int value); |
e00nagog | 0:56bba8101e52 | 82 | int GetParam(int param); |
e00nagog | 0:56bba8101e52 | 83 | void Run(unsigned char dir,int spd); |
e00nagog | 0:56bba8101e52 | 84 | void StepClock(unsigned char dir); |
e00nagog | 0:56bba8101e52 | 85 | void Move(unsigned char dir,int n_step); |
e00nagog | 0:56bba8101e52 | 86 | void GoTo(int abs_pos); |
e00nagog | 0:56bba8101e52 | 87 | void GoTo_DIR(unsigned char dir,int abs_pos); |
e00nagog | 0:56bba8101e52 | 88 | void GoUntil(unsigned char act,unsigned char dir,int spd); |
e00nagog | 0:56bba8101e52 | 89 | void ReleaseSW(unsigned char act,unsigned char dir); |
e00nagog | 0:56bba8101e52 | 90 | void GoHome(); |
e00nagog | 0:56bba8101e52 | 91 | void GoMark(); |
e00nagog | 0:56bba8101e52 | 92 | void ResetPos(); |
e00nagog | 0:56bba8101e52 | 93 | void ResetDevice(); |
e00nagog | 0:56bba8101e52 | 94 | void SoftStop(); |
e00nagog | 0:56bba8101e52 | 95 | void HardStop(); |
e00nagog | 0:56bba8101e52 | 96 | void SoftHiZ(); |
e00nagog | 0:56bba8101e52 | 97 | void HardHiZ(); |
e00nagog | 0:56bba8101e52 | 98 | void Resets(); |
e00nagog | 0:56bba8101e52 | 99 | |
e00nagog | 0:56bba8101e52 | 100 | private: |
e00nagog | 0:56bba8101e52 | 101 | SPI m_spi; |
e00nagog | 0:56bba8101e52 | 102 | DigitalOut m_cs; |
e00nagog | 0:56bba8101e52 | 103 | }; |
e00nagog | 0:56bba8101e52 | 104 | |
e00nagog | 0:56bba8101e52 | 105 | |
e00nagog | 0:56bba8101e52 | 106 | #endif |