View Single Post
  #4   Spotlight this post!  
Unread 10-01-2012, 00:52
JewishDan18's Avatar
JewishDan18 JewishDan18 is offline
Registered User
FRC #1700
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2007
Location: Sunnyvale, CA
Posts: 185
JewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to behold
Re: Finding battery voltage?

Although I think you would be far better off with a closed loop control as Eric said, I took a quick peak in the driverstation code (I would like to read it so I can give myself a more obvious warning when the battery is dying and I can't think of why things stop working), and found something that would most likely work:

Code:
import edu.wpi.first.wpilibj.DriverStation;

...

DrivetStation DS = DriverStation.getInstance();

...

double voltage = DS.getBatteryVoltage();
It is important that the CRIO has the proper jumper to read the voltage; if you see voltage on your dashboard, this should work. I have not tested it, and I don't know what sort of value it returns, but I will most likely look into it tomorrow.

I question why the battery was low enough to make the arm much slower; how long do you run the robot before putting a charged battery in? We swap after the voltage drops below 12v (if we remember ).
Reply With Quote