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 Aug 28 19:53:42 2012 +0000
Revision:
1:df4e9da66448
Parent:
0:66a099b01e08
Child:
2:de090b60d543
can retrieve values, still needs CRC and byte stuffing

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 0:66a099b01e08 18
morten_opprud 1:df4e9da66448 19 while(1)
morten_opprud 1:df4e9da66448 20 {
morten_opprud 1:df4e9da66448 21 /* read parameters of interest */
morten_opprud 1:df4e9da66448 22 total_production = readParameter(RAW_MEAS_VALUES, ENERGY_PRODUCTION, ID_RAW_MEAS_VALUES);
morten_opprud 1:df4e9da66448 23 pc.printf("Production Total: %d [Wh]\n",total_production);
morten_opprud 1:df4e9da66448 24 today_production = readParameter(RAW_MEAS_VALUES, ENERGY_PRODUCTION_TODAY, ID_RAW_MEAS_VALUES);
morten_opprud 1:df4e9da66448 25 pc.printf("Production Today: %d [Wh]\n",today_production);
morten_opprud 1:df4e9da66448 26 //current_production_avg = readParameter(RAW_SMOOTH_VALUES, INSTANT_ENERGY, ID_RAW_SMOOTH_VALUES);
morten_opprud 1:df4e9da66448 27 current_production = readParameter(RAW_MEAS_VALUES, INSTANT_ENERGY, ID_RAW_MEAS_VALUES);
morten_opprud 1:df4e9da66448 28 //pc.printf("Production Now: %04d [W] Avg.: %04d [W] \n",current_production,current_production_avg);
morten_opprud 1:df4e9da66448 29 pc.printf("Production Now: %04d [W] \n",current_production);
morten_opprud 1:df4e9da66448 30
morten_opprud 1:df4e9da66448 31 /* print to console*/
morten_opprud 1:df4e9da66448 32 /* pc.printf("Production Total: %d [Wh]\n",total_production);
morten_opprud 1:df4e9da66448 33 pc.printf("Production Today: %d [Wh]\n",today_production);
morten_opprud 1:df4e9da66448 34 pc.printf("Production Now: %04d [W] \n",current_production);
morten_opprud 1:df4e9da66448 35 */
morten_opprud 1:df4e9da66448 36 wait(3);
morten_opprud 1:df4e9da66448 37
morten_opprud 0:66a099b01e08 38 }
morten_opprud 0:66a099b01e08 39 }