I am still very interested in the first one and looking forward to taking a look at the code.
The second one was me trying to learn timers and how to manipulate them.
I am still very interested in the first one and looking forward to taking a look at the code.
The second one was me trying to learn timers and how to manipulate them.
And now for something Completely Different!
Main brains only got 1 track left.
Ya gotta tell me when to switch to track B ...
OK, back to the first problem.
I've got this code for the last schematic.
It hasn't even seen an electron yet, but I think it's close, although it's guaranteed to change.
I'm trying to make a breadboard for it.
But it's going slower than anticipated. (blame Half-Life).
Here's what I got ...
http://www.pbpgroup.com/files/ZeroDelay1.htm
<br>
DT
Interesting peice of code - over my head for the moment.
Going back to the pulse following example, here is a piece of code I came up with at about 4am this morning.
Code:OSCCON = $70 'set internal resonator to 8mhz DEFINE OSC 8 ADCON0 = %00000001 ADCON1 = %01111100 ADCON2 = %10111110 PORTB = %00000111 TRISA = %11111111 TRISB = %11110000 loop: IF PORTA.5 = 0 THEN flash GOTO loop FLASH: PORTB = %00001100 'turns on fets A = 0 'resets count to 0 while A <= 5 'follow status of i/p turn off fets if i/p goes away PORTB = %00001100 A = A + 1 IF (PORTA.5 = 1) THen PORTB = %00000111 WEND if (A <=4) THEN GOTO loop if (A = 5) then 'if A=5 fets are still on pauseus 1500 'set max time for fets to be on PORTB = %00000111 'turn off fets IF (PORTA.5 = 0) THEN 'if i/p is still on, wait 2ms then repeat loop pause 2 return
jmgelba , These lines will never execute because of the value of "A" before hand.
if (A <=4) THEN <<<<<<<<<<<<<<<<<<<<<<<<< here A = 6
GOTO loop
if (A = 5) then 'if A=5 fets are still on <<<<<<<<<<<<<<<< here A = 6
pauseus 1500 'set max time for fets to be on
PORTB = %00000111 'turn off fets
Also wheres the ENDIF's?
Dave Purola,
N8NTA
Why would A = 6?
Before the goto, A is set to 0, then I'm counting up. If A becomes less than or equal to 4 something happens. If A = 5 then something else happens.
jmgelba, Because "While" it is the loop A is being incremented until it equals 6 right?
Dave Purola,
N8NTA
I thought I was incrementing it until it reached 5? If its equal or less than 4 (>=4) is does something, if it is =5 than it does something else. After it has reached either of those conditions it shouldnt increment again.
Bookmarks