/ examples / HSC / hsc_z_reset.py
hsc_z_reset.py
 1  """
 2  	Example: hsc_z_reset
 3  
 4  	This example shows how to use the z reset functionality of the of the P1-02HSC
 5  
 6      This example works with the P1-02HSC
 7  
 8  	This example will print the position of each counter every second. 
 9      If the z reset input is triggered, each channel will have its potition reset
10      to the specified value
11  	 _____  _____
12  	|  P  ||  S  |
13  	|  1  ||  L  |
14  	|  A  ||  O  |
15  	|  M  ||  T  |
16  	|  -  ||     |
17  	|  2  ||  0  |
18  	|  0  ||  1  |
19  	|  0  ||     |
20  	 ¯¯¯¯¯  ¯¯¯¯¯
21  	Written by FACTS Engineering
22  	Copyright (c) 2023 FACTS Engineering, LLC
23  	Licensed under the MIT license.
24  
25  """
26  
27  import time
28  import P1AM
29  
30  base = P1AM.Base()
31  hsc = base[1] # P1-02HSC module in slot 1
32  cnt1 = hsc[1] # Channel 1
33  cnt2 = hsc[2] # Channel 2
34  
35  cnt1.enable_z_reset = True # Enable z reset functionality
36  cnt2.enable_z_reset = True
37  
38  cnt1.z_reset_position = 1234 # Set positions to reset to when triggered
39  cnt2.z_reset_position = 5678
40  
41  hsc.update_settings() # Write settings to module
42  
43  last_time = time.monotonic()
44  while True:
45      if time.monotonic() - last_time > 1:
46          print(f"cnt1 position = {cnt1.position}")
47          print(f"cnt2 position = {cnt2.position}\n")
48          last_time = time.monotonic()