Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision Next revisionBoth sides next revision | ||
en:software:devices:modbus [2016/12/20 17:34] – created qem103 | en:software:devices:modbus [2016/12/21 16:56] – [5.3. Richieste di lettura] qem103 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== DEVICE MODBUS ====== | ====== DEVICE MODBUS ====== | ||
- | ===== - Introduzione | + | ===== - Introduction |
- | Il protocollo | + | The MODBUS< |
- | integrare | + | The MODBUS |
- | Master/ | + | With using a serial line, there are two modes of transmission used in the Modbus |
- | da tutti gli altri dispositivi connessi.\\ | + | |
- | Il device | + | |
- | Le caratteristiche della trasmissione dati (nr. dispositivo fisico, baud rate, parità, stop bits) e del modo di trasmissione devono | + | |
- | essere selezionate su ogni stazione e non possono essere modificate durante il funzionamento.\\ | + | |
- | Con l' | + | |
- | comunicazione. Il modo è selezionato dal master | + | |
* ASCII (American Standard Code for Information Interchange) | * ASCII (American Standard Code for Information Interchange) | ||
* RTU, (Remote Terminal Unit.) | * RTU, (Remote Terminal Unit.) | ||
- | Il presente manuale si suddivide in due parti:\\ | + | This manual is divided into two parts:\\ |
- | Parte I - Descrizione funzionamento come master\\ | + | Part I - Operation as master\\ |
- | Parte II - Descrizione funzionamento come slave. | + | Part II - Operation as slave. |
- | ===== - Convenzioni | + | ===== - Conventions |
- | Il protocollo di comunicazione | + | The modbus |
- | * INPUT STATUS = Ingressi digitali (Digital Inputs) | + | * INPUT STATUS = Digital Inputs |
- | * COIL STATUS = Uscite digitali (Digital | + | * COIL STATUS = UDigital |
- | * INPUT REGISTER = Ingressi analogici (Analog Inputs) | + | * INPUT REGISTER = Analog Inputs |
- | * HOLDING REGISTER. = Uscite analogiche (Analog Outputs). | + | * HOLDING REGISTER. = Analog Outputs |
- | Nel corso del manuale si deve tener conto delle convenzioni presenti. | + | Throughout the manual you have to take into account existing conventions. |
- | ===== - Dichiarazione device nella unit di configurazione | + | ===== - Device declaration in the configuration |
+ | |||
+ | Declaration of the used device (internal device): device name assigned, MODBUS, slot location and number of the device. | ||
- | Dichiarazione del device utilizzato (device interno): nome del device assegnato, MODBUS, posizione dello slot e numero | ||
- | del device. | ||
<code QCL> | <code QCL> | ||
INTDEVICE | INTDEVICE | ||
... | ... | ||
- | <nome_device> MODBUS | + | <device_name> MODBUS |
... | ... | ||
</ | </ | ||
- | Dove: | + | Where: |
- | |INTDEVICE|è la parola chiave che indica l’inizio della definizione di devices | + | |INTDEVICE|is a keyword indicating the beginning of the definition of internal |
- | |<nome_device>|è il nome del device,| | + | |<device_name>|is the device |
- | |MODBUS|è la parola chiave che identifica il device | + | |MODBUS|is the keyword that identifies the device |
- | |TCamp|è tempo di campionamento del device,| | + | |TCamp|is the sampling time of the device,| |
- | |channel|è la definizione del tipo di canale di comunicazione collegato | + | |channel|is the definition of the type of communications channel connected |
- | Per quanto riguarda la dichiarazione dell’hardware | + | To declare the hardware |
- | riferimento al manuale | + | |
- | **Esempio** | + | **Example** |
<code QCL> | <code QCL> | ||
INTDEVICE | INTDEVICE | ||
Line 58: | Line 51: | ||
</ | </ | ||
- | ===== - Tabelle “scambio dati” per il MODBUS ===== | + | ===== - Tables "data exchange" |
- | ==== - Dati letti dal device ==== | + | ==== - Data read from the device ==== |
- | |::: | + | |::: |
- | |::: | + | |::: |
- | ^Registro\\ Modbus| ||||||||||||||||| | + | ^Modbus\\ register| ||||||||||||||||| |
|0001| |||||||iword1| |||||||2< | |0001| |||||||iword1| |||||||2< | ||
|0002| |||||||iword2| |||||||2< | |0002| |||||||iword2| |||||||2< | ||
Line 98: | Line 91: | ||
|0032| |||||||iword32| |||||||2< | |0032| |||||||iword32| |||||||2< | ||
- | NOTA 1: la “ iword1 ” è la word più significativa della “ ilong1 ” (long = doppia | + | NOTE 1: the “ iword1 ” is the most significant |
- | della “ ilong2 ”, ...\\ | + | NOTE 2: the “ st_ibit0 ” parameter less significant |
- | NOTA 2: il parametro | + | |
- | significativo | + | |
- | ==== - Dati scrivibili da QCL e condivisibili | + | ==== - Writable data from QCL and sharable |
- | |::: | + | |::: |
- | |::: | + | |::: |
- | ^Registro\\ Modbus| ||||||||||||||||| | + | ^Modbus\\ register| ||||||||||||||||| |
|0001| |||||||oword1| |||||||2< | |0001| |||||||oword1| |||||||2< | ||
|0002| |||||||oword2| |||||||2< | |0002| |||||||oword2| |||||||2< | ||
Line 141: | Line 132: | ||
|0032| |||||||oword32| |||||||2< | |0032| |||||||oword32| |||||||2< | ||
- | NOTA 1: la “ oword1 ” è la word più significativa della “ olong1 ” (long = doppia | + | NOTE 1: the “ oword1 ” is the most significant |
- | della “ olong2 ”, ...\\ | + | NOTE 2: the “ st_obit0 ” parameter is the less significant |
- | NOTA 2: il parametro | + | |
- | più significativo | + | |
+ | ===== - Master operation description ===== | ||
+ | |||
+ | The MODBUS device can use a serial port or TCPIP to communicate in master mode (parameter //mode// = 0). Allows (via parameters, states and commands) all instruments to be able to communicate with any equipment utilizing Modbus.\\ | ||
+ | The device provides a data exchange area where the QCL can write or read values shared with the slaves on the network. This area is represented by a list of parameters of the device divided into two groups to differentiate the type of access of the data by the device. The first section is identified as INPUT the second as OUTPUT. The INPUT section, for master operation, is the storage area of reads data. It is used by all reader functions (parameter //type// = 1, 2, 3 o 4). The OUTPUT section, in the master operation, is the area of data storage that the master should transfer to the slaves. It is used by all writing functions (parameter //type// = 5, 6, 15 o 16). To facilitate the exchange of data between devices, the structure of the Exchange area includes data types commonly used in QCL namely WORD, LONG and FLAG. The “BYTE” type does not appear because the modbus usually uses the word size for each address registers. The modbus protocol selects data based on the number of access log register, while the QCL selects based on the parameter symbol, you create a reference table in which each QCL symbol find the corresponding number in the register of access in Modbus protocol. To obtain greater flexibility for addressing, the same area of Exchange data can be manipulated by the QCL with different dimension parameterized. All the symbols that appear in the same row of the table refer to the same memory locations. | ||
+ | |||
+ | ==== - Input and coil Data Access ==== | ||
+ | The data input or //coil// type have in the modbus Protocol a bit size. To store this information in the table of data exchange is defined as follows mode: each register (and then every word parameter of the device) represents 16 elements that are numbered from left to right. For the Scriptures or multiple readings when bits read are higher than those contained in the register the operation continues in the next register.\\ | ||
+ | The // | ||
- | ===== - Descrizione funzionamento come master ===== | + | ==== - Mode of MASTER operation |
- | Il device MODBUS può utilizzare una porta seriale o TCPIP per comunicare in modalità master (parametro // | + | |
- | possibilità (tramite parametri, stati e comandi) a tutti gli strumenti di poter colloquiare con qualsiasi apparecchiatura utilizzante | + | |
- | protocollo Modbus.\\ | + | |
- | Il device rende disponibile una area di scambio dati dove il QCL può scrivere o leggere i valori condivisi con gli slave della | + | |
- | rete. Questa area è rappresentata da una lista di parametri del device suddivisa in due gruppi per differenziare il tipo di | + | |
- | accesso dei dati da parte del device. La prima sezione è identificata come INPUT la seconda come OUTPUT. | + | |
- | La sezione INPUT, per il funzionamento master, è l’area di deposito dei dati letti. Viene utilizzata quindi da tutte le funzioni | + | |
- | di lettura (parametro // | + | |
- | che il master deve trasferire agli slave. Viene utilizzata da tutte le funzioni di scrittura (parametro // | + | |
- | Per semplificare lo scambio dati tra apparecchiature, | + | |
- | usati in QCL e cioè WORD, LONG e FLAG. Il tipo “BYTE” non compare perché il modbus utilizza solitamente la dimensione | + | |
- | word per ogni indirizzo dei registri. Siccome il protocollo modbus seleziona i dati in base al numero di registro di accesso, | + | |
- | mentre il QCL seleziona in base al simbolo del parametro, si crea una tabella di riferimento in cui ogni simbolo | + | |
- | QCL trova il corrispondente numero del registro di accesso nel protocollo Modbus. Per ottenere una maggior flessibilità di | + | |
- | indirizzamento, | + | |
- | simboli che compaiono nella stessa riga della tabella si riferiscono alle medesime locazioni di memoria. | + | |
- | ==== - Accesso dei dati input e coil ==== | + | The master mode is set with the mode parameter |
+ | Using the two commands SEND or SENDSYC you send the read or write request to the slave, a number of States allow an audit on the operation being executed. We see in detail: | ||
- | I dati tipo input o //coi//l hanno nel protocollo modbus una dimensione a bit. Per la memorizzazione di queste informazioni | + | === - Parameters for formatting the message: === |
- | nella tabella di scambio dati è definita la seguente modalità: ogni registro (e quindi ogni parametro word del device) rappresenta | + | |
- | 16 elementi che vengono numerati da sinistra verso destra. Per le scritture o letture multiple quando i bit da leggere | + | |
- | sono superiori a quelli contenuti nel registro l’operazione continua nel registro successivo.\\ | + | |
- | Gli stati // | + | |
- | tabella. | + | |
- | ==== - Modo di funzionamento MASTER | + | **type** |
+ | **idcard** | ||
+ | **addr** | ||
+ | **tabreg** | ||
+ | **num** = number of values that are read or write (if the request type so provides). Are accepted values are between 1 and 128 for values of type parameter = 1, 2, (reading of bits), while for type value = 3, 4, 16 (multiple word reading and writing) the accepted value are between 1 and 32. | ||
- | La modalità master viene impostata con il parametro mode = 0. La scheda genera messaggi modbus solamente su comando | + | === - Commands to send the message: === |
- | del QCL e non automaticamente. Per “formattare” la stringa del messaggio modbus vi sono una serie di parametri.\\ | + | |
- | Mediante i due comandi SEND o SENDSYC si inviano la richiesta di lettura o scrittura allo slave, una serie di stati | + | |
- | permettono una verifica sull’operazione eseguita. Vediamo in dettaglio: | + | |
- | === - Parametri per formattare il messaggio: === | + | SEND sends the request message to the slave.\\ |
- | **type** = tipo di richiesta che si vuole processare (lettura o scrittura di word o di bit).\\ | + | SENDSYC sends the request message to a QEM slave of MODBUS |
- | **idcard** = indirizzo dell’unità | + | |
- | **addr** = indice da cui iniziare | + | |
- | **tabreg** = per le operazioni di lettura (type = 1, 2, 3, 4), questo parametro indica la posizione nella “tabella dei dati letti” dove verrà memorizzato il dato letto sullo slave. Per le operazioni di scrittura | + | |
- | **num** = numero di valori che si intendono leggere o scrivere (se il tipo richiesta type lo prevede). Sono previsti valori tra 1 e 128 per valori del parametro type = 1, 2, (lettura di bit), mentre per valori type = 3, 4, 16 (scrittura multipla e lettura di word) i valori previsti sono tra 1 e 32. | + | |
- | === - Comandi per inviare il messaggio: === | + | === - State variables for diagnostic operation: === |
- | SEND invia il messaggio di richiesta allo slave.\\ | + | |
- | SENDSYC invia il messaggio di richiesta ad uno slave QEM di tipo MODBUS e segnala l’operazione conclusa (// | + | |
- | === - Variabili di Stato per diagnostica operazione: === | + | When ended the message send operation, the status st_sended variable is set to 1. If you used the SEND command the state is set to 1 when the master |
- | Quando l’operazione di trasmissione messaggio è conclusa, viene impostata a 1 la variabile di stato st_sended. Se è | + | The SENDSYC |
- | stato utilizzato il comando | + | |
- | invece è stato utilizzato nel master | + | |
- | avrà eseguito il comando | + | |
- | // | + | |
- | Il comando | + | |
- | ==== - Richieste di lettura | + | ==== - Read request |
=== Read Coil === | === Read Coil === |