Go Back   VEX Forum > Community > Technical Discussion

Technical Discussion Open Technical Discussion of the VEX Robotics System.

Reply
 
Thread Tools
  #1  
Old 04-11-2012, 08:52 PM
StephenDsDude StephenDsDude is offline
Senior Member
VEX # 675B
 
Join Date: Jan 2012
Location: Buford, GA
Posts: 138
Images: 17
RobotC Power Expander Status Battery Voltage

I wish to view the voltage level in the battery attached to the power expander in RobotC. I have this quick calculation:

Code:
    string exp_bat = (float)SensorValue[in6]/45.6;
(for the LCD display) but it returns me a value of about 4.8. Am I doing something wrong? I am using the VEX Cortex.

Thanks
__________________
  • Team Leader of Team 675B
  • Excellence Award at GSMST Qualifier (1-28-2012)
  • Tournament Champions and Excellence Award at Ola Mustangs Qualifier (1-19-2013)
  • Tournament Champions at Carrollton Qualifier (2-9-2013)
Reply With Quote
  #2  
Old 04-11-2012, 10:02 PM
jpearman's Avatar
jpearman jpearman is online now
Senior Member
VEX # 8888
 
Join Date: Apr 2011
Location: Los Angeles
Posts: 3,080
Images: 2
Re: RobotC Power Expander Status Battery Voltage

The numbers on the Wiki were assuming a 10bit A-D conversion, the code I use with my power expander is as follows.

Code:
battery2Level = (int)((float)SensorValue[ BATERY_2_PORT ] * 5.48);
Why 5.48 ?

Well I wanted the battery level in mV not V. As I said, the number 45.6 was for a 10 bit A-D conversion so for ROBOTC with 12 bit A-D the number would be 4 times larger, 45.6 x 4 = 182.4 so

V = AnalogValue / 182.4

but I want mV so

mV = AnalogValue / 182.4 * 1000

1000 / 182.4 = 5.48

Now having said that if you use 182.4 then you will get an even smaller value, so there are two possible explanations.

1. You have something connected wrong, you should have analog input 1 connected to the status port on the power converter. 4.8 x 45.6 gives an analog value of 219, this feels like you are reading an unconnected analog input as it is about the value of a floating input. Does the value on analog in1 change when you connect and disconnect the power expander battery?

2. There is a theory that there are two versions of power converter, I know the one I have is an older model, it has an issue that when the status port is connected then the led flashes red indicating an error even when there is not one. If there is indeed a new model then the calibration may have changed and different numbers needed, I have not been able to test this as the new unit I ordered is still on backorder.

There is some discussion in this thread
http://www.vexforum.com/showthread.php?t=64681

and also this one

http://www.vexforum.com/showthread.php?t=64393
Reply With Quote
  #3  
Old 04-12-2012, 04:13 AM
StephenDsDude StephenDsDude is offline
Senior Member
VEX # 675B
 
Join Date: Jan 2012
Location: Buford, GA
Posts: 138
Images: 17
Re: RobotC Power Expander Status Battery Voltage

Thank you for the reply; I will test out the new conversion tonight and respond back with results.

As for the 4.8 number, it does fluctuate when the arm and only the arm is being moved (which are the 4 motors in the expander) and I do believe it went to 0 when the battery was removed, but I am not fully certain of this. I'll respond back later today.
__________________
  • Team Leader of Team 675B
  • Excellence Award at GSMST Qualifier (1-28-2012)
  • Tournament Champions and Excellence Award at Ola Mustangs Qualifier (1-19-2013)
  • Tournament Champions at Carrollton Qualifier (2-9-2013)
Reply With Quote
  #4  
Old 04-12-2012, 07:44 PM
StephenDsDude StephenDsDude is offline
Senior Member
VEX # 675B
 
Join Date: Jan 2012
Location: Buford, GA
Posts: 138
Images: 17
Re: RobotC Power Expander Status Battery Voltage

Okay, so after testing, it actually gives a value of 48.[something] normally. Multiplying by 5.48 gives me 118[something]. However, I am certain this is tied to the battery because it fluctuates whenever the arm is moved.

(sorry I don't have the [something]s for you; I shorten the number to a 3 character string so I can view the battery, the power expander battery, and the backup batter voltage in one line on the LCD)
__________________
  • Team Leader of Team 675B
  • Excellence Award at GSMST Qualifier (1-28-2012)
  • Tournament Champions and Excellence Award at Ola Mustangs Qualifier (1-19-2013)
  • Tournament Champions at Carrollton Qualifier (2-9-2013)
Reply With Quote
  #5  
Old 04-12-2012, 07:55 PM
jpearman's Avatar
jpearman jpearman is online now
Senior Member
VEX # 8888
 
Join Date: Apr 2011
Location: Los Angeles
Posts: 3,080
Images: 2
Re: RobotC Power Expander Status Battery Voltage

Quote:
Originally Posted by StephenDsDude View Post
Okay, so after testing, it actually gives a value of 48.[something] normally. Multiplying by 5.48 gives me 118[something]. However, I am certain this is tied to the battery because it fluctuates whenever the arm is moved.

(sorry I don't have the [something]s for you; I shorten the number to a 3 character string so I can view the battery, the power expander battery, and the backup batter voltage in one line on the LCD)
Ok, well that sounds like they did change the hardware. 48 * 45.6 gives 2189, this would be about 2.67V on the AD converter.

Try 275 instead of 45.6 in your original equation.

V = Analog Value / 275
Reply With Quote
  #6  
Old 04-13-2012, 08:34 PM
StephenDsDude StephenDsDude is offline
Senior Member
VEX # 675B
 
Join Date: Jan 2012
Location: Buford, GA
Posts: 138
Images: 17
Re: RobotC Power Expander Status Battery Voltage

Thank you, that number works great. Perhaps VEX just has yet to update the wiki page on the Power Expander.

Either that, or I overread the page. Either way, thanks.
__________________
  • Team Leader of Team 675B
  • Excellence Award at GSMST Qualifier (1-28-2012)
  • Tournament Champions and Excellence Award at Ola Mustangs Qualifier (1-19-2013)
  • Tournament Champions at Carrollton Qualifier (2-9-2013)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 10:36 PM.


VEX and VEX Robotics are trademarks or service marks of Innovation First International, Inc.
Copyright © 2002-2013. All Rights Reserved. VEX Robotics, Inc. is a subsidiary of Innovation First International, Inc.
All other product names/marks of others are the property of their respective owners.