[Company Logo Image]        Blackfoot Inverter 

Home Up Contents Search Articles Caveat Purpose Notice                                                           

Notes by JMP Piednoir
The idea of the inverter is :
Output pulse - center pulse = center pulse - Input pulse
Or : Output pulse + Input pulse = 2 x center pulse
Or : Output pulse = 2 x center pulse - input pulse
A simple (probably the simplest) program using the 12F629 features would go like this:
TMR1 period = 1µs period
Preset = 65535 - (2 x center pulse width) -> 65535 - 3000 = 62535 if center = 1500µs
Program :
Stop TMR1 (bcf T1CON,0)
Load Preset into TMR1L & TMR1H
When input goes high :
Start TMR1 (bsf T1CON,0)
When input goes low :
Make output high
When TMR1 reaches maximum (65535) and rolls over :
Make output low.
go back to top
For reliable input change detection, use external interrupt (GPIO,2)
Set to raising edge until detected, change to falling edge once input is high 
(Trick given by Comatose in another thread)
Alternative is to scan one input in a short (3µs) loop :
waithi btfsc GPIO,Input
goto waithi
bsf T1CON,0
etc...
then the same for falling edge of input :
waitlo btfss GPIO,Input
got waitlo
bsf GPIO,Output
TMR1 rollover is detected by its interrupt.
If using the loop scan , interrupt routine can be as simple as :
bcf GPIO,Output
bcf TMR1 interrupt flag
retfie
Thread:    http://www.rcgroups.com/forums/showthread.php?s=&threadid=216289
Download:  Inverter Code for PIC 12C508 inverter


Home ] Up ]                                                                                                                                               

Send mail to ironsidz@hotmail.com with questions or comments about this web site.
Copyright © 2003 
Last modified: March 18, 2004