I wrote most of that (this) code but gave up when delays and software serial, which also blocks, was added. I wrote it in C on a 18F2620 and then converted to basic. Unfortunately, a disk crash cause it all to be lost. I think it ran at 32MHz using the internal oscillator. Actually just looked and found an early version that used PPS to steer the CCP1 output to the PORTB pins and it uses 32 MHz. Couldn't figure out pointers in basic so changed it.
Mike.
Hi M,
I've just spotted your CCP output comment. This PIC only has 2x PINs for this. I spent quite a time trying to get more channels, and the SHIFT REGISTER was introduced.
I think I've figured out how the SHIFT REGISTER works! If I'm correct, then it can work with 5X Channels if wished. So the gap between the 5th CHAN and the FRAME time, will be >10mS. Also there is a gap between each channel 1 and 2mS.
There are 3x PINs that control the shift register, all BIT values.
For now don't think about high to low, or low to high.
1/ 1=RUN, 0=RESET= All output PINS = 0
2/CLK
3/ 1=1 0=0
For this example the LEFT PIN is CH1
The TIMER is set to the time of CH1 ANGLE 'say' 1500us = 1/2 way
Set PIN 1/ to 1-RUN and set 2/ to 1=1 Set 3/ to 1xCLK a 1xBIT is shifted into CH 1.
Wait for the TIMER FLAG (while setting the TIMER to the time of CH2 ANGLE 'say' 1000us = 1/2 way) then
Set 1/ to 1-RUN and set 2/ to 0=0 Set 3/ to 1xCLK a 0 BIT is shifted into CH1 and the 1 BIT shifts to CH2.
Wait for the TIMER FLAG (while setting the TIMER to the time of CH3 ANGLE 'say' 2000us = CW) then
Set 1/ to 1-RUN and set 2/ to 0=0 Set 3/ to 1xCLK a 0 BIT is shifted into CH1 shifting the 0 BIT in CH1 to CH2 and the 1 BIT shifts to CH3.
and so on.
All of the CH times are totalled up, and subtracted from the FRAME time 20000us,then wait till the FRAME time has elapsed.
If 5xCHANNELS are used, then once the 1BIT in CH5 has finished it's TIME, then set PIN1 (reset) to 0 and reset all BITs to 0.
Let me know if I'm incorrect!
C.