question

Nicolas Beltran avatar image

Modbus TCP,Multiplus

Hi,

i would like to know what is the parameter to control power (kW) that gave the batteries, using Modbus TCP from CCGX and if can i modify ?

Modbus TCPmodifications
10 |3000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

2 Answers
juan manuel tirado avatar image

Hola. Estoy intentando escribir un script python que me controle el Grid Set Point, para poder variarlo desde una RaspberryPi.

Mi conocimiento de Python es muy bajo, asi que me he guiado por ejemplos que he visto por la red.

El caso es que cuando cargo un valor igual a 0 o superior, (numero entero) no hay problema.

Pero no me deja cargar valores negativos, aunque en el mapa de registros el 2700 (grid set point) aparece como int16 (-32668 a 32668)

La parte que me da problema es esta:


if Fase_carga == 4:

a = 10

client.write_register(2700,a,unit = 100)


Cuando a es negativo me da error:


Traceback (most recent call last):

File "prueba5 individual.py", line 42, in <module>

client.write_register(2700,a,unit = 100)

File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/client/common.py", line 92, in write_register

return self.execute(request)

File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/client/sync.py", line 106, in execute

return self.transaction.execute(request)

File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/transaction.py", line 149, in execute

broadcast=broadcast

File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/transaction.py", line 213, in _transact

packet = self.client.framer.buildPacket(packet)

File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/framer/socket_framer.py", line 206, in buildPacket

data = message.encode()

File "/home/pi/.local/lib/python2.7/site-packages/pymodbus/register_write_message.py", line 42, in encode

packet += struct.pack('>H', self.value)

struct.error: integer out of range for 'H' format code



------------------

(program exited with code: 1)

Press return to continue




Share
10 |3000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

cquinones (Victron Energy Staff) avatar image
Share
10 |3000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.