A great localtime to everyone!
Please help me figure out which (and how) of the few available Perl Modbus modules to use! I can't seem to figure out coils, registers and addresses. However, this piece of c code (when compiled with modbus libraries) works fine:
/* * sunsaver.c - This program reads all the RAM registers on a Morings +tar SunSaver MPPT and prints the results. * */ /* Compile with: cc sunsaver.c -o sunsaver -lmodbus */ #include <stdio.h> #include <stdlib.h> #include <modbus/modbus.h> #define SUNSAVERMPPT 0x01 /* MODBUS Address of the SunSaver MPPT + */ int main(void) { modbus_param_t mb_param; int ret; float adc_vb_f,adc_va_f,adc_vl_f,adc_ic_f,adc_il_f, Vb_f, Vb_r +ef, Ahc_r, Ahc_t, kWhc; float V_lvd, Ahl_r, Ahl_t, Power_out, Sweep_Vmp, Sweep_Pmax, S +weep_Voc, Vb_min_daily; float Vb_max_daily, Ahc_daily, Ahl_daily, vb_min, vb_max, V_PU +, I_PU; short T_hs, T_batt, T_amb, T_rts; unsigned short charge_state, load_state, led_state; unsigned int hourmeter; unsigned short array_fault, load_fault, dip_switch, array_faul +t_daily, load_fault_daily; unsigned int alarm, alarm_daily; uint16_t data[150]; /* Setup the serial port parameters */ // modbus_init_rtu(&mb_param, "/dev/tty.voltmeter", 9600, "none", + 8, 2); /* Add the appropriate path to your serial port */ modbus_init_tcp(&mb_param, "192.168.0.57", 502);/* Add the app +ropriate path to your serial port */ /* Open the MODBUS connection */ if (modbus_connect(&mb_param) == -1) { printf("ERROR Connection failed\n"); exit(1); } /* Read the RAM Registers */ ret = read_input_registers(&mb_param, SUNSAVERMPPT, 0x0000, 75 +, data); /* Close the MODBUS connection */ modbus_close(&mb_param); /* Convert the results to their proper values and print them o +ut */ V_PU=((data[1] << 16) + data[0]); // printf("%.2f\n",V_PU); I_PU=((data[3] << 16) + data[2]); printf("%.2f\n%.2f\n",data[59]*V_PU*I_PU/131072,data[58]*V_PU* +I_PU/131072); //max P // printf("%.2f\n",data[60]*V_PU*I_PU/131072); //array V, batteryV printf("%.2f\n%.2f\n",data[27]*V_PU/32768,data[38]*V_PU/32768) +; printf("%d\n",data[55]); return(0); }
I've looked into: http://search.cpan.org/search?mode=all&query=Modbus all of these, and I'm giving up. I wrote a perl program that uses the above code to get the dreaded 4 values from this solar controller, but this is not right! Anyone, with experience with Modbus, please help me use the propper module and get the abouve 4 (and hopefully more) values directly from Perl!
In reply to Need help with Modbus by pashanoid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |