Hola amigos, vengo a consultar una duda casi trivial pero que no he podido resolver... He encontrado mucha información pero por mas que la leo no me queda 100% resuelta mi duda y es por esto que vengo a consultar acá (Disculpas de antemano).
Les cuento mi problema:
Pretendo utilizar la libreria Simplemodbusmaster para leer un registro de un equipo.
Datos previos:
direccion de registro que se quiere leer: 0303
id del slave: 2
*El registro a leer varia entre 0-80.000 aproximadamente
Segun leo en el manual el orden de datos a ingresar es:
modbus_construct(direccion de packete, "quien dirige el mensaje"(0 para broadcasting), funcion, direccion hacia donde va el mensaje, desconozco, local_start_address;
[/code]
De modo que segun lo que he logrado captar... para lograr la funcion que yo deseo deberia escribir lo siguiente:
modbus_construct(&packets[PACKET1], 0, READ_HOLDING_REGISTERS, 0303, ????, 0;
Adjunto lo que dice el manual de la libreria:
The fifth parameter is the index of the masters register map. More on this later...
The address, data and local_start_address parameter needs some further clarification.
The address parameter for function 1, 2, 5 and 15 is the number of boolean points. The address
parameter for functions 3, 4, 6 and 16 is an unsigned int index from 0 – 65535. It must be noted
however that some slaves accept the function as explicit or implicit which affects the address range. I.e.
using function 3 as an example, READ_HOLDING_REGISTERS starts at address 40000 which is within the
limits of an unsigned int so referring to address 40000 implicitly refers to function 3 and an address
range of 0 – 9999, but when a slave refers to the function explicitly than the address can range from 0 –
65535.
The data parameter differs when using different functions namely:
For functions 1 & 2 data is the number of points. Points are stored in the masters unsigned int register
map using shifting and padding.
For function 5 data is either ON (0xFF00) or OFF (0x0000)
For function 6 data is exactly that, one register's data
For functions 3, 4 & 16 data is the number of registers
For function 15 data is the number of coils
Mi nivel de ingles y mi poca comprensión lectora me imposibilitan de entender como funcionan a pesar de que el manual es bastante explicativo...
Como se puede apreciar no me queda claro que poner en el 5 parámetro y me surgen dudas sobre el 6 parámetro.... Ojala alguien pueda aclararme las dudas u.u
Necesito que alguien me pueda explicar con peras y manzanas para lograr entender u.u...
De antemano gracias !