View Single Post
  #4   Spotlight this post!  
Unread 18-02-2002, 09:09
JHBurch JHBurch is offline
Registered User
#0045 (TechnoKats)
 
Join Date: Nov 2001
Location: Kokomo, IN
Posts: 10
JHBurch is an unknown quantity at this point
>...can I create a variable and allow that variable to exceed 255? Also do i need to assign it as a word instead of a byte to allow it to work?

Never increment a byte variable past 255. If you do it will wrap around, i.e. 255+1=0. If you need to hold a larger number, declare it as a word. This lets you count up to 65535 before wrapping around to zero. One variable declared as a word takes up exactly the same amount of variable space as two variables declared as bytes.

If this still isn't enough, you can add a bit or two from another variable that you're not using all of. For example if you're using a byte variable for something that never gets higher than 15, declare it as a nibble instead (4 bits) and then use the other half of the byte to extend your count. Each added bit doubles how high you can count, but you'll have to increment it manually when you detect that your word variable is going to roll over.

>The reason i need this is for the pump delay I created.

Isn't there a pressure switch in the kit that you can feed back into one of the digital or analog inputs? Maybe someone else can add more details on this approach.

>Is there a way to start the variables at a certain value other than zero so that the pump turns on right away and then returns to its normal delay cycle?

Yes. Before your main loop you can initialize the variable to one less than the max number, that way the next time it gets incremented you'll turn on your pump and reset the count back to zero. Just make sure that the initialization statement is BEFORE "MainLoop:".
__________________
Jeff Burch
TechnoKats #45