Generating various waveforms with resistive DAC, how to alter pitch?


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default Generating various waveforms with resistive DAC, how to alter pitch?

    Hello. I've built simple R-2R 8 bit DAC and hooked it to PIC MCU.

    The code looks like this:

    Code:
    DO
    PORTB=%00000001
    NOP
    PORTB=%00000010
    NOP
    PORTB=%00000100
    NOP
    LOOP
    And so on, this is just a fragment to get idea.

    Now the output frequency is determined by MCU clock, and time needed for PORTB operation and nop operation. But how control it in realtime?
    I want to hook a simple piano keyboard, and to be able to play at least 2-3 octaves.

    PAUSE/PAUSEUS does not provide required precision, is there any way to replace "nop" with adjustable delay in above code?

    I'm using PIC16F870, but I can use any other in 16 or 18 family.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Generating various waveforms with resistive DAC, how to alter pitch?

    PAUSE/PAUSEUS does not provide required precision, is there any way to replace "nop" with adjustable delay in above code?
    I was going to say that that is prety much what PAUSEUS does but PAUSEUS defaults to 1us "ticks". A workaround solution might be to DEFINE OSC 4 but run the PIC at 40MHz, that way you get 100us resolution. If that's not an option you will have to resort to some ASM type delay loops - which shouldn't be too hard to find.

    Apart from that I think what you should do is look at a DDS aproach instead. IIRC I wrote code for a similar application for a user here a while back. Search around and see if you can find it or I will look into it later and post the link (then if it's suitable or not is another question).

    /Henrik.

  3. #3
    Join Date
    Apr 2006
    Location
    Michigan
    Posts
    70


    Did you find this post helpful? Yes | No

    Default Re: Generating various waveforms with resistive DAC, how to alter pitch?

    I would use a Nuvoton ISD3800 Development board which you can control by SPI with your PIC. These are the same devices in greeting cards but much better quality. I have put them on appliances. http://www.digikey.com/catalog/en/pa...mo-board/40612

  4. #4
    Join Date
    Apr 2006
    Location
    Michigan
    Posts
    70


    Did you find this post helpful? Yes | No

    Default Re: Generating various waveforms with resistive DAC, how to alter pitch?

    I have one of these. If you are interested I can program it with your wav files and it will be ready to go. Go to my site and buy 3 of my diaper checks and send me a note that you want the ISD3800 board instead. www.thediapercheck.com. I am really just giving you the board for what it cost me. It can be difficult to program.

  5. #5
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Generating various waveforms with resistive DAC, how to alter pitch?

    A manual delay should be as fast as asm if you have
    defined no clear watchdogs to be inserted in code,
    and configure the chip with watchdog off.

    Code:
    delay = 20
    
    ...
    
    for count = 0 to delay
    next count
    For something quicker you could set up a number of delays

    Code:
    Delaytwonops:
    @ nop
    @ nop
    return
    Waste four instructions

    Code:
    gosub waste 
    
    ...
    
    waste:
    return
    Last edited by Art; - 24th April 2016 at 02:21.

Similar Threads

  1. Replies: 76
    Last Post: - 11th November 2014, 05:46
  2. 4 Wire resistive touch screen, Need help
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 16th February 2012, 17:28
  3. Reading 500ohm resistive sensors
    By Glenn in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th May 2011, 05:52
  4. dac
    By kaisersystems in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 10th June 2005, 20:23
  5. resistive fuel sender
    By beto in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th May 2005, 21:40

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