Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Heizung
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
c3pb
Heizung
Commits
19b7e86f
Commit
19b7e86f
authored
1 year ago
by
Benjamin Koch
Browse files
Options
Downloads
Patches
Plain Diff
double time before toggling en_measure_current
parent
b8d9c80a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
firmware/rust1/src/bin/heizung.rs
+6
-4
6 additions, 4 deletions
firmware/rust1/src/bin/heizung.rs
with
6 additions
and
4 deletions
firmware/rust1/src/bin/heizung.rs
+
6
−
4
View file @
19b7e86f
...
...
@@ -144,6 +144,8 @@ async fn adc_task(shared_data: &'static AdcData, adc: ADC, mut en_measure_curren
let
mut
adc
=
Adc
::
new
(
adc
,
irq
,
adc
::
Config
::
default
());
let
debug
=
true
;
const
MEASURE_CYCLES_BEFORE_TOGGLE
:
u32
=
16
;
let
mut
en_measure_current_toggle
=
0
;
loop
{
...
...
@@ -191,14 +193,14 @@ async fn adc_task(shared_data: &'static AdcData, adc: ADC, mut en_measure_curren
en_measure_current_toggle
=
0
;
}
else
{
match
en_measure_current_toggle
{
0
|
8
=>
{
en_measure_current
.set_level
(
if
en_measure_current_toggle
>=
8
{
Level
::
High
}
else
{
Level
::
Low
});
0
|
MEASURE_CYCLES_BEFORE_TOGGLE
=>
{
en_measure_current
.set_level
(
if
en_measure_current_toggle
>=
MEASURE_CYCLES_BEFORE_TOGGLE
{
Level
::
High
}
else
{
Level
::
Low
});
// skip in this loop to give it time to settle
measure_currents
=
false
;
}
_
=>
{}
}
en_measure_current_toggle
=
(
en_measure_current_toggle
+
1
)
%
16
;
en_measure_current_toggle
=
(
en_measure_current_toggle
+
1
)
%
(
2
*
MEASURE_CYCLES_BEFORE_TOGGLE
)
;
}
// read another value between looking at output_active and measuring the currents
...
...
@@ -223,7 +225,7 @@ async fn adc_task(shared_data: &'static AdcData, adc: ADC, mut en_measure_curren
];
let
outputs_are_active
=
outputs_active
.load
(
Ordering
::
SeqCst
);
//let en_measure_current_is_active = en_measure_current.is_set_high(); //FIXME I think is_set_high() has a bug.
let
en_measure_current_is_active
=
en_measure_current_toggle
>=
8
;
let
en_measure_current_is_active
=
en_measure_current_toggle
>=
MEASURE_CYCLES_BEFORE_TOGGLE
;
for
i
in
0
..
2
{
// 3.05 V for 4096 counts, shunt resistor is 0.1 ohms (i.e. 0.1 V/A), amplifier gain is 56, result should be mA/10
// (level - offset) * 3.05/4096 / 0.1 * 1/56 * 1e4
...
...
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