Create two PMW signals from AtoD potentiometers
The
potentiometers on AD0 and AD1 can vary the
mark to space ratio of two independent 1khz pulse trains
' lcd_read_AD0_PWMout.bas
' read the values of pots attached to an0 and an2
' display values on LCD
' drive pulse width modulated outputs on port C 2 and 1
AllDigital
TRISC = 0 ' all port C outputs - for CCP1(RC2) and CCP2(RC1)
ADCON1 = 0 'allow ADC inputs port A
' this assumes the HD44780 LCD is connected to
' port B as in the EVA board - all LCD defaults assumed
Lcdinit ' no curser showing
Dim an0 As Word 'the values of the analogue inputs
Dim an1 As Word
loop:
Adcin 0, an0 ' measure volts on pin RA0 as (an0 goes 0 - 1023)
Adcin 1, an1 ' measure volts on pin RA1 as (an1 goes 0 - 1023)
Lcdcmdout LcdClear
Lcdout "Analog AN0 AN1" ' top line of LCD
Lcdcmdout LcdLine2Home
Lcdout "Value ", #an0, " ", #an1 ' second line of LCD
WaitMs 250
PWMon 1, 1 ' CCP1 pin17, mode 1:10bit, 1220Hz for 20MHz clock xtal
PWMduty 1, an0
PWMon 2, 1 ' CCP2 pin16, mode 1:10bit, 1220Hz for 20MHz clock xtal
PWMduty 2, an1
Goto loop