Go to Post "my life is incomplete, my nose has lost the imprint of my safety goggles." - Nin_estarSaerah [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Spotlight this post!  
Unread 29-01-2007, 00:49
bear24rw's Avatar
bear24rw bear24rw is offline
Team 11 Programming Captain
AKA: Max T
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2005
Location: Flanders, NJ
Posts: 385
bear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to behold
Send a message via AIM to bear24rw
Re: Reading battery voltage in software

Wrote this over the summer when playing around with the edu rc. It prints out a float
Code:
current_voltage = rxdata.rc_main_batt; 		// Store current voltage
	average_voltage += current_voltage;		// Add the current voltage to the average stack

	voltage_count++;							// Increase the average stack count
	
	if (voltage_count == 39)					      // If the stack is 40
	{
		average_voltage = (average_voltage / 40) * 0.038 + 0.05;	// Get the average and apply formula
		i = (int)average_voltage;							// Truncate decimals
		i2 = (int) ((average_voltage - i) * 1000);				// Subtract to get decimals only and then multiply by 1000
		printf("Average: %d.%d \n",i,i2);						// Print the two together to make it look like a decimal

		average_voltage = 0;									// Reset the stack
		voltage_count = 0;									// Rest the counter
	}

Last edited by bear24rw : 29-01-2007 at 00:51.
 


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
battery voltage compensation Rickertsen2 Programming 5 17-10-2005 22:12
RC Circuits Melissa Nute Math and Science 3 25-01-2004 05:02
Battery Chargers Neal Probert Electrical 46 16-02-2003 22:31


All times are GMT -5. The time now is 04:59.

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