Darrell,
You should have put the stop at 1 sec in the code, and make people pull it out otherwise. Just a little step towards keeping the knuckle-heads from causing trouble.![]()
Darrell,
You should have put the stop at 1 sec in the code, and make people pull it out otherwise. Just a little step towards keeping the knuckle-heads from causing trouble.![]()
LOL Steve, I like that idea.
But as it is, they have to be holding the button down for it to count down.
If they're still holding it when it reaches 0 ... well ...
I know it can be bypassed, but don't tell them how![]()
DT
Looking for a more efficient way of doing this. I need to monitor 2 inputs and turn on the correct outputs only when the timer is running. This does compile but I havent tested it to see if it actually works. This snippet will go in the main loop of the program that runs while the timer counts down.Code:IF PORTA.2 = 1 OR PORTA.3 = 1 AND DIM = 1 AND timerrunning = 1 THEN PORTA.0 = 1 ENDIF IF PORTA.2 = 1 OR PORTA.3 = 1 AND DIM = 2 AND timerrunning = 1 THEN PORTA.1 = 1 ENDIF IF PORTA.2 = 1 OR PORTA.3 = 1 AND DIM = 3 AND timerrunning = 1 THEN PORTA.0 = 1 PORTA.1 = 1 ENDIF
Here's one idea/Henrik.Code:Temp VAR BYTE If TimerRunning = 1 THEN If (PortA.2 = 1) OR (PortA.3 = 1) THEN Temp = PortA & %11111100 PortA = Temp + DIM ENDIF ENDIF
Henrik I see what you are doing but wouldnt this create an issue with the higher bits? For instance if I am understanding correctly, the higher bits are always at 1, which would indicate a high, which in the program would stop and reset the timer. If I were to make them 0 in the loop, they would never change to 1 when the switch was closed. Switches are on bits 4, 5, 6 and 7.
Hi,
No, the high bits are not always 'at 1'.
When doing a bitwise AND both "inputs" must be true for the "output" to be true. Thus Temp = PortA & %11111100 will do a 'copy' of PortA except the two LSB's will be forced to zero. All the other bits will be left as they are when PortA is read.
Besides, it doesn't really matter what you write to the port/pins which are configured as inputs. If, for example, PortA.5 is an input and you write '1' to it it will still read the actual state that whatever is connected to it drives it to - which isn't neccesarily '1'. If you look at the schematic for the I/O pins you'll see that the output driver for the pin is disabled when TRIS is set (ie. pin is made an input). If it wasn't it would short out whatever drives the pin to either Vdd or Vss.
/Henrik.
Bookmarks