Commit 4a165399 authored by Clement Remi's avatar Clement Remi
Browse files

update

Showing with 909 additions and 5 deletions
+909 -5
2022-01-24-150110_1920x1080_scrot.png

1.2 MB

2022-01-24-150201_1920x1080_scrot.png

1.21 MB

2022-01-24-150447_1920x1080_scrot.png

1.25 MB

2022-01-24-150500_1920x1080_scrot.png

1.25 MB

...@@ -12,7 +12,7 @@ print('\ \_/ / | | || | | || | _| |_') ...@@ -12,7 +12,7 @@ print('\ \_/ / | | || | | || | _| |_')
print(' \___/\_| |_/\_| |_/\_| \___/ ') print(' \___/\_| |_/\_| |_/\_| \___/ ')
print('\033[0m') print('\033[0m')
print('OhmPi 4 elec start' ) print('OhmPi 4 elec start' )
print('Vers: 1.00') print('Vers: 1.01')
print('Import library') print('Import library')
...@@ -24,6 +24,7 @@ from pandas import DataFrame ...@@ -24,6 +24,7 @@ from pandas import DataFrame
from datetime import datetime from datetime import datetime
from adafruit_mcp230xx.mcp23008 import MCP23008 from adafruit_mcp230xx.mcp23008 import MCP23008
from adafruit_mcp230xx.mcp23017 import MCP23017 from adafruit_mcp230xx.mcp23017 import MCP23017
from termcolor import colored
import digitalio import digitalio
from digitalio import Direction from digitalio import Direction
from gpiozero import CPUTemperature from gpiozero import CPUTemperature
...@@ -33,6 +34,8 @@ print(current_time.strftime("%Y-%m-%d %H:%M:%S")) ...@@ -33,6 +34,8 @@ print(current_time.strftime("%Y-%m-%d %H:%M:%S"))
hardware parameters hardware parameters
""" """
R_shunt = 2# reference resistance value in ohm R_shunt = 2# reference resistance value in ohm
Imax=4800/50/2
print(colored(('The maximum current cannot be higher than ',Imax, 'mA'), 'red'))
coef_p2 = 2.50# slope for current conversion for ADS.P2, measurement in V/V coef_p2 = 2.50# slope for current conversion for ADS.P2, measurement in V/V
coef_p3 = 2.50 # slope for current conversion for ADS.P3, measurement in V/V coef_p3 = 2.50 # slope for current conversion for ADS.P3, measurement in V/V
offset_p2= 0 offset_p2= 0
...@@ -50,8 +53,8 @@ with open('ohmpi_param.json') as json_file: ...@@ -50,8 +53,8 @@ with open('ohmpi_param.json') as json_file:
i2c = busio.I2C(board.SCL, board.SDA) #activation du protocle I2C i2c = busio.I2C(board.SCL, board.SDA) #activation du protocle I2C
mcp = MCP23008(i2c, address=0x20) #connexion I2C MCP23008, injection de courant mcp = MCP23008(i2c, address=0x20) #connexion I2C MCP23008, injection de courant
ads_current = ADS.ADS1115(i2c, gain=2/3,data_rate=860, address=0X48)# connexion ADS1115, pour la mesure de courant ads_current = ADS.ADS1115(i2c, gain=2/3,data_rate=128, address=0X48)# connexion ADS1115, pour la mesure de courant
ads_voltage = ADS.ADS1115(i2c, gain=2/3,data_rate=860, address=0X49)# connexion ADS1115, pour la mesure de voltage ads_voltage = ADS.ADS1115(i2c, gain=2/3,data_rate=128, address=0X49)# connexion ADS1115, pour la mesure de voltage
#initialisation desvoie pour la polarité #initialisation desvoie pour la polarité
pin0 = mcp.get_pin(0) pin0 = mcp.get_pin(0)
pin0.direction = Direction.OUTPUT pin0.direction = Direction.OUTPUT
......
No preview for this file type
{ {
"nb_electrodes": 64, "nb_electrodes": 64,
"injection_duration": 4, "injection_duration":0.2,
"nbr_meas": 100, "nbr_meas": 100,
"sequence_delay": 1, "sequence_delay": 1,
"stack": 1, "stack": 1,
"export_path": "/home/pi/ohmpi/ohmpi/master/measurement.csv" "export_path": "/home/pi/Documents/OhmPi/measurement.csv"
} }
...@@ -3,6 +3,7 @@ libraries to install using the package manager : libatlas-base-dev ...@@ -3,6 +3,7 @@ libraries to install using the package manager : libatlas-base-dev
python libraries dependencies : python libraries dependencies :
Adafruit-Blinka==3.2.0 Adafruit-Blinka==3.2.0
adafruit-circuitpython-ads1x15==2.1.1 adafruit-circuitpython-ads1x15==2.1.1
adafruit-circuitpython-mcp230xx==2.5.1
adafruit-circuitpython-busdevice==4.0.1 adafruit-circuitpython-busdevice==4.0.1
Adafruit-PlatformDetect==1.3.8 Adafruit-PlatformDetect==1.3.8
adafruit-circuitpython-tca9548a==0.5.1 adafruit-circuitpython-tca9548a==0.5.1
......
"""
Created on Tue Dec 7 06:39:33 2021
Code for testing switch MUX for ohmpi 2
@author: remi.clement
"""
import time , board, busio,adafruit_tca9548a
from adafruit_mcp230xx.mcp23017 import MCP23017
import digitalio
from digitalio import Direction
address=0X70# choose the mux board address
activation_time=1 # choose your activation time in second
i2c = busio.I2C(board.SCL, board.SDA) #activation du protocle I2C
def switch_mux_on(electrode,address):
tca= adafruit_tca9548a.TCA9548A(i2c, address)
if electrode < 17:
nb_i2C=7
a=electrode
elif electrode > 16 and electrode< 33:
nb_i2C=6
a=electrode-16
elif electrode > 32 and electrode < 49:
nb_i2C=5
a=electrode-32
elif electrode > 48 and electrode < 65:
nb_i2C=4
a=electrode-48
mcp2 = MCP23017(tca[nb_i2C])
mcp2.get_pin(a-1).direction=Direction.OUTPUT
mcp2.get_pin(a-1).value=True
def switch_mux_off(electrode,address):
tca= adafruit_tca9548a.TCA9548A(i2c, address)
if electrode < 17:
nb_i2C=7
a=electrode
elif electrode > 16 and electrode < 33:
nb_i2C=6
a=electrode-16
elif electrode > 32 and electrode < 49:
nb_i2C=5
a=electrode-32
elif electrode > 48 and electrode < 65:
nb_i2C=4
a=electrode-48
mcp2 = MCP23017(tca[nb_i2C])
mcp2.get_pin(a-1).direction=digitalio.Direction.OUTPUT
mcp2.get_pin(a-1).value=False
a=input(' if vous want try 1 channel choose 1, if you want try all channel choose 2!')
if a=='1':
b=0
print ("run channel by channel test")
electrode=int(input(' Choose your electrode number (integer):'))
switch_mux_on(electrode,address)
print('electrode:',electrode,' activate' )
time.sleep(activation_time)
switch_mux_off(electrode,address)
print('electrode:',electrode,' deactivate' )
if a== '2':
for electrode in range(1, 65):
switch_mux_on(electrode,address)
print('electrode:',electrode,' activate' )
time.sleep(activation_time)
switch_mux_off(electrode,address)
print('electrode:',electrode,' deactivate' )
time.sleep(activation_time)
if a not in ['1', '2']:
print ("Wrong choice !")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment