Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
darwin_robot_driver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
humanoides
darwin
darwin_robot_driver
Commits
9a1c2074
Commit
9a1c2074
authored
8 years ago
by
Irene Garcia Camacho
Browse files
Options
Downloads
Patches
Plain Diff
Added a function to read limit current of the smart charger
parent
17f33fdf
No related branches found
No related tags found
1 merge request
!2
Added a function to read limit current of the smart charger
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/darwin_robot.cpp
+45
-28
45 additions, 28 deletions
src/darwin_robot.cpp
src/darwin_robot.h
+8
-4
8 additions, 4 deletions
src/darwin_robot.h
src/examples/darwin_smart_charger_test.cpp
+7
-15
7 additions, 15 deletions
src/examples/darwin_smart_charger_test.cpp
with
60 additions
and
47 deletions
src/darwin_robot.cpp
+
45
−
28
View file @
9a1c2074
...
@@ -1837,7 +1837,7 @@ bool CDarwinRobot::is_smart_charger_det_and_en(void)
...
@@ -1837,7 +1837,7 @@ bool CDarwinRobot::is_smart_charger_det_and_en(void)
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
}
//Set smart charger period in s
void
CDarwinRobot
::
smart_charger_set_period
(
double
period
)
void
CDarwinRobot
::
smart_charger_set_period
(
double
period
)
{
{
unsigned
short
int
period_ms
;
unsigned
short
int
period_ms
;
...
@@ -1855,7 +1855,7 @@ void CDarwinRobot::smart_charger_set_period(double period)
...
@@ -1855,7 +1855,7 @@ void CDarwinRobot::smart_charger_set_period(double period)
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
}
//Get smart charger period in s
double
CDarwinRobot
::
smart_charger_get_period
(
void
)
double
CDarwinRobot
::
smart_charger_get_period
(
void
)
{
{
unsigned
short
int
period_ms
;
unsigned
short
int
period_ms
;
...
@@ -1884,9 +1884,11 @@ void CDarwinRobot::smart_charger_get_period(double *period)
...
@@ -1884,9 +1884,11 @@ void CDarwinRobot::smart_charger_get_period(double *period)
throw CDarwinRobotException(_HERE_,"Invalid robot device");
throw CDarwinRobotException(_HERE_,"Invalid robot device");
}
}
*/
*/
/* Obtain time to full, to empty and battery status
*/
TChargerData
CDarwinRobot
::
smart_charger_get_data
(
void
)
TChargerData
CDarwinRobot
::
smart_charger_get_data
(
void
)
{
{
// unsigned short charger_data[3];
TChargerData
smart_charger_data
;
TChargerData
smart_charger_data
;
if
(
this
->
robot_device
!=
NULL
)
if
(
this
->
robot_device
!=
NULL
)
...
@@ -1898,6 +1900,46 @@ TChargerData CDarwinRobot::smart_charger_get_data(void)
...
@@ -1898,6 +1900,46 @@ TChargerData CDarwinRobot::smart_charger_get_data(void)
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
}
//Set limit input current
void
CDarwinRobot
::
smart_charger_range_current
(
double
min_current
,
double
max_current
)
{
this
->
MAX_limit_current
=
max_current
;
this
->
MIN_limit_current
=
min_current
;
}
//Get limit current in A
double
CDarwinRobot
::
smart_charger_get_limit_current
(
void
)
{
unsigned
short
int
limit_current_ma
;
if
(
this
->
robot_device
!=
NULL
)
{
this
->
robot_device
->
read_word_register
(
DARWIN_SMART_CHARGER_LIMIT_CURRENT_L
,
&
limit_current_ma
);
return
((
double
)
limit_current_ma
)
/
1000
;
}
else
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
//Set limit current in A
void
CDarwinRobot
::
smart_charger_set_limit_current
(
double
limit_current
)
{
unsigned
short
int
limit_current_ma
;
if
(
this
->
robot_device
!=
NULL
)
{
//if(limit_current > MIN_limit_current && limit_current < MAX_limit_current){
if
(
limit_current
>
0.255
&&
limit_current
<
1.025
){
limit_current_ma
=
(
limit_current
/
2
)
*
1000
;
this
->
robot_device
->
write_word_register
(
DARWIN_SMART_CHARGER_LIMIT_CURRENT_L
,
limit_current_ma
);
}
else
{
std
::
cout
<<
" Invalid current value"
<<
std
::
endl
;
}
}
else
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
unsigned
int
CDarwinRobot
::
smart_charger_read_time_empty
(
void
)
unsigned
int
CDarwinRobot
::
smart_charger_read_time_empty
(
void
)
{
{
...
@@ -1938,31 +1980,6 @@ unsigned char CDarwinRobot::smart_charger_read_status(void)
...
@@ -1938,31 +1980,6 @@ unsigned char CDarwinRobot::smart_charger_read_status(void)
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
}
//Set limit input current
void
CDarwinRobot
::
smart_charger_range_current
(
double
min_current
,
double
max_current
)
{
this
->
MAX_limit_current
=
max_current
;
this
->
MIN_limit_current
=
min_current
;
}
void
CDarwinRobot
::
smart_charger_set_limit_current
(
double
limit_current
)
{
unsigned
short
int
limit_current_ma
;
if
(
this
->
robot_device
!=
NULL
)
{
//if(limit_current > MIN_limit_current && limit_current < MAX_limit_current){
if
(
limit_current
>
0.255
&&
limit_current
<
1.0
){
limit_current_ma
=
limit_current
*
1000
;
this
->
robot_device
->
write_word_register
(
DARWIN_SMART_CHARGER_LIMIT_CURRENT_L
,
limit_current_ma
);
}
else
{
std
::
cout
<<
" Invalid current value"
<<
std
::
endl
;
}
}
else
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
CDarwinRobot
::~
CDarwinRobot
()
CDarwinRobot
::~
CDarwinRobot
()
{
{
if
(
this
->
robot_device
!=
NULL
)
if
(
this
->
robot_device
!=
NULL
)
...
...
This diff is collapsed.
Click to expand it.
src/darwin_robot.h
+
8
−
4
View file @
9a1c2074
...
@@ -218,11 +218,11 @@ class CDarwinRobot
...
@@ -218,11 +218,11 @@ class CDarwinRobot
void
smart_charger_disable
(
void
);
void
smart_charger_disable
(
void
);
/**
/**
* \brief Function to set smart charger's read operation period
* \brief Function to set smart charger's read operation period
* \param period
_ms
Period in
m
s of smart charger module
* \param period Period in s of smart charger module
*/
*/
void
smart_charger_set_period
(
double
period
);
void
smart_charger_set_period
(
double
period
);
/**
/**
* \brief Function to get smart charger's read operation period
* \brief Function to get smart charger's read operation period
in segs
*/
*/
double
smart_charger_get_period
(
void
);
double
smart_charger_get_period
(
void
);
/**
/**
...
@@ -234,8 +234,12 @@ class CDarwinRobot
...
@@ -234,8 +234,12 @@ class CDarwinRobot
*/
*/
void
smart_charger_range_current
(
double
min_current
,
double
max_current
);
void
smart_charger_range_current
(
double
min_current
,
double
max_current
);
/**
/**
* \brief Function to set smart charger's period
* \brief Function to get limit current in A
* \param limit_current Value of limit current
*/
double
smart_charger_get_limit_current
(
void
);
/**
* \brief Function to set smart charger's limit current
* \param limit_current Value of limit current in A
*/
*/
void
smart_charger_set_limit_current
(
double
limit_current
);
void
smart_charger_set_limit_current
(
double
limit_current
);
/**
/**
...
...
This diff is collapsed.
Click to expand it.
src/examples/darwin_smart_charger_test.cpp
+
7
−
15
View file @
9a1c2074
...
@@ -32,6 +32,7 @@ int main(int argc, char *argv[])
...
@@ -32,6 +32,7 @@ int main(int argc, char *argv[])
double
period
;
double
period
;
int
control
,
status
;
int
control
,
status
;
TChargerData
charger_data
;
TChargerData
charger_data
;
double
current
;
try
{
try
{
CDarwinRobot
darwin
(
"Darwin"
,
robot_device
,
1000000
,
0x02
);
CDarwinRobot
darwin
(
"Darwin"
,
robot_device
,
1000000
,
0x02
);
...
@@ -76,15 +77,6 @@ int main(int argc, char *argv[])
...
@@ -76,15 +77,6 @@ int main(int argc, char *argv[])
std
::
cout
<<
"Motion manager is running"
<<
std
::
endl
;
std
::
cout
<<
"Motion manager is running"
<<
std
::
endl
;
//WRITE EEPROM
//WRITE EEPROM
/* unsigned short int length = 6; //8 bytes - RAM 0x20 to 0x27
unsigned short int data_eeprom[3]; //BATTERY_INPUT_CURRENT / BATTERY_CHARGE_CURRENT / BATTERY_CHARGE_VOLTAGE / BATTERY_LIMIT_CURRENT
unsigned char *p_eeprom;
p_eeprom=(uint8_t *)&data_eeprom;
error=dyn_master_read_table(&darwin_dyn_master,id,BATTERY_INPUT_MAX_CURRENT_L,length,p_eeprom);
std::cout << "Limit current eeprom: " << data_eeprom[0] << std::endl;
std::cout << "Output current eeprom: " << data_eeprom[1] << std::endl;
std::cout << "Output voltage eeprom: " << data_eeprom[2] << std::endl;
*/
double
max_current
=
1.0
;
double
max_current
=
1.0
;
double
min_current
=
0.255
;
double
min_current
=
0.255
;
double
limit_current
=
0.512
;
//(A)
double
limit_current
=
0.512
;
//(A)
...
@@ -92,13 +84,11 @@ int main(int argc, char *argv[])
...
@@ -92,13 +84,11 @@ int main(int argc, char *argv[])
// darwin.smart_charger_range_current(min_current, max_current);
// darwin.smart_charger_range_current(min_current, max_current);
darwin
.
smart_charger_set_limit_current
(
limit_current
);
darwin
.
smart_charger_set_limit_current
(
limit_current
);
//current=darwin.smart_charger_get_limit_current();
std
::
cout
<<
"LIMIT CURRENT: "
<<
darwin
.
smart_charger_get_limit_current
()
<<
"A"
<<
std
::
endl
;
//READ SMART CHARGER DATA
//READ SMART CHARGER DATA
// charger_data=darwin.smart_charger_get_data();
// std::cout << "battery status: " << charger_data.bat_status << std::endl;
// std::cout << "Avg time to empty: " << charger_data.avg_time_empty << std::endl;
// std::cout << "Avg time to full: " << charger_data.avg_time_full << std::endl;
while
(
1
){
while
(
1
){
charger_data
=
darwin
.
smart_charger_get_data
();
charger_data
=
darwin
.
smart_charger_get_data
();
...
@@ -108,13 +98,15 @@ int main(int argc, char *argv[])
...
@@ -108,13 +98,15 @@ int main(int argc, char *argv[])
std
::
cout
<<
"battery status: connected"
<<
std
::
endl
;
std
::
cout
<<
"battery status: connected"
<<
std
::
endl
;
else
if
(
charger_data
.
bat_status
==
128
)
else
if
(
charger_data
.
bat_status
==
128
)
std
::
cout
<<
"battery status: connected and charging "
<<
std
::
endl
;
std
::
cout
<<
"battery status: connected and charging "
<<
std
::
endl
;
else
std
::
cout
<<
"Battery status value: "
<<
charger_data
.
bat_status
<<
std
::
endl
;
//y totalmente cargado o descargado???
//y totalmente cargado o descargado???
std
::
cout
<<
"Avg time to empty: "
<<
charger_data
.
avg_time_empty
<<
" min"
<<
std
::
endl
;
std
::
cout
<<
"Avg time to empty: "
<<
charger_data
.
avg_time_empty
<<
" min"
<<
std
::
endl
;
std
::
cout
<<
"Avg time to full: "
<<
charger_data
.
avg_time_full
<<
" min"
<<
std
::
endl
;
std
::
cout
<<
"Avg time to full: "
<<
charger_data
.
avg_time_full
<<
" min"
<<
std
::
endl
;
std
::
cout
<<
"---------------------- "
<<
std
::
endl
;
std
::
cout
<<
"---------------------- "
<<
std
::
endl
;
//std::cout << "Avg time to empty: " << darwin.smart_charger_read_time_empty() << " min" << std::endl;
//std::cout << "Avg time to empty: " << darwin.smart_charger_read_time_empty() << " min" << std::endl;
//charger status --> batteries detected, AC detected, etc
//charger status --> batteries detected, AC detected, etc
//status=darwin.smart_charger_read_status();
//status=darwin.smart_charger_read_status();
...
...
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