Last active
June 19, 2023 09:34
-
-
Save stefanherdy/5711937f02f6fa0e84e2ce6f26ac28d6 to your computer and use it in GitHub Desktop.
This script can be used to controll the Bronkhorst Gas Flow Controllers
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
#!/usr/bin/env python3 | |
""" | |
Script Name: bronkhorst-propar_set_bronkhorst_massflow_controller.py | |
Author: Stefan Herdy | |
Date: 13.12.2019 | |
Description: | |
This script can be used to controll the Bronkhorst Gas Flow Controllers | |
Usage: | |
- Install the bronkhorst-propar package (pip install bronkhorst-propar) | |
- use the functions below to controll the gas flow | |
""" | |
import propar | |
import time | |
def MFCinit(node): | |
el_flow = propar.instrument(node) | |
return el_flow | |
def setGasFlow(percent, el_flow): | |
# Connect to the local instrument, when no settings provided | |
# defaults to locally connected instrument (address=0x80, baudrate=38400) | |
# The setpoint and measure parameters are available | |
# as properties, for ease of use. | |
# el_flow.setpoint = 15000 | |
MES_MODE = 0 | |
el_flow.write(1, 4, propar.PP_TYPE_INT8, MES_MODE) | |
SETPOINT_SLOPE = 0.5 | |
el_flow.write(1, 2, propar.PP_TYPE_INT16, SETPOINT_SLOPE) | |
# The instruments are scaled from 0 to 32000 | |
fval = percent/100*32000 | |
t = el_flow.write(1, 1, propar.PP_TYPE_INT16, int(fval)) | |
# print(x) | |
time.sleep(SETPOINT_SLOPE) | |
# All parameters can be read using the process and parameter numbers, | |
# as well as the parameters data type. | |
# read the parameter to double-check if mass flow is actually set | |
set_param = el_flow.read(1, 1, propar.PP_TYPE_INT16) | |
return set_param | |
if __name__ == "__main__": | |
# We used Raspbian as OS for our project | |
# Specify the instrument node adress according to your OS | |
node = '/dev/ttyUSB0' | |
MFCinit() | |
set_param = setGasFlow(int(input('Enter Flow Value in %: '))) | |
print('Gas Flow set to: ' + str(int(set_param/32000*100)) + ' %') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment