Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed X_NUCLEO_IHM03A1_for
powerstep.hpp@50:144a92eeddb9, 2021-02-27 (annotated)
- Committer:
- nerit
- Date:
- Sat Feb 27 16:18:50 2021 +0000
- Revision:
- 50:144a92eeddb9
- Parent:
- 31:92a9e183be8e
Aggiornamento parametri relativi al driver stepper installato sulla scheda. ; Dalla versione V8 del pcb sono installati mosfet non integrati nel driver.; Deve essere selezionato il tipo di scheda prima della compilazione.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| nerit | 3:a469bbd294b5 | 1 | /* Variables -----------------------------------------------------------------*/ |
| nerit | 3:a469bbd294b5 | 2 | |
| nerit | 3:a469bbd294b5 | 3 | /* Initialization parameters of the motor connected to the expansion board. */ |
| nerit | 3:a469bbd294b5 | 4 | /* Voltage mode. */ |
| nerit | 50:144a92eeddb9 | 5 | #if defined(pcb_V8) |
| nerit | 50:144a92eeddb9 | 6 | powerstep01_init_u_t init = |
| nerit | 50:144a92eeddb9 | 7 | { |
| nerit | 50:144a92eeddb9 | 8 | /* common parameters */ |
| nerit | 50:144a92eeddb9 | 9 | //.cm.cp.cmVmSelection = POWERSTEP01_CM_VM_CURRENT, // enum powerstep01_CmVm_t |
| nerit | 50:144a92eeddb9 | 10 | .cm.cp.cmVmSelection = POWERSTEP01_CM_VM_VOLTAGE, // enum powerstep01_CmVm_t |
| nerit | 50:144a92eeddb9 | 11 | 1455,//500, // Acceleration rate in step/s2, range 14.55 to 59590 steps/s^2 582 |
| nerit | 50:144a92eeddb9 | 12 | 1455,//500, // Deceleration rate in step/s2, range 14.55 to 59590 steps/s^2 582 |
| nerit | 50:144a92eeddb9 | 13 | 305.00,//122.00, // Maximum speed in step/s, range 15.25 to 15610 steps/s 488 92.45 180.45 |
| nerit | 50:144a92eeddb9 | 14 | 1.0, // Minimum speed in step/s, range 0 to 976.3 steps/s |
| nerit | 50:144a92eeddb9 | 15 | POWERSTEP01_LSPD_OPT_ON, // Low speed optimization bit, enum powerstep01_LspdOpt_t |
| nerit | 50:144a92eeddb9 | 16 | 15624.00, // Full step speed in step/s, range 7.63 to 15625 steps/s 244.16 |
| nerit | 50:144a92eeddb9 | 17 | POWERSTEP01_BOOST_MODE_OFF, // Boost of the amplitude square wave, enum powerstep01_BoostMode_t |
| nerit | 50:144a92eeddb9 | 18 | 968.75, // Overcurrent threshold settings via enum powerstep01_OcdTh_t 281.25 |
| nerit | 50:144a92eeddb9 | 19 | STEP_MODE_1_8, // Step mode settings via enum motorStepMode_t |
| nerit | 50:144a92eeddb9 | 20 | POWERSTEP01_SYNC_SEL_DISABLED, // Synch. Mode settings via enum powerstep01_SyncSel_t |
| nerit | 50:144a92eeddb9 | 21 | (POWERSTEP01_ALARM_EN_OVERCURRENT| |
| nerit | 50:144a92eeddb9 | 22 | POWERSTEP01_ALARM_EN_THERMAL_SHUTDOWN| |
| nerit | 50:144a92eeddb9 | 23 | POWERSTEP01_ALARM_EN_THERMAL_WARNING| |
| nerit | 50:144a92eeddb9 | 24 | POWERSTEP01_ALARM_EN_UVLO| |
| nerit | 50:144a92eeddb9 | 25 | POWERSTEP01_ALARM_EN_STALL_DETECTION| |
| nerit | 50:144a92eeddb9 | 26 | POWERSTEP01_ALARM_EN_SW_TURN_ON| |
| nerit | 50:144a92eeddb9 | 27 | POWERSTEP01_ALARM_EN_WRONG_NPERF_CMD), // Alarm settings via bitmap enum powerstep01_AlarmEn_t |
| nerit | 50:144a92eeddb9 | 28 | POWERSTEP01_IGATE_64mA, // Gate sink/source current via enum powerstep01_Igate_t 64 |
| nerit | 50:144a92eeddb9 | 29 | POWERSTEP01_TBOOST_0ns, // Duration of the overboost phase during gate turn-off via enum powerstep01_Tboost_t |
| nerit | 50:144a92eeddb9 | 30 | POWERSTEP01_TCC_500ns, // Controlled current time via enum powerstep01_Tcc_t 500 |
| nerit | 50:144a92eeddb9 | 31 | POWERSTEP01_WD_EN_DISABLE, // External clock watchdog, enum powerstep01_WdEn_t |
| nerit | 50:144a92eeddb9 | 32 | POWERSTEP01_TBLANK_375ns, // Duration of the blanking time via enum powerstep01_TBlank_t 375 |
| nerit | 50:144a92eeddb9 | 33 | POWERSTEP01_TDT_125ns, // Duration of the dead time via enum powerstep01_Tdt_t 125 |
| nerit | 50:144a92eeddb9 | 34 | #if defined(provaStepper) |
| nerit | 50:144a92eeddb9 | 35 | 93.60, // KVAL Hold torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 50:144a92eeddb9 | 36 | 173.00,//273.00, // KVAL RUN torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 50:144a92eeddb9 | 37 | 173.00,//273.00, // KVAL ACC torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 50:144a92eeddb9 | 38 | 173.00,//273.00, // KVAL DEC torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 50:144a92eeddb9 | 39 | #else |
| nerit | 50:144a92eeddb9 | 40 | 93.60, // KVAL Hold torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 50:144a92eeddb9 | 41 | 273.00, // KVAL RUN torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 50:144a92eeddb9 | 42 | 273.00, // KVAL ACC torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 50:144a92eeddb9 | 43 | 273.00, // KVAL DEC torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 50:144a92eeddb9 | 44 | #endif |
| nerit | 50:144a92eeddb9 | 45 | POWERSTEP01_TOFF_FAST_28us, //Maximum fast decay time , enum powerstep01_ToffFast_t 8 28 |
| nerit | 50:144a92eeddb9 | 46 | POWERSTEP01_FAST_STEP_28us, //Maximum fall step time , enum powerstep01_FastStep_t 12 28 |
| nerit | 50:144a92eeddb9 | 47 | 3.0, // Minimum on-time in us, range 0.5us to 64us 3.0 |
| nerit | 50:144a92eeddb9 | 48 | 21.0, // Minimum off-time in us, range 0.5us to 64us 21.0 |
| nerit | 50:144a92eeddb9 | 49 | POWERSTEP01_CONFIG_INT_16MHZ_OSCOUT_2MHZ, // Clock setting , enum powerstep01_ConfigOscMgmt_t |
| nerit | 50:144a92eeddb9 | 50 | // POWERSTEP01_CONFIG_SW_HARD_STOP, // External switch hard stop interrupt mode, enum powerstep01_ConfigSwMode_t |
| nerit | 50:144a92eeddb9 | 51 | POWERSTEP01_CONFIG_SW_USER, // External switch hard stop interrupt mode, enum powerstep01_ConfigSwMode_t |
| nerit | 50:144a92eeddb9 | 52 | POWERSTEP01_CONFIG_TQ_REG_TVAL_USED, // External torque regulation enabling , enum powerstep01_ConfigEnTqReg_t |
| nerit | 50:144a92eeddb9 | 53 | POWERSTEP01_CONFIG_VS_COMP_ENABLE, // Motor Supply Voltage Compensation enabling , enum powerstep01_ConfigEnVscomp_t |
| nerit | 50:144a92eeddb9 | 54 | POWERSTEP01_CONFIG_OC_SD_DISABLE, // Over current shutwdown enabling, enum powerstep01_ConfigOcSd_t |
| nerit | 50:144a92eeddb9 | 55 | POWERSTEP01_CONFIG_UVLOVAL_LOW, // UVLO Threshold via powerstep01_ConfigUvLoVal_t |
| nerit | 50:144a92eeddb9 | 56 | POWERSTEP01_CONFIG_VCCVAL_7_5V//, // VCC Val, enum powerstep01_ConfigVccVal_t |
| nerit | 50:144a92eeddb9 | 57 | //POWERSTEP01_CONFIG_TSW_124us, // Switching period, enum powerstep01_ConfigTsw_t 048 |
| nerit | 50:144a92eeddb9 | 58 | //POWERSTEP01_CONFIG_PRED_ENABLE // Predictive current enabling , enum powerstep01_ConfigPredEn_t |
| nerit | 50:144a92eeddb9 | 59 | }; |
| nerit | 50:144a92eeddb9 | 60 | /* Motor Control Component. */ |
| nerit | 50:144a92eeddb9 | 61 | PowerStep01 *motor; |
| nerit | 50:144a92eeddb9 | 62 | #endif |
| nerit | 50:144a92eeddb9 | 63 | |
| nerit | 50:144a92eeddb9 | 64 | /* Initialization parameters of the motor connected to the expansion board. */ |
| nerit | 50:144a92eeddb9 | 65 | /* Current mode. */ |
| nerit | 50:144a92eeddb9 | 66 | #if defined(pcb_V7) |
| nerit | 3:a469bbd294b5 | 67 | powerstep01_init_u_t init = |
| nerit | 3:a469bbd294b5 | 68 | { |
| nerit | 3:a469bbd294b5 | 69 | /* common parameters */ |
| nerit | 17:9629eb019892 | 70 | .cm.cp.cmVmSelection = POWERSTEP01_CM_VM_CURRENT, // enum powerstep01_CmVm_t |
| nerit | 17:9629eb019892 | 71 | //.cm.cp.cmVmSelection = POWERSTEP01_CM_VM_VOLTAGE, // enum powerstep01_CmVm_t |
| nerit | 31:92a9e183be8e | 72 | 500, // Acceleration rate in step/s2, range 14.55 to 59590 steps/s^2 582 |
| nerit | 31:92a9e183be8e | 73 | 500, // Deceleration rate in step/s2, range 14.55 to 59590 steps/s^2 582 |
| nerit | 28:0534c86365ec | 74 | 122.00, // Maximum speed in step/s, range 15.25 to 15610 steps/s 488 92.45 180.45 |
| nerit | 3:a469bbd294b5 | 75 | 1.0, // Minimum speed in step/s, range 0 to 976.3 steps/s |
| nerit | 3:a469bbd294b5 | 76 | POWERSTEP01_LSPD_OPT_ON, // Low speed optimization bit, enum powerstep01_LspdOpt_t |
| nerit | 3:a469bbd294b5 | 77 | 15624.00, // Full step speed in step/s, range 7.63 to 15625 steps/s 244.16 |
| nerit | 3:a469bbd294b5 | 78 | POWERSTEP01_BOOST_MODE_OFF, // Boost of the amplitude square wave, enum powerstep01_BoostMode_t |
| nerit | 17:9629eb019892 | 79 | 968.75, // Overcurrent threshold settings via enum powerstep01_OcdTh_t 281.25 |
| nerit | 3:a469bbd294b5 | 80 | STEP_MODE_1_8, // Step mode settings via enum motorStepMode_t |
| nerit | 3:a469bbd294b5 | 81 | POWERSTEP01_SYNC_SEL_DISABLED, // Synch. Mode settings via enum powerstep01_SyncSel_t |
| nerit | 3:a469bbd294b5 | 82 | (POWERSTEP01_ALARM_EN_OVERCURRENT| |
| nerit | 3:a469bbd294b5 | 83 | POWERSTEP01_ALARM_EN_THERMAL_SHUTDOWN| |
| nerit | 3:a469bbd294b5 | 84 | POWERSTEP01_ALARM_EN_THERMAL_WARNING| |
| nerit | 3:a469bbd294b5 | 85 | POWERSTEP01_ALARM_EN_UVLO| |
| nerit | 3:a469bbd294b5 | 86 | POWERSTEP01_ALARM_EN_STALL_DETECTION| |
| nerit | 3:a469bbd294b5 | 87 | POWERSTEP01_ALARM_EN_SW_TURN_ON| |
| nerit | 3:a469bbd294b5 | 88 | POWERSTEP01_ALARM_EN_WRONG_NPERF_CMD), // Alarm settings via bitmap enum powerstep01_AlarmEn_t |
| nerit | 3:a469bbd294b5 | 89 | POWERSTEP01_IGATE_64mA, // Gate sink/source current via enum powerstep01_Igate_t 64 |
| nerit | 3:a469bbd294b5 | 90 | POWERSTEP01_TBOOST_0ns, // Duration of the overboost phase during gate turn-off via enum powerstep01_Tboost_t |
| nerit | 3:a469bbd294b5 | 91 | POWERSTEP01_TCC_500ns, // Controlled current time via enum powerstep01_Tcc_t 500 |
| nerit | 3:a469bbd294b5 | 92 | POWERSTEP01_WD_EN_DISABLE, // External clock watchdog, enum powerstep01_WdEn_t |
| nerit | 3:a469bbd294b5 | 93 | POWERSTEP01_TBLANK_375ns, // Duration of the blanking time via enum powerstep01_TBlank_t 375 |
| nerit | 3:a469bbd294b5 | 94 | POWERSTEP01_TDT_125ns, // Duration of the dead time via enum powerstep01_Tdt_t 125 |
| nerit | 18:7c978f69cc51 | 95 | #if defined(provaStepper) |
| nerit | 18:7c978f69cc51 | 96 | 93.60, // KVAL Hold torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 18:7c978f69cc51 | 97 | 233.00, // KVAL RUN torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 18:7c978f69cc51 | 98 | 233.00, // KVAL ACC torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 18:7c978f69cc51 | 99 | 233.00, // KVAL DEC torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 18:7c978f69cc51 | 100 | #else |
| nerit | 18:7c978f69cc51 | 101 | 93.60, // KVAL Hold torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 18:7c978f69cc51 | 102 | 273.00, // KVAL RUN torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 18:7c978f69cc51 | 103 | 273.00, // KVAL ACC torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 18:7c978f69cc51 | 104 | 273.00, // KVAL DEC torque in mV, range from 0.0mV to 0.996 mV |
| nerit | 18:7c978f69cc51 | 105 | #endif |
| nerit | 17:9629eb019892 | 106 | POWERSTEP01_TOFF_FAST_28us, //Maximum fast decay time , enum powerstep01_ToffFast_t 8 |
| nerit | 17:9629eb019892 | 107 | POWERSTEP01_FAST_STEP_28us, //Maximum fall step time , enum powerstep01_FastStep_t 12 |
| nerit | 3:a469bbd294b5 | 108 | 3.0, // Minimum on-time in us, range 0.5us to 64us 3.0 |
| nerit | 3:a469bbd294b5 | 109 | 20.5, // Minimum off-time in us, range 0.5us to 64us 21.0 |
| nerit | 3:a469bbd294b5 | 110 | POWERSTEP01_CONFIG_INT_16MHZ_OSCOUT_2MHZ, // Clock setting , enum powerstep01_ConfigOscMgmt_t |
| nerit | 3:a469bbd294b5 | 111 | POWERSTEP01_CONFIG_SW_HARD_STOP, // External switch hard stop interrupt mode, enum powerstep01_ConfigSwMode_t |
| nerit | 3:a469bbd294b5 | 112 | POWERSTEP01_CONFIG_TQ_REG_TVAL_USED, // External torque regulation enabling , enum powerstep01_ConfigEnTqReg_t |
| nerit | 3:a469bbd294b5 | 113 | POWERSTEP01_CONFIG_VS_COMP_ENABLE, // Motor Supply Voltage Compensation enabling , enum powerstep01_ConfigEnVscomp_t |
| nerit | 6:e8c18f0f399a | 114 | POWERSTEP01_CONFIG_OC_SD_DISABLE, // Over current shutwdown enabling, enum powerstep01_ConfigOcSd_t |
| nerit | 3:a469bbd294b5 | 115 | POWERSTEP01_CONFIG_UVLOVAL_LOW, // UVLO Threshold via powerstep01_ConfigUvLoVal_t |
| nerit | 3:a469bbd294b5 | 116 | POWERSTEP01_CONFIG_VCCVAL_7_5V, // VCC Val, enum powerstep01_ConfigVccVal_t |
| nerit | 18:7c978f69cc51 | 117 | POWERSTEP01_CONFIG_TSW_124us, // Switching period, enum powerstep01_ConfigTsw_t 048 |
| nerit | 3:a469bbd294b5 | 118 | POWERSTEP01_CONFIG_PRED_ENABLE // Predictive current enabling , enum powerstep01_ConfigPredEn_t |
| nerit | 3:a469bbd294b5 | 119 | }; |
| nerit | 3:a469bbd294b5 | 120 | /* Motor Control Component. */ |
| nerit | 3:a469bbd294b5 | 121 | PowerStep01 *motor; |
| nerit | 50:144a92eeddb9 | 122 | #endif |