Hello.
I try to. I'm learning. But I don't know how to do it.
I have a Raspberry PI 3B +. I need an RS232 to Modbus TCP converter.
I have a REGO 637 regulation. The protocol is on the web:
[http://rago600.sourceforge.net.] (https: // REGO 637)
I need the resulting Modbus TCP format for control.
I would like to solve this with Node-RED.
Thank you for your help.
for example. I have for the Weintek MT8070iE panel
// Free protokol IVT - Ctení GT1 - Zpatecka
macro_command main()
char command[9], response[5], on_off
int address, data, read_data
short address_pom, data_pom, checksum
short return_value, i
char read_data1, read_data2
FILL(command[0], 0, 9) // init dotaz
FILL(response[0], 0, 5) // init
command[0] = 0x81 // CISLO STANICE - 81
command[1] = 0x02 // READ (CTENI) - 2
address = 0x000409 // READ ADRESA - 0409
HIWORD(address, address_pom)
LOBYTE(address_pom, command[2])
HIBYTE(address, command[3])
LOBYTE(address, command[4])
data = 0x000000 // READ DATA - 000000
HIWORD(data, data_pom)
LOBYTE(data_pom,command[5])
HIBYTE(data, command[6])
LOBYTE(data, command[7])
command[8] = 0x0D // checksum
//short TimeDelayDotaz
//GetData(TimeDelayDotaz, "Local HMI", LW, 302, 1) // Čte čas spoždění mezi dotazem a odpovědí
//INPORT(response[0], "Free Protocol", 5, return_value) //Start přenosu
//DELAY(TimeDelayDotaz) // Pausa
OUTPORT(command[0], "Free Protocol", 9) // Pošli dotaz
INPORT(response[0], "Free Protocol", 5, return_value) // DATA NAVRAT
if return_value > 0 then //bez chyby > 0
read_data = (response[1] * 256) + (response[2] * 128) + response[3] // data navrat 00 00 00
SetData(read_data, "Local HMI", LW, 502, 1) //read data 0xff ff ff - Teplota součet kladné
SetData(return_value, "Local HMI", LB, 5800, 1) //Indikace úspěchu čtení
end if
SetData(return_value, "Local HMI", LB, 5800, 1) //Indikace neúspěchu čtení
//// =================== LOG Terminal ===============
char dotaz[20], navrat[10], ukaz[34]
bool loguj = true //ukazuj ANO
FILL(dotaz[0], 0, 20)
FILL(navrat[0], 0, 10)
FILL(ukaz[0], 0, 34)
GetData(loguj, "Local HMI", LB, 5900, 1) // === Bude se LOGOVAT
if loguj then // Když ano
short x,y
y = 0
for x = 0 to 18
HEX2ASCII(command, dotaz[y], 2) // dotaz
y = y + 2
next x
y = 0
for x = 0 to 10
HEX2ASCII(response[x], navrat[y], 2) // navrat
y = y + 2
next x
StringCopy(dotaz[0], ukaz[0]) // ======= Slož String pro zobrazená v LOGu
StringCopy("--", ukaz[18])
StringCopy(navrat[0], ukaz[20])
StringCopy("-GT1", ukaz[30])
StringSet(ukaz[0], "Local HMI", LW, 6000, 34) // ======= Uložení dat pro zobrazení v LOGU
bool z = true
SetDataEx(z, "Local HMI", LB, 5997, 1) // Čti právě teď
DELAY(10)
z = false
SetDataEx(z, "Local HMI", LB, 5997, 1) // Dokončení pulzu čtení
end if
end macro_command