DDS (generating sine waves) with onboard DAC using latest PIC 16F chips?


Closed Thread
Results 1 to 40 of 77

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Re: DDS (generating sine waves) with onboard DAC using latest PIC 16F chips?

    Why dont you change to a 18F46K20 or similar that you can run on 64MHz. A 64MHz pic is not that much more expensive unless you plan to make lots and lots of your product.

    Speed could be helpful sometimes.

    Meep Meeep as the Road Runner would have said!

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: DDS (generating sine waves) with onboard DAC using latest PIC 16F chips?

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: DDS (generating sine waves) with onboard DAC using latest PIC 16F chips?

    Quote Originally Posted by Jumper View Post
    Why dont you change to a 18F46K20 or similar that you can run on 64MHz. A 64MHz pic is not that much more expensive unless you plan to make lots and lots of your product.

    Speed could be helpful sometimes.

    Meep Meeep as the Road Runner would have said!
    I'm not designing a product...this is just me learning about the benefits/constraints of DDS, think I need a break from this one for a few days now though!

    RE going with an 18F PIC....the 16f1822 can run at 32Mhz (which is pretty fast!)....also smaller PICs just appeal to my sense of "wow, look what was squeezed out of that tiny thing!"

  4. #4
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Re: DDS (generating sine waves) with onboard DAC using latest PIC 16F chips?

    MIIPS MIIIPS !! What the Road Runner really meant.

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: DDS (generating sine waves) with onboard DAC using latest PIC 16F chips?

    Hi,
    I had a play with this. Just a counter variable pointing into the lookup table which outputs the value to PortB where a R2R ladder and 2nd order low-pass filter with a cutoff at ~6kHz is waiting.

    Here's a scopeshot, raw signal on Ch1, filtered on Ch2 (as if that wasn't obvious):
    Name:  Scope 5kHz.jpg
Views: 1916
Size:  108.3 KB
    To get ~5kHz output I had to index the table in steps of 20 but then I'm only running at 8Mhz. At 32Mhz you should be able to get pretty good performance and signal "quality". Of course, everything is relative...

    I did (or do) have a weird problem though with the PIC resetting that I can't figure out but I'll post that in a separate thread.

    /Henrik.

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: DDS (generating sine waves) with onboard DAC using latest PIC 16F chips?

    Hi Henrick,

    It's heartening that you've sufficient interest in this to experiment...I've parked my DDS exploits for a little while...on account I think I'm going to have to get my feet wet with assembly (every DDS implementation on the net seems to use assembly)

    I've tried to make a start, but after two nights struggling with even the most basic "Hello World" (light an LED), I realise that it'll probably be about 2.5 years before I can contemplate using assembly for DDS!

    RE your raw vs filtered signal...nice, but what I found (certainly using PWM ...which still holds massive appeals vs R2R ladders/DACs) was the the signal got severely attenuated with increasing frequency (eg 100Hz 4V peak to peak, 5khz 1V peak to peak)...whereas I'd really like something that yielded an amplitude of similar magnitude upto 5Khz.

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: DDS (generating sine waves) with onboard DAC using latest PIC 16F chips?

    Hi Hank,
    I don't think you need to resort to assembly. As I'm typing this I'm looking at scope displaying a fairly nice looking 5kHz sinewave and I'm using the 32bit accumulator code I posted earlier - all PBP and running at 8Mhz. But yes, it does get attenuated quite a bit, at 5kHz I'm looking at around 2Vp-p I think the problem in your case is the PWM carrier frequency is to low compared to the desired output frequency and I don't see how assembly will helå there. Yes, it does get attenuated, I'm looking at~4.7Vp-p at ~1kHz but only around 2V at 5kHz. My guess is that it would increase a bit if the oscillator speed is increased so I can "hit" more entries in the lookup table. An assembly routine will likely run slightly faster allowing to "hit" even more entries but I don't think it's going to make THAT much difference.

    Anyway, quite fun this, I actually didn't think it was going to work this good.

    /Henrik.

  8. #8
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: DDS (generating sine waves) with onboard DAC using latest PIC 16F chips?

    Hi henrik,

    Perhaps I wasn't clear about what I was trying to put across ...the best way for me to learn is to find someone who has already done what I seek & establish what they've done by looking at their code ....this is where I'm coming unstuck....there's only assembly DDS code out there & I don't know how to interpret it!

    As an aside, when I was dabbling above, I was only using a 16 bit accumulator (on account I don't know how to go bigger!)... 24 bits ought to give me sufficient resolution.....but it's pointless having the resolution, if I can't work out how to get the pic/picbasic to do the 24/32 bit maths to resolve the correct tuning word value autonomously! (ie not offline on a spreadsheet!)

    tuning word = (desired frequency/interrupt frequency) * number of accumulator values available -......that's tricky on an 8 bit PIC using PICbasic for me at least!

    Agreed about the pwm method...but at 32mhz ....the pwm frequency can be rather high, which should make filtering much less attenuative in the 0-5khz range....I need to dabble!
    Last edited by HankMcSpank; - 2nd September 2011 at 22:35.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts