What do you mean by
and what do you mean by... I have a clean nice looking analog signal on the oscilloscope
...as soon as I hook up the input to PORTA.0 ... the signal gets nasty
What do you mean by
and what do you mean by... I have a clean nice looking analog signal on the oscilloscope
...as soon as I hook up the input to PORTA.0 ... the signal gets nasty
regards
Ralph
_______________________________________________
There are only 10 types of people:
Those who understand binary, and those who don't ...
_______________________________________________
What I meant by clean analog signal is that I can distinguish parts of the signal that correspond to known timing signals (the signal is clocked out by TTL signals going into the chip). And when I hook up the analog signal to PORTA.0, I can no longer get good data. It's as if the PIC is loading the circuit down. My code is as follows:
' Connect analog input to (RA0)
' Connect clocks to PORTB
' PORTB.0 is the Reset Clock
' PORTB.1 is the Vphase1 clock
' PORTB.2 is the Vphase2 clock
' PORTB.3 is the Hphase1 clock
' PORTB.4 is the Hphase2 clock
' The reset will be connected to a HWPM clock pin #17, USE FEEDBACK WIRE!!
' 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 HSEROUT parameters
DEFINE HSER_TXSTA 24h ' High speed baud generator
DEFINE HSER_BAUD 57600 ' 57600 baud rate
' Define HPWM parameters
DEFINE HPWM1_TIMER 2
DEFINE CCP1_REG PORTC
DEFINE CCP1_BIT 2 ' RC2
TRISC.1 = 0 ' HPWM automatically does this for you, but just in case
CCP1CON = %00001100 ' PWM mode
HPWM 1,31,3205 ' RC2/CCP1 3.205kHz @ ~1/8% duty
' Define interrupt parameters
INTCON2 = %01000000 ' External Interrupt on Rising Edge
INTCON.7 = 0 ' Disables global interrupts
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %00001110 ' Set PORTA digital, except for bit 0
TRISB = %00000001 ' Set PORTB to all output, except for bit 0
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.1 = 0
PORTB.2 = 0
PORTB.3 = 1
PORTB.4 = 0
PORTB.5 = 0 ' LED off indicates that the camera is not transferring data
buttonloop:
IF PORTA.2 = 1 then
PORTB.5 = 1
GOTO vertloop
else
PORTB.5 = 0
GOTO buttonloop ' Waits for 5V that signals shutter is closed
ENDIF
vertloop:
horizpulse = 1
PORTB.1 = 1
PAUSEUS 312
PORTB.1 = 0
PORTB.2 = 1
PAUSEUS 312
PORTB.1 = 1
PORTB.2 = 0
PAUSEUS 312
PORTB.1 = 0
PAUSEUS 312
vertpulse = vertpulse + 1
IF vertpulse < 512 THEN
GOTO horizloop
ELSE
PORTB.5 = 0
GOTO buttonloop
ENDIF
horizloop:
INTCON.1 = 0 ' Resets interrupt flag to 0
Resetcheck: ' Loops back to make sure the PORTB.3 goes low and
IF INTCON.1 = 0 THEN ' PORTB.4 goes high as close
GOTO Resetcheck ' to the external trigger's rising edge as possible
ENDIF
PORTB.3 = 0
PORTB.4 = 1
PAUSEUS 156
PORTB.4 = 0
PORTB.3 = 1
ADCIN 0, adval ' A/D 8 bit value from PORTA.0 into adval
HSEROUT [adval] ' Output ASCII character rep of word serially to PC from C.6
horizpulse = horizpulse + 1
IF horizpulse < 796 THEN
GOTO horizloop
ELSE
PAUSEUS 312
GOTO vertloop
ENDIF
END
TurboLS,
give us an idea what you "analog signal" looks like and where it is comming from.
regards
Ralph
_______________________________________________
There are only 10 types of people:
Those who understand binary, and those who don't ...
_______________________________________________
The analog signal is coming from a sample and hold op amp that is sampling an analog video signal coming from a CCD chip. Please click on the following link and look at the Vout signal on page 13 of the PDF. That is the signal we are getting before we attach the PIC chip.
http://www.kodak.com/global/plugins/...2ELongSpec.pdf
Then when we attach it, the signal gets loaded down and all we get is noise in the A/D. thanks again for takin a look.
I also tried putting the signal through a buffering op amp and that doesn't seem to help. For some reason, the A/D input of the PIC does not like the signal coming from output of the buffer, nor does it like the input of our sample and hold circuitry, nor the signal coming directly from the CCD. So we tried to amplify the signal before buffering it and the output just becomes noisy as hell with or without the PIC connected.
HELP!
So it's not a PIC problem, it's more a problem with the output of your sensor.we tried to amplify the signal before buffering it and the output just becomes noisy as hell with or without the PIC connected.
With external hardware.Is there any way to set PORTA.0 as a low impedance input???
It's still not really clear to me what you are trying to achieve.
What does the timing of the analog signal look like?
regards
Ralph
_______________________________________________
There are only 10 types of people:
Those who understand binary, and those who don't ...
_______________________________________________
Bookmarks