tobias_84
Member
Hi!
I have been testing to control a servo over modbus RTU from an Schneider TM241C24T but haven't had any success.
I get a output from the PLC but it's not the data I expected.
The goal on this try I attached is to send data to device 01 and use the function 08. Sending test data '12' '12' and it should reply with '12' '12' but there is no respond at all. I can't read that the data output from the PLC is correct so there seems to be a problem with the code I'm running.
Any pointers to get the function working?
I uploaded PDF-files to an other server due to the size.
Schneider Modbus tutorial. Using exemple from page 32.
https://revenhole.tk/s/UAwIZEstzDgzebZ
SMC LEC servo documentation.
Testing the echo function on page 24.
https://revenhole.tk/s/vN5cO9pY0HIIaK1
Output from logic analyzer:
https://revenhole.tk/s/XH1mfaSYC1iNmNS
Screenshots from SoMachine while running is attached.
Regards
Tobias
I have been testing to control a servo over modbus RTU from an Schneider TM241C24T but haven't had any success.
I get a output from the PLC but it's not the data I expected.
The goal on this try I attached is to send data to device 01 and use the function 08. Sending test data '12' '12' and it should reply with '12' '12' but there is no respond at all. I can't read that the data output from the PLC is correct so there seems to be a problem with the code I'm running.
Any pointers to get the function working?
I uploaded PDF-files to an other server due to the size.
Schneider Modbus tutorial. Using exemple from page 32.
https://revenhole.tk/s/UAwIZEstzDgzebZ
SMC LEC servo documentation.
Testing the echo function on page 24.
https://revenhole.tk/s/vN5cO9pY0HIIaK1
Output from logic analyzer:
https://revenhole.tk/s/XH1mfaSYC1iNmNS
Screenshots from SoMachine while running is attached.
Code:
PROGRAM POU
VAR
ADDM_MODBUS_LEC : ADDM;
v_Adress_Modbus_LEC : ADDRESS ;
v_xAddress_Done : BOOL := FALSE ;
v_xAddress_Error : BOOL := FALSE ;
v_xAddress_Is_OK : BOOL := FALSE ;
x_Start_ADDM : BOOL;
Blink_Test_Data : BLINK;
xRead_test_Data :BOOL;
Read_Var_Data : WRITE_READ_VAR;
v_wRegister_Read_Testdata : WORD := 0 ;
Read_data_1 : UINT ;
Read_data_2 : UINT ;
Read_data_3 : UINT ;
Read_data_4 : UINT ;
Read_data_5 : UINT ;
Read_data_6 : UINT ;
Read_data_7 : UINT ;
Read_data_8 : UINT ;
Write_data_1 : UINT ;
Write_data_2 : UINT ;
Write_data_3 : UINT ;
Write_data_4 : UINT ;
Write_data_5 : UINT ;
Write_data_6 : UINT ;
Write_data_7 : UINT ;
Write_data_8 : UINT ;
Read_Data_Value : ARRAY [0..7] OF WORD := [8(0)];
Write_Data_Value : ARRAY [0..7] OF WORD := [8(0)];
END_VAR
// Adressing the device
ADDM_MODBUS_LEC(
AddrTable := v_Adress_Modbus_LEC,
Execute := x_Start_ADDM,
Addr := '2.1',
Done => v_xAddress_Done,
Error => v_xAddress_Error,
);
// send test data every 500ms
Blink_Test_Data.ENABLE := TRUE;
Blink_Test_Data.TIMELOW := T#500MS;
Blink_Test_Data.TIMEHIGH := T#500MS;
Blink_Test_Data();
xRead_test_Data := Blink_Test_Data.OUT ;
// Sending (and reading) data over modbus.
Read_Var_Data(
Execute := xRead_test_Data,
Abort := FALSE,
Addr := v_Adress_Modbus_LEC,
Timeout := 5,
ObjType := ObjectType.MW,
FirstWriteObj := 08,
WriteQuantity := 2,
WriteBuffer := ADR(Write_Data_Value),
FirstReadObj := 08,
ReadQuantity := 2,
ReadBuffer := ADR(Read_Data_Value),
);
Read_data_1 := WORD_TO_UINT(Read_Data_Value[0]);
Read_data_2 := WORD_TO_UINT(Read_Data_Value[1]);
Read_data_3 := WORD_TO_UINT(Read_Data_Value[2]);
Read_data_4 := WORD_TO_UINT(Read_Data_Value[3]);
Read_data_5 := WORD_TO_UINT(Read_Data_Value[4]);
Read_data_6 := WORD_TO_UINT(Read_Data_Value[5]);
Read_data_7 := WORD_TO_UINT(Read_Data_Value[6]);
Read_data_8 := WORD_TO_UINT(Read_Data_Value[7]);
Write_data_1 := WORD_TO_UINT(Write_Data_Value[0]);
Write_data_2 := WORD_TO_UINT(Write_Data_Value[1]);
Write_data_3 := WORD_TO_UINT(Write_Data_Value[2]);
Write_data_4 := WORD_TO_UINT(Write_Data_Value[3]);
Write_data_5 := WORD_TO_UINT(Write_Data_Value[4]);
Write_data_6 := WORD_TO_UINT(Write_Data_Value[5]);
Write_data_7 := WORD_TO_UINT(Write_Data_Value[6]);
Write_data_8 := WORD_TO_UINT(Write_Data_Value[7]);
Regards
Tobias