View unanswered posts | View active topics It is currently Sat Sep 26, 2020 8:53 am






Reply to topic  [ 15 posts ] 
Display EV3 Battery Level 
Author Message
Rookie

Joined: Fri Aug 22, 2014 4:23 am
Posts: 1
Post Display EV3 Battery Level
Hi:
I just use the code to display the battery level of EV3:


task main()
{while(true){
displayBigTextLine(4," %i",nImmediateBatteryLevel);
}
}

But it always display "0" . Do I get something wrong?
Thanks.


Fri Aug 22, 2014 4:53 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Display EV3 Battery Level
No, the opcode was a little disfunctional. I saw a fix for it in the changelog just yesterday :)

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Aug 22, 2014 5:55 am
Profile WWW
Rookie

Joined: Fri Sep 20, 2013 8:39 am
Posts: 38
Post Re: Display EV3 Battery Level
What is the difference between that method and the getBatteryVoltage() function


Fri Aug 22, 2014 6:02 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Display EV3 Battery Level
On the EV3 I am not sure, but on the NXT, the immediate one returns the value right hat moment, but the other one is an averaged value. The battery value can fluctuate wildly when motors are running, due to the amount of current being used.

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Aug 22, 2014 6:15 am
Profile WWW
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: Display EV3 Battery Level
mightor wrote:
On the EV3 I am not sure, but on the NXT, the immediate one returns the value right hat moment, but the other one is an averaged value. The battery value can fluctuate wildly when motors are running, due to the amount of current being used.

= Xander


Correct; the EV3 has one 'official' battery command at the moment: getBatteryVoltage(), which "Returns the battery level in tenth of a volt precision, as measured by the EV3 brick."

The NXT has several (some of which are not yet officially supported by the EV3), including the nAvgBatteryLevel variable and nImmediateBatteryLevel variable. nAvgBatteryLevel is the "average battery level in millivolts as measured by the NXT brick. The value is taken from the average of 20 recent samples of the current voltage.", while nImmediateBatteryLevel is "the most recent sample of battery level in millivolts".

As far as functionality, the getBatteryVoltage() command and nImmediateBatteryLevel variable should work the same way on their respective platforms.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.


Fri Aug 22, 2014 10:11 am
Profile
Rookie

Joined: Fri Sep 20, 2013 8:39 am
Posts: 38
Post Re: Display EV3 Battery Level
Ok. What does the getBatteryCurrent() command do and what does it need as a parameter.


Fri Aug 22, 2014 7:00 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Display EV3 Battery Level
I daresay it returns the amount of current that is being consumed. I am not sure how accurate or useful that information is, though. I remember reading somewhere that the data from it is spotty at best. The EV3's VM does quite a bit of "magic" with the power data it retrieves from the kernel. One of the things it does is make sure the EV3 does not consume too much power, for too long a period of time, to prevent overheating. A lot (if not all) of this battery management happens outside the ROBOTC VM.

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sat Aug 23, 2014 1:21 am
Profile WWW
Rookie

Joined: Fri Sep 20, 2013 8:39 am
Posts: 38
Post Re: Display EV3 Battery Level
Hiya

Any thoughts as to what parameter that you have to pass it - a time interval for example.

It would be lovely to see some documentation - is there an SDK for the EV3 that is available to read and which may give some insights.


Sat Aug 23, 2014 4:37 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Display EV3 Battery Level
The focus has been on getting a working product out the door. The documentation and examples will follow very shortly :)

No argument needs to be passed to that function:
Code:
// Get battery current
intrinsic float getBatteryCurrent()
                asm(byte(opcdEV3_LEGO), byte(opUI_READ), byte(GET_IBATT), functionReturn);

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sat Aug 23, 2014 4:48 am
Profile WWW
Rookie

Joined: Fri Sep 20, 2013 8:39 am
Posts: 38
Post Re: Display EV3 Battery Level
Hiya

When I attempt to compile the following program, the getBatteryVoltage compiles but the getBatteryCurrent says Parameter "float & current" is "None Specified"
Code:
task main()
{
getBatteryVoltage();
getBatteryCurrent();
}


Also in the Text Function pane it states "getBatteryCurrent(current).

The getBatteryCurrent is listed in the Text Functions under "Battery & Power Control" while the getBatteryVoltage is listed under "EV3Misc"

No doubt once everything is working, things like this can be tidied up.


Last edited by Sirius on Sun Aug 24, 2014 2:11 am, edited 1 time in total.



Sat Aug 23, 2014 7:27 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Display EV3 Battery Level
I am guessing that's a mistake :) I'll pass it on.

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sat Aug 23, 2014 11:45 pm
Profile WWW
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 616
Post Re: Display EV3 Battery Level
Sirius and Xander. Thanks for the comments. Both items have already been fixed and will be in the next release. THe voltage and current functions both return 'float' and have no parameters. They are both in the "Battery & Power Control" heading in the "menu" pane.


Sun Aug 24, 2014 12:32 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Display EV3 Battery Level
Dick,

Awesome!

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Aug 24, 2014 12:34 am
Profile WWW
Rookie

Joined: Fri Sep 20, 2013 8:39 am
Posts: 38
Post Re: Display EV3 Battery Level
Dick and Xander

Just trying to point out inconsistencies without being trivial.

Looks like you guys may well be on top of the next release and I am looking forward to it.

Sirius.


Sun Aug 24, 2014 1:49 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Display EV3 Battery Level
Keep 'em coming, Sirius :)

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Aug 24, 2014 1:55 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 15 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.