bsodmike
New Member
Hello All!
The following code should do as it says. What I am taking for granted is that with the Vref == Vdd that the A/D res is 5/255 = 19.6mv per 'bit'.
Today I tested this on the PIC (had to disable internal OSC as it was complaning of not being able to find the calibration value @ that address) and @ 0v input the output was 15hz and 3.8v was giving 480 - 500Hz...
The Duty Cycle was 98% .....
Nigel your help would be greatly appreciated!
So how this code works:
testing for 0.4v I check to see if the A/D res is over '26' if it is not, go back to the start and check again. If it is over then I set half_t (half of the frequency == half the period) as 105hz/2 = 53hz and pulse the DC signal high for that time and low again for that time (i.e. 50% duty cycle)...
However, this code is driving the PIC 'essentially' nuts....
Any help will be greatly appreciated!
Ohh and a free PIC programmer to anyone that can help solve this
The following code should do as it says. What I am taking for granted is that with the Vref == Vdd that the A/D res is 5/255 = 19.6mv per 'bit'.
Today I tested this on the PIC (had to disable internal OSC as it was complaning of not being able to find the calibration value @ that address) and @ 0v input the output was 15hz and 3.8v was giving 480 - 500Hz...
The Duty Cycle was 98% .....
Nigel your help would be greatly appreciated!
Code:
;=======Subroutines========================================================
;~~~~~~~Delay Loop~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
delay movfw half_t ; copy half_t to accu
subwf _tmr0,w ; perform tmr0 - w, result in w
btfss _status,2 ; check if tmr0 = 0, return
goto delay ; tmr0 != 0, so loop.
retlw 0 ; else, return
;-------Untested
;delay clrf _tmr0 ; Start tmr0
;dloop movfw _tmr0 ; Read tmr0 into w, w holds time
; sublw half_t ; Time - half_t
; btfss _status,2 ; Check Time - half_t = 0
; goto dloop ; Time is not = half_t
; retlw 0 ; Time is half_t, return
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
So how this code works:
testing for 0.4v I check to see if the A/D res is over '26' if it is not, go back to the start and check again. If it is over then I set half_t (half of the frequency == half the period) as 105hz/2 = 53hz and pulse the DC signal high for that time and low again for that time (i.e. 50% duty cycle)...
However, this code is driving the PIC 'essentially' nuts....
Any help will be greatly appreciated!
Ohh and a free PIC programmer to anyone that can help solve this