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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "unilynx.h"
00003 
00004 Serial pc(USBTX, USBRX);
00005 DigitalOut myled(LED1);
00006 
00007 int current_production_avg;
00008 int current_production;
00009 int today_production;
00010 int total_production;
00011 
00012 int main()
00013 {
00014     /* setup terminal */
00015     pc.baud(115200);
00016     /* setup RS485 */
00017     rs485init();
00018     pc.printf("ULX Data logger init, build %s",__TIME__);
00019 
00020     while(1) 
00021     {
00022         /* read parameters of interest */
00023         total_production        = readParameter(RAW_MEAS_VALUES, ENERGY_PRODUCTION, ID_RAW_MEAS_VALUES);
00024         pc.printf("Production Total: %d [Wh]\n",total_production);
00025         today_production        = readParameter(RAW_MEAS_VALUES, ENERGY_PRODUCTION_TODAY, ID_RAW_MEAS_VALUES);
00026         pc.printf("Production Today: %d [Wh]\n",today_production);
00027         //current_production_avg  = readParameter(RAW_SMOOTH_VALUES, INSTANT_ENERGY, ID_RAW_SMOOTH_VALUES);
00028         current_production      = readParameter(RAW_MEAS_VALUES, INSTANT_ENERGY, ID_RAW_MEAS_VALUES);
00029         //pc.printf("Production Now: %04d [W] Avg.: %04d [W] \n",current_production,current_production_avg);
00030         pc.printf("Production Now: %04d [W] \n",current_production);
00031         
00032         /* print to console*/
00033 /*        pc.printf("Production Total: %d [Wh]\n",total_production);
00034         pc.printf("Production Today: %d [Wh]\n",today_production);
00035         pc.printf("Production Now: %04d [W] \n",current_production);
00036 */
00037         wait(3);
00038 
00039     }
00040 }