adr63_vlt
I'm using OpenPLC V4.x on an Arduino OPTA platform and wanted to clarify how OpenPLC uses ModBus.
If I understand correctly, does an Arduino target work as a Modbus slave by default? Did I understand correctly?
Is Modbus used by the editor to view variables in real time?
In addition to this configuration, can I use ModBus as a master to query external devices?
I can't find how to enable it...
Can I do this from C code in an Arduino function block?
Best regards
Adriano
Reply 0 0
richw
#1 you have to load a blank sketch from editor to the arduino with the modbus option checked in the editor
#2 yes you can view modbus variables in the editor by selecting the debug icon by the variables in the table above the sketch
#3 if you want to use modbus master on the arduino you will have to create a C\C++ or python function block to communicate with other slaves
Reply 0 0
462eng
Modbus is just a way to communicate between devices, the master can read and/or write one or more UINT (16 bits) from/to slaves.
Only one master per bus, always the master that reads or writes (=slave cannot send data to master, only respond to requests).
 
You can view the variables, but you will have to: 1. have OpenPLC acts as master, 2. have the registers defined as read, 3. have the slave respond.
If your slave is an Arduino, you will have to upload a modbus slave sketch on the Arduino.
 
In OpenPLC, to make it act as a Modbus master, you click the + on the left, add a Remote Device, select 'Modbus/TCP' (ignore the TCP, this is TCP/RTU/Serial), and configure it. You will need to set your slave id and register addresses to what is in the Arduino sketch, and create variables with Location matching what is associated with the registers.
Reply 0 0
adr63_vlt
I'm responding to your comments.
#1 Can you explain better? It's not clear to me.
#2 Okay, clear.
#3 Yes, as I imagined.
Thanks.
Reply 0 0
adr63_vlt
Modbus è solo un modo per comunicare tra dispositivi: il master può leggere e/o scrivere uno o più UINT (16 bit) da/verso gli slave.
Solo un master per bus, ed è sempre il master a leggere o scrivere (= lo slave non può inviare dati al master, ma solo rispondere alle richieste).
 
È possibile visualizzare le variabili, ma è necessario: 1. che OpenPLC agisca come master, 2. che i registri siano definiti come read, 3. che lo slave risponda.
Se lo slave è un Arduino, sarà necessario caricare uno sketch Modbus Slave su Arduino.
 
In OpenPLC, per farlo funzionare come master Modbus, clicca sul + a sinistra, aggiungi un Dispositivo Remoto, seleziona "Modbus/TCP" (ignora il TCP, questo è TCP/RTU/Serial) e configuralo. Dovrai impostare l'ID slave e gli indirizzi dei registri in base a quelli presenti nello sketch Arduino e creare variabili con una posizione corrispondente a quella associata ai registri.
"In OpenPLC, to make it act as a Modbus master, click the + on the left, add a Remote Device, and select "Modbus/TCP" (ignore TCP)."
I tried doing this, but it says "Remote device configuration in only available in OpenPLC Runtime v4 target." I have an Arduino OPTA 4.1.6 target.
Reply 0 0
462eng
"In OpenPLC, to make it act as a Modbus master, click the + on the left, add a Remote Device, and select "Modbus/TCP" (ignore TCP)."
I tried doing this, but it says "Remote device configuration in only available in OpenPLC Runtime v4 target." I have an Arduino OPTA 4.1.6 target.
You said in your first message that you're running a v4 runtime, if that's the case, you should be able to set it as 'OpenPLC Runtime v4' in Device > Configuration,
not sure about the I/O tho, I never used Arduino (either Opta or not) to run OpenPLC directly.
After that, you should be able to enable Modbus.
Reply 0 0
thiagoralves
Arduino targets (as the Arduino Opta and all other microcontroller-based systems) only support Modbus slave on OpenPLC. You can enable that on the board selection screen by ticking the checkbox that says Modbus RTU or Modbus TCP depending on which type of Modbus you want (TCP is over the network, RTU is over serial).
 
If you want to use Modbus master on an Arduino target you will have to write the code for that on a C/C++ Function Block. These blocks work like Arduino sketches. You can try looking for examples online on how to write a Modbus master sketch.
Reply 1 0
adr63_vlt
Arduino targets (as the Arduino Opta and all other microcontroller-based systems) only support Modbus slave on OpenPLC. You can enable that on the board selection screen by ticking the checkbox that says Modbus RTU or Modbus TCP depending on which type of Modbus you want (TCP is over the network, RTU is over serial).
 
If you want to use Modbus master on an Arduino target you will have to write the code for that on a C/C++ Function Block. These blocks work like Arduino sketches. You can try looking for examples online on how to write a Modbus master sketch.
Okay, everything's clear on this topic. Thanks for the reply.
Reply 1 0
Reply