CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

digipot problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mshearer



Joined: 12 Jan 2009
Posts: 33

View user's profile Send private message

digipot problem
PostPosted: Mon Jun 08, 2009 3:26 am     Reply with quote

Hi

I'm using an 18f4520 and trying to control a digitpot. In general this works perfectly for me.
I can configure the digipot at the start of my project to adjust a adc input to exactly 2.5V.

However I have made a small GUI to manually adjust the digipot, allowing me to enter any hex value and watch the change in the voltage.

My problem is, while I can enter 0xFF and get 5V. If I then enter 0x2F, I should get 2.5V. Instead I get 3.99V then if I send again 2.5V.
Seems when coming back down through the voltages the digipot takes two attempts.

my digipot function:

Code:
void set_digipot_bias(uint8_t digiPotValue)


reg_SSPCON1 = 0x20;
reg_SSPSTAT = 0x40; // set SPI to txd on rising edge of SCK

bit_RE2 = FALSE;     // Chip select the digipot

reg_SSPBUF = 0x00;
while(!bit_BF);

reg_SSPBUF = digiPotValue;
while(!bit_BF);


bit_RE2 = TRUE;     // de-select the digipot
}

Any help would be really great,

Matt


Last edited by mshearer on Mon Jun 08, 2009 10:26 am; edited 1 time in total
Ttelmah
Guest







PostPosted: Mon Jun 08, 2009 5:02 am     Reply with quote

It'd help if you told us 'what digipot'.....

Best Wishes
mshearer



Joined: 12 Jan 2009
Posts: 33

View user's profile Send private message

PostPosted: Mon Jun 08, 2009 10:25 am     Reply with quote

ah very sorry AD8400
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 08, 2009 11:27 am     Reply with quote

Use the CCS AD8400 driver instead of your code and see if it works:
Quote:
c:\program files\picc\drivers\ad8400.c
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Mon Jun 08, 2009 2:46 pm     Reply with quote

mshearer wrote:
ah very sorry AD8400

How did you wire the pot up? As a potentiometer or as a rheostat (tying the wiper to either A or B)? I have used this part before and have not had issues with it.
Guest








PostPosted: Tue Jun 09, 2009 7:43 am     Reply with quote

got it sorted.
Stupidly enough it wasn't the digipot really, just the delay i was leaving between digipot settings and reading the adc. changing from 2ms to 200ms fixed all my problems.
Guest








PostPosted: Tue Jun 09, 2009 3:52 pm     Reply with quote

Hi all,

The AD8400.c file in my driver directory seems incomplete. It looks like it's supposed to work with 'N' pots, but it's clearly coded for only a single unit. The InitPot function is also incomplete. My compiler is about a year old. Is there a later version of the AD8400.c or is completing it left as an exercise for the user?

Dave
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group