Hi,
The very short program works but the frequency output is extremely variable from 500Hz to 2Khz. The program should max at 512Hz..
Also the output is very noisy, any recommendation on the output ? extra capacitor ?
Code:'////////////////////////////////////////////////////////////////////////////////// '// 555 simulator using PIC16F88 '// Variable frequency, fixed Dutycycle '////////////////////////////////////////////////////////////////////////////////// '///////////////////////// '// Define section // '///////////////////////// INCLUDE "modedefs.bas" OSCCON = %01110000 '8 Mhz DEFINE OSC 8 ANSEL = 0 CMCON = 7 DEFINE CCP1_REG PORTB 'Define output port of pulses out DEFINE CCP1_BIT 0 'Define output port of pulses out Define ADC_BITS 10 ' Set number of bits in result Define ADC_CLOCK 3 ' Set clock source (3=rc) Define ADC_SAMPLEUS 50 ' Set sampling time in uSec TRISA = %11111111 ' Set PORTA to all input TRISB = %00000000 ' Set PORTB to all output voltage_check var word Frequency var word Mainloop: ADCON0.2 = 1 'Start Conversion max 1024 ADCIN 3, voltage_check 'analog pin 1 get the 10 bit result Check the battery voltage on pin PORTA.3 Frequency = voltage_check /2 'max 512Hz HPWM 1,126,Frequency goto Mainloop END








Bookmarks