Can someone check my code? Serially Controlled Digital Pot


Results 1 to 5 of 5

Threaded View

  1. #3
    Join Date
    Apr 2006
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    Good question, well the "pot" I'm speaking of is really a voltage divider strip, like one of those force sensitive resistor strips, however made as a voltage divider rather than a variable resistor. I said "pot" just to simplify the explaination of my example since in this scenario it really can be any kind of analog sensor input to the Pic.
    However, this strip I'm speaking of is essentially a voltage divider used as a ribbon controller for electronic musical instruments. It can be wired to output a resistance, but not enough OHMS to control my analog oscillator circuit.

    The problem is I want to use this voltage divider strip (ribbon controller)
    to control an analog sound generating circuit (an oscillator). The voltage divider strip won't do the job if connected directly to the analog ocsillator circuit. So I would like to connect this voltage divider strip to the pic and have the pic control the digital pot, and the digital pot control the analog oscillator.

    In addition, I'll also be able to do some things with the digital pot (like switching it on and off to create stacatto effects, etc.) that an analog sensor wired directly to the analog circuit couldn't do.


    So essentially I can also do some tricks by having the pic control the pot on my analog oscillator circuit.

    I'm thinking if I just remove the section of code where Mister-E wrote in the above posted code:

    for wiper = 0 to 255 'wiper is the variable written to the pot in the shiftout command

    with instead:

    ADCin 1, ADCVar 'Read voltage divider strip on pin 3
    WIPER = ADCVar / x 'scale the voltage divider strip to get 0-255; "x" is a number I'll use to scale the value for "Wiper"
    if wiper > 255 then 'if the reading goes above 255 look for new reading
    goto Start
    endif

    and then do this:

    shiftout si,clk, MSBFIRST,[WriteOnPot0, WIPER] ' Write to Digital Pot

    I'm thinking this might be a starting point, but haven't tried it yet.


    Thanks again,
    Tony A
    Last edited by TonyA; - 24th January 2007 at 19:17.

Similar Threads

  1. decoding quadrature encoders
    By ice in forum mel PIC BASIC Pro
    Replies: 93
    Last Post: - 28th February 2017, 09:02
  2. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  3. Writing code for battery operated projects
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th June 2005, 03:39
  4. Code check (sorry)
    By barkerben in forum General
    Replies: 5
    Last Post: - 30th November 2004, 15:54
  5. DS1868 Digital Pot
    By ero in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 31st August 2004, 13:22

Members who have read this thread : 0

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