Hi,
Im working on a project that will watch RB.4 for square wave input pulses from a hall effect sensor, and needs to time them, and re-output them on another port. During this process, it will need to check the input pulse, if it doesnt exist (ie pin constantly in one state) for say 0.5 sec (or 0.65 sec if i use timer overflow on ccp), the pic needs to output pulses at a fixed frequency of approx 16hz until the input pulses exceed 16hz, then the output pulses will match the input pulses again. The pic cannot miss any input / output pulses, it must be 1:1.
The input pulses will vary in frequency, from 0 to about 380 hz. It is a square wave that is usually high, with a low going pulse duty cycle of around 15%
Think of this circut as a very crude failsafe / frequency corrector, I would like to be able to add a correction to the output signal so I can change the frequency of the output in proportion to the input by + / - 50%.
The use of this project will be to monitor a shaft's RPM. If the shaft is stopped for > 0.5 sec, then it will output pulses to 'pretend' the shaft is turning at a low speed, until the shaft does indeed start turning again and soon as its turning above the 'pretended' speed (16hz) then the output will be the same as the input plus or minus the correction.
This should be possible by manipulating the input pulse timings before outputting them.
My plan is to use CCP to watch the input pulses, Set and clear the timer on initial high to low transition and time time how long it takes to go low to high to give me the low pulse width (xxx), and then time how long it takes from here to go high to low again to get the high part (yyy), then reset the timer to get the next reading. I am pretty sure I can get this part of the code working
----|___|-------------|___|------
Where im stuck is how to create the output pulses and perform the checks on the input pulses without missing any of the input pulses. Also on how to keep the output pulses happening whilst there is no input.
Ie if I use
<get ccp timings>
high output pin,
pause yyy ,
low output pin,
pause xxx etc,
or
pulsout outputpin yyy,
pause xxx,
I have a feeling that the pulsout and pauses will hang the program thus missing the next input pulse in the sequence while it is completing the operation of sending the output pulse?
Anyone have any ideas / comments on this, im sorry if the post above is a bit full on and confusing but i had to type it all while it was fresh in my head![]()
Bookmarks