Skip to content
Extraits de code Groupes Projets
Valider 1a8d921a rédigé par Nicolas Roisin's avatar Nicolas Roisin
Parcourir les fichiers

equipment script

parent 694f0f51
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 238 ajouts et 147 suppressions
......@@ -3,8 +3,8 @@
## Description
Data analysis and Operation Software (DOpeS) provides a set of tools for
1. Data analysis for data coming from lab equipment such as Raman spectrometer, white-light interferometer, ...
2. Controlling lab equipment such as multimeter, source measurement units, pressure generator, climatic chamber, monochromator, ...
1. the analysis of data coming from lab equipment such as Raman spectrometer, white-light interferometer, ...
2. the control of lab equipment such as multimeter, source measurement units, pressure generator, climatic chamber, monochromator, ...
## Structure
- **data_analysis** for the analysis of lab equipment:
......@@ -18,18 +18,13 @@ Data analysis and Operation Software (DOpeS) provides a set of tools for
- Monochromator *CM110*
- Pressure generator and monitor *KAL100*
- Climatic chamber *SH242* (sh242.py)
- script examples for the equipments
## Requirements
DOpeS is made from functions, classes and scripts based on Python programming lanquage. The following packages are required for the data analysis and the equipment control:
- <a href=https://pypi.org/project/numpy/> **Numpy** </a> for the data handling and processing
- <a href=https://pypi.org/project/scipy/> **SciPy** </a> for the data processing tools such as interpolation and filtering (only for *data_analysis* part)
- <a href=https://pypi.org/project/PyVISA/> **Pyvisa** </a> for the communication with equipment (only for *equipment_control* part)
The python packages can be installed from python the Python Package Index (pip):
```
pip install numpy, scipy, pyvisa
```
- <a href=https://pypi.org/project/pyserial/> **Pyserial** </a> for the serial communication with equipment (only for *equipment_control* part)
## Installation
......@@ -52,7 +47,7 @@ import sys
sys.path.insert(1, '/path/to/dopes')
```
The various tools can then be accessed as any python packages and classes:
The various tools can then be accessed as any python package and class:
```
import equipment_control.equipment as eq
import equipment_control.k2400 as k2400
......@@ -64,7 +59,7 @@ import data_analysis.raman as ram
We welcome any feedback on issued, missing operation or equipment but also idea for further improvements.
## Authors and acknowledgment
The intitial idea of this project has been thought by **Loïc Lahaye** with the help of **Nicolas Roisin**.
The initial idea of this project has been thought by **Loïc Lahaye** with the help of **Nicolas Roisin**.
## License
DOpeS © 2025 by Loïc Lahaye and Nicolas Roisin is licensed under <a href=https://creativecommons.org/licenses/by-nc-sa/4.0/> Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International </a> (<a href=https://creativecommons.org/licenses/by-nc-sa/4.0/> CC BY-NC-SA 4.0</a>)
......
# ChOpeS
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://forge.uclouvain.be/LocLahaye/chopes.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://forge.uclouvain.be/LocLahaye/chopes/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
Fichier ajouté
Aucun aperçu pour ce type de fichier
Fichier ajouté
......@@ -39,7 +39,7 @@ class cm110(equipment.equipment):
self.serial_resource.write(serial.to_bytes(reset))
time.sleep(waiting_time)
def set_wavelength(self, wavelength,waiting_time=10):
def set_wavelength(self, wavelength,waiting_time=5):
""" Function to set the wavelength of the monochromator
args:
......@@ -50,6 +50,14 @@ class cm110(equipment.equipment):
self.serial_resource.write(serial.to_bytes(set_position))
time.sleep(waiting_time)
def select_grating(self, grating_number,waiting_time=30):
""" Function to select the gratin
- grating_number (int) : select the grating (Grating 1 : AG2400-00240-303 (2400 G/mm and 180 nm - 680 nm) and Grating 2 : AG1200-00750-303 (1200 G/mm and 480 nm - 1500 nm))
- waiting_time (int) : waiting time in seconds after changing the grating and reset to the initial position
"""
self.serial_resource.write(serial.to_bytes([26,grating_number]))
time.sleep(waiting_time)
def close_connection(self):
""" Function to close the serial connection with the equipment """
self.serial_resource.close()
......
# =============================================================================
# 1. Import classes and modules
# =============================================================================
import sys
#sys.path.insert(1, '/path/to/application/app/folder')
sys.path.insert(1, 'D:/Roisin/Documents/chopes')
import equipment_control.equipment as eq
import equipment_control.cm110 as cm110
# =============================================================================
# 2. List available connections (chopes use pyvisa package for communicate with most equipments)
# =============================================================================
rm=eq.resource_manager()
list_connections= eq.available_connections()
print("Available connections: %s"%str(list_connections))
# =============================================================================
# 3. Connection to the equipments
# =============================================================================
mycm110=cm110.cm110('COM5') # serial link through port COM5
# =============================================================================
# 4. Measurement parameters
# =============================================================================
wavelength=600
grating=1 # Grating 1 : AG2400-00240-303 (2400 G/mm and 180 nm - 680 nm) and Grating 2 : AG1200-00750-303 (1200 G/mm and 480 nm - 1500 nm)
# =============================================================================
# 5. Initialization of the equipment
# =============================================================================
mycm110.initialize(grating_number=grating,waiting_time=30)
# =============================================================================
# 6. Set wavelength
# =============================================================================
# mycm110.set_wavelength(wavelength,waiting_time=1)
# =============================================================================
# 7. Close connection
# =============================================================================
mycm110.close_connection()
\ No newline at end of file
......@@ -20,7 +20,7 @@ list_connections= eq.available_connections()
print("Available connections: %s"%str(list_connections))
# =============================================================================
# 3. Connection to the equipments
# 3. Connection to the equipment
# =============================================================================
mydmm=dmm.dmm('USB0::0x05E6::0x6500::04529651::INSTR',timeout=1e3)
......@@ -31,7 +31,6 @@ units={"voltage":"V", "current":"A", "resistance":"Ohms", "4wires":"Ohms"}
mode="current"
autozero=True
offset_compensation=True
nplc=1
digits=4
continuous_trigger = False
......@@ -41,11 +40,10 @@ file_path='temp.txt'
t_init=time.time()
# =============================================================================
# 5. Initialization of the equipments
# 5. Initialization of the equipment
# =============================================================================
mydmm.initialize( mode=mode, autozero=autozero, offset_compensation=offset_compensation,
continuous_trigger=continuous_trigger, digits=digits,nplc=nplc,disp_enable=disp_enable
,k2000=k2000)
mydmm.initialize( mode=mode, autozero=autozero, continuous_trigger=continuous_trigger,
digits=digits,nplc=nplc,disp_enable=disp_enable,k2000=k2000)
# =============================================================================
# 6. Measurement script
......
......@@ -19,7 +19,7 @@ list_connections= eq.available_connections(rm=rm) # you can use the function fro
print("-------------------------------------------------\n Available connections: %s"%str(list_connections))
# =============================================================================
# 3. Connection to the equipments
# 3. Connection to the equipment
# =============================================================================
myHP4145=hp4145.hp4145("GPIB0::1::INSTR",timeout=100e3)
......@@ -35,13 +35,13 @@ smu_bias={"SMU1":10,"SMU2":0,"SMU3":0,"SMU4":0}
smu_compliance={"SMU1":1e-6,"SMU2":1e-6,"SMU3":1e-6,"SMU4":1e-6}
sweep_param={"start":0,"stop":1,"step":0.05}
sweep_type="linear"
integration_mode="IT1"
integration_mode="S"
delay_time=0
hold_time=0
# =============================================================================
# 5. Initialization of the equipments
# 5. Initialization of the equipment
# =============================================================================
print("-------------------------------------------------\n Starting initialisation ...", end='')
......
......@@ -20,7 +20,7 @@ list_connections= eq.available_connections()
print("Available connections: %s"%str(list_connections))
# =============================================================================
# 3. Connection to the equipments
# 3. Connection to the equipment
# =============================================================================
myk2400=k2400.k2400("GPIB0::29::INSTR",timeout=1e3)
......@@ -33,7 +33,6 @@ source_mode = "current"
measurement_mode = "voltage"
compliance = 1
autozero = True
offset_compensation = True
nplc = 1
digits = 6
continuous_trigger = False
......@@ -42,11 +41,11 @@ bias_source = 1e-6
file_path = 'temp.txt'
t_init=time.time()
# =============================================================================
# 5. Initialization of the equipments
# 5. Initialization of the equipment
# =============================================================================
myk2400.initialize(source_mode=source_mode, measurement_mode=measurement_mode,
compliance=compliance, autozero=autozero, offset_compensation=offset_compensation,
digits=digits,continuous_trigger=continuous_trigger,disp_enable=disp_enable, nplc=nplc)
compliance=compliance, autozero=autozero, digits=digits,
continuous_trigger=continuous_trigger,disp_enable=disp_enable, nplc=nplc)
# =============================================================================
# 6. Measurement script
......
......@@ -20,7 +20,7 @@ list_connections= eq.available_connections()
print("Available connections: %s"%str(list_connections))
# =============================================================================
# 3. Connection to the equipments
# 3. Connection to the equipment
# =============================================================================
myk2450=k2450.k2450("GPIB0::29::INSTR",timeout=5e3)
......@@ -33,7 +33,6 @@ source_mode = "voltage"
measurement_mode = "current"
compliance = 1e-6
autozero = True
offset_compensation = True
nplc = 1
digits = 6
continuous_trigger = True
......@@ -42,11 +41,11 @@ bias_source = 1
file_path = 'temp.txt'
t_init=time.time()
# =============================================================================
# 5. Initialization of the equipments
# 5. Initialization of the equipment
# =============================================================================
myk2450.initialize(source_mode=source_mode, measurement_mode=measurement_mode,
compliance=compliance, autozero=autozero, offset_compensation=offset_compensation,
digits=digits,continuous_trigger=continuous_trigger,disp_enable=disp_enable, nplc=nplc)
compliance=compliance, autozero=autozero, digits=digits,
continuous_trigger=continuous_trigger,disp_enable=disp_enable, nplc=nplc)
# =============================================================================
# 6. Measurement script
......
......@@ -12,14 +12,14 @@ import traceback # to write error message in try/except command
import datetime
# =============================================================================
# 2. List available connections (chopes use pyvisa package for communicate with most equipments)
# 2. List available connections
# =============================================================================
rm=eq.resource_manager() # you can use the function from equipment class or directly the pyvisa command rm = pyvisa.ResourceManager()
list_connections= eq.available_connections(rm=rm) # you can use the function from equipment class or directly the pyvisa command rm.list_resources()
print("-------------------------------------------------\n Available connections: %s"%str(list_connections))
# =============================================================================
# 3. Connection to the equipments
# 3. Connection to the equipment
# =============================================================================
myK4200=k4200.k4200("GPIB0::17::INSTR",timeout=10e3)
......@@ -41,7 +41,7 @@ hold_time=0
# =============================================================================
# 5. Initialization of the equipments
# 5. Initialization of the equipment
# =============================================================================
print("-------------------------------------------------\n Starting initialisation ...", end='')
......@@ -70,10 +70,10 @@ myK4200.close_connection()
# 8. Save data
# =============================================================================
custom_header="IV results with K4200\n"
comment_delimiter="#"
print("-------------------------------------------------\n Print in file %s"%file_path)
print(" - Header:")
print(" # %s"%(datetime.datetime.now().strftime("%c")))
for line in (custom_header+data_header).split('\n'):
print(" # "+line)
myK4200.write_in_file(file_path,data,overwrite=True,header=custom_header+data_header)
myK4200.write_in_file(file_path,data,overwrite=True,header=custom_header+data_header,comment=comment_delimiter)
# =============================================================================
# 1. Import classes and modules
# =============================================================================
import sys
#sys.path.insert(1, '/path/to/application/app/folder')
sys.path.insert(1, 'D:/Roisin/Documents/chopes')
import equipment_control.equipment as eq
import equipment_control.kal100 as kal100
# =============================================================================
# 2. List available connections (chopes use pyvisa package for communicate with most equipments)
# =============================================================================
rm=eq.resource_manager()
list_connections= eq.available_connections()
print("Available connections: %s"%str(list_connections))
# =============================================================================
# 3. Connection to the equipments
# =============================================================================
mykal100=kal100.kal100('COM7') # serial link through port COM7
# =============================================================================
# 4. Measurement parameters
# =============================================================================
pressure=1 # in kPa
# =============================================================================
# 5. Initialization of the equipment
# =============================================================================
mykal100.initialize(units="hPa")
# =============================================================================
# 6. Set wavelength
# =============================================================================
mykal100.set_pressure(pressure)
# =============================================================================
# 7. Close connection
# =============================================================================
mykal100.close_connection()
# =============================================================================
# 1. Import classes and modules
# =============================================================================
import sys
#sys.path.insert(1, '/path/to/application/app/folder')
sys.path.insert(1, 'D:/Roisin/Documents/chopes')
import equipment_control.equipment as eq
import equipment_control.sh242 as sh242
# =============================================================================
# 2. List available connections (chopes use pyvisa package for communicate with most equipments)
# =============================================================================
rm=eq.resource_manager()
list_connections= eq.available_connections()
print("Available connections: %s"%str(list_connections))
# =============================================================================
# 3. Connection to the equipments
# =============================================================================
mysh242=sh242.sh242('USB0::0x05E6::0x6500::04529651::INSTR',timeout=1e3)
# =============================================================================
# 4. Measurement parameters
# =============================================================================
temperature=30
humidity=50
wait_for_stabilization=True # if True, wait for the temperature and humidity to be stabilized to continue the script
# =============================================================================
# 5. Initialization of the equipment
# =============================================================================
mysh242.initialize(temperature=True, humidity=True,temperature_dic={"upper":125,"lower":-45,"set":20},humidity_dic={"upper":100,"lower":0,"set":55})
# =============================================================================
# 6. Read temperature and humidity
# =============================================================================
data_temperature=mysh242.read_temperature()
data_humidity=mysh242.read_humidity()
print("\n- Temperature: %.2f °C\n- Humidity: %.2f %%"%(data_temperature,data_humidity))
# =============================================================================
# 7. Set temperature and humidity
# =============================================================================
mysh242.set_temperature(temperature,wait_for_stabilization=wait_for_stabilization)
mysh242.set_humidity(humidity,wait_for_stabilization=wait_for_stabilization)
# =============================================================================
# 8. Close connection
# =============================================================================
mysh242.close_connection()
\ No newline at end of file
......@@ -20,10 +20,11 @@ class kal100(equipment.equipment):
baudrate=9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS
bytesize=serial.EIGHTBITS,
timeout=10
)
def initialize(self,units="kPa",percentage=100, mode_operation="MS", mode_input="positive"):
def initialize(self,units="kPa",percentage=100, mode_operation="MS", mode_input="positive",zero_adjust=True):
""" Function to initialize the KAL100
args:
......@@ -33,26 +34,30 @@ class kal100(equipment.equipment):
- mode_input (string) : Positive P-input ("positive"), Negative P-input ("negative"), Differential pressure measurement ("differential")
"""
units_dic={"kPa":0,"Pa":1,"hPa":0}
units_dic={"kPa":0,"Pa":1,"hPa":2}
mode_dic={"positive":"MI0","negative":"MI1","differential":"MI2"}
self.units=units
self.serial_resource.write(">PD%d"%units_dic[units])
time.sleep(1)
self.serial_resource.write(">PP%d"%percentage) # percentage of the target
time.sleep(1)
# self.serial_resource.write(str.encode(">PD%d\n"%units_dic[units]))
# self.serial_resource.read_until(b'\r')
self.serial_resource.write(str.encode(">PE%d\n"%units_dic[units]))
self.serial_resource.read_until(b'\r')
self.serial_resource.write(str.encode(">PP%d\n"%percentage)) # percentage of the target
self.serial_resource.read_until(b'\r')
self.serial_resource.write("%s"%mode_dic[mode_input]) # MI0: Positive P-input, MI1: Negative P-input, MI2: Differential pressure measurement
time.sleep(1)
self.serial_resource.write(str.encode("%s\n"%mode_dic[mode_input])) # MI0: Positive P-input, MI1: Negative P-input, MI2: Differential pressure measurement
self.serial_resource.read_until(b'\r')
self.serial_resource.write("MZ") # mode zeroing
time.sleep(1)
self.serial_resource.write("%s"%mode_operation) #MT: mode test, MZ: mode zeroing, MS: mode target value, MP: mode pressure measurement
time.sleep(1)
if zero_adjust:
self.serial_resource.write(str.encode("MZ\n")) # mode zeroing
self.serial_resource.read_until(b'\r')
time.sleep(10)
self.serial_resource.write(str.encode("%s\n"%mode_operation)) #MT: mode test, MZ: mode zeroing, MS: mode target value, MP: mode pressure measurement
self.serial_resource.read_until(b'\r')
if mode_operation=="MS":
self.serial_resource.write("PS%3.5f"%0)
time.sleep(1)
self.serial_resource.write(str.encode(">PS%3.5f\n"%0))
self.serial_resource.read_until(b'\r')
def set_pressure(self,pressure):
""" Function to set pressure level of the KAL100
......@@ -60,10 +65,13 @@ class kal100(equipment.equipment):
args:
- pressure (scalar) : targeted pressure
"""
self.serial_resource.write("MS")
time.sleep(1)
self.serial_resource.write("PS%3.5f"%pressure)
time.sleep(1)
units_mult={"kPa":10,"Pa":1e-3,"hPa":1}
self.serial_resource.write(str.encode("MS\n"))
self.serial_resource.read_until(b'\r')
self.serial_resource.write(str.encode(">PS%3.5f\n"%(pressure*units_mult[self.units])))
# self.serial_resource.write(str.encode(">PS%3.5f\n"%(pressure)))
self.serial_resource.read_until(b'\r')
def close_connection(self):
""" Function to close the serial connection with the equipment """
......
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 20 11:42:02 2025
@author: nroisin
"""
import serial
import pyvisa
rm = pyvisa.ResourceManager()
print(rm.list_resources())
mykal100=serial.Serial(
port="COM7",
baudrate=9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=10
)
mykal100.write(str.encode('MS\n'))
print(mykal100.read_until(b'\r'))
mykal100.write(str.encode('>PD0\n'))
print(mykal100.read_until(b'\r'))
# mykal100.write(str.encode('>PP100\n'))
# print(mykal100.read())
# mykal100.write('MZ\n'.encode('utf-8'))
# mykal100.write('?PS\n'.encode('ascii'))
# print(mykal100.readline())
# mykal100.write('MZ\n'.encode('ascii'))
mykal100.close()
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter