FINAL ACS TO BE USED FOR TESTING. COMMISSIONING, ACS MAIN, DATA ACQ ALL DONE.
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of ACS_FULL_Flowchart_BAE by
Revision 15:e09aaaccf134, committed 2016-04-19
- Comitter:
- lakshya
- Date:
- Tue Apr 19 21:27:07 2016 +0000
- Parent:
- 14:a9588f443f1a
- Child:
- 16:cc77770d787f
- Commit message:
- checking
Changed in this revision
--- a/ACS.cpp Thu Apr 14 09:34:06 2016 +0000 +++ b/ACS.cpp Tue Apr 19 21:27:07 2016 +0000 @@ -421,7 +421,7 @@ gyro_data[i]=(float)bit_data; gyro_data[i]=gyro_data[i]/senstivity_gyro; gyro_data[i]+=gyro_error[i]; - // pc_acs.printf("%f\t",gyro_data[i]); + // pc_acs.printf("%f\t",gyro_data[i]); } // pc_acs.printf("\nMag Values:\n"); for(int i=0; i<3; i++) { @@ -430,7 +430,7 @@ mag_data[i]=(float)bit_data; mag_data[i]=mag_data[i]/senstivity_mag; mag_data[i]+=mag_error[i]; - // pc_acs.printf("%f\t",mag_data[i]); + //pc_acs.printf("%f\t",mag_data[i]); } for(int i=0; i<3; i++) { // data[i]=gyro_data[i];
--- a/EPS.cpp Thu Apr 14 09:34:06 2016 +0000 +++ b/EPS.cpp Tue Apr 19 21:27:07 2016 +0000 @@ -8,7 +8,7 @@ extern char BAE_chardata[74]; //m_I2C.frequency(10000) -const char RCOMP0= 0x97; +const char RCOMP0= 0x97;// don't know what it is now BAE_HK_actual actual_data; BAE_HK_quant quant_data; BAE_HK_min_max bae_HK_minmax; @@ -27,8 +27,8 @@ //AnalogIn Vbatt_ang(VBATT); AnalogIn Batt_voltage(PIN20); //Battery voltage -SPI spi_bt(PIN99,PIN100,PIN98); //MOSI,MISO,SLK -DigitalOut ssn1(PIN19); //Slave select1 +SPI spi_bt(PIN99,PIN100,PIN98); //MOSI,MISO,SLK // battery temp something 3 +DigitalOut ssn1(PIN19); //Slave select1 // low line master talks DigitalOut ssn2(PIN21);//Slave select2 //DigitalOut PS(PTB0); //DigitalOut HS(PTB1); @@ -37,6 +37,7 @@ AnalogIn VoltageInput(PIN53); // Input from Voltage Multiplexer //PIN53 AnalogIn BAE_temp_sensor(PIN55); //Input from BAE temp sensor +/*mux for reading value one by one*/ DigitalOut SelectLinea3 (PIN46); // MSB of Select Lines DigitalOut SelectLinea2 (PIN45); DigitalOut SelectLinea1 (PIN44); @@ -66,7 +67,7 @@ FCTN_BATTERYGAUGE_INIT(); FCTN_BATTTEMP_INIT(); EN3V3A = 1; //enable dc dc converter A - char value=alertFlags(); + char value=alertFlags(); // initialization part of battery gauge unsigned short value_u= (short int )value; value_u &=0x0001; if(value_u ==0x0001) // battery gauge not initialised @@ -77,7 +78,7 @@ else { actual_data.Batt_gauge_actual[1] = soc(); - actual_data.Batt_voltage_actual = Batt_voltage.read()*3.3; + actual_data.Batt_voltage_actual = Batt_voltage.read()*3.3; //1 corresponds to 3.3 scaling factor FCTN_EPS_POWERMODE(actual_data.Batt_gauge_actual[1]); EPS_BATTERY_GAUGE_STATUS = 's'; //set EPS_BATTERY_GAUGE_STATUS } @@ -87,6 +88,8 @@ } //----------------------------------------------------Power algo code--------------------------------------------------------------------// +/*update the power modes*/ + void FCTN_EPS_POWERMODE(float soc) //dummy algo { if(soc >= 80) @@ -100,7 +103,7 @@ } //...................................................HK...........................................// - +/*reading values*/ void FCTN_HK_MAIN() { @@ -452,7 +455,7 @@ { //Read the current 16-bit register value unsigned short value = read(REG_MODE); - + //Set the QuickStart bit value |= (1 << 14);
--- a/TCTM.cpp Thu Apr 14 09:34:06 2016 +0000 +++ b/TCTM.cpp Tue Apr 19 21:27:07 2016 +0000 @@ -83,7 +83,8 @@ { // tm1[0] = 1; uint8_t service_type=(tc[2]&0xF0); - + /*chaged*/ + uint8_t* tm; // without it some identifier error uint16_t crc16; @@ -99,17 +100,64 @@ case 0x01: { printf("Read from Flash\r\n"); + uint16_t jj; + uint16_t MID = ((uint16_t)tc[3] << 8) | tc[4]; + switch(MID) + {case 0x1100:jj=0x00;// using uint16_t as jj typesimilarly used in FCTN_CDMS_WR_FLASH + break; + case 0x0100:jj=0x01; + break; + case 0x0101:jj=0x02; + break; + case 0x0102:jj=0x03; + break; + case 0x0107:jj=0x04; + break; + case 0x0103:jj=0x05; + break; + case 0x0104:jj=0x05; + break; + case 0x0105:jj=0x06; + break; + case 0x0106:jj=0x07; + break; + } + /*pointer....!!!!*/ + uint32_t FLASH_TEMP = FCTN_CDMS_RD_FLASH(jj); + + tm[0] = 0x60; + tm[1] = tc[0]; + tm[2] = ACK_CODE; + for(int i=0; i<8*4; i+=4) + { + tm[4+i] =(uint8_t )(((FLASH_TEMP)>>24)&0xFF); + tm[5+i] =(uint8_t ) (((FLASH_TEMP)>>16)&0xFF); + tm[6+i] =(uint8_t ) (((FLASH_TEMP)>>8)&0xFF); + tm[7+i] =(uint8_t ) ((FLASH_TEMP) & 0xFF); + + } + + + for (int i=4+8*4; i<132;i++) + { + tm[i] = 0x00; + } + crc16 = CRC::crc16_gen(tm,132); + tm[132] = (uint8_t)((crc16&0xFF00)>>8); + tm[133] = (uint8_t)(crc16&0x00FF); + break; } case 0x02: { + printf("Read from RAM\r\n"); uint16_t MID = ((uint16_t)tc[3] << 8) | tc[4]; switch(MID) { case 0x0001: { - printf("Read from RAM\r\n"); + printf("\nRead from MID 0001 hk\n"); /*taking some varible till we find some thing more useful*/ //uint8_t ref_val=0x01; @@ -182,10 +230,34 @@ telemetry[24] = P_EPS_MAIN_COUNTER>>8; telemetry[25] = P_EPS_MAIN_COUNTER; + //actual_data.AngularSpeed_actual[0]=5.32498; for(int i=0; i<3; i++) - FCTN_CONVERT_FLOAT(actual_data.Bvalue_actual[i],&telemetry[26+ (i*4)]); + FCTN_CONVERT_FLOAT((float)actual_data.Bvalue_actual[i],&telemetry[26+ (i*4)]); for(int i=0; i<3; i++) - FCTN_CONVERT_FLOAT(actual_data.AngularSpeed_actual[i],&telemetry[38+(i*4)]); + FCTN_CONVERT_FLOAT((float)actual_data.AngularSpeed_actual[i],&telemetry[38+(i*4)]); + + //printf("\n\rthe value is 38\t %x\n",telemetry[38]); + //printf("\n\rthe value is 39\t%x\n",telemetry[39]); + //printf("\n\rthe value is 40\t%x\n",telemetry[40]); + //printf("\n\rthe value is 41\t%x\n",telemetry[41]); + //printf("\n\rthe value true\t%f\n",actual_data.AngularSpeed_actual[0]); + + + //uint32_t input_stage1=0x00000000; + //uint8_t output1[4]; + //output1[0]=(uint32_t)(telemetry[38]); + //output1[1]=(uint32_t)(telemetry[39]); + //output1[2]=(uint32_t)(telemetry[40]); + //output1[3]=(uint32_t)(telemetry[41]); + + //input_stage1=output[3]+(output[2]*(0x100))+(output[1]*(0x10000))+(output[0]*(0x1000000)); + //input_stage1=(output1[0]<<24) | (output1[1]<<16) | (output1[2]<<8) | (output1[3]); + + + //assert(sizeof(float) == sizeof(uint32_t)); + //float* temp1 = reinterpret_cast<float*>(&input_stage1); + + //printf("\n\r the value is: %f \n",*temp1); //FAULT_FLAG(); telemetry[50] = actual_data.faultIr_status; @@ -242,6 +314,7 @@ } case 0x0002: { + printf("\r\n"); telemetry[0] = 0x60; telemetry[1] = tc[0]; telemetry[2] = ACK_CODE; @@ -312,7 +385,87 @@ } case 0x05: { - printf("Write on Flash\r\n"); + printf("\nRead from MID 0001 min max\n"); + /*changed*/ + printf("\n\rwrite on flash\n"); + uint32_t FLASH_DATA[8]; + + uint16_t MID = ((uint16_t)tc[3] << 8) | tc[4]; + switch(MID ) + { + + case 0x0100: + { + FLASH_DATA[0] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x00,FLASH_DATA[0]); + break; + } + case 0x0101: + { + FLASH_DATA[1] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x01,FLASH_DATA[1]); + break; + } + + case 0x0102: + { + FLASH_DATA[2] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x02,FLASH_DATA[2]); + break; + } + + case 0x0103: + { + FLASH_DATA[3] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x03,FLASH_DATA[3]); + break; + } + case 0x0104: + { + FLASH_DATA[4] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x04,FLASH_DATA[4]); + break; + } + + case 0x0105: + { + FLASH_DATA[5] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x05,FLASH_DATA[5]); + break; + } + case 0x0106: + { + FLASH_DATA[6] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x06,FLASH_DATA[6]); + break; + } + + case 0x0107: + { + FLASH_DATA[7] = (((uint32_t)tc[5] << 24) | ((uint32_t)tc[6] << 16) | ((uint32_t)tc[7] << 8) | (uint32_t)tc[6]); + FCTN_CDMS_WR_FLASH(0x07,FLASH_DATA[7]); + break; + } + + default: + { + printf("Invalid MMS\r\n"); + } + } + + + for (int i=4; i<132;i++) + { + tm[i] = 0x00; + } + crc16 = CRC::crc16_gen(tm,132); + tm[132] = (uint8_t)((crc16&0xFF00)>>8); + tm[133] = (uint8_t)(crc16&0x00FF); + tm[0] = 0x60; + tm[1] = tc[0]; + tm[2] = ACK_CODE; + + printf("Written on Flash\r\n"); break; } default: @@ -1070,6 +1223,7 @@ // Convert float to 4 uint8_t + void FCTN_CONVERT_FLOAT(float input, uint8_t output[4]) { assert(sizeof(float) == sizeof(uint32_t)); @@ -1077,13 +1231,21 @@ //float* output1 = reinterpret_cast<float*>(temp); - printf("\n\r %f ", input); - std::cout << "\n\r uint32"<<*temp << std::endl; + //printf("\n\r %f ", input); + //std::cout << "\n\r uint32"<<*temp << std::endl; output[0] =(uint8_t )(((*temp)>>24)&0xFF); - output[2] =(uint8_t ) (((*temp)>>16)&0xFF); - output[1] =(uint8_t ) (((*temp)>>8)&0xFF); - output[3] =(uint8_t ) ((*temp) & 0xFF); // verify the logic + output[1] =(uint8_t ) (((*temp)>>16)&0xFF); + output[2] =(uint8_t ) (((*temp)>>8)&0xFF); + output[3] =(uint8_t ) ((*temp) & 0xFF); // verify the logic + + printf("\n\rthe values generated are\n"); + /*printf("\n\r%x\n",output[0]); + printf("\n\r%x\n",output[1]); + printf("\n\r%x\n",output[2]); + printf("\n\r%x\n",output[3]); + to check the values generated + */ //printf("\n\r inside %d %d %d %d", output[3],output[2],output[1],output[0]); //std:: cout << "\n\r uint8 inside " << output[3] << '\t' << output[2] << '\t' << output[1] << '\t' << output[0] <<std::endl; } \ No newline at end of file
--- a/main.cpp Thu Apr 14 09:34:06 2016 +0000 +++ b/main.cpp Tue Apr 19 21:27:07 2016 +0000 @@ -238,7 +238,7 @@ pc.printf("gyro values\n\r"); //printing the angular velocity and magnetic field values for(int i=0; i<3; i++) { - pc.printf("%f\n\r",actual_data.AngularSpeed_actual[i]); + printf("%f\n\r",actual_data.AngularSpeed_actual[i]); } pc.printf("mag values\n\r"); for(int i=0; i<3; i++) @@ -429,9 +429,12 @@ while(1) { Thread::signal_wait(0x4); - wait_us(200); // can be between 38 to 15700 + wait_us(200); + //printf("\n\rreached\n"); // can be between 38 to 15700 if( slave.receive() == 0) - slave.stop(); + {slave.stop(); + //printf("\n\rnot send\n"); + } else if( slave.receive() == 1) // slave writes to master { if(data_send_flag == 'h') @@ -440,7 +443,9 @@ // pc.printf("\n\r here"); write_ack=slave.write(BAE_chardata,74); if(write_ack==0) - irpt_2_mstr = 0; + {irpt_2_mstr = 0; + printf("\n\rgot interrupt\n"); + } } else if(data_send_flag == 't') {