Ok, here is my updated code, now I just have a few questions:
1.) Is there a way to split PORTA into analog and digital inputs?
2.) PORTB.4 is the reset clock and basically it has to be pulsing as soon as the microcontroller powers up. The problem is that once i start the other clocks, the time at which the reset goes high has to be in synch with H1 going low and H2 going high. In addition, it's high duration is 1/4 of the high time of the horizontal clocks. I will post up a timing diagram to explain what i mean later today. So basically I can't just put it in one of my loops, I have to start it pulsing at like a 25% duty cycle and when the other clocks are going, it has to be in synch with the horiztonals like i said earlier.
any help is appreciated.
' Connect analog input to (RA0)
' Connect clocks to PORTB
' PORTB.0 is the Vphase1 clock
' PORTB.1 is the Vphase2 clock
' PORTB.2 is the Hphase1 clock
' PORTB.3 is the Hphase2 clock
' PORTB.4 is the reset clock
' Connect pin 2 from the DB9 connector to PORTC.6
' Have a +5V source ready to touch PORTA.2 to trigger clocking process
include "modedefs.bas"
' Define ADCIN parameters
Define ADC_BITS 8 ' Set number of bits in result
DEFINE OSC 20 ' Sets clock speed to 20Mhz
Define ADC_CLOCK 4 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %00000010 ' Set PORTA analog
TRISB = %00000000 ' Set PORTB to all output
Pause 500 ' Wait .5 second
Pause 500 ' Wait .5 second
horizpulse var byte
vertpulse var byte
adval var byte ' Create adval to store result
horizpulse = 1 ' Initialize counters, initial states
vertpulse = 1
PORTB.0 = 0
PORTB.1 = 0
PORTB.2 = 1
PORTB.3 = 0
PORTB.4 = 0
buttonloop:
IF PushButtonOnPORTABIT2 = 1
THEN GOTO vertloop ' Waits for 5V that signals shutter is closed
ELSE GOTO buttonloop
vertloop:
horizpulse = 1
PORTB.0 = 1
PAUSEUS 139
PORTB.0 = 0
PORTB.1 = 1
PAUSEUS 139
PORTB.0 = 1
PORTB.1 = 0
PAUSEUS 139
PORTB.0 = 0
PAUSEUS 270
vertpulse = vertpulse + 1
IF vertpulse < 512
THEN GOTO horizloop
ELSE GOTO buttonloop
horizloop:
PORTB.2 = 0
PORTB.3 = 1
PAUSEUS 139
PORTB.3 = 0
PORTB.2 = 1
PAUSEUS 50
ADCIN 0, adval ' A/D 8 bit value from PORTA.0 into adval
SEROUT2 PORTC.6,16416,[BIN8 adval,13,10] ' Output 8 bit word serially to PC from C.6
PAUSE 87
horizpulse = horizpulse + 1
IF horizpulse < 784
THEN GOTO horizloop
ELSE GOTO vertloop
END




Bookmarks