Mohd Tahir / Mbed 2 deprecated ADRS_hv-sensing

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
tahir786
Date:
Sat Feb 09 19:43:13 2019 +0000
Parent:
3:fbd5857ea534
Commit message:
For hv sensing pcb;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Jun 07 13:35:42 2017 +0000
+++ b/main.cpp	Sat Feb 09 19:43:13 2019 +0000
@@ -1,24 +1,43 @@
 #include "mbed.h"
- 
-AnalogIn analog_value(A0);
- 
+Ticker ticker;
+CAN can1(PA_11, PA_12);
+AnalogIn LV_voltage(PB_0);
+AnalogIn HV_currentp(PC_1);
+AnalogIn HV_currentn(PC_2);
+AnalogIn HV_voltagep(PC_0);
+AnalogIn HV_voltagen(PC_3);
+char counter = 0;
 DigitalOut led(LED1);
-
-int main() {
-    float meas;
-    
-    printf("\nAnalogIn example\n");
-    
-    while(1) {
-        meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
-        meas = meas * 3300; // Change the value to be in the 0 to 3300 range
-        printf("measure = %.0f mV\n", meas);
-        if (meas > 2000) { // If the value is greater than 2V then switch the LED on
-          led = 1;
+CANMessage msg;
+//DAQ pcb node address=1000
+//hv-sensing pcb address=2000
+void send() 
+{
+    int32_t hv_v=(HV_voltagep-HV_voltagen)*67;//such that last 2 digits are rightside of decimal
+    int32_t hv_c=(HV_currentp-HV_currentn)*77;
+    int32_t lv_v=LV_voltage*50;//to be changed
+    if(can1.read(msg)&&(msg.id==1000))
+    {
+        printf("Information requested from 1000. \n");
+         if(can1.write(CANMessage(1000,(char*)&hv_v,4)))
+        {
+            printf("Message sent: %d\n",hv_v);
+        } 
+         if(can1.write(CANMessage(1000,(char*)&hv_c,4)))
+        {
+            printf("Message sent: %d\n",hv_c);
+        } 
+         if(can1.write(CANMessage(1000,(char*)&lv_v,4)))
+        {
+            printf("Message sent: %d\n",lv_v);
         }
-        else {
-          led = 0;
-        }
-        wait(0.2); // 200 ms
-    }
+    } 
 }
+int main() 
+{
+    can1.attach(&send);
+    while(1) 
+    {
+       ;
+    } 
+}       
\ No newline at end of file