Hi
This week I are been mostly working on HWPM.......... to produce undetermined fixed frequencies on CCP1 between approx 10,000Hz and 500,000Hz for durations of approx 10 seconds. For the moment the dutycycle is a secondary consideration. I am testing using a 16f628A at the moment but I may have to change to an 18 series. It must use HPWM
As this is a broad range and to achieve better resolution at the higher frequencies I am running at 16mhz and introducing prescaling at the lower frequencies.
The frequency required is received HSER as a WORD and the code calculates PR2 etc. My own code sort of works Ok but it is very ugly and limited ( I upgraded to 2.5 to use LONGS etc but have yet to been unable to get PBL to compile with anything significant)
However,
I have also had an constant eye on HPWM10 By Darrell Taylor (Peu and Mister E whose Pic multi-Calc I use as de facto: thankyou Mister E) considering that I may have certain frequency ranges dedicated to different channels.
HPWM10 works beautifully to update the dutycycle of given frequencies, smooth and glitch free and very easy to use. However I would be using it the other way round ie to update the frequency for a given dutycycle. Given the fact that 10Bit resolution is not always available over the ranges I am working with, I set the variable _DutyCycle = 100.
There are stages in my frequency range when the BYTE value of PR2 overflows and the prescaler is incremented. For the purpose of this post I have the prescaler set 1:1
A bit long winded but I have captured the value of PR2 with respect to frequency as output from HPWM10 and inconsistencies start to occur around 35940Hz , PR2 recovers at 36140Hz but as can be seen in capture1.txt the trend occurs more regularly thereafter. The inconsistencies are as compared to Mister E's Pic multi-Calc.
I should be able to work out why this is happening rather than just observing, however I am confused......... could this be to do with parsing during the maths calculation?
Duncan
Bookmarks