Sponsored links

Go Back   MP3Car.com > Mp3Car Technical > General Hardware Discussion > Fusion Brain > FB Software


Reply
 
Share Thread Tools Display Modes
Old 08-06-2008, 10:14 PM   #1
Low Bitrate
 
Join Date: Dec 2007
Posts: 105
RonS is an unknown quantity at this point
Timer

Exactly what can I use the timers for? As in. Can I use them to time an event. Like how long it takes a voltage to go from 1 to 2 volts. Or use them to set a start and stop time and then find out the voltage change on an input. I have an idea for calculating MPG but I need a timer. What I really need a timer that can be started and then when there is a certain voltage change the timer is stopped and the time used in a calculation. But I don't believe that this can be done.
RonS is offline   Reply With Quote
Advertisement
 
Advertisement
Sponsored links

Old 08-06-2008, 10:51 PM   #2
FLAC
 
Join Date: Oct 2006
Location: Las Vegas
Posts: 1,283
h3rk will become famous soon enough
The timers are always running.

http://www.mp3car.com/vbulletin/fusi...ml#post1206317

I have similar needs, I did try to explain this before and I hadn't really recieved a response. That was a while ago.

It's more like there is a missing building block, something more like a programming language structure: a counter for events.

since the timer is always running, it would be nice to have a block in a function that says counts the timer to X and then Fire. Maybe flexible enough so that it can be enabled by a boolean variable and configurable as 'always repeat' or fire once. The output or value of the variable could be as simple as boolean, allowing any other function to use it.


Something like that?

Last edited by h3rk; 08-06-2008 at 10:57 PM.
h3rk is offline   Reply With Quote
Old 08-07-2008, 12:17 AM   #3
Fusion Brain Creator
 
2k1Toaster's Avatar
 
Join Date: Mar 2006
Location: Colorado, but Canadian!
Posts: 8,862
2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future
For timing of events, make a variable that always get +1 every loop. There's your timer. If variable > value, then do stuff, reset variable. and repeat.

And as h3rk said those timers are the program's timers to know when to fire graphics, logic, and i/o.
2k1Toaster is offline   Reply With Quote
Old 08-07-2008, 12:37 AM   #4
FLAC
 
Join Date: Oct 2006
Location: Las Vegas
Posts: 1,283
h3rk will become famous soon enough
That makes sense. Thanks for the new feature.
h3rk is offline   Reply With Quote
Old 08-07-2008, 10:33 AM   #5
Low Bitrate
 
Join Date: Dec 2007
Posts: 105
RonS is an unknown quantity at this point
I feel dumb now. I am not understanding the variable as a timer. I know that it is going to be one of those slap yourself in the forehead things. But give an old guy a break. I need to time how long it takes to burn a gallon of gas.
RonS is offline   Reply With Quote
Old 08-07-2008, 04:19 PM   #6
Fusion Brain Creator
 
2k1Toaster's Avatar
 
Join Date: Mar 2006
Location: Colorado, but Canadian!
Posts: 8,862
2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future
Code:
variable_timer = 0; loop { variable_timer = variable_timer + 1; if(fuel sender is between x and y) { number_of_times_in_loop = variable_timer; variable_timer = 0; time_to_burn = (number_of_times_in_loop * time_for_each_loop); } }

So every time variable goes up by 1.

Capture the 1 mile of gas being burned. In that capture moment, reset the varaible to 0. The time it took to get there was the variable value (number of times in the loop) multiplied by the time it takes each loop which is every "timer" value that you set. So if the timer is set to 100mS, and the variable is 4000, then it took 4000*100 = 400000mS = 400s = 6.66 minutes.
2k1Toaster is offline   Reply With Quote
Old 08-07-2008, 05:27 PM   #7
Constant Bitrate
 
Join Date: Jun 2008
Location: Georgia, USA
Posts: 172
Dan2008 is an unknown quantity at this point
Instead of:

Code:
number_of_times_in_loop = variable_timer; variable_timer = 0; time_to_burn = (number_of_times_in_loop * time_for_each_loop);

Why not:

Code:
time_to_burn = (variable_timer * time_for_each_loop); variable_timer = 0;

__________________
Thanks,

Dan
Dan2008 is offline   Reply With Quote
Old 08-07-2008, 05:39 PM   #8
Fusion Brain Creator
 
2k1Toaster's Avatar
 
Join Date: Mar 2006
Location: Colorado, but Canadian!
Posts: 8,862
2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future
Quote: Originally Posted by Dan2008 View Post
Instead of:

Code:
number_of_times_in_loop = variable_timer; variable_timer = 0; time_to_burn = (number_of_times_in_loop * time_for_each_loop);

Why not:

Code:
time_to_burn = (variable_timer * time_for_each_loop); variable_timer = 0;

I was just trying to make it easy with the variable names. Coding it in MDX looks a million times different anyways.

And by storing it in a seperate variable, you can compare your current with your past.
2k1Toaster is offline   Reply With Quote
Sponsored links
Advertisement
 
Advertisement
Old 08-07-2008, 05:46 PM   #9
Constant Bitrate
 
Join Date: Jun 2008
Location: Georgia, USA
Posts: 172
Dan2008 is an unknown quantity at this point
Gotcha...it makes it easier to read too.

I always make my code work then put it on a diet to try and get the smallest, most efficient code. Some times though, the smallest is not necessarily the most efficient.
__________________
Thanks,

Dan
Dan2008 is offline   Reply With Quote
Old 08-07-2008, 07:33 PM   #10
Low Bitrate
 
Join Date: Dec 2007
Posts: 105
RonS is an unknown quantity at this point
SMACK!! (hits his forehead). Ok sounds good and makes sense. Now to play with that.

Thanks
Ron
RonS is offline   Reply With Quote
Sponsored links
Advertisement
 
Advertisement
Reply

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
12 Volt Timer For Computer kozmo Power Supplies 20 02-18-2007 11:02 AM
555 Timer Problem.. Need it To Trigger when key removed fire Power Supplies 19 07-27-2006 04:44 AM
VB6 Crew, Timer Control Question kamikaze2112 Coders Corner 3 04-09-2006 07:23 PM
Timer Circuit Fox_Mulder General Hardware Discussion 3 11-04-2005 10:47 AM
sleep timer for lcd projector ŠuTcH Off Topic 1 11-23-2004 08:00 PM



All times are GMT -5. The time now is 05:07 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.2
Copyright © 1999 - 2008 Mp3Car.com Inc.Ad Management by RedTyger
Message Board Statistics