Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Code Python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
procom2022-robotise
Code Python
Commits
505c799a
Commit
505c799a
authored
2 years ago
by
TERRU Theo
Browse files
Options
Downloads
Patches
Plain Diff
V1 script final 3 lignes
parent
6ae8d0f9
No related branches found
No related tags found
1 merge request
!1
MAJ BDD + Data commande fonctionnel
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bibliotheques/machine/script_flowmeter.py
+33
-10
33 additions, 10 deletions
bibliotheques/machine/script_flowmeter.py
with
33 additions
and
10 deletions
bibliotheques/machine/script_flowmeter.py
+
33
−
10
View file @
505c799a
...
...
@@ -4,6 +4,7 @@ from time import sleep # this lets us have a time delay (see line 12)
import
sys
increment
=
0
nbrBoucle
=
0
stop
=
0
args
=
[]
...
...
@@ -25,7 +26,7 @@ def testDebimetre(bec, quantite): # quantité en cl (int), bec (int)
# Setup des composants
GPIO
.
setmode
(
GPIO
.
BCM
)
# set up BCM GPIO numbering
GPIO
.
setup
(
25
,
GPIO
.
IN
)
# DEBITMETRE
GPIO
.
setup
(
25
,
GPIO
.
IN
,
pull_up_down
=
GPIO
.
PUD_DOWN
)
# DEBITMETRE
GPIO
.
setup
(
24
,
GPIO
.
OUT
,
initial
=
GPIO
.
LOW
)
# ELECTROVANNE 1
GPIO
.
setup
(
21
,
GPIO
.
OUT
,
initial
=
GPIO
.
LOW
)
# ELECTROVANNE 2
GPIO
.
setup
(
23
,
GPIO
.
OUT
)
# POMPE
...
...
@@ -33,13 +34,20 @@ def testDebimetre(bec, quantite): # quantité en cl (int), bec (int)
global
increment
global
stop
Q
=
int
(
quantite
/
5
)
q
=
int
(
quantite
%
5
)
print
(
"
Q =
"
,
Q
)
print
(
"
q =
"
,
q
)
# Define a threaded callback function to run in another thread when events are detected
def
my_callback
(
channel
):
global
increment
global
stop
global
nbrBoucle
# Si la quantité désirée a été pompée
if
increment
==
quantite
and
not
stop
:
if
nbrBoucle
==
Q
-
1
and
not
stop
:
# Arrêt de tous les composants
...
...
@@ -61,13 +69,7 @@ def testDebimetre(bec, quantite): # quantité en cl (int), bec (int)
print
(
increment
)
# Ajout du callback débitmètre
GPIO
.
add_event_detect
(
25
,
GPIO
.
BOTH
,
callback
=
my_callback
)
# Démarrage des composants requis
if
args
[
Pompe1
]:
p
.
start
(
80
)
print
(
"
Pompe1 ouverte
"
)
#GPIO.output(23, GPIO.HIGH)
GPIO
.
add_event_detect
(
25
,
GPIO
.
RISING
,
callback
=
my_callback
,
bouncetime
=
5
)
if
args
[
EV1
]:
GPIO
.
output
(
24
,
GPIO
.
HIGH
)
...
...
@@ -77,6 +79,27 @@ def testDebimetre(bec, quantite): # quantité en cl (int), bec (int)
GPIO
.
output
(
21
,
GPIO
.
HIGH
)
print
(
"
Electrovanne2 ouverte
"
)
# Démarrage des composants requis
if
args
[
Pompe1
]:
global
nbrBoucle
print
(
"
Pompe1 ouverte
"
)
for
i
in
range
(
Q
):
PWM
=
0
increment
=
1
while
PWM
<=
50
:
p
.
start
(
PWM
)
print
(
"
PWM =
"
,
PWM
)
PWM
+=
5
sleep
(
0.1
)
while
increment
%
5
!=
0
:
pass
increment
=
1
p
.
stop
()
nbrBoucle
+=
1
#sleep(0.3)
#GPIO.output(23, GPIO.HIGH)
try
:
# Thread du débitmètre tourne en fond
while
not
stop
:
...
...
@@ -101,5 +124,5 @@ if __name__=="__main__":
args
.
append
(
int
(
strParam
))
except
ValueError
:
print
(
"
Bad parameter value: %s
"
%
strParam
,
file
=
sys
.
stderr
)
testDebimetre
(
2
,
5
)
testDebimetre
(
2
,
28
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment