.

Dependencies:   mbed cantran

Files at this revision

API Documentation at this revision

Comitter:
drorbalbul
Date:
Fri Dec 27 18:06:43 2019 +0000
Commit message:
.

Changed in this revision

Map.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
trasmit.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 91eadeaa067b Map.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Map.lib	Fri Dec 27 18:06:43 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/drorbalbul/code/cantran/#ac294c579449
diff -r 000000000000 -r 91eadeaa067b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Dec 27 18:06:43 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
diff -r 000000000000 -r 91eadeaa067b trasmit.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trasmit.cpp	Fri Dec 27 18:06:43 2019 +0000
@@ -0,0 +1,52 @@
+#include "mbed.h"
+#include <Map.hpp>
+#define ConvertToVolt 3300;
+#define Sum 3300;
+//#define ConvertToDagree (1800/7);
+ 
+AnalogIn analog_value1(PA_3);
+AnalogIn analog_value2(PA_4);
+Serial pc(USBTX,USBRX);
+//Ticker ticker;
+CAN can1(PA_11, PA_12);
+int matzeret = 0;
+char matzeretc = 0;
+ 
+ 
+ void send() {
+    if(can1.write(CANMessage(1337, &matzeretc, 1))) {
+        pc.printf("massage sent %d", matzeretc);
+    } 
+ }
+ 
+int main() {
+    float pedal1, pedal2, sumpedal, subpedal;
+    Map mapvaltovolt = Map(0, 1, 0, 3300);
+    Map mapvaltodagree = Map(850, 1200, 0, 90);
+    while(1) {
+        pedal1 = analog_value1.read();
+        pedal2 = analog_value2.read();
+        pedal1 = mapvaltovolt.Calculate(pedal1);
+        pedal2 = mapvaltovolt.Calculate(pedal2);
+        //pedal2 = pedal2 * ConvertToVolt; // Change the value to be in the 0 to 3300range*/
+        
+        
+        pc.printf("pedal1 is: %.4f, pedal2 is:%.4f\n\r", pedal1, pedal2);
+        sumpedal = pedal1+pedal2;
+        //pc.printf("sumpedal is: %.4f\n\r", sumpedal);
+        subpedal = abs(3500-sumpedal);
+        //pc.printf("Subpedal is: %.4f\n\r", subpedal);
+        //if (subpedal<175) {
+            matzeret = mapvaltodagree.Calculate(pedal1);
+            pc.printf("dagree %d\n\r", matzeret);
+            //matzeret = (matzeret - (1530/7))/10000;
+            matzeretc = matzeret;
+            send();
+        //}
+        /*else{
+            pc.printf("error\n\r");
+        }*/
+        wait(1);
+        //ticker.attach(&send, 1);
+     }
+}
\ No newline at end of file