DT - Thanks, that fixed the issue.
Now, an unexpected one has appeared. First I'll explain the product.
We are looking for a 1 to 2ms pulse appearing on either porta.0 or porta.1. Upon receipt of the pulse I have to send out a 1, 2, 4 or 8ms pulse to turn on 2 FETs located at portb.0 and portb.1 The time of the pulse depends upon dipswitch settings.
So if set to 4ms, the program should scan the capacitors for the correct voltage, wait for a pulse input, fire FET's for 4ms when received, go back and wait for the next pulse in.
The problem is the FETS fire anywhere from 1 time to 6 times per one 1 ms pulse input.
I need an ultra fast reaction time so after a pulse is recieved I cant go and do other stuff before turning on the FET's.
I thought about adding a 10ms delay at the end of the flash subroutine and I've thought about adding a count. If count = 1 and there is a pulse received, I could tell it to ignore the input. The count would have to get to reset to zero in the loop somewhere.
Heres the code as it stands right now.
Code:OSCCON = $70 'set internal resonator to 8mhz Define ADC_BITS 10 ' Set number of bits in result Define ADC_CLOCK 5 ' Set clock source (3=rc) Define ADC_SAMPLEUS 20 ' Set sampling time in uS DEFINE OSC 8 BNK1 VAR WORD BNK2 VAR WORD DUR VAR WORD ADCON0 = %00000001 ADCON1 = %01111100 ADCON2 = %10111110 TRISA = %11111111 TRISB = %11110000 PORTB.0 = 1 PORTB.1 = 1 PORTB.2 = 1 PORTB.3 = 0 BNK1 = 0 BNK2 = 0 DUR = 0 MAIN: DUR = 0 PORTB.3 = 0 BNK1 = 0 BNK2 = 0 ADCIN 0, BNK1 ADCIN 1, BNK2 IF PORTB.4 = 1 then DUR = 8 endif IF PORTB.5 = 1 THEN DUR = 4 endif IF PORTB.6 = 1 THEN DUR = 2 endif IF PORTB.7 = 1 THEN DUR = 1 endif IF (BNK1 => 466) OR (BNK2 => 466) THEN FLASH goto MAIN FLASH: IF PORTA.4 = 1 OR PORTA.5 = 0 THEN PORTB.0 = 0 : PORTB.1 = 0 : PORTB.3 = 1 endif IF DUR = 1 THEN PAUSE 1 endif IF DUR = 2 THEN PAUSE 2 endif IF DUR = 4 THEN PAUSE 4 endif IF DUR = 8 THEN PAUSE 8 endif PORTB.0 = 1 : PORTB.1 = 1 : PORTB.3 = 0 GOTO MAIN
Bookmarks