Skip to content

Commit dbf0a0e

Browse files
interface update for turning HV power on
1 parent 902b3c7 commit dbf0a0e

File tree

5 files changed

+180
-38
lines changed

5 files changed

+180
-38
lines changed

environment_pyfus.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: pyfus
2+
channels:
3+
- defaults
4+
dependencies:
5+
- bzip2=1.0.8=h2bbff1b_6
6+
- ca-certificates=2024.7.2=haa95532_0
7+
- expat=2.6.2=hd77b12b_0
8+
- libffi=3.4.4=hd77b12b_1
9+
- openssl=3.0.14=h827c3e9_0
10+
- pip=24.2=py312haa95532_0
11+
- python=3.12.4=h14ffc60_1
12+
- setuptools=72.1.0=py312haa95532_0
13+
- sqlite=3.45.3=h2bbff1b_0
14+
- tk=8.6.14=h0416ee5_0
15+
- vc=14.40=h2eaa2aa_0
16+
- vs2015_runtime=14.40.33807=h98bb1dd_0
17+
- wheel=0.43.0=py312haa95532_0
18+
- xz=5.4.6=h8cc25b3_1
19+
- zlib=1.2.13=h8cc25b3_1
20+
- pip:
21+
- asttokens==2.4.1
22+
- base58==2.1.1
23+
- beartype==0.18.5
24+
- cachetools==5.5.0
25+
- cfgv==3.4.0
26+
- chardet==5.2.0
27+
- codespell==2.3.0
28+
- colorama==0.4.6
29+
- comm==0.2.2
30+
- contourpy==1.2.1
31+
- coverage==7.6.7
32+
- crc==7.0.0
33+
- crcmod==1.7
34+
- cycler==0.12.1
35+
- debugpy==1.8.5
36+
- decorator==5.1.1
37+
- deepdiff==7.0.1
38+
- distlib==0.3.8
39+
- executing==2.0.1
40+
- filelock==3.15.4
41+
- fonttools==4.53.1
42+
- h5py==3.11.0
43+
- identify==2.6.0
44+
- imageio==2.37.0
45+
- iniconfig==2.0.0
46+
- ipykernel==6.29.5
47+
- ipython==8.26.0
48+
- ipywidgets==8.1.5
49+
- jaxtyping==0.2.31
50+
- jedi==0.19.1
51+
- jupyter-client==8.6.2
52+
- jupyter-core==5.7.2
53+
- jupyterlab-widgets==3.0.13
54+
- k-wave-python==0.3.4
55+
- kiwisolver==1.4.5
56+
- lazy-loader==0.4
57+
- matplotlib==3.9.0
58+
- matplotlib-inline==0.1.7
59+
- nest-asyncio==1.6.0
60+
- networkx==3.4.2
61+
- nibabel==5.3.2
62+
- nodeenv==1.9.1
63+
- numpy==1.26.4
64+
- nvidia-ml-py==12.570.86
65+
- opencv-python==4.10.0.84
66+
- openexr==3.3.2
67+
- ordered-set==4.1.0
68+
- packaging==24.1
69+
- pandas==2.2.2
70+
- parso==0.8.4
71+
- pillow==10.4.0
72+
- platformdirs==4.3.6
73+
- pluggy==1.5.0
74+
- pre-commit==3.8.0
75+
- prompt-toolkit==3.0.47
76+
- psutil==6.0.0
77+
- pure-eval==0.2.3
78+
- pygments==2.18.0
79+
- pynvml==12.0.0
80+
- pyparsing==3.1.2
81+
- pyproject-api==1.8.0
82+
- pyqt5==5.15.11
83+
- pyqt5-qt5==5.15.2
84+
- pyqt5-sip==12.15.0
85+
- pyqt6==6.8.1
86+
- pyqt6-qt6==6.8.2
87+
- pyqt6-sip==13.10.0
88+
- pyserial==3.5
89+
- pytest==8.3.3
90+
- pytest-cov==6.0.0
91+
- python-dateutil==2.9.0.post0
92+
- python-dotenv==1.0.1
93+
- pytz==2024.1
94+
- pyudev==0.24.3
95+
- pywin32==306
96+
- pywinusb==0.4.2
97+
- pyyaml==6.0.2
98+
- pyzmq==26.2.0
99+
- qasync==0.27.1
100+
- scikit-image==0.25.2
101+
- scipy==1.13.1
102+
- six==1.16.0
103+
- stack-data==0.6.3
104+
- tifffile==2025.3.13
105+
- tornado==6.4.1
106+
- tox==4.23.2
107+
- traitlets==5.14.3
108+
- typeguard==2.13.3
109+
- tzdata==2024.1
110+
- virtualenv==20.26.3
111+
- vtk==9.3.1
112+
- wcwidth==0.2.13
113+
- widgetsnbextension==4.0.13
114+
- xarray==2024.7.0

notebooks/test_console.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@
9393
print("Failed to turn on 12V.")
9494

9595
# Set High Voltage Level
96-
print("Set HV Power to +/- 45V")
97-
if interface.hvcontroller.set_voltage(voltage=45.0):
98-
print("Voltage set to 45.0 V.")
96+
print("Set HV Power to +/- 85V")
97+
if interface.hvcontroller.set_voltage(voltage=75.0):
98+
print("Voltage set to 85.0 V.")
9999
else:
100100
print("Failed to set voltage.")
101101

notebooks/test_pwr.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
interface.hvcontroller.ping()
2222

2323
print("Starting DAC value increments...")
24-
hvp_value = 2900
25-
hrp_value = 3750
26-
hrm_value = 3750
27-
hvm_value = 2900
24+
hvp_value = 2400
25+
hrp_value = 2095
26+
hrm_value = 2095
27+
hvm_value = 2400
2828

2929
print(f"Setting DACs: hvp={hvp_value}, hrp={hrp_value}, hvm={hvm_value}, hrm={hrm_value}")
3030
if interface.hvcontroller.set_dacs(hvp=hvp_value, hrp=hrp_value, hvm=hvm_value, hrm=hrm_value):

notebooks/test_updated_if.py

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from __future__ import annotations
22

3+
import sys
4+
from asyncio import sleep
5+
36
import numpy as np
47

58
from openlifu.bf.pulse import Pulse
@@ -24,7 +27,35 @@
2427
else:
2528
print(f'LIFU Device NOT Fully Connected. TX: {tx_connected}, HV: {hv_connected}')
2629

27-
print("Ping the device")
30+
if hv_connected:
31+
print("Ping Console device")
32+
interface.hvcontroller.ping()
33+
34+
print("Turn 12V ON")
35+
interface.hvcontroller.turn_12v_on()
36+
sleep(2)
37+
else:
38+
print("HV Controller not connected.")
39+
sys.exit()
40+
41+
42+
if interface.txdevice.is_connected():
43+
print("LIFU Transmitter device connected.")
44+
print("Ping Transmitter device")
45+
interface.txdevice.ping()
46+
else:
47+
print("Transmitter device not connected.")
48+
sys.exit()
49+
50+
print("Set HV to 20V")
51+
interface.hvcontroller.set_voltage(20.0)
52+
53+
# Get Set High Voltage Setting
54+
print("Get Current HV Voltage")
55+
read_voltage = interface.hvcontroller.get_voltage()
56+
print(f"HV Voltage {read_voltage} V.")
57+
58+
print("Ping Transmitter device")
2859
interface.txdevice.ping()
2960

3061
print("Toggle LED")
@@ -108,34 +139,10 @@
108139
else:
109140
print("Failed to get trigger setting.")
110141

111-
print("Starting Trigger...")
112-
if interface.txdevice.start_trigger():
113-
print("Trigger Running Press enter to STOP:")
114-
input() # Wait for the user to press Enter
115-
if interface.txdevice.stop_trigger():
116-
print("Trigger stopped successfully.")
117-
else:
118-
print("Failed to stop trigger.")
119-
else:
120-
print("Failed to get trigger setting.")
121142

122-
print("Set Trigger")
123-
json_trigger_data = {
124-
"TriggerFrequencyHz": 25,
125-
"TriggerPulseCount": 0,
126-
"TriggerPulseWidthUsec": 20000,
127-
"TriggerPulseTrainInterval": 0,
128-
"TriggerPulseTrainCount": 0,
129-
"TriggerMode": 1,
130-
"ProfileIndex": 0,
131-
"ProfileIncrement": 0
132-
}
133-
134-
trigger_setting = interface.txdevice.set_trigger_json(data=json_trigger_data)
135-
if trigger_setting:
136-
print(f"Trigger Setting: {trigger_setting}")
137-
else:
138-
print("Failed to set trigger setting.")
143+
144+
print("Turn HV ON")
145+
interface.hvcontroller.turn_hv_on()
139146

140147
print("Starting Trigger...")
141148
if interface.txdevice.start_trigger():
@@ -146,7 +153,10 @@
146153
else:
147154
print("Failed to stop trigger.")
148155
else:
149-
print("Failed to start trigger.")
156+
print("Failed to get trigger setting.")
157+
158+
print("Turn HV OFF")
159+
interface.hvcontroller.turn_hv_off()
150160

151161
print("Reset Device:")
152162
# Ask the user for confirmation

src/openlifu/io/LIFUInterface.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,19 @@ def start_sonication(self) -> bool:
166166
if self._test_mode:
167167
return True
168168

169+
logger.info("Turn ON HV")
170+
bHvOn = self.hvcontroller.turn_hv_on()
171+
169172
logger.info("Start Sonication")
170173
# Send the solution data to the device
171-
return self.txdevice.start_trigger()
174+
bTriggerOn = self.txdevice.start_trigger()
175+
176+
if bTriggerOn and bHvOn:
177+
logger.info("Sonication started successfully.")
178+
return True
179+
else:
180+
logger.error("Failed to start sonication.")
181+
return False
172182

173183
except ValueError as v:
174184
logger.error("ValueError: %s", v)
@@ -203,7 +213,15 @@ def stop_sonication(self) -> bool:
203213

204214
logger.info("Stop Sonication")
205215
# Send the solution data to the device
206-
return self.txdevice.stop_trigger()
216+
bTriggerOff = self.txdevice.stop_trigger()
217+
bHvOff = self.hvcontroller.turn_hv_off()
218+
219+
if bTriggerOff and bHvOff:
220+
logger.info("Sonication stopped successfully.")
221+
return True
222+
else:
223+
logger.error("Failed to stop sonication.")
224+
return False
207225

208226
except ValueError as v:
209227
logger.error("ValueError: %s", v)

0 commit comments

Comments
 (0)