-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86ac460
commit b316b74
Showing
4 changed files
with
66 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
Example: Power Cycle | ||
This example shows how to re-init the base after power has been cycled. | ||
When powering your device with both USB and external power, this example can | ||
be used to catch and handle errors produced by a temporary loss of external 24V. | ||
This example uses a discrete output module, but can be adapted to other modules. | ||
_____ _____ | ||
| P || S | | ||
| 1 || L | | ||
| A || O | | ||
| M || T | | ||
| - || | | ||
| 2 || 0 | | ||
| 0 || 1 | | ||
| 0 || | | ||
¯¯¯¯¯ ¯¯¯¯¯ | ||
Written by FACTS Engineering | ||
Copyright (c) 2023 FACTS Engineering, LLC | ||
Licensed under the MIT license. | ||
""" | ||
|
||
import time | ||
import P1AM | ||
|
||
base = P1AM.Base() # Intializes base. Returns the base object. | ||
module = base[1] # module object for slot 1 | ||
output = module[2] # 2nd channel object for our output module. | ||
# output = module.outputs[2] # on combos select outputs with module.outputs | ||
|
||
while True: | ||
try: | ||
# removing external 24V here will raise a RuntimeError | ||
output.value = True | ||
time.sleep(1) | ||
output.value = False | ||
time.sleep(1) | ||
except RuntimeError: | ||
while True: | ||
# loop until base is re-initialized | ||
try: | ||
base.init() # must be called if external 24V is interrupted | ||
break | ||
except RuntimeError: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters