for controlling stepper motor with A4980
Dependents: HIDTympDeviceWithPIDController
A4980ControlRegi.h@0:9156e6b6bf46, 2014-10-06 (annotated)
- Committer:
- piniels
- Date:
- Mon Oct 06 11:57:45 2014 +0000
- Revision:
- 0:9156e6b6bf46
jkhasd
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
piniels | 0:9156e6b6bf46 | 1 | /*----------------------------------------------------------- |
piniels | 0:9156e6b6bf46 | 2 | * COPYRIGHT (C) 2010. |
piniels | 0:9156e6b6bf46 | 3 | * GN Otometrics. All rights reserved. |
piniels | 0:9156e6b6bf46 | 4 | *----------------------------------------------------------- |
piniels | 0:9156e6b6bf46 | 5 | * P R O P R I E T A R Y R I G H T S |
piniels | 0:9156e6b6bf46 | 6 | * This document must not be used, nor copied in any form or |
piniels | 0:9156e6b6bf46 | 7 | * handed over to third party, without prior written |
piniels | 0:9156e6b6bf46 | 8 | * permission from GN Otometrics. |
piniels | 0:9156e6b6bf46 | 9 | *----------------------------------------------------------- |
piniels | 0:9156e6b6bf46 | 10 | * |
piniels | 0:9156e6b6bf46 | 11 | * This source file is part of the 1082 Turtle project. |
piniels | 0:9156e6b6bf46 | 12 | * |
piniels | 0:9156e6b6bf46 | 13 | * P4 Info: (P4-filetype must be "ktext" for these to work!) |
piniels | 0:9156e6b6bf46 | 14 | * Last edit by: $Author:$ |
piniels | 0:9156e6b6bf46 | 15 | * Date: $DateTime:$ |
piniels | 0:9156e6b6bf46 | 16 | * Filename: $File:$ |
piniels | 0:9156e6b6bf46 | 17 | * Revision: $Revision:$ |
piniels | 0:9156e6b6bf46 | 18 | * |
piniels | 0:9156e6b6bf46 | 19 | * File Info: |
piniels | 0:9156e6b6bf46 | 20 | * Original author: peilni |
piniels | 0:9156e6b6bf46 | 21 | * Creation date: Nov 19, 2013 |
piniels | 0:9156e6b6bf46 | 22 | * |
piniels | 0:9156e6b6bf46 | 23 | * Doxygen Info: *//*! |
piniels | 0:9156e6b6bf46 | 24 | * @file |
piniels | 0:9156e6b6bf46 | 25 | * @brief Blah blah blah. |
piniels | 0:9156e6b6bf46 | 26 | * |
piniels | 0:9156e6b6bf46 | 27 | * @htmlonly |
piniels | 0:9156e6b6bf46 | 28 | * @endhtmlonly |
piniels | 0:9156e6b6bf46 | 29 | * |
piniels | 0:9156e6b6bf46 | 30 | * Blah blah |
piniels | 0:9156e6b6bf46 | 31 | */ |
piniels | 0:9156e6b6bf46 | 32 | #ifndef A4980CONTROLREGI_H_ |
piniels | 0:9156e6b6bf46 | 33 | #define A4980CONTROLREGI_H_ |
piniels | 0:9156e6b6bf46 | 34 | #include <stdint.h> |
piniels | 0:9156e6b6bf46 | 35 | |
piniels | 0:9156e6b6bf46 | 36 | /* |
piniels | 0:9156e6b6bf46 | 37 | * (*) are default |
piniels | 0:9156e6b6bf46 | 38 | */ |
piniels | 0:9156e6b6bf46 | 39 | typedef union |
piniels | 0:9156e6b6bf46 | 40 | { |
piniels | 0:9156e6b6bf46 | 41 | uint16_t I; |
piniels | 0:9156e6b6bf46 | 42 | |
piniels | 0:9156e6b6bf46 | 43 | struct |
piniels | 0:9156e6b6bf46 | 44 | { |
piniels | 0:9156e6b6bf46 | 45 | uint16_t pwm : 1; // bit0 PWM configuration *0=Fixed off-time, 1=Fixed frequency |
piniels | 0:9156e6b6bf46 | 46 | uint16_t tofFrq : 3; // bit3-1 Off time (only valid when PWM bit = 0).Replaces FRQ bits(Assumes 4-MHz clock) 000=20us, 001=24us, 010=28us, 011=32us, 100=36us, 101=40us, *110=44us, 111=48us// Frequency )(only valid when PWM bit = 1)Replace TOF bits(Assumes 4-MHz clock) 000=24us/41.7kHz, 001=32us/31.3kHz, 010=40us/25kHz, 011=46us/21.7kHz, 100=52us/19.2kHz 101=56us/17.9kHz, *110=60us/16.7kHz, 111=64us/15.6kHz |
piniels | 0:9156e6b6bf46 | 47 | uint16_t tbk : 2; // bit5-4 Blank Time (Assumes 4-MHz clock) 00=1us, *01=1.5us, 10=2.5us, 11=3.5us |
piniels | 0:9156e6b6bf46 | 48 | uint16_t pfd : 3; // bit8-6 Fast decay time for mixed decay. Assumes 4-MHz clock 000=2us, 001=3us, 010=4us, 011=6us, 100=8us, 101=10us, 110=14us, 111=20us |
piniels | 0:9156e6b6bf46 | 49 | uint16_t mx : 2; // bit10-9. Max phase current as a percentage of I(SMAX) 00=25% 01=50% 10=75% *11=100% |
piniels | 0:9156e6b6bf46 | 50 | uint16_t ms : 2; // bit12-11. Microstep mode for external STEP input control *00=Full Step 01=Half Step 10=Quarter Step 11=Sixteenth Step |
piniels | 0:9156e6b6bf46 | 51 | uint16_t syr : 1; // bit13. Synchronous rectification 0=Diode recirculation *1=Synchronous |
piniels | 0:9156e6b6bf46 | 52 | uint16_t addr : 2; // bit15-14 Address config0 = 0b00 |
piniels | 0:9156e6b6bf46 | 53 | |
piniels | 0:9156e6b6bf46 | 54 | } B; |
piniels | 0:9156e6b6bf46 | 55 | } t_config_control_regi_0; |
piniels | 0:9156e6b6bf46 | 56 | |
piniels | 0:9156e6b6bf46 | 57 | /* |
piniels | 0:9156e6b6bf46 | 58 | * (*) are default |
piniels | 0:9156e6b6bf46 | 59 | */ |
piniels | 0:9156e6b6bf46 | 60 | typedef union |
piniels | 0:9156e6b6bf46 | 61 | { |
piniels | 0:9156e6b6bf46 | 62 | uint16_t I; |
piniels | 0:9156e6b6bf46 | 63 | |
piniels | 0:9156e6b6bf46 | 64 | struct |
piniels | 0:9156e6b6bf46 | 65 | { |
piniels | 0:9156e6b6bf46 | 66 | uint16_t diag : 2; // bit1-0 Selects signal routed to DIAG output *00=Fault-low true, 01=ST-low true, 10=PWN-on Phase A, 11=Temperature |
piniels | 0:9156e6b6bf46 | 67 | uint16_t cd : 4; // bit5-2 PWM count difference for ST detection default to 8 |
piniels | 0:9156e6b6bf46 | 68 | uint16_t notInUse : 5; // bit10-6 Not in use value = 0 |
piniels | 0:9156e6b6bf46 | 69 | uint16_t tsc : 2; // bit12-11 Overcurrent fault delay(Assumes 4-MHz clock) 00=0.5us, 01=1us, *10=2us, 11=3us |
piniels | 0:9156e6b6bf46 | 70 | uint16_t osc : 1; // bit13 Selects clock source *0=internal, 1=external |
piniels | 0:9156e6b6bf46 | 71 | uint16_t addr : 2; // bit15-14 Address config0 = 0b01 |
piniels | 0:9156e6b6bf46 | 72 | |
piniels | 0:9156e6b6bf46 | 73 | } B; |
piniels | 0:9156e6b6bf46 | 74 | }t_config_control_regi_1; |
piniels | 0:9156e6b6bf46 | 75 | |
piniels | 0:9156e6b6bf46 | 76 | /* |
piniels | 0:9156e6b6bf46 | 77 | * (*) are default |
piniels | 0:9156e6b6bf46 | 78 | */ |
piniels | 0:9156e6b6bf46 | 79 | typedef union |
piniels | 0:9156e6b6bf46 | 80 | { |
piniels | 0:9156e6b6bf46 | 81 | uint16_t I; |
piniels | 0:9156e6b6bf46 | 82 | |
piniels | 0:9156e6b6bf46 | 83 | struct |
piniels | 0:9156e6b6bf46 | 84 | { |
piniels | 0:9156e6b6bf46 | 85 | uint16_t sc : 6; // bit5-0 Step change number 2’s complement format. Positive value increases Step Angle Number. Negative value decreases Step Angle Number |
piniels | 0:9156e6b6bf46 | 86 | uint16_t dcy : 2; // bit7-6 Decay mode selection 00=Slow, *01=Mixed-PFD fixed, 10=Mixed-PFD auto, 11=Fast |
piniels | 0:9156e6b6bf46 | 87 | uint16_t brk : 1; // bit8 Brake enable *0=Normal operation 1=Brake active |
piniels | 0:9156e6b6bf46 | 88 | uint16_t slew : 1; // bit9 Slew rate control 0=Disable *1=Enable |
piniels | 0:9156e6b6bf46 | 89 | uint16_t hlr : 1; // bit10. Selects slow decay and brake recirculation path *0=High side, 1=Low side |
piniels | 0:9156e6b6bf46 | 90 | uint16_t ol : 2; // bit12-11. Open load current threshold as a percentage of maximum current defined by ISMAX and MXI[1..0] 00=20%, *01=30%, 10=40%, 11=50% |
piniels | 0:9156e6b6bf46 | 91 | uint16_t en : 1; // bit13. Phase current enable OR with ENABLE pin *0=Output bridges disabled if ENABLE pin = 0, 1=Output bridges enabled |
piniels | 0:9156e6b6bf46 | 92 | uint16_t addr : 2; // bit15-14 Address run = 0b10 |
piniels | 0:9156e6b6bf46 | 93 | |
piniels | 0:9156e6b6bf46 | 94 | } B; |
piniels | 0:9156e6b6bf46 | 95 | }t_run_regi; |
piniels | 0:9156e6b6bf46 | 96 | |
piniels | 0:9156e6b6bf46 | 97 | |
piniels | 0:9156e6b6bf46 | 98 | |
piniels | 0:9156e6b6bf46 | 99 | #endif /* A4980CONTROLREGI_H_ */ |