Go to Post Man I hate it when people muddy up our rampant speculation with facts and logic, jeez :D - rsisk [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 24-11-2003, 09:31
Josh Siegel's Avatar
Josh Siegel Josh Siegel is offline
lurker
#0448 (Crandroids)
 
Join Date: Nov 2003
Rookie Year: 2003
Location: Bloomfield Hills, Michigan
Posts: 67
Josh Siegel will become famous soon enough
Send a message via AIM to Josh Siegel Send a message via MSN to Josh Siegel
Battery voltage

How would I go about reading battery voltage in PBasic (and C)? In all the examples I've looked at, it switches between batt_volt and bat_volt for the variable.
I'm currently using batt_volt in my code, with it in serin (but not out), and it's never reading anything but 127.
Thanks in advance for any help
  #2   Spotlight this post!  
Unread 19-12-2003, 10:03
Josh Siegel's Avatar
Josh Siegel Josh Siegel is offline
lurker
#0448 (Crandroids)
 
Join Date: Nov 2003
Rookie Year: 2003
Location: Bloomfield Hills, Michigan
Posts: 67
Josh Siegel will become famous soon enough
Send a message via AIM to Josh Siegel Send a message via MSN to Josh Siegel
Re: Battery voltage

Does anyone know how? If so, please respond (it's getting fairly urgent).
  #3   Spotlight this post!  
Unread 19-12-2003, 10:53
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,727
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Battery voltage

Quote:
Originally Posted by Josh Siegel
Does anyone know how? If so, please respond (it's getting fairly urgent).
In PBasic use:

bat_volt VAR byte

'RC Analog Input 8, hardwired to the Battery
'Vin = ((4.7/14.7)* Battery voltage)-0.4
'Binary Battery Voltage = (Vin/5.0 V)*255
.
.
.
c_batt_volt CON 1

Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB _mode,packet_num,sensor1,sensor2,p2_y,p1_y,sensor3 ,sensor4,p4_y,p3_y,sensor5,sensor6,p2_wheel,p1_whe el,sensor7,bat_volt,p4_wheel,p3_wheel,p2_aux,p1_aux,p4_aux,p3_aux,del ta_t,res01]


---
bat_volt will be the variable holding the value you want

For the new controller in C it’s:
current_voltage = battery_voltage * 0.038 + 0.05;

To avoid floating point processing use something like
volts1000s = (battery_voltage * 38 + 50);

The value battery_voltage is provided by the Master uP through rxdata.rc_analog01
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 19-12-2003 at 11:08.
  #4   Spotlight this post!  
Unread 19-12-2003, 17:10
Josh Siegel's Avatar
Josh Siegel Josh Siegel is offline
lurker
#0448 (Crandroids)
 
Join Date: Nov 2003
Rookie Year: 2003
Location: Bloomfield Hills, Michigan
Posts: 67
Josh Siegel will become famous soon enough
Send a message via AIM to Josh Siegel Send a message via MSN to Josh Siegel
Re: Battery voltage

Thanks for the reply, but I have one question:
That looks like it will hold a variable, but will it read from the edu board? thanks so much
  #5   Spotlight this post!  
Unread 22-12-2003, 08:28
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,727
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Battery voltage

Quote:
Originally Posted by Josh Siegel
Thanks for the reply, but I have one question:
That looks like it will hold a variable, but will it read from the edu board? thanks so much
I don't have last year's EDU controller handy to verify the PBasic code. It's now locked in the school for the holiday break. We used this code with the 2003 Full RC. The Serin is the Read that loads the variable. You shouldn't be getting 127 in any case. That's neutral on a joystick or wheel input not a voltage. Based on the symptom I would guess that your Serin variable order isn't correct (i.e., bat_volt is falling on one of your wheel inputs. It should be where the EDU default code had sensor8) or the serin flags don't match the serin list of variables. e.g.,

c_p1_y CON 1
c_p1_x CON 1
...
c_p1_wheel CON 1
...
c_batt_volt CON 1

Serin COMA\COMB, INBAUD, [p1_x, p1_y, p1_wheel, bat_volt]
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 22-12-2003 at 11:57.
  #6   Spotlight this post!  
Unread 22-12-2003, 10:15
Josh Siegel's Avatar
Josh Siegel Josh Siegel is offline
lurker
#0448 (Crandroids)
 
Join Date: Nov 2003
Rookie Year: 2003
Location: Bloomfield Hills, Michigan
Posts: 67
Josh Siegel will become famous soon enough
Send a message via AIM to Josh Siegel Send a message via MSN to Josh Siegel
Re: Battery voltage

Thank you SO much! It was the serin staring me in the face the whole time! I guess thats what I get for sleeping instead of programming... As soon as we get back from break, I'll test it out again. Thank you again!
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick release battery connector and 120 amps n[ate]vw Electrical 6 18-01-2003 23:41
Off-topic battery stuff. FotoPlasma Electrical 4 06-01-2003 12:19
Output voltage in PBASIC diego25 Programming 7 31-01-2002 22:50
connecting to the battery ahecht Technical Discussion 1 25-01-2002 17:15


All times are GMT -5. The time now is 14:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi