Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MessdatenSilo
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lennard Kloock
MessdatenSilo
Commits
2645ae35
Commit
2645ae35
authored
3 years ago
by
Lennard
Browse files
Options
Downloads
Patches
Plain Diff
Update DmsMessung.ino
parent
c58bea19
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sketches/DmsMessung/DmsMessung.ino
+39
-106
39 additions, 106 deletions
sketches/DmsMessung/DmsMessung.ino
with
39 additions
and
106 deletions
sketches/DmsMessung/DmsMessung.ino
+
39
−
106
View file @
2645ae35
#include
<HX711_ADC.h>
HX711_ADC
LoadCell
(
2
,
3
);
HX711_ADC
LoadCell2
(
6
,
7
);
HX711_ADC
LoadCell3
(
8
,
9
);
HX711_ADC
LoadCell4
(
12
,
13
);
static
float
Offset
=
0
;
static
float
Offset2
=
0
;
static
float
Offset3
=
0
;
static
float
Offset4
=
0
;
int
anzahl
=
1000
;
int
caltime
=
2
;
float
calFac
=
2500
;
float
calFac2
=
2500
;
float
calFac3
=
2500
;
float
calFac4
=
2500
;
HX711_ADC
loadCell
[]
=
{
HX711_ADC
(
2
,
3
),
HX711_ADC
(
6
,
7
),
HX711_ADC
(
8
,
9
),
HX711_ADC
(
12
,
13
)};
float
measurement
[
4
];
float
offset
[
4
];
int
count
=
1000
;
long
stabilisation
=
2000
;
boolean
t_are
=
true
;
float
messwertges
;
float
messwertges2
;
float
messwertges3
;
float
messwertges4
;
float
messwert
;
float
messwert2
;
float
messwert3
;
float
messwert4
;
void
regelbetrieb
(
HX711_ADC
zelle
,
HX711_ADC
zelle2
,
HX711_ADC
zelle3
,
HX711_ADC
zelle4
)
{
float
messwertAlt
=
messwert
;
float
messwertAlt2
=
messwert2
;
float
messwertAlt3
=
messwert3
;
float
messwertAlt4
=
messwert4
;
messwert
=
0
;
messwert2
=
0
;
messwert3
=
0
;
messwert4
=
0
;
for
(
int
i
=
1
;
i
<=
anzahl
;
i
++
)
{
zelle
.
update
();
zelle2
.
update
();
zelle3
.
update
();
zelle4
.
update
();
messwert
=
messwert
+
(
getDaten
(
Offset
,
zelle
));
messwert2
=
messwert2
+
(
getDaten
(
Offset2
,
zelle2
));
messwert3
=
messwert3
+
(
getDaten
(
Offset3
,
zelle3
));
messwert4
=
messwert4
+
(
getDaten
(
Offset4
,
zelle4
));
delay
(
1
);
void
readData
()
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
measurements
[
i
]
=
0
;
}
messwert
=
messwert
/
anzahl
;
messwert2
=
messwert2
/
anzahl
;
messwert3
=
messwert3
/
anzahl
;
messwert4
=
messwert4
/
anzahl
;
messwert
=
messwert
/
calFac
;
messwert2
=
messwert2
/
calFac2
;
messwert3
=
messwert3
/
calFac3
;
messwert4
=
messwert4
/
calFac4
;
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
loadCells
[
j
].
update
();
}
float
getDaten
(
float
offset
,
HX711_ADC
zelle
)
{
float
Offsetnew
=
offset
;
float
data
;
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
measurement
[
j
]
+=
loadCell
[
j
].
getRareData
()
-
offset
[
j
];
}
data
=
(
float
)
zelle
.
getRareData
()
-
Offsetnew
;
delay
(
1
);
}
return
data
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
measurements
[
i
]
/=
count
*
2500
;
}
}
void
writeInData
()
{
void
loop
()
{
if
(
Serial
.
available
())
{
Serial
.
read
();
delay
(
20
);
Serial
.
println
(
1
);
regelbetrieb
(
LoadCell
,
LoadCell2
,
LoadCell3
,
LoadCell4
);
Serial
.
println
(
messwert
);
delay
(
20
);
Serial
.
println
(
1
);
// for identification
Serial
.
println
(
messwert2
);
delay
(
20
);
readData
();
Serial
.
println
(
messwert3
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
Serial
.
println
(
measurements
[
i
]);
delay
(
20
);
Serial
.
println
(
messwert4
);
}
}
float
epsilonumgebung
(
float
hierMesswert
,
float
hierMesswertAlt
)
{
if
(
hierMesswert
<
hierMesswertAlt
+
0.25
&&
hierMesswert
>
hierMesswertAlt
-
0.25
)
{
hierMesswert
=
hierMesswertAlt
;
}
return
hierMesswert
;
}
void
setup
()
{
Serial
.
begin
(
9600
);
LoadCell
.
begin
();
LoadCell2
.
begin
();
LoadCell3
.
begin
();
LoadCell4
.
begin
();
LoadCell
.
start
(
stabilisation
,
t_are
);
LoadCell2
.
start
(
stabilisation
,
t_are
);
LoadCell3
.
start
(
stabilisation
,
t_are
);
LoadCell4
.
start
(
stabilisation
,
t_are
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
loadCell
[
i
].
begin
();
}
LoadCell
.
update
();
LoadCell2
.
update
();
LoadCell3
.
update
();
LoadCell4
.
update
();
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
loadCell
[
i
].
start
(
stabilisation
,
true
);
}
Offset
=
getDaten
(
0
,
LoadCell
);
Offset2
=
getDaten
(
0
,
LoadCell2
);
Offset3
=
getDaten
(
0
,
LoadCell3
);
Offset4
=
getDaten
(
0
,
LoadCell4
);
readData
();
delay
(
500
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
offset
[
i
]
=
measurement
[
i
];
}
void
loop
()
{
writeInData
();
delay
(
500
);
}
\ No newline at end of file
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