Getting the battery voltage

I would like to get the voltage of the battery in the code itself.
I belive this is very possible, but I do not know how to do it.
I have the voltage shown properly on the driver station.
If anyone knows how to get the voltage I would appreciate it.

Since your jumper is setup correctly, you just need to read Analog Input #8

You’ll need an OPEN in your BEGIN.VI, then simply do a GET from that analog input.

I have already tried that, and it gave me a value of 0, than it also gave me 0 on the driver station.
I will try that again.
Meanwhile, any other suggestions?

The communication task already acquires Analog Input 8 on slot 1. I don’t think the system will let you open it again.

You might be able to modify the Start Communication vi to save the battery voltage in a global variable for you. Find the case where it says “Read the battery voltage every 200ms.” and try storing the result of the multiplication in the “0” case into a new global that you can read elsewhere in the project.

The real question is, why are you reading the battery voltage on the robot side? That sounds interesting.

Alternately, just wire the 12V into another AI port and read that.

12V is outside of the range of the analog inputs. A voltage divider would be required for this configuration.

If you aren’t seeing it on the driver station, you may be missing the jumper that selects it.

Here is the odd thing. Like the OP, we do not display the battery voltage on the drivers station. It worked just fine until we applied the last updates to both the cRio and the DS. Now it only gives us “0.00”.
The jumper is on the outer two pins of the analog bumper, exactly where it was before the update. Other than that, everything works perfectly.

Any ideas?

Is the green power LED lit on the analog breakout board?

Yes sir. Our Gyro on Ch.1 works as well, so we know the board is getting power to the bumper.

It really seems odd to us. The ONLY thing we changed between when it worked and when it didn’t was the curio firmware and the DS software.

we had an issue similar to this but the problem was intermittent, eventually traced it back to a flakey jumper, try changing it out see if that makes a difference

This is what I’m leaning toward as well. It will be one of the first things we check when we open the bag.

Well, the jumper checked out normal. So now we are at a loss. We will have the robot out of the bag for four hours this Saturday, hopefully we can figure this out.

Does anyone else have any ideas what may be preventing this from working correctly?
Again, it worked fine until we did the last cRio and DS updates.

Any chance your code is now opening channel 8 on its own? This will cause a resource in use error. I’m guessing your module is ok since you said the gyro works… metal shavings in the db15 connectors can kill the slot and make all channels return 0.

If you have both analog modules installed, you could read the battery voltage from the slot 2 module.


We’ve seen this before when the analog breakout itself went bad at MARC last year - we were helping the robot next to us and NO one could figure out why they weren’t getting battery voltage - so we started swapping out hardware.

You might try swapping your analog breakout.

OK, found the root cause of our issue. The “Diagnostics” tab on the drivers station is what pointed us in the right direction.

It turns out that one of our new programmers, a true genius but not experienced at programing, had placed a call to AI8 in the that no one knew about. We are not using his portion of the code, so it was deleted and now we have a voltage displayed on the drivers station!!

We see here a reason for people not to get upset when the “experts” are unwilling to accept claims that nothing changed before something broke. :cool:

I’m glad you found the problem. I’m especially glad that you found it based on the diagnostic messages provided by the system.

Thanks Alan!

We were tearing our hair out, wait, no, I have no hair, over this one. We had swapped out the AI module, the breakout board and the jumper with no success. We were at a loss. The I remembered seeing the diagnostics tab. “What the heck” I thought, “lets see if it says anything helpful”. Duhhhhhh, error on analog input, resource already in use. “Oh man, let’s look at the code again”. And there it was.

It’s funny, I have made a living for the last 28 years troubleshooting systems. I have found that error messages are not always helpful, but sometimes they are. I have found that familiarity with the system is your best tool. I must say though, this error message definitely was helpful.

Add this one to the lesson book.