Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
reversaal
OhmPi
Commits
82434f5b
Commit
82434f5b
authored
Dec 19, 2019
by
Forquet Nicolas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete ohmi_measure.py
parent
b9caf7d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
57 deletions
+0
-57
ohmpi_measure.py
ohmpi_measure.py
+0
-57
No files found.
ohmpi_measure.py
deleted
100644 → 0
View file @
b9caf7d8
import
RPi.GPIO
as
GPIO
import
time
import
board
import
busio
import
adafruit_ads1x15.ads1115
as
ADS
from
adafruit_ads1x15.analog_in
import
AnalogIn
# paramètres de mesure
nbr_stack
=
1
# défini le nombre de stack (1 stack une injection positive et negative
current_injection_time
=
0.5
# temps d'injection du courant en seconde
# paramètres liées à la carte de mesure
Rref
=
50
# valeur de la resistance de référence
som_I
=
0
som_Vmn
=
0
som_Ps
=
0
coeff_p0
=
2.02
# coefficient à vérifier + offset
coeff_p1
=
2.02
i2c
=
busio
.
I2C
(
board
.
SCL
,
board
.
SDA
)
# definition du protocole I2C
ads
=
ADS
.
ADS1115
(
i2c
,
gain
=
2
/
3
)
# activation de la connection I2C
#initialisation des gpio
GPIO
.
setmode
(
GPIO
.
BCM
)
GPIO
.
setwarnings
(
False
)
GPIO
.
setup
(
7
,
GPIO
.
OUT
)
GPIO
.
setup
(
8
,
GPIO
.
OUT
)
# mesure de la resistance
for
n
in
range
(
0
,
3
+
2
*
nbr_stack
-
1
)
:
print
(
n
+
1
)
if
(
n
%
2
)
==
0
:
GPIO
.
output
(
7
,
GPIO
.
HIGH
)
# polarité n°1
print
(
'positif'
)
else
:
GPIO
.
output
(
7
,
GPIO
.
LOW
)
# polarité n°1
print
(
'negatif'
)
GPIO
.
output
(
8
,
GPIO
.
HIGH
)
# injection du courant
time
.
sleep
(
current_injection_time
)
# delay fonction du temps d'injection
Ia1
=
AnalogIn
(
ads
,
ADS
.
P0
).
voltage
*
coeff_p0
# lecture de la voie A0
Ib1
=
AnalogIn
(
ads
,
ADS
.
P1
).
voltage
*
coeff_p1
# lecture de la voie A1
Vm1
=
AnalogIn
(
ads
,
ADS
.
P2
).
voltage
# lecture de la voie A2
Vn1
=
AnalogIn
(
ads
,
ADS
.
P3
).
voltage
# lecture de la voie A3
GPIO
.
output
(
8
,
GPIO
.
LOW
)
# stop injection du courant
I1
=
(
Ia1
-
Ib1
)
/
Rref
;
som_I
=
som_I
+
I1
;
Vmn1
=
(
Vm1
-
Vn1
);
if
(
n
%
2
)
==
0
:
som_Vmn
=
som_Vmn
-
Vmn1
;
som_Ps
=
som_Ps
+
Vmn1
;
else
:
som_Vmn
=
som_Vmn
+
Vmn1
;
som_Ps
=
som_Ps
+
Vmn1
;
#valeur à renvoyer
Vmn
=
som_Vmn
/
(
3
+
2
*
nbr_stack
-
1
)
I
=
som_I
/
(
3
+
2
*
nbr_stack
-
1
)
R
=
Vmn
/
I
Ps
=
som_Ps
/
(
3
+
2
*
nbr_stack
-
1
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment