RS485 configuration for RTD Hat & Sixteen Analog/Digital Inputs Hat with additional external RS485 Devices Codesys

mwyss

New member
Hi all

I have one RTD Hat with one sixteen Analog/Digital Hat and two 3. Party external RS485 Relais Boards with Raspberry 5.

I am using Codesys.

What is the recomandation for the 3 DipSwitchs (TX,RX,Term) for the RS485 for the 2 Hat's with Codesys and 2 external RS485 Relais Board?

Best regards
martin
 

alexburcea

Moderator
Staff member
Hi,

If you use the two HATs on the same Raspberry Pi, you can use just one RS485 port because both are connected to the same Raspberry Pi pins.
To use any of the RS485 ports you need to disable the card (RTD or 16-universal inputs) Modbus feature by running the appropriate command. The configuration is saved in the card nonvolatile memory so need to be done just once.
 

mwyss

New member
Hi

Thank you very much for your super fast respond!

Yes, the two Hat's are on the same Raspberry. And 2 external RS485 RelaisBoards which i connect to the Hats AB RS485 connector.

Regarding Codesys, i assume i have to configure a Modbus Master in Codesys and the external Realisboards are Slave's.
Should i therfore configer the Hat's also as Slaves?
 

alexburcea

Moderator
Staff member
I don't know much about the external relays cards and about using the Codesys as Modbus master, but the Sequent HATs are not controlled over Modbus, more, one of them acts as an RS485 transceiver for Raspberry PI Serial port so his Modbus protocol needs to be disabled.
 

mwyss

New member
ok. Going step by step. I have installed the codesys library for the rtd hat. how to see it in Codesys Device Tree?
 

alexburcea

Moderator
Staff member
I am a little rusty on Codesys, if the example project that came with the library does not answer your questions, let me know and I will remake my Codesys setup to find the answers.
 

mwyss

New member
the sample project works now, very nice, though the package did not install corectly by itself, but i managed to instal manually.
Sofar - very nice!!

Next step will be to integrate the 16 DI/AI Hat, but for this i am not sure, how the best way is, because there is no Codesys package from you - is that correct?
If yes, then it must be the way by rs485 modbus? And how do i configure the 3 rs485 switches on this card/hat?
 

alexburcea

Moderator
Staff member
Hi,

Yes, we did not have Codesys library for that HAT yet. The card implements MODBUS RTU slave so you can control it with any device with Modbus master. How you can do this with Codesys I do not know but you should start with connecting the RTD card to Raspberry that you have access to the terminal, and install the rtd command line interface from Github. Disable the Modbus protocol at the RTD card so you can use it as a simple transceiver for the Raspberry serial port and turn on the tx and rx dipswitches. Now connect the RS485 between the two cards (the Sixteen inputs card settings and dipswitches remain default) and you can access the card on Modbus at address 0x01, serial settings 38400-8-N-1.
 

mwyss

New member
Hi

iam ready to test the modbus on 16in-Hat but on github the modbus.md seems to be empty..?
Are there any other dcuments?
 

mwyss

New member
Hi,

the 16univin i can set to modbus slave, message comes: modbus rtu slave enabled.
Stack id switch 001

but on the rtd i can not set rtd 0 rs485wr 0 0 0 0 0, it say's done. But after rtd rs485rd there is 0 9600 1 0 1 - should it not to be 00000 now?
 

alexburcea

Moderator
Staff member
Hi,

If you disable the Modbus protocol on a card, only the first parameter count (to be 0) the rest of them have no meaning and can be any value. I filled out the Modbus.md
 

mwyss

New member
hi

thank you!!

in the Codesyscontrol_user.cfg is this the correct entry:?

[syscom]
linux.devicefile=serial (or ttyAMA0?)
portnum:com.syscom.sys_comport1

with "serial" the comport 1 works with ttyAMA0 it will not going green in codesys
 

mwyss

New member
Hi

Just to be sure, for digital input only, the config switches doesn't matter - correct?
The digital Input can be 5V or 10V? Whats the minimum Valtage, where the input goes "High"?

thank you for your support and best regards
martin
 

alexburcea

Moderator
Staff member
The Raspberry serial port name is dev/ttyAMA0.
For digital inputs (if there is no dry contact) the settings dipswitches do not matter.
 

mwyss

New member
i still have a problem with the 16Univin

1. RTD Board works fine with Codesys
2. RTD RS485 Interface in passive Bridg-Mode works fine on ttyAMA0
3. the 3. Party Rely Board connected to the RTD RS485 Port works also fine, in Linux only (modpoll) and also in Codesys

But the 16Univin does not work connected to RS485 on the RTD RS485 port with Modpoll and therfore also not in Codesys.
Any Input?
 

alexburcea

Moderator
Staff member
Hi,

I did not receive the notifications for your messages. I'm sorry.
If you look at the schematics you will see that the digital inputs are fed through a diode so logic 0 means a voltage lower than 0.5V and logic 1 means a voltage bigger than 2V (by the way you should enable the 1k or 10K switch for the digital inputs).
The defaults settings (if you did not change it) for the 16Universal inputs are 38400 8N1, and modbus address = 1 + stack level dipswitch value. We tested the card with QModMaster on Windows and USBto485 adapter.
 

mwyss

New member
no Problem, thanks.

Yes i thought that with the diode and just want your answer that 10V input ist fine.

And yes modpoll with RTU or Codesys the 3. party Relayboard does work fine through/connected via rtd-card’s rs485 interface in passiv mode!

I am now familiar, how to configure your hat‘s regarding the rs485 configuration. Actually very nice implemented with the switches and the hardware connecters for rs485-indeed very flexible!

If you say stack level + 1;
If jumper 1 from 0,1,2 is set only, then stack level would be 2, but modbus adress would be 3? Correct?
 
Top