Mange
There is a way of using pin 12 on a RasberryPi4 for PWM output.
The adress for pin 12 is then %QW0 I understood.
But if you want to run Modbus in the same time, I have found that holding register 0, should to be adressed %QW0 too...
Does this mean I cant adress both the PWM pin and write to holding register 0 in the same time?
Or is it no problem as the Modbus shoud be WORD and the PWM should be UINT (Or what it should be..?) ?
Reply 0 0
thiagoralves
Modbus registers are mapped to IO registers. That’s the purpose of it. That’s how you can, for example, read from an HMI the value of the PWM on pin 12. Just read holding register 0
Reply 0 0
Mange
Modbus registers are mapped to IO registers. That’s the purpose of it. That’s how you can, for example, read from an HMI the value of the PWM on pin 12. Just read holding register 0
I understand. But my problem is that the PWM is to be used for creating a 0-10V signal for one pump, but the Modbus connection is for writing to holding register on adress 0, in another device, an inverter for a compressor. So its two different units.
Reply 0 0
thiagoralves
That’s fine, you can write to another device’s Modbus holding register 0. This has nothing to do with your own device Modbus holding register 0.
Reply 0 0
Mange
That’s fine, you can write to another device’s Modbus holding register 0. This has nothing to do with your own device Modbus holding register 0.
OK, but I have one Modbus slave where I want to write to adress 0.
And I have another device which I want to control by the PWM..
How can OpenPLC runtime know which one Im controlling if the both the same adress, %QW0 ?
Reply 0 0
richw
Slave address on the OpenPLC runtime start at 100. So if you setup a slave on the runtime with the start address at 0 and read/write to address 100 on the runtime it will read/write to address 0 on the slave. Address on the runtime start at 0.
Reply 1 0
Mange
Slave address on the OpenPLC runtime start at 100. So if you setup a slave on the runtime with the start address at 0 and read/write to address 100 on the runtime it will read/write to address 0 on the slave. Address on the runtime start at 0.
Hmm, you mean that I shall use adress %QW0.100 in OpenPLC in order to R/W to holding register adress 0 in the slave?
Reply 0 0
fg71
How can OpenPLC runtime know which one Im controlling if the both the same adress, %QW0 ?
You do not use the same address in the OpenPLC Editor but the the device could use the same starting address.
In other words every slave device have it own memory and starting address. If you communicate with tcp you use port number
and if you use rtu you use slave id (0 - 255). You could only have 1 master in rtu but that is not true for tcp.
 
Q is coil or output, W is word and 0 is memory location, It means the starting address is 0 and have size of word (16-bits). Your second device start at %QW1. It means the second device have offset of 16bits from memory location 0.
 
ex.
 
%QX0.0 -> 0.7 is 8 bits..... if the length of your reading is 8 you will read 0.0 - 0.7, the starting bit is 0 and thats why it ends with 7
X is bit 0 or 1, meaning start adress 0 have 8 bits = 1 byte or to make it more complicated 2 bytes is 1 word = 16 bits.
 
When you make a hash table you make a storage table with bits, when plc do a cycle it read the value of the hash table
The starting adress is really a offset in memory space to store bits. The offset for OpenPLC runtime its 100
The address register is reference or pointer to value in the hash table.
Reply 1 0
richw
Can you show a screen shot of your slave devices setup to get a better understanding
Reply 0 0
Mange
You do not use the same address in the OpenPLC Editor but the the device could use the same starting address.
In other words every slave device have it own memory and starting address. If you communicate with tcp you use port number
and if you use rtu you use slave id (0 - 255). You could only have 1 master in rtu but that is not true for tcp.
 
Q is coil or output, W is word and 0 is memory location, It means the starting address is 0 and have size of word (16-bits). Your second device start at %QW1. It means the second device have offset of 16bits from memory location 0.
 
ex.
 
%QX0.0 -> 0.7 is 8 bits..... if the length of your reading is 8 you will read 0.0 - 0.7, the starting bit is 0 and thats why it ends with 7
X is bit 0 or 1, meaning start adress 0 have 8 bits = 1 byte or to make it more complicated 2 bytes is 1 word = 16 bits.
 
When you make a hash table you make a storage table with bits, when plc do a cycle it read the value of the hash table
The starting adress is really a offset in memory space to store bits. The offset for OpenPLC runtime its 100
The address register is reference or pointer to value in the hash table.
OK, thanks! So this means that as 0 in fact is offseted by 100 in the case of Modbos slaves, its correct in PLC-editor to put the adress %QW0 (on that only slave I have), for memory R/W of adress 0 in the slave? Sorry If I put stupid questions but Im not a SW-guy...
Reply 0 0
Mange
Can you show a screen shot of your slave devices setup to get a better understanding
Im not sure how you mean, I have only one slave connected to the TX/RX pins of the RapsberryPi master, by a RS485 hat. Will run RTU.
Reply 0 0
thiagoralves
You need to setup that slave on the slave devices tab on the OpenPLC runtime. Then you’ll get a better idea of the addresses and mappings
Reply 1 0
Mange
You need to setup that slave on the slave devices tab on the OpenPLC runtime. Then you’ll get a better idea of the addresses and mappings
Yea, I think Ill get it then!
Reply 0 0
Mange
Can you show a screen shot of your slave devices setup to get a better understanding
Im not sure if I got this right. All I need is to be able to write to Holding register 0 in my RTU slave device.
My understanding is that as there is an offset of 100 for modbus adresses, I must use adress %QW100 in my program for writings to holding register 0.
So my slave configuration in the Rasp Runtime now looks like this, is it correct?:
[203128%2F9139592%2Fmceclip0]
Reply 0 0
thiagoralves
You've configured the runtime to both read and write to holding registers 0-16. You should pick one. Either you write or you read. Since it seems that you need to write to them, leave the "Holding Registers - Read" section all zeroed.
Reply 0 0
Reply