Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HEV - High Energy Ventilator
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
HEV - High Energy Ventilator
Commits
f08f69a2
Commit
f08f69a2
authored
4 years ago
by
Your Name
Browse files
Options
Downloads
Patches
Plain Diff
Modified johan's code for valve PWM testing
parent
c93fc372
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arduino/basic_io/src/johan.cpp
+63
-48
63 additions, 48 deletions
arduino/basic_io/src/johan.cpp
with
63 additions
and
48 deletions
arduino/basic_io/src/johan.cpp
+
63
−
48
View file @
f08f69a2
...
...
@@ -29,7 +29,7 @@ Adafruit_MCP9808 tempsensor = Adafruit_MCP9808();
// Set Board to "ESP32 Dev Module"
// Set Port to /dev/ttyUSB0 on Linux
const
int
freq
=
9
00
;
// 900 Hz for burkert 2875; Note - could be 500 Hz; depending on valve
const
int
freq
=
5
00
;
// 900 Hz for burkert 2875; Note - could be 500 Hz; depending on valve
float
duty_cycle
=
0.0
;
const
float
max_duty_cycle
=
0.85
;
...
...
@@ -87,15 +87,17 @@ void setup() {
// NodeMCU32
// pwm
ledcSetup
(
0
,
freq
,
8
);
ledcSetup
(
1
,
freq
,
8
);
ledcSetup
(
1
,
2200
,
8
);
// buzzer frequency
//
ledcSetup(1,2200,8); // buzzer frequency
//ledcAttachPin(pin_valve_o2_in , 0);
ledcAttachPin
(
pin_valve_inhale
,
0
);
ledcAttachPin
(
pin_valve_exhale
,
1
);
ledcAttachPin
(
buzzer
,
1
);
ledcWrite
(
1
,
128
);
//buzzer
//
ledcWrite(1, 128); //buzzer
pinMode
(
A13
,
INPUT
);
// potentiometer
...
...
@@ -113,7 +115,7 @@ void setup() {
// Valves IO config
pinMode
(
pin_valve_air_in
,
OUTPUT
);
pinMode
(
pin_valve_exhale
,
OUTPUT
);
//
pinMode(pin_valve_exhale,OUTPUT);
pinMode
(
pin_valve_purge
,
OUTPUT
);
pinMode
(
pin_valve_o2_in
,
OUTPUT
);
...
...
@@ -125,13 +127,13 @@ void setup() {
digitalWrite
(
pin_valve_air_in
,
HIGH
);
digitalWrite
(
pin_valve_exhale
,
LOW
);
//
digitalWrite(pin_valve_exhale, LOW);
digitalWrite
(
pin_valve_purge
,
LOW
);
digitalWrite
(
pin_valve_o2_in
,
HIGH
);
digitalWrite
(
redled
,
HIGH
);
digitalWrite
(
yellowled
,
HIGH
);
digitalWrite
(
greenled
,
HIGH
);
//
digitalWrite(redled, HIGH);
//
digitalWrite(yellowled, HIGH);
//
digitalWrite(greenled, HIGH);
DEBUG_PRINT
(
"Hello"
);
Serial
.
println
(
"Hello"
);
...
...
@@ -185,46 +187,59 @@ void loop() {
duty_cycle
=
max_duty_cycle
;
}
//Serial.print("Pot ");
//Serial.print(String((int)res));
//Serial.print(" p_patient ");
//Serial.print(String((int)pressure_patient));
//Serial.print(" p_buffer ");
//Serial.print(String((int)pressure_buffer));
//Serial.print(" p_as ");
//Serial.print(String((int)pressure_asupply));
//Serial.print(" p_ar ");
//Serial.print(String((int)pressure_aregulated));
//Serial.print(" p_inhale ");
//Serial.print(String((int)pressure_inhale));
//Serial.print(" p_o2s ");
//Serial.print(String((int)pressure_o2supply));
//Serial.print(" p_o2r ");
//Serial.print(String((int)pressure_o2regulated));
//Serial.print(" Temp: ");
//Serial.print(c, 4);
//// measuring Valves voltage and current
//Serial.print(" ");
//Serial.print((float)INA.getBusMilliVolts(0)/1000.0,4);
//DEBUG_PRINT("V ");
//DEBUG_PRINT2((float)INA.getShuntMicroVolts(0)/5,0);
//DEBUG_PRINT("mA ");
//DEBUG_PRINT2((float)INA.getShuntMicroVolts(1)/5,0);
//DEBUG_PRINT("mA ");
//DEBUG_PRINT2((float)INA.getShuntMicroVolts(2)/5,0);
//DEBUG_PRINT("mA ");
//DEBUG_PRINT2((float)INA.getShuntMicroVolts(3)/5,0);
//DEBUG_PRINT("mA ");
duty_cycle
=
0.6
;
int
val
=
(
int
)(
255.0
*
duty_cycle
);
Serial
.
print
(
"Pot "
);
Serial
.
print
(
String
((
int
)
res
));
Serial
.
print
(
" p_patient "
);
Serial
.
print
(
String
((
int
)
pressure_patient
));
Serial
.
print
(
" p_buffer "
);
Serial
.
print
(
String
((
int
)
pressure_buffer
));
Serial
.
print
(
" p_as "
);
Serial
.
print
(
String
((
int
)
pressure_asupply
));
Serial
.
print
(
" p_ar "
);
Serial
.
print
(
String
((
int
)
pressure_aregulated
));
Serial
.
print
(
" p_inhale "
);
Serial
.
print
(
String
((
int
)
pressure_inhale
));
Serial
.
print
(
" p_o2s "
);
Serial
.
print
(
String
((
int
)
pressure_o2supply
));
Serial
.
print
(
" p_o2r "
);
Serial
.
print
(
String
((
int
)
pressure_o2regulated
));
Serial
.
print
(
" Temp: "
);
Serial
.
print
(
c
,
4
);
// measuring Valves voltage and current
Serial
.
print
(
" "
);
Serial
.
print
((
float
)
INA
.
getBusMilliVolts
(
0
)
/
1000.0
,
4
);
DEBUG_PRINT
(
"V "
);
DEBUG_PRINT2
((
float
)
INA
.
getShuntMicroVolts
(
0
)
/
5
,
0
);
DEBUG_PRINT
(
"mA "
);
DEBUG_PRINT2
((
float
)
INA
.
getShuntMicroVolts
(
1
)
/
5
,
0
);
DEBUG_PRINT
(
"mA "
);
DEBUG_PRINT2
((
float
)
INA
.
getShuntMicroVolts
(
2
)
/
5
,
0
);
DEBUG_PRINT
(
"mA "
);
DEBUG_PRINT2
((
float
)
INA
.
getShuntMicroVolts
(
3
)
/
5
,
0
);
DEBUG_PRINT
(
"mA "
);
Serial
.
print
(
" duty cycle "
);
Serial
.
println
(
String
(
duty_cycle
));
ledcWrite
(
0
,
val
);
delay
(
1000
);
int
vallow
=
(
int
)(
255.0
*
0.1
);
//Serial.print(" duty cycle ");
//Serial.println(String(duty_cycle));
//Serial.print(" raw val ");
//Serial.println(String(val));
digitalWrite
(
greenled
,
HIGH
);
//ledcWrite(0, val);// inhale
ledcWrite
(
0
,
0
);
//vallow);// exhale
delay
(
1000
);
ledcWrite
(
0
,
0
);
//val);// exhale
delay
(
200
);
//ledcWrite(1, 0);// exhale
//digitalWrite(greenled, LOW);
//delay(1000);
}
This diff is collapsed.
Click to expand it.
Preview
0%
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