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.
Diff: main.cpp
- Revision:
- 5:ee37889edcab
- Parent:
- 4:66b2a94a607f
- Child:
- 6:58bd138f08af
diff -r 66b2a94a607f -r ee37889edcab main.cpp
--- a/main.cpp Fri Mar 08 21:54:08 2013 +0000
+++ b/main.cpp Sat Mar 09 06:10:08 2013 +0000
@@ -80,16 +80,16 @@
void PopulateData(void)
{
CANdataSet1[0] = (char)((steering + 110) /220 * 255);
- CANdataSet1[1] = (char)(throttle/5 * 255);
+ CANdataSet1[1] = (char)((throttle)/5 * 255);
CANdataSet1[2] = (char)(((uint16_t)wratio_actual) >> 8); //Check range later.
CANdataSet1[3] = (char)(((uint16_t)wratio_actual)); //For now assumed to be 16 bit 0 - 65535
CANdataSet1[4] = (char)((wratio_desired - 0.5) / 1.4);
CANdataSet1[5] = (char)(throttle_Left/5 * 255);
- CANdataSet1[6] = (char)(throttle_Right/5 * 255);
+ CANdataSet1[6] = (char)((throttle_Right)/5 * 255);
CANdataSet1[7] = 0;
CANdataSet2[0] = (char)((steering2 + 110) /220 * 255);
- CANdataSet2[1] = (char)(throttle2/5 * 255);
+ CANdataSet2[1] = (char)((throttle2)/5 * 255);
CANdataSet2[2] = (char)(rpm_Left/1000 * 255);
CANdataSet2[3] = (char)(rpm_Right/1000 * 255);
CANdataSet2[4] = (char)(rpm_FrontLeft/1000 * 255);
@@ -121,7 +121,7 @@
#define SPI_BYTE_ARRAY_SIZE 13
uint8_t SPIDataFromICAP[SPI_BYTE_ARRAY_SIZE];
uint8_t startByte, endByte;
-uint8_t flagsFromICAP;
+uint8_t volatile flagsFromICAP;
int SPIByteCounter = 0;
bool SPIError = false;
Ticker PullDataFromICAP;
@@ -141,8 +141,8 @@
steering = -110 + SPIDataFromICAP[1]*220/255;
steering2 = -110 + SPIDataFromICAP[2]*220/255;
- throttle = SPIDataFromICAP[3]*5/255;
- throttle2 = SPIDataFromICAP[4]*5/255;
+ throttle = ((float)(SPIDataFromICAP[3])/255*4+0.5);
+ throttle2 = ((float)(SPIDataFromICAP[4])*4/255+0.5);
brake = SPIDataFromICAP[5]; //Abhi ke liye let be be 0 to 255 only
brake2 = SPIDataFromICAP[6]; //Abhi ke liye let be be 0 to 255 only
rpm_Left = SPIDataFromICAP[7]*1000/255;
@@ -150,6 +150,9 @@
rpm_FrontLeft = SPIDataFromICAP[9]*1000/255;
rpm_FrontRight = SPIDataFromICAP[10]*1000/255;
flagsFromICAP = SPIDataFromICAP[11];
+ //printf("Steering = %f \n", steering);
+ //printf("Throttle 1, 2 = %f \t %f \n", throttle, throttle2);
+ //printf("Throttle 1, 2 = %f \t %f \n", throttle, throttle2);
}
void SPIPullData()
@@ -159,11 +162,11 @@
{
cs=0;
spi.write(0xFF);
- SPIDataFromICAP[SPIByteCounter] = spi.write(0xAA);
+ SPIDataFromICAP[SPIByteCounter] = (uint8_t)spi.write(0xAA);
//pc.printf("%u",SPIDataFromICAP[SPIByteCounter]);
SPIByteCounter++;
cs = 1;
- wait(0.0001);
+ wait(0.001);
}
UpdateData();
}
@@ -237,7 +240,9 @@
// - - - - FMEA OUTPUT - - - - //
//Openloop Flag
-volatile bool openloop_lowrpm = true;
+///////////////////Made FALSE deliberately for OFFLINE Testing//////////////////////
+///////////////////Should ideally be true at startup as the car is at standstill.///
+volatile bool openloop_lowrpm = false;
volatile bool openloop_driver = false;
const float rpm_openloop_limit = 100;
@@ -286,7 +291,7 @@
////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////
int main()
{
- for_FmeaCall.attach(&FmeaCall,1);
+ //for_FmeaCall.attach(&FmeaCall,1);
for_algo.attach_us(&ediff_func,(algoperiod)); //call ediff func every "algoperiod" sec
SendDataToDAQ.attach(&SendData, 0.05);
@@ -316,7 +321,8 @@
if (useBoschSteeringRequest)
{
//send message to DASH that asks driver permission for using Bosch Steering
- }
+ }
+
}
}