The PIC is dedicated to doing this alone, nothing else.
As far as resolution, the more the better of course. I just don't know how much I can bullshit the controller until I hook it up.
I am playing around with the PULSIN for the incoming PWM and HPWM for the outgoing signal. It seems to be working pretty good.
Here is the code.
Code:Include "modedefs.bas" ' Mode definitions for Serout Yellow Var PortC.5 Red Var PortC.4 Green Var PortC.3 Rate var PortC.1 LCD var PortB.5 VoltIn var word Flasher var word Speed var word Numerator var word Divisor var word Total var word Prefix con $FE ' needed before each command LcdCls CON $51 ' clear LCD (use PAUSE 5 after) CursorPS con $45 'Cursor Position Backlight con $53 ' Backlighting 1-8 TRISC = 0000010 TRISB=000000 TRISB=111111 Option_Reg.7=0 'Pull-Ups Enabled ANSELH=0 'PortB Digital WPUB.0=1 WPUB.1=1 WPUB.2=1 WPUB.3=1 WPUB.4=1 INTCON.7=0 Flasher = 0 define OSC 4 'OSCCON.6=1'0 '250khz 'OSCCON.5=0 '250khz 'OSCCON.4=0'0 '250khzHZ pause 10 SEROUT2 LCD,84, [Prefix,Backlight,8] 'LCD used for debug purpose Serout2 LCD, 84, [Prefix,LcdCLS] pause 10 SEROUT2 LCD,84, [Prefix,CursorPS,0, "RPM Simulator "] pause 1000 Serout2 LCD, 84, [Prefix,LcdCLS] high green high red high yellow Repeat GOSUB ON_Off Flasher = Flasher + 1 UNTIL Flasher = 5 Flasher = 0 '245 to 24000 for frequency out in the HPWM 23755 range '15.3HZ to 1.52kHZ at the 1/16 flip flop output Start: gosub Get_Pulse Gosub Math Goto Start Get_Pulse: Pulsin Rate,0,Numerator pulsin Rate,1,Divisor Total=Numerator+Divisor If Total=0 then 'LED Green when PWM present, red when no PWM HIgh Yellow Low Red High Green else HIgh Yellow High Red Low Green endif return Math: SEROUT2 LCD,84, [Prefix,CursorPS,0, dec5 Numerator," ",dec5 Divisor, " ", dec5 Total] Divisor=Divisor/10 Speed = (240*Divisor) SEROUT2 LCD,84, [Prefix,CursorPS,64, dec5 Speed] HPWM 1,127,Speed Return '___________________________________________ '-----------Activate/Deactivate Outputs----- On_Off: high REd high Green high Yellow PAUSE 100 high REd low Green high Yellow PAUSE 100 RETURN




Bookmarks