discrete_output.py
1 """ 2 Example: Discrete Output 3 4 This example shows how to write to discrete output modules. 5 6 Discrete ouputs are any output that is only ON or OFF such as a relay. 7 This example works with all P1000 Series: 8 - Discrete ouput modules such as P1-08TRS, P1-08TD1, P1-16TR, etc. 9 - Discrete combo modules such as P1-15CDD1, P1-15CDD2, P1-16CDR, etc. 10 11 This example will toggle channel 2 of slot 1 on and off every second. 12 _____ _____ 13 | P || S | 14 | 1 || L | 15 | A || O | 16 | M || T | 17 | - || | 18 | 2 || 0 | 19 | 0 || 1 | 20 | 0 || | 21 ¯¯¯¯¯ ¯¯¯¯¯ 22 Written by FACTS Engineering 23 Copyright (c) 2023 FACTS Engineering, LLC 24 Licensed under the MIT license. 25 """ 26 27 import time 28 import P1AM 29 30 base = P1AM.Base() # Intializes base. Returns the base object. 31 module = base[1] # module object for slot 1 32 output = module[2] # 2nd channel object for our output module. 33 # output = module.outputs[2] # on combos select outputs with module.outputs 34 35 while True: 36 output.value = True 37 time.sleep(1) 38 output.value = False 39 time.sleep(1)