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.
Revision 13:ac024885d0bf, committed 2019-11-19
- Comitter:
- open4416
- Date:
- Tue Nov 19 11:54:12 2019 +0000
- Parent:
- 12:2f229919b012
- Child:
- 14:bcf5cb4d08a5
- Commit message:
- Fix error after test & add brk sensor
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| main.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Nov 18 17:55:37 2019 +0000
+++ b/main.cpp Tue Nov 19 11:54:12 2019 +0000
@@ -9,10 +9,11 @@
DigitalOut Fault_Ind(PC_12,0); //Indicate fault bt flashing, 1 active
DigitalOut LED(D13, 0); //Internal LED output, general purpose
AnalogIn AUX_1(PC_0); //Auxilaru analog sensor
-AnalogIn AUX_2(PC_4);
+AnalogIn AUX_2(PC_3);
AnalogIn AUX_3(PC_2);
AnalogIn AUX_4(PC_1);
AnalogIn SDn_sense(PB_0); //Shutdown circuit driving end detection
+AnalogIn Brk_sense(PA_4); //Brake sensor readings
CAN can1(PB_8, PB_9, 1000000); //1Mbps, contain critical torque command message
SPI spi2(PB_15, PB_14, PB_13); //1Mbps default, MOSI MISO SCLK, forIMU
ImuDriver <spi2, PA_13, PA_14, PA_15> imu; //SPI instance, reset, data ready, slave select
@@ -86,7 +87,7 @@
(VDU_FLT != 0)) {
VDU_STAT = VDU_Fault;
FLT_print = 1;
- } else {
+ } else if ((FL_online*FR_online*RL_online*RR_online*PSU_online)!=0) {
//All module online & POST pass
VDU_STAT = VDU_Idle;
printf("All module online, VDU now Idle\n");
@@ -110,7 +111,7 @@
*/
//Forced RTD_HMI for debug purpose 2019/11/14
- RTD_HMI = 1; //Should be set if can bus received data
+// RTD_HMI = 1; //Should be set if can bus received data
//Forced RTD_HMI for debug purpose 2019/11/14
RUNT(); //Run test
@@ -275,11 +276,12 @@
void Aux_read(void)
{
//Capture analog in at once
- AUX_1_u16 = AUX_1.read_u16();
- AUX_2_u16 = AUX_2.read_u16();
- AUX_3_u16 = AUX_3.read_u16();
- AUX_4_u16 = AUX_4.read_u16();
+ AUX_1_u16 = AUX_1.read_u16() >> 4U;
+ AUX_2_u16 = AUX_2.read_u16() >> 4U;
+ AUX_3_u16 = AUX_3.read_u16() >> 4U;
+ AUX_4_u16 = AUX_4.read_u16() >> 4U;
SDn_voltage = 18.81f*SDn_sense.read(); //Read in Shutdown circuit voltage in output end
+ Brk_voltage = 5.5f*Brk_sense.read();
}
void IMU_read(void)
--- a/main.h Mon Nov 18 17:55:37 2019 +0000
+++ b/main.h Tue Nov 19 11:54:12 2019 +0000
@@ -116,7 +116,7 @@
uint16_t AUX_3_u16 = 0x0;
uint16_t AUX_4_u16 = 0x0;
float SDn_voltage = 0.0f;
-
+float Brk_voltage = 0.0f;
//VDU states
typedef enum {
VDU_PowerOn = 0U,