???????????????originally posted by hankmcspank
Were the fun in that?!![]()
Robert
???????????????originally posted by hankmcspank
Were the fun in that?!![]()
Robert
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
I meant if simply used dedicated ICs to solve each and every one of my needs - I wouldn't learn anything about PIC programming (the fun bit)
it was a meant to be a quip.
If I'm to grasp PIC programming, then I need a small bite sized goal/challenges (& grasp some concepts)...sure there's normally dedicated h/w for just about everything nowadays, but I won't learn much if I simply throw in a dedicated IC for each & every requirement....hence my line of questiong & reluctance to add in extra h/w,
Last edited by HankMcSpank; - 7th March 2010 at 13:45.
If you have a super clean sine wave signal with no distortion, you might be able to do this with a pic that is also performing other tasks. Otherwise, it is a very difficult task involving FFT or DFT programming--certainly not the standard place to start learning PIC programming. (And PBP is a pretty code-heavy compiler, so it may not be able to process the data fast enough, even as slow as 150Hz.)
The biggest drawbacks I see to the NE567 is high voltage requirement and high current draw. On the other hand, it is the perfect simple solution to a potentially challenging problem.
Well it's not my first PIC project - that was PIC AGC...then I got the relaxtaion ocillator setup to do PIC capaciitve touch - but this is my first exploration into frequency counters (ie my latest goal if you like)
Re the waveform, I'd be trying to glean the frequency after the complex harmonics have dropped out, here's the waveform (it's been amplified to get it up nearer the 5V that the PIC prefers) ....
...pretty clean & pretty sine-waveish too!
ok, if you think it's do-able, I'll push on & give it a pop.
So what would be the best way to set up a 100mS sampling 'window' to see how many transitions (cycles) the comparator has toggled in that time?
Last edited by HankMcSpank; - 7th March 2010 at 16:55.
Well that sure does look clean! For your rough and ready approach, how about a simple count command like this:
COUNT PORTB.1,100,W1
That will count pulses during a 100ms period. Other way to do it for more accuracy is interrupts. But as you say, you just are going to do a lookup table.
Edit:
For the accuracy you need between D and D# etc, you would need to sample for 1 second using this method. If that's too long, you would have to go with interrupts, and measure time between pulses. Another quick and dirty try might be pulsin? Not sure how well that would work on an analog signal though. Maybe you could average a few...
Last edited by ScaleRobotics; - 7th March 2010 at 17:37.
Here's another approach.
You can use timer 1 as a frequency counter. Not sure if will be accurate enough? You did not say which pic you are using? Timer 1 external input is normally on portc. There should be a way to route the comparator output to tmr1? You will have to play with the pause statement to calibrate the output ie "pause 97" to compensate for the delays in pbp.
CCP1CON = %00000101 ' Capture every rising edge
T1CON = %00000011 ' No prescale/Osc off/Sync on/External source/TMR1 on
Freq var word ' 100ms count result
LOOP:
TMR1H = 0 ' Clear Timer1 high 8-bits
TMR1L = 0 ' Clear Timer1 low 8-bits
T1CON.0 = 1 ' Start 16-bit timer
Pause 100 ' Capture 100 mS of Input
T1CON.0 = 0 ' Stop 16-bit Timer
Freq.BYTE0 = TMR1L ' Read Low 8-bits
Freq.BYTE1 = TMR1H ' Read High 8-bits
GoTo LOOP
Bookmarks