| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| davt 
 
 
 Joined: 07 Oct 2003
 Posts: 66
 Location: England
 
 
			    
 
 | 
			
				| use of float |  
				|  Posted: Thu Mar 31, 2005 4:17 am |   |  
				| 
 |  
				| Hi everybody 
 I am designing a long delay timer and I need a 32 bit variable to count a large number of "ticks" , can I just declare a float variable and use it to count the "ticks" .
 Thanks
   
 Dave
 |  | 
	
		|  | 
	
		| valemike Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				|  |  
				|  Posted: Thu Mar 31, 2005 7:41 am |   |  
				| 
 |  
				| I don't know what the range of CCS's floats are, but even those are finite. 
 How many ticks, or Seconds, do you want to elapse? For example, if I wanted to count, say, 30 minutes, I would do the following.
 
 Looking at CCS's example program ex_stwt1.c, there is a SECONDS timer. So if I wanted to get 30 minutes out of it, then I would need 60 x 30 = 1800 seconds. See how 1800 easily fits inside an "unsigned long" which can go up to 65535 (thus 65535 / 60 = 1092 minutes).
 
 That is how i would go about achieving a long timer, rather than using a float.
 |  | 
	
		|  | 
	
		| Darren Rook 
 
 
 Joined: 06 Sep 2003
 Posts: 287
 Location: Milwaukee, WI
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Thu Mar 31, 2005 7:46 am |   |  
				| 
 |  
				| So, why not use int32? |  | 
	
		|  | 
	
		| DragonPIC 
 
 
 Joined: 11 Nov 2003
 Posts: 118
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Mar 31, 2005 10:58 am |   |  
				| 
 |  
				|  	  | Darren Rook wrote: |  	  | So, why not use int32? | 
 
 good question.
 _________________
 -Matt
 |  | 
	
		|  | 
	
		|  |