Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Ardupilot
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
OpenSource
Ardupilot
Commits
33d9ae23
Commit
33d9ae23
authored
12 years ago
by
Andrew Tridgell
Browse files
Options
Downloads
Patches
Plain Diff
battery: use set_pin() to allow pins to be changed at runtime
parent
f541b2a0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ArduCopter/sensors.pde
+2
-0
2 additions, 0 deletions
ArduCopter/sensors.pde
ArduPlane/sensors.pde
+4
-0
4 additions, 0 deletions
ArduPlane/sensors.pde
with
6 additions
and
0 deletions
ArduCopter/sensors.pde
+
2
−
0
View file @
33d9ae23
...
@@ -78,10 +78,12 @@ static void read_battery(void)
...
@@ -78,10 +78,12 @@ static void read_battery(void)
if
(
g
.
battery_monitoring
==
3
||
g
.
battery_monitoring
==
4
)
{
if
(
g
.
battery_monitoring
==
3
||
g
.
battery_monitoring
==
4
)
{
static
AP_AnalogSource_Arduino
batt_volt_pin
(
g
.
battery_volt_pin
);
static
AP_AnalogSource_Arduino
batt_volt_pin
(
g
.
battery_volt_pin
);
batt_volt_pin
.
set_pin
(
g
.
battery_volt_pin
);
battery_voltage1
=
BATTERY_VOLTAGE
(
batt_volt_pin
.
read_average
());
battery_voltage1
=
BATTERY_VOLTAGE
(
batt_volt_pin
.
read_average
());
}
}
if
(
g
.
battery_monitoring
==
4
)
{
if
(
g
.
battery_monitoring
==
4
)
{
static
AP_AnalogSource_Arduino
batt_curr_pin
(
g
.
battery_curr_pin
);
static
AP_AnalogSource_Arduino
batt_curr_pin
(
g
.
battery_curr_pin
);
batt_curr_pin
.
set_pin
(
g
.
battery_curr_pin
);
current_amps1
=
CURRENT_AMPS
(
batt_curr_pin
.
read_average
());
current_amps1
=
CURRENT_AMPS
(
batt_curr_pin
.
read_average
());
current_total1
+=
current_amps1
*
0.02778
;
// called at 100ms on average, .0002778 is 1/3600 (conversion to hours)
current_total1
+=
current_amps1
*
0.02778
;
// called at 100ms on average, .0002778 is 1/3600 (conversion to hours)
}
}
...
...
This diff is collapsed.
Click to expand it.
ArduPlane/sensors.pde
+
4
−
0
View file @
33d9ae23
...
@@ -41,10 +41,14 @@ static void read_battery(void)
...
@@ -41,10 +41,14 @@ static void read_battery(void)
if
(
g
.
battery_monitoring
==
3
||
g
.
battery_monitoring
==
4
)
{
if
(
g
.
battery_monitoring
==
3
||
g
.
battery_monitoring
==
4
)
{
static
AP_AnalogSource_Arduino
batt_volt_pin
(
g
.
battery_volt_pin
);
static
AP_AnalogSource_Arduino
batt_volt_pin
(
g
.
battery_volt_pin
);
// this copes with changing the pin at runtime
batt_volt_pin
.
set_pin
(
g
.
battery_volt_pin
);
battery_voltage1
=
BATTERY_VOLTAGE
(
batt_volt_pin
.
read_average
());
battery_voltage1
=
BATTERY_VOLTAGE
(
batt_volt_pin
.
read_average
());
}
}
if
(
g
.
battery_monitoring
==
4
)
{
if
(
g
.
battery_monitoring
==
4
)
{
static
AP_AnalogSource_Arduino
batt_curr_pin
(
g
.
battery_curr_pin
);
static
AP_AnalogSource_Arduino
batt_curr_pin
(
g
.
battery_curr_pin
);
// this copes with changing the pin at runtime
batt_curr_pin
.
set_pin
(
g
.
battery_curr_pin
);
current_amps1
=
CURRENT_AMPS
(
batt_curr_pin
.
read_average
());
current_amps1
=
CURRENT_AMPS
(
batt_curr_pin
.
read_average
());
current_total1
+=
current_amps1
*
(
float
)
delta_ms_medium_loop
*
0.0002778
;
// .0002778 is 1/3600 (conversion to hours)
current_total1
+=
current_amps1
*
(
float
)
delta_ms_medium_loop
*
0.0002778
;
// .0002778 is 1/3600 (conversion to hours)
}
}
...
...
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