- Видео 89
- Просмотров 6 269
Anders Østergaard
Дания
Добавлен 30 июн 2012
PROFIBUS - Master/Slave communication simple configuration
Simple profibus Master to Slave communication. There will be a better video on this one.
Просмотров: 21
Видео
Rockwell - IP addresses, BOOTP, RSLink Classic
Просмотров 232 месяца назад
Rockwell - IP addresses, BOOTP, RSLink Classic
Rockwell - PI regulator (Direkte regulering)
Просмотров 159 месяцев назад
Rockwell - PI regulator (Direkte regulering)
Rockwell - PI regulator (Invers regulator)
Просмотров 179 месяцев назад
Rockwell - PI regulator (Invers regulator)
Kan du opdatere værdierne i eksempelvis input registers løbende med den metode der?
Du kan godt med dette lib opdatere input registers løbende men det kræver lidt mere som: from pymodbus.server.async_io import StartAsyncTcpServer from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext from pymodbus.datastore import ModbusSequentialDataBlock import asyncio # Opret registre coils = ModbusSequentialDataBlock(0, [0]*10) discrete_inputs = ModbusSequentialDataBlock(0, [1]*10) input_registers = ModbusSequentialDataBlock(0, [100]*10) holding_registers = ModbusSequentialDataBlock(0, [200]*10) store = ModbusSlaveContext( co=coils, di=discrete_inputs, ir=input_registers, hr=holding_registers ) context = ModbusServerContext(slaves=store, single=True) # Funktion til at opdatere registre løbende async def update_registers(): counter = 0 while True: # Simuler dynamisk ændring i Input Registers new_input_values = [counter + i for i in range(10)] input_registers.setValues(0, new_input_values) print("Opdaterede Input Registers:", new_input_values) # Simuler også ændringer i Holding Registers new_holding_values = [v * 2 for v in new_input_values] holding_registers.setValues(0, new_holding_values) print("Opdaterede Holding Registers:", new_holding_values) counter += 10 await asyncio.sleep(5) # Opdater hvert 5. sekund # Kør Modbus-serveren async def run_server(): print("Starter Modbus TCP Server på 0.0.0.0:5020") await StartAsyncTcpServer(context, address=("0.0.0.0", 5020)) # Hovedfunktion for at starte både server og opdatering async def main(): await asyncio.gather(run_server(), update_registers()) # Start programmet if __name__ == "__main__": asyncio.run(main())
❤
g00d
This already looks promising. I hope you plan many more videos, especially those that are not necessarily aimed at beginners. With this video, it goes in any case in the right direction!
Thank you Jack i will be making more videos :)