This is a complete listing of the RS-EDP software for the mbed module to support the RS-EDP platform.

Dependencies:   mbed

Committer:
DavidGilesHitex
Date:
Fri Nov 19 09:49:16 2010 +0000
Revision:
0:5b7639d1f2c4

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DavidGilesHitex 0:5b7639d1f2c4 1 /* Driver for brushed DC Motor Controler */
DavidGilesHitex 0:5b7639d1f2c4 2 /* ************************************* */
DavidGilesHitex 0:5b7639d1f2c4 3
DavidGilesHitex 0:5b7639d1f2c4 4
DavidGilesHitex 0:5b7639d1f2c4 5
DavidGilesHitex 0:5b7639d1f2c4 6 /* Include Files Here */
DavidGilesHitex 0:5b7639d1f2c4 7 #include "mbed.h" /* mbed header file */
DavidGilesHitex 0:5b7639d1f2c4 8 #include "misra_types.h" /* MISRA Types header file */
DavidGilesHitex 0:5b7639d1f2c4 9 #include "defines.h"
DavidGilesHitex 0:5b7639d1f2c4 10 #include "mbed_Port_Structure.h" /* Port structure for MBED Module */
DavidGilesHitex 0:5b7639d1f2c4 11
DavidGilesHitex 0:5b7639d1f2c4 12
DavidGilesHitex 0:5b7639d1f2c4 13
DavidGilesHitex 0:5b7639d1f2c4 14
DavidGilesHitex 0:5b7639d1f2c4 15
DavidGilesHitex 0:5b7639d1f2c4 16 /*
DavidGilesHitex 0:5b7639d1f2c4 17 The standard software module for the MC1 has been modified to accomodate the mapping of the mbed pins to it.
DavidGilesHitex 0:5b7639d1f2c4 18 Not all of the functions usually available for control of the MC1 module are available.
DavidGilesHitex 0:5b7639d1f2c4 19 Below in the commented out section is the full section of functions.
DavidGilesHitex 0:5b7639d1f2c4 20 In the function prototype section are the ones that are implemented
DavidGilesHitex 0:5b7639d1f2c4 21 */
DavidGilesHitex 0:5b7639d1f2c4 22
DavidGilesHitex 0:5b7639d1f2c4 23 /*
DavidGilesHitex 0:5b7639d1f2c4 24 The mapping of the various functions to the mbed module are as follows...
DavidGilesHitex 0:5b7639d1f2c4 25 int16_t RSEDP_MC1_Read_VDCLINK(uint8_t channel); VDCLINK - Analogue AN2 - pin 17 mbed MCU
DavidGilesHitex 0:5b7639d1f2c4 26 uint16_t RSEDP_MC1_Read_VSENSE(uint8_t channel); VSENSE - Analogue AN0 - pin 15 mbed MCU
DavidGilesHitex 0:5b7639d1f2c4 27 uint16_t RSEDP_MC1_Read_VTACH(uint8-t channel); VTACH - possible Analogue AN4 - pin 19 mbed MCU - but not implemnted as this pin 19 used as brake input
DavidGilesHitex 0:5b7639d1f2c4 28 uint16_t RSEDP_MC1_Read_Acceleration_Ramp(void); Accelration ramp - Not implemented
DavidGilesHitex 0:5b7639d1f2c4 29 uint16_t RSEDP_MC1_Read_Deceleration_Ramp(void); Deceleration lamp - not implemented
DavidGilesHitex 0:5b7639d1f2c4 30
DavidGilesHitex 0:5b7639d1f2c4 31
DavidGilesHitex 0:5b7639d1f2c4 32 uint8_t RSEDP_MC1_Read_External_Fault_Input(void); External Fault - not implemented
DavidGilesHitex 0:5b7639d1f2c4 33 uint8_t RSEDP_MC1_Read_Fault_Reset_Switch(void); Fault Reset - not implemented
DavidGilesHitex 0:5b7639d1f2c4 34 uint8_t RSEDP_MC1_Read_Open_Switch(uint8_t pin_option); Open Switch - Mapped to EVM2_GPIO41 - pin 11 mbed digital input
DavidGilesHitex 0:5b7639d1f2c4 35 uint8_t RSEDP_MC1_Read_Closed_Switch(uint8_t pin_option); Closed Switch - not implemented
DavidGilesHitex 0:5b7639d1f2c4 36 uint8_t RSEDP_MC1_Read_Encoder0_Input(uint8_t pin_option); Read Encoder0 - mapped to EVG6_GPIO52 - pin 30 mbed digital input (possible timer input capture)
DavidGilesHitex 0:5b7639d1f2c4 37 uint8_t RSEDP_MC1_Read_Encoder1_Input(uint8_t pin_option); Read Encoder1 - mapped to EVG7_GPIO54 - pin 8 mbed digital input
DavidGilesHitex 0:5b7639d1f2c4 38 uint8_t RSEDP_MC1_Read_Tacho_Input(uint8_t pin_option); Tacho Pulses - Duplicate function to Encoder0
DavidGilesHitex 0:5b7639d1f2c4 39 uint8_t RSEDP_MC1_Read_Motor_RunStop(uint8_t pin_option); Motor Run Stop - mapped to EVG3_GPIO46 pin 26 mbed digital input
DavidGilesHitex 0:5b7639d1f2c4 40 uint8_t RSEDP_MC1_Read_Motor_Direction(uint8_t pin_option); Read Motor Direction - not implemented
DavidGilesHitex 0:5b7639d1f2c4 41 uint8_t RSEDP_MC1_Read_Current_Limit_Match(uint8_t pin_option); Motor Current Limit - not implemented
DavidGilesHitex 0:5b7639d1f2c4 42
DavidGilesHitex 0:5b7639d1f2c4 43
DavidGilesHitex 0:5b7639d1f2c4 44 void RSEDP_MC1_Set_Motor_Direction(uint8_t motor_direction, uint8_t pin_option); Set Motor Direction - mapped to pin 24 - digital out
DavidGilesHitex 0:5b7639d1f2c4 45 void RSEDP_MC1_Brake(uint8_t brake_onoff, uint8_t pin_option); Brake on/off - mapped to GPIO0 - pin 19 mbed module digital out
DavidGilesHitex 0:5b7639d1f2c4 46 void RSEDP_MC1_Set_Motor_Speed_Duty(float motor_speed_duty, uint8_t pin_option); Set motor speed duty - mapped to EVG0_GPIO40 - pin 23 mbed PWM out
DavidGilesHitex 0:5b7639d1f2c4 47 void RSEDP_MC1_Set_Current_Trip_Duty(float current_trip_duty, uint8_t pin_option); Set current trip duty - mapped to CPU_DACO0_GPIO17 - pin 21 PWM out
DavidGilesHitex 0:5b7639d1f2c4 48 */
DavidGilesHitex 0:5b7639d1f2c4 49
DavidGilesHitex 0:5b7639d1f2c4 50
DavidGilesHitex 0:5b7639d1f2c4 51
DavidGilesHitex 0:5b7639d1f2c4 52
DavidGilesHitex 0:5b7639d1f2c4 53
DavidGilesHitex 0:5b7639d1f2c4 54
DavidGilesHitex 0:5b7639d1f2c4 55 /* function Prototypes */
DavidGilesHitex 0:5b7639d1f2c4 56 void RSEDP_MC1_Setup(void); /* Setup the MC1 Board */
DavidGilesHitex 0:5b7639d1f2c4 57
DavidGilesHitex 0:5b7639d1f2c4 58 /* Analogue Levels */
DavidGilesHitex 0:5b7639d1f2c4 59 uint16_t RSEDP_MC1_Read_VDCLINK(uint8_t channel); /* Read the filtered 12V DC voltage on the MC1 board via pot down resistors */
DavidGilesHitex 0:5b7639d1f2c4 60 uint16_t RSEDP_MC1_Read_VSENSE(uint8_t channel); /* Read the filtered current sense output from the MC1 board */
DavidGilesHitex 0:5b7639d1f2c4 61
DavidGilesHitex 0:5b7639d1f2c4 62
DavidGilesHitex 0:5b7639d1f2c4 63 /* Digital level inputs */
DavidGilesHitex 0:5b7639d1f2c4 64 uint8_t RSEDP_MC1_Read_Encoder0_Input(uint8_t pin_option); /* Read the physical level on the Encoder0 input pin on P301 pin 8 on the MC1 board*/
DavidGilesHitex 0:5b7639d1f2c4 65 uint8_t RSEDP_MC1_Read_Encoder1_Input(uint8_t pin_option); /* Read the physical level on the Encoder1 input pin on P301 pin 10 on the MC1 board*/
DavidGilesHitex 0:5b7639d1f2c4 66 uint8_t RSEDP_MC1_Read_Tacho_Input(uint8_t pin_option); /* Read the physical level on the Tacho Pulses Input pin on P301 pin 6 on the MC1 board */
DavidGilesHitex 0:5b7639d1f2c4 67
DavidGilesHitex 0:5b7639d1f2c4 68
DavidGilesHitex 0:5b7639d1f2c4 69 /* Outputs */
DavidGilesHitex 0:5b7639d1f2c4 70 void RSEDP_MC1_Set_Motor_Direction(uint8_t motor_direction, uint8_t pin_option); /* Set the motor direction */
DavidGilesHitex 0:5b7639d1f2c4 71 void RSEDP_MC1_Brake(uint8_t brake_onoff, uint8_t pin_option); /* turn the brake on or off */
DavidGilesHitex 0:5b7639d1f2c4 72 void RSEDP_MC1_Set_Motor_Speed_Duty(float motor_speed_duty, uint8_t pin_option); /* Power control of motor speed controller using PWM */
DavidGilesHitex 0:5b7639d1f2c4 73
DavidGilesHitex 0:5b7639d1f2c4 74
DavidGilesHitex 0:5b7639d1f2c4 75
DavidGilesHitex 0:5b7639d1f2c4 76
DavidGilesHitex 0:5b7639d1f2c4 77
DavidGilesHitex 0:5b7639d1f2c4 78
DavidGilesHitex 0:5b7639d1f2c4 79 /* Setup the MC1 Board */
DavidGilesHitex 0:5b7639d1f2c4 80 void RSEDP_MC1_Setup(void)
DavidGilesHitex 0:5b7639d1f2c4 81 {
DavidGilesHitex 0:5b7639d1f2c4 82 PwmOut_Pin23.period_us(50); /* 20KHz fundemental PWM */
DavidGilesHitex 0:5b7639d1f2c4 83 RSEDP_MC1_Set_Motor_Speed_Duty(0, EVG0_GPIO40); /* Speed set to zero */
DavidGilesHitex 0:5b7639d1f2c4 84 RSEDP_MC1_Brake(BRAKE_ON, GPIO0); /* Brake ON */
DavidGilesHitex 0:5b7639d1f2c4 85 }
DavidGilesHitex 0:5b7639d1f2c4 86
DavidGilesHitex 0:5b7639d1f2c4 87
DavidGilesHitex 0:5b7639d1f2c4 88 /* Read The VDCLINK Voltage */
DavidGilesHitex 0:5b7639d1f2c4 89 uint16_t RSEDP_MC1_Read_VDCLINK(uint8_t channel)
DavidGilesHitex 0:5b7639d1f2c4 90 {
DavidGilesHitex 0:5b7639d1f2c4 91 /* There are two possible AD conveter channels where we can measure the VDCLINK voltage */
DavidGilesHitex 0:5b7639d1f2c4 92 /* Either ADC channel AN2 or ADC channel AN12 selectable via JP312 */
DavidGilesHitex 0:5b7639d1f2c4 93 /* channel therefore has two value 2 or 12 */
DavidGilesHitex 0:5b7639d1f2c4 94
DavidGilesHitex 0:5b7639d1f2c4 95 float return_value = 0;
DavidGilesHitex 0:5b7639d1f2c4 96
DavidGilesHitex 0:5b7639d1f2c4 97 if (channel == AN2)
DavidGilesHitex 0:5b7639d1f2c4 98 {
DavidGilesHitex 0:5b7639d1f2c4 99 /* Link JP312 1-2 */
DavidGilesHitex 0:5b7639d1f2c4 100 return_value = (AD2 * 3300);
DavidGilesHitex 0:5b7639d1f2c4 101 }
DavidGilesHitex 0:5b7639d1f2c4 102
DavidGilesHitex 0:5b7639d1f2c4 103 if (channel == AN12)
DavidGilesHitex 0:5b7639d1f2c4 104 {
DavidGilesHitex 0:5b7639d1f2c4 105 /* Link JP312 2-3 */
DavidGilesHitex 0:5b7639d1f2c4 106 /* AN12 is mapped onto AD3 on the mbed module via link option */
DavidGilesHitex 0:5b7639d1f2c4 107 return_value = (AD3 * 3300);
DavidGilesHitex 0:5b7639d1f2c4 108 }
DavidGilesHitex 0:5b7639d1f2c4 109
DavidGilesHitex 0:5b7639d1f2c4 110 return (uint16_t) return_value;
DavidGilesHitex 0:5b7639d1f2c4 111 }
DavidGilesHitex 0:5b7639d1f2c4 112
DavidGilesHitex 0:5b7639d1f2c4 113
DavidGilesHitex 0:5b7639d1f2c4 114 /* Read the current sense output from the MC1 board */
DavidGilesHitex 0:5b7639d1f2c4 115 uint16_t RSEDP_MC1_Read_VSENSE(uint8_t channel)
DavidGilesHitex 0:5b7639d1f2c4 116 {
DavidGilesHitex 0:5b7639d1f2c4 117 /* Read the current sense output from the motor drive device */
DavidGilesHitex 0:5b7639d1f2c4 118 /* This voltage signal is proprtional to the motor current */
DavidGilesHitex 0:5b7639d1f2c4 119 /* We can read this from a choice of two AD channels AN0 and AN10 selectable via JP307 */
DavidGilesHitex 0:5b7639d1f2c4 120
DavidGilesHitex 0:5b7639d1f2c4 121 float return_value = 0;
DavidGilesHitex 0:5b7639d1f2c4 122
DavidGilesHitex 0:5b7639d1f2c4 123 if (channel == AN0)
DavidGilesHitex 0:5b7639d1f2c4 124 {
DavidGilesHitex 0:5b7639d1f2c4 125 /* Link JP307 1-2 */
DavidGilesHitex 0:5b7639d1f2c4 126 return_value = (AD0 * 3300);
DavidGilesHitex 0:5b7639d1f2c4 127
DavidGilesHitex 0:5b7639d1f2c4 128 }
DavidGilesHitex 0:5b7639d1f2c4 129
DavidGilesHitex 0:5b7639d1f2c4 130 if (channel == AN10)
DavidGilesHitex 0:5b7639d1f2c4 131 {
DavidGilesHitex 0:5b7639d1f2c4 132 /* Link JP307 2-3 */
DavidGilesHitex 0:5b7639d1f2c4 133 /* AN10 is mapped onto AD1 via link option on the mbed module */
DavidGilesHitex 0:5b7639d1f2c4 134 return_value = (AD1 * 3300);
DavidGilesHitex 0:5b7639d1f2c4 135 }
DavidGilesHitex 0:5b7639d1f2c4 136
DavidGilesHitex 0:5b7639d1f2c4 137 return (uint16_t) return_value;
DavidGilesHitex 0:5b7639d1f2c4 138 }
DavidGilesHitex 0:5b7639d1f2c4 139
DavidGilesHitex 0:5b7639d1f2c4 140
DavidGilesHitex 0:5b7639d1f2c4 141
DavidGilesHitex 0:5b7639d1f2c4 142 /* Read the filtered tacho voltage. This voltage is proportional to RPM */
DavidGilesHitex 0:5b7639d1f2c4 143 uint16_t RSEDP_MC1_Read_VTACH(uint8_t channel)
DavidGilesHitex 0:5b7639d1f2c4 144 {
DavidGilesHitex 0:5b7639d1f2c4 145 /* The VTACH signal is an analogue voltage produces by the tacho which is proprtional to RPM. The faster the rotation the higher the votlage */
DavidGilesHitex 0:5b7639d1f2c4 146 /* Not all tachos produce a variable output voltage but the motor drive module is able to cope with both pulse fed tacho and also voltage supplied tacho voltage feedback signals */
DavidGilesHitex 0:5b7639d1f2c4 147 /* This function is for the feedback voltage method */
DavidGilesHitex 0:5b7639d1f2c4 148 /* The VTACH voltage is available on two analogue pins AN4 and AN14 selectable via JP304 */
DavidGilesHitex 0:5b7639d1f2c4 149
DavidGilesHitex 0:5b7639d1f2c4 150 if (channel == AN4)
DavidGilesHitex 0:5b7639d1f2c4 151 {
DavidGilesHitex 0:5b7639d1f2c4 152 /* Link JP304 1-2 */
DavidGilesHitex 0:5b7639d1f2c4 153 /* not implemented */
DavidGilesHitex 0:5b7639d1f2c4 154 }
DavidGilesHitex 0:5b7639d1f2c4 155
DavidGilesHitex 0:5b7639d1f2c4 156 if (channel == AN14)
DavidGilesHitex 0:5b7639d1f2c4 157 {
DavidGilesHitex 0:5b7639d1f2c4 158 /* Link JP304 2-3 */
DavidGilesHitex 0:5b7639d1f2c4 159 /* not implemented - AN14 is not mapped on to the MBED module */
DavidGilesHitex 0:5b7639d1f2c4 160 }
DavidGilesHitex 0:5b7639d1f2c4 161
DavidGilesHitex 0:5b7639d1f2c4 162 /* not implemented */
DavidGilesHitex 0:5b7639d1f2c4 163 return 0;
DavidGilesHitex 0:5b7639d1f2c4 164 }
DavidGilesHitex 0:5b7639d1f2c4 165
DavidGilesHitex 0:5b7639d1f2c4 166
DavidGilesHitex 0:5b7639d1f2c4 167
DavidGilesHitex 0:5b7639d1f2c4 168
DavidGilesHitex 0:5b7639d1f2c4 169
DavidGilesHitex 0:5b7639d1f2c4 170
DavidGilesHitex 0:5b7639d1f2c4 171
DavidGilesHitex 0:5b7639d1f2c4 172 /* Read the physical level on the Encoder0 input pin on P301 pin 8 on the MC1 board*/
DavidGilesHitex 0:5b7639d1f2c4 173 uint8_t RSEDP_MC1_Read_Encoder0_Input(uint8_t pin_option)
DavidGilesHitex 0:5b7639d1f2c4 174 {
DavidGilesHitex 0:5b7639d1f2c4 175 /* The Encoder0 pin can be routed to two output pins EVM5_GPIO47 or EVG6_GPIO52 via JP302 on the MC1 motor Drive module */
DavidGilesHitex 0:5b7639d1f2c4 176 /* To use this Encoder input JP303 also needs to be set in the 2-3 position */
DavidGilesHitex 0:5b7639d1f2c4 177
DavidGilesHitex 0:5b7639d1f2c4 178 uint8_t return_value = 0;
DavidGilesHitex 0:5b7639d1f2c4 179
DavidGilesHitex 0:5b7639d1f2c4 180 if (pin_option == EVM5_GPIO47)
DavidGilesHitex 0:5b7639d1f2c4 181 {
DavidGilesHitex 0:5b7639d1f2c4 182 /* Links JP302 1-2 and JP303 2-3 */
DavidGilesHitex 0:5b7639d1f2c4 183 /* not implemented */
DavidGilesHitex 0:5b7639d1f2c4 184 }
DavidGilesHitex 0:5b7639d1f2c4 185
DavidGilesHitex 0:5b7639d1f2c4 186 if (pin_option == EVG6_GPIO52)
DavidGilesHitex 0:5b7639d1f2c4 187 {
DavidGilesHitex 0:5b7639d1f2c4 188 /* Links JP302 2-3 and JP303 2-3 */
DavidGilesHitex 0:5b7639d1f2c4 189 return_value = DigitalIn_Pin30;
DavidGilesHitex 0:5b7639d1f2c4 190 }
DavidGilesHitex 0:5b7639d1f2c4 191
DavidGilesHitex 0:5b7639d1f2c4 192 return return_value;
DavidGilesHitex 0:5b7639d1f2c4 193 }
DavidGilesHitex 0:5b7639d1f2c4 194
DavidGilesHitex 0:5b7639d1f2c4 195
DavidGilesHitex 0:5b7639d1f2c4 196
DavidGilesHitex 0:5b7639d1f2c4 197 /* Read the physical level on the Encoder1 input pin on P301 pin 10 on the MC1 board*/
DavidGilesHitex 0:5b7639d1f2c4 198 uint8_t RSEDP_MC1_Read_Encoder1_Input(uint8_t pin_option)
DavidGilesHitex 0:5b7639d1f2c4 199 {
DavidGilesHitex 0:5b7639d1f2c4 200 /* The Encoder1 pin can be routed to two output pins EVM6_GPIO49 or EVG7_GPIO54 via JP306 on the MC1 motor Drive module */
DavidGilesHitex 0:5b7639d1f2c4 201
DavidGilesHitex 0:5b7639d1f2c4 202 uint8_t return_value = 0;
DavidGilesHitex 0:5b7639d1f2c4 203
DavidGilesHitex 0:5b7639d1f2c4 204 if (pin_option == EVM6_GPIO49)
DavidGilesHitex 0:5b7639d1f2c4 205 {
DavidGilesHitex 0:5b7639d1f2c4 206 /* Link option JP306 1-2 */
DavidGilesHitex 0:5b7639d1f2c4 207 /* not implemented */
DavidGilesHitex 0:5b7639d1f2c4 208 }
DavidGilesHitex 0:5b7639d1f2c4 209
DavidGilesHitex 0:5b7639d1f2c4 210 if (pin_option == EVG7_GPIO54)
DavidGilesHitex 0:5b7639d1f2c4 211 {
DavidGilesHitex 0:5b7639d1f2c4 212 /* Link option JP306 2-3 */
DavidGilesHitex 0:5b7639d1f2c4 213 return_value = DigitalIn_Pin8;
DavidGilesHitex 0:5b7639d1f2c4 214 }
DavidGilesHitex 0:5b7639d1f2c4 215
DavidGilesHitex 0:5b7639d1f2c4 216 return return_value;
DavidGilesHitex 0:5b7639d1f2c4 217 }
DavidGilesHitex 0:5b7639d1f2c4 218
DavidGilesHitex 0:5b7639d1f2c4 219
DavidGilesHitex 0:5b7639d1f2c4 220
DavidGilesHitex 0:5b7639d1f2c4 221 /* Read the physical level on the Tacho Pulses Input pin on P301 pin 6 on the MC1 board */
DavidGilesHitex 0:5b7639d1f2c4 222 uint8_t RSEDP_MC1_Read_Tacho_Input(uint8_t pin_option)
DavidGilesHitex 0:5b7639d1f2c4 223 {
DavidGilesHitex 0:5b7639d1f2c4 224 /* The Tacho Pulses pin uses the same hardware as the Encoder0 pin and either input is selected via jumper JP303 */
DavidGilesHitex 0:5b7639d1f2c4 225 /* This tacho pulse can like the Encoder0 pin be routed to two output pins EVM5_GPIO47 or EVG6_GPIO52 */
DavidGilesHitex 0:5b7639d1f2c4 226 /* to use this Encoder input JP303 needs to be set in the 1-2 position */
DavidGilesHitex 0:5b7639d1f2c4 227
DavidGilesHitex 0:5b7639d1f2c4 228 return RSEDP_MC1_Read_Encoder0_Input(pin_option);
DavidGilesHitex 0:5b7639d1f2c4 229 }
DavidGilesHitex 0:5b7639d1f2c4 230
DavidGilesHitex 0:5b7639d1f2c4 231
DavidGilesHitex 0:5b7639d1f2c4 232
DavidGilesHitex 0:5b7639d1f2c4 233
DavidGilesHitex 0:5b7639d1f2c4 234
DavidGilesHitex 0:5b7639d1f2c4 235
DavidGilesHitex 0:5b7639d1f2c4 236
DavidGilesHitex 0:5b7639d1f2c4 237 /* Set the motor direction */
DavidGilesHitex 0:5b7639d1f2c4 238 void RSEDP_MC1_Set_Motor_Direction(uint8_t motor_direction, uint8_t pin_option)
DavidGilesHitex 0:5b7639d1f2c4 239 {
DavidGilesHitex 0:5b7639d1f2c4 240 /* the Motor Direction can be set by the MCU via EVG1_GPIO42 or EVG5_GPIO50 selectable via link option JP206 and JP207 on MC1 motor drive module */
DavidGilesHitex 0:5b7639d1f2c4 241 if (pin_option == EVG1_GPIO42)
DavidGilesHitex 0:5b7639d1f2c4 242 {
DavidGilesHitex 0:5b7639d1f2c4 243 /* Link options JP206 1-2 and JP207 2-3 */
DavidGilesHitex 0:5b7639d1f2c4 244 if (motor_direction == FORWARD)
DavidGilesHitex 0:5b7639d1f2c4 245 {
DavidGilesHitex 0:5b7639d1f2c4 246 DigitalOut_Pin24 = 1;
DavidGilesHitex 0:5b7639d1f2c4 247 }
DavidGilesHitex 0:5b7639d1f2c4 248 else{
DavidGilesHitex 0:5b7639d1f2c4 249 DigitalOut_Pin24 = 0;
DavidGilesHitex 0:5b7639d1f2c4 250 }
DavidGilesHitex 0:5b7639d1f2c4 251 }
DavidGilesHitex 0:5b7639d1f2c4 252
DavidGilesHitex 0:5b7639d1f2c4 253 if (pin_option == EVG5_GPIO50)
DavidGilesHitex 0:5b7639d1f2c4 254 {
DavidGilesHitex 0:5b7639d1f2c4 255 /* Link options JP206 2-3 and JP207 2-3 */
DavidGilesHitex 0:5b7639d1f2c4 256 /* Not implemented */
DavidGilesHitex 0:5b7639d1f2c4 257 }
DavidGilesHitex 0:5b7639d1f2c4 258 }
DavidGilesHitex 0:5b7639d1f2c4 259
DavidGilesHitex 0:5b7639d1f2c4 260
DavidGilesHitex 0:5b7639d1f2c4 261
DavidGilesHitex 0:5b7639d1f2c4 262 /* turn the brake on or off */
DavidGilesHitex 0:5b7639d1f2c4 263 void RSEDP_MC1_Brake(uint8_t brake_onoff, uint8_t pin_option)
DavidGilesHitex 0:5b7639d1f2c4 264 {
DavidGilesHitex 0:5b7639d1f2c4 265 /* The brake can be turned ON or OFF via this function call */
DavidGilesHitex 0:5b7639d1f2c4 266 /* A choice of two pins can beused to control the brake, GPIO0 or GPIO1 selectable via jumper JP209 */
DavidGilesHitex 0:5b7639d1f2c4 267 if (pin_option == GPIO0)
DavidGilesHitex 0:5b7639d1f2c4 268 {
DavidGilesHitex 0:5b7639d1f2c4 269 /* Link option JP209 2-3 */
DavidGilesHitex 0:5b7639d1f2c4 270 if (brake_onoff == BRAKE_ON)
DavidGilesHitex 0:5b7639d1f2c4 271 {
DavidGilesHitex 0:5b7639d1f2c4 272 DigitalOut_Pin19 = 1;
DavidGilesHitex 0:5b7639d1f2c4 273 }
DavidGilesHitex 0:5b7639d1f2c4 274 else{
DavidGilesHitex 0:5b7639d1f2c4 275 DigitalOut_Pin19 = 0;
DavidGilesHitex 0:5b7639d1f2c4 276 }
DavidGilesHitex 0:5b7639d1f2c4 277 }
DavidGilesHitex 0:5b7639d1f2c4 278
DavidGilesHitex 0:5b7639d1f2c4 279 if (pin_option == GPIO1)
DavidGilesHitex 0:5b7639d1f2c4 280 {
DavidGilesHitex 0:5b7639d1f2c4 281 /* Link option JP209 1-2 */
DavidGilesHitex 0:5b7639d1f2c4 282 /* Not implmented */
DavidGilesHitex 0:5b7639d1f2c4 283 }
DavidGilesHitex 0:5b7639d1f2c4 284 }
DavidGilesHitex 0:5b7639d1f2c4 285
DavidGilesHitex 0:5b7639d1f2c4 286
DavidGilesHitex 0:5b7639d1f2c4 287
DavidGilesHitex 0:5b7639d1f2c4 288 /* Power control of motor speed controller using PWM */
DavidGilesHitex 0:5b7639d1f2c4 289 void RSEDP_MC1_Set_Motor_Speed_Duty(float motor_speed_duty, uint8_t pin_option)
DavidGilesHitex 0:5b7639d1f2c4 290 {
DavidGilesHitex 0:5b7639d1f2c4 291 /* This function controls the speed of the motor by controlling the PWM duty of the bridge */
DavidGilesHitex 0:5b7639d1f2c4 292 /* The duty is fed by a PWM signal either from EVG0_GPIO40 or EVG4_GPIO48 selectable via link option JP204 and link JP203 & JP205 */
DavidGilesHitex 0:5b7639d1f2c4 293 if (pin_option == EVG0_GPIO40)
DavidGilesHitex 0:5b7639d1f2c4 294 {
DavidGilesHitex 0:5b7639d1f2c4 295 /* Link option JP204 1-2 and Link JP203 2-3 and JP205 1-2 */
DavidGilesHitex 0:5b7639d1f2c4 296 PwmOut_Pin23 = (1.0f - motor_speed_duty);
DavidGilesHitex 0:5b7639d1f2c4 297 }
DavidGilesHitex 0:5b7639d1f2c4 298
DavidGilesHitex 0:5b7639d1f2c4 299 if (pin_option == EVG4_GPIO48)
DavidGilesHitex 0:5b7639d1f2c4 300 {
DavidGilesHitex 0:5b7639d1f2c4 301 /* Link option JP204 2-3 and Link JP203 2-3 and JP205 1-2 */
DavidGilesHitex 0:5b7639d1f2c4 302 /* not implmented */
DavidGilesHitex 0:5b7639d1f2c4 303
DavidGilesHitex 0:5b7639d1f2c4 304 }
DavidGilesHitex 0:5b7639d1f2c4 305
DavidGilesHitex 0:5b7639d1f2c4 306
DavidGilesHitex 0:5b7639d1f2c4 307 }
DavidGilesHitex 0:5b7639d1f2c4 308
DavidGilesHitex 0:5b7639d1f2c4 309