Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sensor System
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Institut für Informatik
QE Research Group
FORTE
Sensor System
Commits
a3dc59a7
Commit
a3dc59a7
authored
2 years ago
by
User expired
Browse files
Options
Downloads
Patches
Plain Diff
use internal averaging of ads1115
parent
4c507b15
No related branches found
No related tags found
3 merge requests
!39
Merge Develop into Main
,
!19
development into master
,
!18
Power management satellite
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/libs/dr26_analogue/dr26.cpp
+29
-22
29 additions, 22 deletions
client/libs/dr26_analogue/dr26.cpp
client/libs/dr26_analogue/dr26.hpp
+1
-1
1 addition, 1 deletion
client/libs/dr26_analogue/dr26.hpp
with
30 additions
and
23 deletions
client/libs/dr26_analogue/dr26.cpp
+
29
−
22
View file @
a3dc59a7
...
@@ -2,15 +2,10 @@
...
@@ -2,15 +2,10 @@
static
const
char
*
TAG
=
"DR26"
;
static
const
char
*
TAG
=
"DR26"
;
void
ForteDR26
::
setup
()
{
void
ForteDR26
::
setup
()
{
// This was changed by Bilal on november 25th from
// Wire.begin(6,7);
pinMode
(
2
,
OUTPUT
);
Wire
.
begin
();
Wire
.
begin
();
// ads.setGain(GAIN_ONE);
// ads.begin() ? Serial.println("ADS initialized") : Serial.println("failed to initialize ADS");
ads1
.
setGain
(
GAIN_ONE
);
ads1
.
setGain
(
GAIN_ONE
);
ads1
.
setDataRate
(
RATE_ADS1115_8SPS
);
ads1
.
begin
()
?
ESP_LOGD
(
TAG
,
"ADS initialized"
)
:
ESP_LOGE
(
TAG
,
"failed to initialize ADS"
);
ads1
.
begin
()
?
ESP_LOGD
(
TAG
,
"ADS initialized"
)
:
ESP_LOGE
(
TAG
,
"failed to initialize ADS"
);
delay
(
100
);
delay
(
100
);
channel
=
0
;
channel
=
0
;
...
@@ -18,20 +13,33 @@ void ForteDR26::setup() {
...
@@ -18,20 +13,33 @@ void ForteDR26::setup() {
float
ForteDR26
::
readData
()
{
float
ForteDR26
::
readData
()
{
float
volts
=
0
;
float
volts
=
0
;
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
int16_t
adc
=
0
;
float
volt
=
0
;
try
{
adc
=
ads1
.
readADC_SingleEnded
(
channel
);
volt
=
ads1
.
computeVolts
(
adc
);
}
catch
(
NoDataAvailableException
&
e
)
{
throw
NoDataAvailableException
();
//propagate exception
}
volts
+=
volt
;
}
volts
/=
10
;
// adjust data rate instead of yourself. ADC averages on its on with low data rate
// FIXME: Test which datarate gets most stable result. If it still is not good enough consider adding a small capacitor or averaging again
// for (int i = 0; i < 10; i++) {
// int16_t adc = 0;
// float volt = 0;
// try {
// adc = ads1.readADC_SingleEnded(channel);
// volt = ads1.computeVolts(adc);
// }
// catch (NoDataAvailableException &e) {
// throw NoDataAvailableException(); //propagate exception
// }
// volts += volt;
// }
// volts /= 10;
int16_t
adc
=
0
;
try
{
adc
=
ads1
.
readADC_SingleEnded
(
channel
);
volts
=
ads1
.
computeVolts
(
adc
);
}
catch
(
NoDataAvailableException
&
e
)
{
throw
NoDataAvailableException
();
//propagate exception
}
return
volts
;
return
volts
;
}
}
...
@@ -61,14 +69,13 @@ void ForteDR26::setChannel(int c) {
...
@@ -61,14 +69,13 @@ void ForteDR26::setChannel(int c) {
std
::
list
<
Message
>
ForteDR26
::
buildMessages
()
{
std
::
list
<
Message
>
ForteDR26
::
buildMessages
()
{
std
::
list
<
Message
>
messages
;
std
::
list
<
Message
>
messages
;
float
data
=
readData
();
float
data
=
readData
();
MeasurementData
IncrementData
{
data
,
0
,
{},
"CIRCUMFERENCE_INCREMENT"
};
MeasurementData
IncrementData
{
data
,
channel
,
{},
"CIRCUMFERENCE_INCREMENT"
};
messages
.
emplace_back
(
IncrementData
,
sensorInformation
,
Time
::
getInstance
().
getEpochSeconds
());
messages
.
emplace_back
(
IncrementData
,
sensorInformation
,
Time
::
getInstance
().
getEpochSeconds
());
return
messages
;
return
messages
;
}
}
// FIXME: Channel shadows a member variable, we don't need it, just take the member variable instead
// FIXME: passing the measurementType as a string is not a good idea, we should use an enum like we do for other sensors
// FIXME: passing the measurementType as a string is not a good idea, we should use an enum like we do for other sensors
std
::
list
<
Message
>
ForteDR26
::
buildMessages
(
int
channel
,
std
::
string
measurementType
)
{
std
::
list
<
Message
>
ForteDR26
::
buildMessages
(
std
::
string
measurementType
)
{
std
::
list
<
Message
>
messages
;
std
::
list
<
Message
>
messages
;
float
data
=
readData
();
float
data
=
readData
();
MeasurementData
IncrementData
{
data
,
channel
,
{},
measurementType
};
MeasurementData
IncrementData
{
data
,
channel
,
{},
measurementType
};
...
...
This diff is collapsed.
Click to expand it.
client/libs/dr26_analogue/dr26.hpp
+
1
−
1
View file @
a3dc59a7
...
@@ -16,7 +16,7 @@ class ForteDR26 : public ForteSensor<float> {
...
@@ -16,7 +16,7 @@ class ForteDR26 : public ForteSensor<float> {
void
changeGain
(
adsGain_t
gain
);
void
changeGain
(
adsGain_t
gain
);
void
setChannel
(
int
channel
);
void
setChannel
(
int
channel
);
std
::
list
<
Message
>
buildMessages
()
override
;
std
::
list
<
Message
>
buildMessages
()
override
;
std
::
list
<
Message
>
buildMessages
(
int
channel
,
std
::
string
mesurment_type
);
std
::
list
<
Message
>
buildMessages
(
std
::
string
mesurment_type
);
[[
nodiscard
]]
SensorInformation
getSensorInformation
()
const
override
;
[[
nodiscard
]]
SensorInformation
getSensorInformation
()
const
override
;
static
Adafruit_ADS1115
ads1
;
static
Adafruit_ADS1115
ads1
;
...
...
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