Shop OBEX P1 Docs P2 Docs Learn Events
Voltage --> A2D --> Stamp --> Digital Pot — Parallax Forums

Voltage --> A2D --> Stamp --> Digital Pot

Keith HiltonKeith Hilton Posts: 150
edited 2004-12-10 03:33 in Learn with BlocklyProp
tongue.gif·Working on feeding an analog voltage to AD converter, to BS-2, then to a digital potentiometer.tongue.gif
Working from Matt Gilliland's "The Microcontroller Application Cookbook #1"
Page 221 is my hookup and program for the analog voltage input.· Page· 188 is my hookup and program for my digital potentiometer.· I am trying to combine both these programs to eventually convert a analog voltage, 0 to 5 volts, into a resistance value coming out of the digital pot.· Would like resistance to change as quickly as the analog voltage changes.shocked.gif In my program, I have changed the numbers in the program on page 188.· Here are the changes: 3 changed to 13, 2 changed to 12, and 1 changed to 11.· I can get the program on page 221 to run great.· I can get the program on page 188 to run great.· I have not been able to combine them and get them to work together.
'{$STAMP BS2}
x VAR byte
y VAR byte
Incr VAR byte
here:
LOW 0 'enable the 0831 AD converter
PULSOUT 1,1 'send the first set up out clock pulse.
x=0 'set x to 0
FOR y= 1 to 8·· 'loop 8 times to get 8 data bits
PULSOUT1,1·· 'send a clock pulse
x=x*2·· 'shift the bits left
x=x+IN2·· 'add the value of x to the incoming bit
NEXT
HIGH 0·· 'disable the 0831 AD converter
DEBUG ?X· 'display the result.
'To this point everything is working great!hop.gif
' This is where I screw up, getting the information to the 1804 POT.
LOW 13·· 'select DS 1804 Digital POT.
LOW 12· 'set direction to counter -clockwise
Incr=x· 'Read analog voltage number
FOR x=1 to 255
HIGH 11
LOW 11
NEXT
HIGH 12·· 'set direction to clockwise
Incr=x·· 'Read analog voltage number
FOR x= 1 to 255
PAUSE 1000·· 'View it on the ohm meter
HIGH 11
LOW 11
NEXT
GOTO heretongue.gif
I am brand new at programming.·Help--Teacher is in Florida at a Teacher's conference.tongue.gif

Post Edited By Moderator (Jon Williams) : 12/9/2004 4:13:56 AM GMT

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-09 04:17
    If you're using the BS2 family the you should use built-in commands to handle the shifting of data from the ADC0831 (Matt's book is designed to be compatible with lots of controllers).· The attached file will get you going with the ADC0831.

    You're having trouble with your digital pot because you're destroying the·adc value (in x) with a FOR-NEXT loop.

    Let me suggest that you also read the section of the Help file called "The Elements of PBASIC Style."· Using single-letter variables an pin numbers (instead of named pins) is an easy way to make a big mess and get lost.· PBASIC allows for very elegant coding that will save you from creating lots of bugs in the long run.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office


    Post Edited (Jon Williams) : 12/9/2004 4:29:39 AM GMT
  • Keith HiltonKeith Hilton Posts: 150
    edited 2004-12-09 04:23
    Thanks Jon. I couldn't down load the ADC0831.BS2 file. My computer said I need a program to down load a 'BS2 File'. Help. I want to look at that file. Thanks Keith Hilton
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-09 04:28
    Right-click on it, the select "Save Target As"

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • edited 2004-12-09 07:36
    Here is a list of Stamps in Class resources for working with the BASIC Stamp 2 and an ADC0831.· All these texts are available for free download from www.parallax.com -> Downloads -> Stamps in Class Tutorials:

    Basic Analog and Digital - Chapter 3 has a similar BASIC Stamp 2, ADC0831, potentiometer/voltmeter application and lots of explanations.· There is also some warm-up material in the chapter before, and some simple applications in the chapters that follow.·

    Understanding Signals - Chapter 5 takes a closer look at the synchronous serial communication between the BASIC Stamp 2 and the ADC0831.· With the aid of the Parallax Oscilloscope, the SHIFTIN command is examined along with the mechanics of making the ADC0831 transmit its digital value.

    Industrial Control - Chapters 4 through 6 use the ADC0831 to measure a temperature probe in a closed loop temperature control system.

    Post Edited (Andy Lindsay) : 12/9/2004 7:39:28 AM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-09 14:20
    And not that you want to wait that long, by my February column in Nuts & Volts magazine discusses the ADC0831 and the two-channel version, the ADC0832.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Keith HiltonKeith Hilton Posts: 150
    edited 2004-12-09 17:00
    tongue.gif·Jon, still not able to down load the file attachment: ADC0831.BS2· I went to "Save Target As", like you suggested, and still couldn't down load it.· Help, I want to see that file.· Keith Hiltontongue.gif
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-10 00:06
    Okay, Keith, I don't know what's wrong so I've attached a text version of the file that you can copy-and-paste into your editor.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Keith HiltonKeith Hilton Posts: 150
    edited 2004-12-10 03:33
    Thanks for helping me Jontongue.gif··It down loaded great!·Our teacher left for a teacher's meeting in Florida last week. So ,there has been no one to answer any questions. This monday each student has to give a presentation on some project he has developed. I am working on two presentations for "safety", a LCD frequency display guitar tuner, and a volume control.· The volume control uses the digital pot in the feedback loop of a inverting OP Amp arrangement.· Tomarrow I will do some testing in the lab at school.· I am taking the Basic Stamp class at Ozark Technical College in Springfield, Missouri. I'll come back and let you know what works and don't work.tongue.gif
Sign In or Register to comment.