PDA

View Full Version : Digital Pot Advice



Tobias
- 22nd October 2007, 18:46
I am attempting to get an AD5220 Digital Pot to work with a PIC. I have it working great with a STAMP and am now crossing over. Attached is a zip file with two screen shots. The two screen shots are from a PIC and STAMP.

I am using a PIC16F877A. Following is the code I used for the STAMP and PIC. My question is why does the output of the POT look so different? The STAMP 'saw-toothes' and the PIC is more like a saw tooth with dull blades. I think the true saw-tooth pattern is the correct output.

I have tried changing the pulsout length but the POT never seems to make it too 5v when I am using this with the PIC. I am thinking if I don't have something configured wrong, I need to insert a pause somewhere.

Thanks in advance
Toby

---STAMP Code---
' {$STAMP BS2}
' {$PBASIC 2.5}

Up_Down PIN 0
CLK PIN 1
counter VAR Byte

DO
LOW Up_Down
FOR counter = 0 TO 128
PULSOUT CLK, 1
NEXT

HIGH Up_Down
FOR counter = 0 TO 128
PULSOUT CLK, 1
NEXT
LOOP

----PIC Code----
include "bs2defs.bas"
TRISD = 00000000
CLK VAR PortD.1 'Controls the Digital Pot
Up_Down VAR PortD.0
Checker VAR word
Checker =0

Loop:
High Up_Down
For Checker = 0 to 128
PULSOUT CLK, 1
Next Checker

Low Up_Down
For Checker = 0 to 128
PULSOUT CLK, 1
Next Checker
Goto Loop:

Tobias
- 22nd October 2007, 20:38
I got it, bad ground to the Dig Pot when testing with a PIC