How can I stop a bit counter from underflowing ?

Grant666

Member
Hi All

I have set up a bit as a counter.

So for example b1=10, I then count this down via b1=b1-1. The problem is that once I count down to 0 ( zero ), if I then count one less I get and underflow which the sets the value of b1 to 255 then 254 etc

How can I stop b1 from underflowing if it still receives the b1=b1-1 in the program?

I have tried a few variations of the forum posts, but to no success.

I await your enlightened replys

Thank you
 

techElder

Well-known member
Grant, look in Manual 2 under "Variables - Mathematics" for the MIN function. That's one way to go to a minimum value and stay there.

Without all of your code, it will be difficult for others to give you more than examples of solutions.
 
Top