- G-code 50.7%
- Jupyter Notebook 48%
- Python 1%
- C++ 0.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| Enderscopy_Control | ||
| Lecture_pH | ||
| pH_Probe_Control | ||
| Piece_3D | ||
| Pump_Control | ||
| .gitignore | ||
| Interface.py | ||
| README.md | ||
Projet instrumentation
Commander l’électrode pH
https://wiki.dfrobot.com/sen0161-v2/docs/20941
Matériel
- SEN0161-V2 Gravity: Analog pH Sensor V2 x1
- Standard Buffer Solution 4.0(Included with SEN0161-V2) x1
- Standard Buffer Solution 7.0(Included with SEN0161-V2) x1
- DFR0216-2 DFRduino UNO R3 with IO Expansion Shield and USB Cable A-B x1 (carte électronique (c’est l’arduino en fait)qui reçoit le signal de l'électrode et le transforme en un signal que l'Arduino peut lire)
- FIT0897 Gravity: Analog Sensor Cable for Arduino(Included with SEN0161-V2) x1
- cable pour relier arduino à l’ordinateur
Brancher l’électrode comme ceci
et brancher l’arduino à un port USB de l’ordi.
avoir téléchargé et installé la bibliothèque https://www.arduinolibraries.info/libraries/df-robot_ph
et l’uploader dans le logiciel arduino IDE
Sketch, include library et sélectionner le fichier zip
dans le terminal de l’ordinateur sélectionner le port auquel est branché arduino en tapant: sudo chmod a+rw /dev/ttyACM0
\* file DFRobot\_PH.ino
\* @ https\://github.com/DFRobot/DFRobot\_PH
\*
\* This is the sample code for Gravity: Analog pH Sensor / Meter Kit V2, SKU:SEN0161-V2
\* In order to guarantee precision, a temperature sensor such as DS18B20 is needed, to execute automatic temperature compensation.
\* You can send commands in the serial monitor to execute the calibration.
\* Serial Commands:
\* enterph \-\> enter the calibration mode
\* calph \-\> calibrate with the standard buffer solution, two buffer solutions(4.0 and 7.0) will be automaticlly recognized
\* exitph \-\> save the calibrated parameters and exit from calibration mode
\*
\* Copyright \[DFRobot\](http\://www\.dfrobot.com), 2018
\* Copyright GNU Lesser General Public License
\*
\* version V1.0
\* date 2018-04
\*/
\#include "DFRobot\_PH.h"
\#include \<EEPROM.h\>
\#define PH\_PIN A1
float voltage,phValue,temperature \= 25;
DFRobot\_PH ph;
void setup()
{
Serial.begin(115200);
ph.begin();
}
void loop()
{
static unsigned long timepoint \= millis();
if(millis()\-timepoint\>1000U){ //time interval: 1s
timepoint \= millis();
//temperature \= readTemperature(); // read your temperature sensor to execute temperature compensation
voltage \= analogRead(PH\_PIN)/1024.0\*5000; // read the voltage
phValue \= ph.readPH(voltage,temperature); // convert voltage to pH with temperature compensation
Serial.print("temperature:");
Serial.print(temperature,1);
Serial.print("^C pH:");
Serial.println(phValue,2);
}
ph.calibration(voltage,temperature); // calibration process by Serail CMD
}
float readTemperature()
{
//add your code here to get the temperature from your temperature sensor
}
je compile et j’upload
outils moniteur série(Tools, serial monitor), je séléctionne la valeur qu’il y a dans le code
Serial.begin(115200);
donc 115200 bud
ça affiche ça
temperature:25.0^C pH:7.56
temperature:25.0^C pH:7.58
temperature:25.0^C pH:7.58
temperature:25.0^C pH:7.58
temperature:25.0^C pH:7.58
temperature:25.0^C pH:7.58
temperature:25.0^C pH:7.61
temperature:25.0^C pH:7.61
temperature:25.0^C pH:7.58
temperature:25.0^C pH:7.58
temperature:25.0^C pH:7.56
etc en continu
Calibration pH 7
Programme Python pour récupérer infos de l'électrode
dans terminal linux
sudo apt install python3-pip
Si tu fermes tout et reprends demain :
cd \[ton dossier de projet\]
Puis :
source pH\_arduino/bin/activate
Tu dois voir :
(pH\_arduino)
Puis, Arduino branché :
python3 \-m serial.tools.list\_ports
et vérifier que /dev/ttyACM0 apparaît.
emi@chimie6:\~\$ python3 \-m venv pH\_arduino
emi@chimie6:\~\$ source pH\_arduino/bin/activate
(pH\_arduino) emi@chimie6:\~\$ cd "/home/emi/Downloads/ENS 2e année/instrumentation"
(pH\_arduino) emi@chimie6:\~/Downloads/ENS 2e année/instrumentation\$ python3 test\_arduino.py
et à coté j’ai créé le fichier test_arduino.py dans l’éditeur texte et dans ce fichier, j’ai écrit ça
import serial
import time \#module python qui donne accès aux fonctions liées au temps
import csv
from datetime import datetime
arduino \= serial.Serial('/dev/ttyACM0', 115200\)
time.sleep(2) \#on laisse 2s à l'arduino pour démarrer
arduino.reset\_input\_buffer() \#on jette les anciennes données
debut \= time.time() \#on mesure le temps depuis le lancement du programme
nom\_fichier \= "mesures\_ph\_" \+ datetime.now().strftime("%Y-%m-%d\_%H-%M-%S") \+ ".csv"
with open(nom\_fichier, "w", newline="") as fichier:
writer \= csv.writer(fichier)
writer.writerow(\["temps\_s", "pH"\])
while True:
ligne \= arduino.readline().decode().strip()
if "pH:" in ligne:
pH \= float(ligne.split("pH:")\[1\])
temps \= time.time() \- debut
print("Temps \=", round(temps, 1), "s | pH \=", pH)
writer.writerow(\[round(temps, 1), pH\])
fichier.flush()
Tracer la courbe et calculer le volume équivalent
https://github.com/TobiasTR/jupyter-titration-curve/blob/master/titration-curve.ipynb
écrire dans le terminal
jupyter lab
ça ouvre jupyter dans chrome
Contrôle de la pompe avec python
La pompe est contrôlée via le module Pump_Control. Les fonctionnalités sont une mise à jour des débits avec la fonction self.set_rates(IRATE, WRATE) ainsi qu'un débit de liquide avec les fonction WITHDRAW_VOLUME et INFUSE_VOLUME. Ces fonctions sont utilisées pour réaliser le titrage