implementation of parts of the unilynx protocol, for communicating with danfos photovoltaic inverters. Still BETA ! needs byte stuff/unstuff fixed, and some CRC are left out for niw...

Dependencies:   mbed

Committer:
morten_opprud
Date:
Tue Sep 04 05:48:43 2012 +0000
Revision:
2:de090b60d543
Parent:
1:df4e9da66448
cleaned a bit before comitting, !NOTE! byte stuffing/unstuffing still needs wors, also CRC on incoming data is to be done

Who changed what in which revision?

UserRevisionLine numberNew contents of line
morten_opprud 0:66a099b01e08 1 #include "mbed.h"
morten_opprud 0:66a099b01e08 2 #include "unilynx.h"
morten_opprud 0:66a099b01e08 3
morten_opprud 1:df4e9da66448 4 Serial pc(USBTX, USBRX);
morten_opprud 0:66a099b01e08 5 DigitalOut myled(LED1);
morten_opprud 0:66a099b01e08 6
morten_opprud 1:df4e9da66448 7 int current_production_avg;
morten_opprud 1:df4e9da66448 8 int current_production;
morten_opprud 1:df4e9da66448 9 int today_production;
morten_opprud 1:df4e9da66448 10 int total_production;
morten_opprud 1:df4e9da66448 11
morten_opprud 1:df4e9da66448 12 int main()
morten_opprud 1:df4e9da66448 13 {
morten_opprud 1:df4e9da66448 14 /* setup terminal */
morten_opprud 1:df4e9da66448 15 pc.baud(115200);
morten_opprud 1:df4e9da66448 16 /* setup RS485 */
morten_opprud 1:df4e9da66448 17 rs485init();
morten_opprud 2:de090b60d543 18 pc.printf("ULX Data logger init, build %s",__TIME__);
morten_opprud 0:66a099b01e08 19
morten_opprud 1:df4e9da66448 20 while(1)
morten_opprud 1:df4e9da66448 21 {
morten_opprud 1:df4e9da66448 22 /* read parameters of interest */
morten_opprud 1:df4e9da66448 23 total_production = readParameter(RAW_MEAS_VALUES, ENERGY_PRODUCTION, ID_RAW_MEAS_VALUES);
morten_opprud 1:df4e9da66448 24 pc.printf("Production Total: %d [Wh]\n",total_production);
morten_opprud 1:df4e9da66448 25 today_production = readParameter(RAW_MEAS_VALUES, ENERGY_PRODUCTION_TODAY, ID_RAW_MEAS_VALUES);
morten_opprud 1:df4e9da66448 26 pc.printf("Production Today: %d [Wh]\n",today_production);
morten_opprud 1:df4e9da66448 27 //current_production_avg = readParameter(RAW_SMOOTH_VALUES, INSTANT_ENERGY, ID_RAW_SMOOTH_VALUES);
morten_opprud 1:df4e9da66448 28 current_production = readParameter(RAW_MEAS_VALUES, INSTANT_ENERGY, ID_RAW_MEAS_VALUES);
morten_opprud 1:df4e9da66448 29 //pc.printf("Production Now: %04d [W] Avg.: %04d [W] \n",current_production,current_production_avg);
morten_opprud 1:df4e9da66448 30 pc.printf("Production Now: %04d [W] \n",current_production);
morten_opprud 1:df4e9da66448 31
morten_opprud 1:df4e9da66448 32 /* print to console*/
morten_opprud 1:df4e9da66448 33 /* pc.printf("Production Total: %d [Wh]\n",total_production);
morten_opprud 1:df4e9da66448 34 pc.printf("Production Today: %d [Wh]\n",today_production);
morten_opprud 1:df4e9da66448 35 pc.printf("Production Now: %04d [W] \n",current_production);
morten_opprud 1:df4e9da66448 36 */
morten_opprud 1:df4e9da66448 37 wait(3);
morten_opprud 1:df4e9da66448 38
morten_opprud 0:66a099b01e08 39 }
morten_opprud 0:66a099b01e08 40 }