FORARKADI
Dependencies: mbed mypidror1 Motor Map
Diff: recive.cpp
- Revision:
- 4:d40399d8ae44
- Parent:
- 3:94eac3bdfbf5
- Child:
- 5:8ef69c6f3718
--- a/recive.cpp Fri Mar 06 17:04:41 2020 +0000 +++ b/recive.cpp Fri Mar 06 17:35:15 2020 +0000 @@ -177,7 +177,7 @@ if (msg.data[2]==1){ errorcounter = 1; perrorflag = 1; - //sendError(); + sendError(); } if (msg.data[2]==0){ perrorflag = 0; @@ -189,15 +189,6 @@ BrakeOff(); } pdagree = msg.data[0]; - /*if(msg.data[0]<30){ - pdagree = 30; - } - if(msg.data[0]>30){ - pdagree = msg.data[0]; - }*/ - //pid.sample(); - //pc.printf("Subthorttle is: %.4f\n\r", pdagree); - //pc.printf("Error is: %.4f\n\r", msg.data[2]); } if (!can1.read(msg)) { can.start(); @@ -205,8 +196,9 @@ if (can.read() > 0.1) { // if message not recieved more then 0.1 sec send error can.stop(); //can.reset(); + errorcounter = 1; cantimeoutflag = 1; - //sendError(); + sendError(); } } @@ -236,7 +228,6 @@ } if (counter == 10) { mdagree = sumthorttle/10; - //getData(); counter = 0; sumthorttle = 0; } @@ -250,26 +241,16 @@ t.stop(); t.reset(); terrorflag = 1; - //sendError(); + errorcounter = 1; + sendError(); } } } int main() { pc.baud(9600); pid.start(); - //tpid.start(); main_ticker.attach(readSensors, 0.0005); - //motor.attach(commandMotor, 0.0005); while(1){ - /*if (cantimeoutflag = 1){ - pc.printf(pc.printf("Canbus message timeout\n");); - }*/ - //if (perrorflag == 1){ - //myMotor.speed(0); - //pc.printf("Pedal sensor worng values\n"); - //} - pc.printf("Pedal %.4f\n\r, Thorttle %.4f\n\r, subthorttle %.4f\n\r, counter %d\n\r", pdagree, mdagree, subThorttle, recievecounter); - - //wait(Ts); + pc.printf("Pedal: %.4f\n\n\r, Thorttle: %.4f\n\n\r, subthorttle: %.4f\n\n\r, recievecounter: %d\n\n\r, ThorttleErrorFlag: %d\n\n\r, PedalErrorFlag: %d\n\n\r, CanTimeoutFlag: %d\n\n\r", pdagree, mdagree, subThorttle, recievecounter, terrorflag, perrorflag, cantimeoutflag); } } \ No newline at end of file