![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
power board firmware for dyno
Diff: main.cpp
- Revision:
- 3:609e4be772e0
- Parent:
- 2:5ce2ad0782de
--- a/main.cpp Tue Jul 20 19:35:55 2021 +0000 +++ b/main.cpp Mon Sep 06 20:01:24 2021 +0000 @@ -16,7 +16,6 @@ //setup scaling float HV_CURRENT_SCALING = 0.0400; //V/A float LV_CURRENT_SCALING = 0.0550; //V/A -float VOL_SENSE_SCALING = (1000000.0+30000.0)/30000.0; //V per Volt float SYSTEM_VOLTAGE = 3.3; //volts float VCC = 5.0; //volts float EXT_CURRENT_SCALING = 0.008; //Sensitivity = 8mv/A external sensor @@ -65,13 +64,15 @@ wait(0.0003); //MAKE SURE IT's 1-3k rate, higher we will fill the CAN buffer float hv_cur = float((hv_current.read()*SYSTEM_VOLTAGE-VCC/2.0) / HV_CURRENT_SCALING); //PUBLISH float lv_cur = float((lv_current.read()*SYSTEM_VOLTAGE-VCC/2.0) / LV_CURRENT_SCALING); //PUBLISH - float vol = (voltage_sense.read()*SYSTEM_VOLTAGE)*VOL_SENSE_SCALING; //INACCURATE ON THE HARDWARE SIDE!!! //PUBLISH + float vol = (voltage_sense.read()*SYSTEM_VOLTAGE); //*67.232-96.149; //PUBLISH float V_OUT_EXT = (ext_current_A.read()*SYSTEM_VOLTAGE); float V_REF_EXT = (ext_current_B.read()*SYSTEM_VOLTAGE); float ext_cur = (V_OUT_EXT-V_REF_EXT) / EXT_CURRENT_SCALING; //PUBLISH + //pc.printf("Volts: %f\n", vol); + //now we have to publish the four floats to the CAN BUS pack_cmd(&currMsg, hv_cur, ext_cur); pack_cmd(&statMsg, vol, lv_cur);