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

something wrong with DigPot AD8402

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



Joined: 07 Jan 2006
Posts: 64
Location: Braga

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

something wrong with DigPot AD8402
PostPosted: Wed Nov 08, 2006 10:59 am     Reply with quote

I'm using the driver code (AD8400.c) that comes with CCS and using this main code to test the digital Pot :

#include <16f870.h>
#device adc=8

#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP
#use delay(clock=8388608)

#include <AD8400.c>
#include <flex_lcd_4x20_3.c>

int8 PotA=125;

int8 PotV=125;

#define VoltsMenos PIN_C7 // key V-
#define VoltsMais PIN_C0 // key V+




void main()
{

setup_adc_ports(AN0_AN1_AN3);
setup_adc(ADC_CLOCK_INTERNAL);
//setup_psp(PSP_DISABLED);
//setup_spi(FALSE);
setup_adc(ADC_CLOCK_INTERNAL);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_timer_2(T2_DISABLED,0,1);
int_count=INTS_PER_SECOND;
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
init_pots ();
delay_ms(500);
lcd_init();
delay_ms(500);



WHILE (TRUE) {


printf(lcd_putc,"\f Volts %LU\n Amps %U",PotV,PotA);

if (input(VoltsMenos)) {PotV=PotV-10;}
if ((PotV)<1) {PotV=1;}
if (input(VoltsMais)) {PotV=PotV+10;}
if ((PotV)>256) {PotV=256;}

set_pot (1, PotV);

delay_ms(250);

}


}


With all this , the digital Pot. simply don't change at all is OHM, it's stucked at middle scale (5k)

Can anybody help me ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 08, 2006 12:41 pm     Reply with quote

Read the AD8400 data sheet:
http://www.analog.com/UploadedFiles/Data_Sheets/248207866AD8400_2_3_c.pdf
It has a table on the right side of page 13, that shows the input value
for the Pot, and the corresponding resistance. The table shows values
from 0 to 255.

Look at your code. What value are you using as the maximum value ?
Compare it to the permissable value in the table.


Also, you have declared your Pot voltage variables as 8-bit (unsigned)
variables. What is the range of values that such as variable can hold ?
Look at your code. You are trying to put a value of 256 in those
variables. What is the actual value that the variable will be set to,
if you try to do this ? Answer these questions and you will solve your
problem.
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