From: Benjamin Braatz Date: Wed, 3 Feb 2021 05:23:48 +0000 (+0100) Subject: Test Presse 05 X-Git-Url: http://git.graph-it.com/?a=commitdiff_plain;h=f631a94ef9e0c4261efb3f0cf256ee2f27eecdde;p=graphit%2Fschaltschrank.git Test Presse 05 --- diff --git a/conf.json b/conf.json index ad32949..a65a0fd 100644 --- a/conf.json +++ b/conf.json @@ -4,7 +4,7 @@ "address": 56, "pins": [ [ "A1-1", "T1-1" ], [ "A1-2", "T1-2" ], - [ "A1-3", "T1-3" ], [ "A1-4", "T1-4" ], + [ "A1-3", "T1-3", "Zentralschmierung" ], [ "A1-4", "T1-4", "Ölpumpe" ], [ "A1-5", "T1-5" ], [ "A1-6", "T1-6" ], [ "A1-7", "T1-7" ], [ "A1-8", "T1-8" ] ] }, { "name": "A2", @@ -13,16 +13,16 @@ "pins": [ [ "A2-1", "T1-9" ], [ "A2-2", "T1-10" ], [ "A2-3", "T1-11" ], [ "A2-4", "T1-12" ], - [ "A2-5", "T1-13" ], [ "A2-6", "T1-14" ], + [ "A2-5", "T1-13" ], [ "A2-6", "T1-14", "Öllampe" ], [ "A2-7", "T1-15" ], [ "A2-8", "T1-16" ] ] }, { "name": "E1", "type": "input", "address": 32, "interrupt pin": 4, "pins": - [ [ "E1-1", "T1-18" ], [ "E1-2", "T1-19" ], - [ "E1-3", "T1-20" ], [ "E1-4", "T1-21" ], - [ "E1-5", "T1-22" ], [ "E1-6", "T1-23" ], + [ [ "E1-1", "T1-18", "Schwungrad" ], [ "E1-2", "T1-19", "Takt" ], + [ "E1-3", "T1-20", "Öldruck" ], [ "E1-4", "T1-21", "Bruchplatte" ], + [ "E1-5", "T1-22", "Bruchplatte Einzug" ], [ "E1-6", "T1-23" ], [ "E1-7", "T1-24" ], [ "E1-8", "T1-25" ] ] }, { "name": "E2", "type": "input", @@ -38,10 +38,10 @@ "address": 34, "interrupt pin": 27, "pins": - [ [ "E3-1", "T2-1" ], [ "E3-2", "T2-2" ], - [ "E3-3", "T2-3" ], [ "E3-4", "T2-4" ], - [ "E3-5", "T2-5" ], [ "E3-6", "T2-6" ], - [ "E3-7", "T2-7" ], [ "E3-8", "T2-8" ] ] }, + [ [ "E3-1", "T2-1" ], [ "E3-2", "T2-2", "Notaus" ], + [ "E3-3", "T2-3", "Stop" ], [ "E3-4", "T2-4", "Dauerlauf" ], + [ "E3-5", "T2-5", "Schmierung" ], [ "E3-6", "T2-6", "Vorlauf" ], + [ "E3-7", "T2-7", "Rücklauf" ], [ "E3-8", "T2-8" ] ] }, { "name": "E4", "type": "input", "address": 35, diff --git a/gmodbus/hitachi.py b/gmodbus/hitachi.py index 2fb7372..4aa6c95 100644 --- a/gmodbus/hitachi.py +++ b/gmodbus/hitachi.py @@ -11,6 +11,25 @@ class SJP1Fu(): def __init__(self, client: ClientInterface) -> None: self.__protocol = DatatypesProtocol(client, SJP1FU_COILS, SJP1FU_REGISTERS) + async def set_parameters(self) -> None: + # AA115 = 01, 14-43 + await self.__protocol.write_register(12015, 1) + # AC120 = 0.5 s, 14-44 + await self.__protocol.write_register(12220, 0.5) + # bA122 = 02, 14-53 + await self.__protocol.write_register(13022, 2) + # bA123 = 35 A, 14-53 + await self.__protocol.write_register(13023, 35) + # bA124 = 5 s, 14-53 + await self.__protocol.write_register(13024, 5) + # Cb40 = 01, 14-58 + await self.__protocol.write_register(14140, 1) + # Hb102 = 11 kW, 14-64 + await self.__protocol.write_register(15102, 11) + # Hb103 = 4, 14-64 + await self.__protocol.write_register(15103, 4) + # bA124 = 22.5A Motorschutz ??? + async def set_frequency(self, frequency: int) -> None: # Page 532 / 14-41 await self.__protocol.write_register(10502, frequency) @@ -42,83 +61,111 @@ SJP1FU_COILS = { SJP1FU_REGISTERS = { - 10001: { - 'code': 'dA-01', - 'name': 'Output frequency monitor', - 'rw': 'r', - 'type': 'uint16', + 10502: { + 'name': 'Set Frequency', + 'rw': 'rw', + 'type': 'int32', 'conf': { - 'min': 0, + 'min': -590, 'max': 590, 'unit': 'Hz', 'scale': 0.01, }, }, - - 10003: { - 'code': 'dA-03', - 'name': 'Operation direction monitor', - 'rw': 'r', + 12015: { + 'code': 'AA115', + 'name': 'First stop mode selection', + 'rw': 'rw', 'type': 'enum', 'conf': { 'values': { - 0: 'Stop', - 1: 'Zero-speed out', - 2: 'Forward run', - 3: 'Reverse run', - } - } + 0: 'Deceleration stop', + 1: 'Free-run', + }, + }, }, - - 10502: { - 'name': 'Set Frequency', + 12220: { + 'code': 'AC120', + 'name': 'First acceleration time 1', 'rw': 'rw', 'type': 'int32', 'conf': { - 'min': -590, - 'max': 590, - 'unit': 'Hz', + 'min': 0, + 'max': 3600, + 'unit': 's', 'scale': 0.01, }, }, - - 11010: { - 'code': 'FA-10', - 'name': 'Acceleration time (monitor + setting)', + 13022: { + 'code': 'bA122', + 'name': 'First overload limit 1 selection', 'rw': 'rw', - 'type': 'uint32', + 'type': 'enum', 'conf': { - 'min': 0, - 'max': 3600, - 'unit': 's', - 'scale': 0.01, + 'values': { + 0: 'Disabled', + 1: 'During acceleration and at constant speed', + 2: 'At constant speed', + 3: 'Speed increases during regeneration', + }, }, }, - 11012: { - 'code': 'FA-12', - 'name': 'Deceleration time (monitor + setting)', + 13023: { + 'code': 'bA123', + 'name': 'First overload limit 1 level', 'rw': 'rw', - 'type': 'uint32', + 'type': 'uint16', 'conf': { - 'min': 0, + 'unit': 'A', + 'scale': 0.1, + }, + }, + 13024: { + 'code': 'bA124', + 'name': 'First overload limit 1 operation time', + 'rw': 'rw', + 'type': 'int32', + 'conf': { + 'min': 0.1, 'max': 3600, 'unit': 's', 'scale': 0.01, }, }, - - 12501: { - 'code': 'AF101', - 'name': 'First DC braking selection', + 14140: { + 'code': 'Cb-40', + 'name': 'Thermistor selection', 'rw': 'rw', 'type': 'enum', 'conf': { 'values': { -# 0: 'Stop', -# 1: 'Zero-speed out', -# 2: 'Forward run', -# 3: 'Reverse run', - } - } + 0: 'Disabled', + 1: 'PTC', + 2: 'NTC', + }, + }, + }, + 15102: { + 'code': 'Hb102', + 'name': 'First IM motor capacity selection', + 'rw': 'rw', + 'type': 'uint16', + 'conf': { + 'min': 0.01, + 'max': 160, + 'unit': 'kW', + 'scale': 0.01, + }, + }, + 15103: { + 'code': 'Hb103', + 'name': 'Selection of number of firs IM motor poles', + 'rw': 'rw', + 'type': 'uint16', + 'conf': { + 'min': 0, + 'max': 23, + 'scale': 1, + }, }, } diff --git a/schaltschrank/config.py b/schaltschrank/config.py index d358d06..c3b30b2 100644 --- a/schaltschrank/config.py +++ b/schaltschrank/config.py @@ -1,5 +1,6 @@ +import serialio from gpin import PCF8574Output, PCF8574Input, GPIOInputPin -from gmodbus.transport import SerialPort, SerialClient +from gmodbus.transport import SerialClient from gmodbus.hitachi import SJP1Fu @@ -34,7 +35,9 @@ async def process_configuration(conf, queues): fu = None if 'modbus' in conf: modbus_conf = conf['modbus'] - port = SerialPort(modbus_conf['serial device']) + #port = SerialPort(modbus_conf['serial device']) + port = serialio.serial_for_url(f"serial://{modbus_conf['serial_device']}") + await port.open() client = SerialClient(port, modbus_conf['slave id']) fu = SJP1Fu(client) return (pins, fu) diff --git a/schaltschrank/websocket.py b/schaltschrank/websocket.py index 6d3d000..4ec8ab6 100644 --- a/schaltschrank/websocket.py +++ b/schaltschrank/websocket.py @@ -23,6 +23,8 @@ async def process_command(command, pins, fu, queue): await queue.put({'event': 'pinstate', 'pin': pin_name, 'settable': pin.settable, 'value': pin.value, 'changed': False}) + elif command['command'] == 'setparameters': + await fu.set_parameters() elif command['command'] == 'setfrequency': await fu.set_frequency(command['value']) elif command['command'] == 'getfrequency': @@ -43,11 +45,52 @@ async def command_handler(websocket, path, pins, fu, queue): await process_command(command, pins, fu, queue) -async def event_handler(websocket, path, queue): +async def event_handler(websocket, path, pins, fu, queue): while True: event = await queue.get() message = json.dumps(event) await websocket.send(message) + if event['event'] == 'pinstate': and event['changed']: + okay = ( pins['Zentralschmierung'].value and + pins['Ölpumpe'].value and + pins['Schwungrad'].value and + pins['Öldruck'].value and + pins['Bruchplatte Einzug'].value ) + pins['Öllampe'].value = okay + if not okay: + active = await fu.inverter_active + if active: + await fu.stop_inverter() + if event['value']: + if event['pin'] == 'Notaus': + await fu.stop_inverter() + pins['Zentralschmierung'].value = False + pins['Ölpumpe'].value = False + elif event['pin'] == 'Stop': + await fu.stop_inverter() + pins['Zentralschmierung'].value = False + pins['Ölpumpe'].value = False + elif event['pin'] == 'Schmierung': + pins['Zentralschmierung'].value = True + pins['Ölpumpe'].value = True + elif event['pin'] == 'Vorlauf': + if not pins['Dauerlauf'].value: + await fu.set_parameters() + await fu.set_frequency(5) + await fu.start_inverter() + await asyncio.sleep(1) + await fu.stop_inverter() + else: + await fu.set_parameters() + await fu.set_frequency(20) + await fu.start_inverter() + elif event['pin'] == 'Rücklauf': + if not pins['Dauerlauf'].value: + await fu.set_parameters() + await fu.set_frequency(-5) + await fu.start_inverter() + await asyncio.sleep(1) + await fu.stop_inverter() queue.task_done() @@ -57,7 +100,7 @@ async def handler(pins, fu, queues, websocket, path): command_task = asyncio.create_task(command_handler(websocket, path, pins, fu, queue)) event_task = asyncio.create_task(event_handler(websocket, path, - queue)) + pins, fu, queue)) done, pending = await asyncio.wait( [command_task, event_task], return_when=asyncio.FIRST_COMPLETED, diff --git a/setup.py b/setup.py index 624a8a9..374dc70 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,7 @@ setuptools.setup( "websockets", "pigpio", "umodbus", + "serialio", ], classifiers=[ "Programming Language :: Python",