surfer0815
- 27th November 2005, 16:24
Hi! want to read the 8 Bit AD of the 12F675 an put it out as PWM with duty cyle between 0-100%.
My Programm is working well, but when AD gets 5V, I get Pulses out with 400ĩS Pause. But at AD 5 V it should be permanently on, without Pulses
I donīt know whats the problem.
Here Is my Programm, I attached the Scope Picture.
Define OSCCAL_1K 1 ' Calibrate internal oscillator
' Define ADCIN parameters
Define ADC_BITS 8 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
LED Var GPIO.0 ' LED is bit 0, PIN 7
adval var word ' Create adval to store result
i var word
ANSEL = %00111000 ' Set AN3 analog, rest digital
CMCON = 7 ' Analog comparators off
loop:
ADCIN 3, adval ' Read channel 3 to adval
i = 256 - adval
I = i * 10
Pulsout LED,adval ' Puls is 2,56 ms
Pauseus i 'cycle = 5,12ms = 195 Hz
Goto loop ' Do it forever
End
Hope, Someone could help me!
My Programm is working well, but when AD gets 5V, I get Pulses out with 400ĩS Pause. But at AD 5 V it should be permanently on, without Pulses
I donīt know whats the problem.
Here Is my Programm, I attached the Scope Picture.
Define OSCCAL_1K 1 ' Calibrate internal oscillator
' Define ADCIN parameters
Define ADC_BITS 8 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
LED Var GPIO.0 ' LED is bit 0, PIN 7
adval var word ' Create adval to store result
i var word
ANSEL = %00111000 ' Set AN3 analog, rest digital
CMCON = 7 ' Analog comparators off
loop:
ADCIN 3, adval ' Read channel 3 to adval
i = 256 - adval
I = i * 10
Pulsout LED,adval ' Puls is 2,56 ms
Pauseus i 'cycle = 5,12ms = 195 Hz
Goto loop ' Do it forever
End
Hope, Someone could help me!