electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

adc resolution lowering - 24bit to 8 bit


Post new topic  Reply to topic    EDAboard.com Forum Index -> Electronic Elementary Questions -> adc resolution lowering - 24bit to 8 bit
Author Message
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post05 Nov 2009 10:33   

adc resolution


hi..
I am using cs5460 adc which gives digital output in 24bit 2's complement.
I want to coonect this with microcontrooler 89c52. i want to use only 8bit of output data.what to do for adc resolution????can i get perfect output by only using 8bit???
Back to top
mandar_mahajan



Joined: 08 Jul 2009
Posts: 97
Helped: 1
Location: mumbai


Post05 Nov 2009 10:57   

Re: adc resolution


Hello bhoomi,

CS5460 (cirrus logic) gives digital output in 24bit 2's complement.
U can have the data in 8 bit by discarding the lower 16 bits(s/w tricks).
May i know for which data processing ur using cirrus ?, means u want to use just 8 bits.....
Also cirrus has a long list of SFR's which is to be used....
Anyways, hope this will help u.
Can post queries for further help..
Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post06 Nov 2009 13:08   

Re: adc resolution


first of all thnx 4 reply


I am using this circuit for presuure display..sensor gives output in mv. I m applying this voltage to Vin+ and Vin- pin to Ic. I want to read instantaneous voltage register. should i get correct value by just reading 8 higher bit of the register?? if yes then how..
plz help me..

Added after 5 hours 12 minutes:

If its not possible then is it possible to read 24 bit and then display it on to 2digit 7segment display??
plz some 1 help me
Back to top
mandar_mahajan



Joined: 08 Jul 2009
Posts: 97
Helped: 1
Location: mumbai


Post07 Nov 2009 7:11   

Re: adc resolution


Hello,

Read all the 24 bits, then discard the unwanted 16 bits.
U will get the corrrect values as cs5460 is highly pricise.
U can take the average of may be say 16 readings of the instantaneous values.
then discard the unwanted bits . This will increase ur stability as well as ur readings will be pricise.

Hope this helps u.
Back to top
FvM



Joined: 22 Jan 2008
Posts: 5151
Helped: 766
Location: Bochum, Germany


Post07 Nov 2009 10:22   

adc resolution


It sounds a bit funny to use a high precision 24 bit ADC to get a 8 bit result, but it's possible of course. You didn't tell
however about the intended scaling of the result. The highbyte result is a signed number, representing a range of -128
to +127.

If you want to measure integer mV, the ADC has to be calibrated for a +/- 128 mV range. If the range is different,
the ADC output can be scaled (multiplied with a factor). But in this case, you would surely use more than 8 bit of
ADC output, otherwise you won't even get 8 bit accuracy due to rounding errors.

Generally, averaging don't make much sense with an ADC that has a programmable filter. And even at
high data rates, it's unlikely to see changes in the 8 bit result, unless you have a very noise input signal. The noise-free
resolution tables in datasheet can tell you why.
Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post09 Nov 2009 8:21   

Re: adc resolution


should i do any calculation for just taking 8 bit for output???
my output will be in the range of -128 to 127.
Back to top
mandar_mahajan



Joined: 08 Jul 2009
Posts: 97
Helped: 1
Location: mumbai


Post09 Nov 2009 10:12   

Re: adc resolution


I don't understand what really do u want to say or intended to do.
Here is a small example , hope will help u..

The value in cirrus_rms_curr is of reg IRMS.
The value in cirrus_rms_vtg is of reg VRMS.


void store_n_compute_rms(unsigned char ch_no)
{
unsigned char ch;
static unsigned long lng;
switch(ch_no){
case 1:
rms_curr_array[irms_counter] = cirrus_rms_curr;

irms_counter++;
irms_counter &= 0x07; //0x0f;

lng = 0;
for(ch = 0; ch < 8; ch++) //take running avg of 8 readings
lng += rms_curr_array[ch];

lng >>= 3;

avg_rms_curr = lng >> 12; //discard lower 12 bits
break;

case 2:
rms_vtg_array[vrms_counter] = cirrus_rms_vtg;

vrms_counter++;
vrms_counter &= 0x07; //0x0f;

lng = 0;
for(ch = 0; ch < 8; ch++)
lng += rms_vtg_array[ch];

lng >>= 3; //average of 8 readings
avg_rms_vtg = lng >> 12; //discard lower 12 bits
break;

default:
break;
}
}
Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post10 Nov 2009 13:12   

Re: adc resolution lowering - 24bit to 8 bit


hi..thanx..
I have atken the upper 12bit for getting output..
but still i dnt able to get any output on my 7seg display..
so,plz can you tell me the sequence to initiallize serial port, write and read the register??
Back to top
mandar_mahajan



Joined: 08 Jul 2009
Posts: 97
Helped: 1
Location: mumbai


Post11 Nov 2009 6:22   

Re: adc resolution lowering - 24bit to 8 bit


but still i dnt able to get any output on my 7seg display..

U will not get the values just by using this code. It was just an example.
U have toinitialize the cs5460. Use its datasheet for ref, post the code u have done.


[/code]
Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post12 Nov 2009 8:25   

Re: adc resolution lowering - 24bit to 8 bit


i have first reset the cd5460 then initialize using fffffffe and then write the value in cycle count register and then start the conversion by giving e8 command..
my steps are right???
Back to top
Google
AdSense
Google Adsense




Post12 Nov 2009 8:25   

Ads




Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post13 Nov 2009 12:06   

Re: adc resolution lowering - 24bit to 8 bit


can anyone tell me how to convert 2's complement register value in binary form???
Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post17 Nov 2009 8:24   

Re: adc resolution lowering - 24bit to 8 bit


hello plz help me..
i have written the program in which i can send the command and read the default values of the registers.. but whenever i try to write value in any register 0 o/p i get for any register reading....so, plz some one help me...
Back to top
mandar_mahajan



Joined: 08 Jul 2009
Posts: 97
Helped: 1
Location: mumbai


Post17 Nov 2009 9:56   

Re: adc resolution lowering - 24bit to 8 bit


Can u post the code u have done for writing values in the registers..As it is impossible to comment anything on it without seeing the code..
Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post17 Nov 2009 12:37   

Re: adc resolution lowering - 24bit to 8 bit


set_adc_system()
{

dout1=0xff;
serial_out=dout;
P11=0;
++nop;
++nop;
adc_cmd();

dout=0xff;
serial_out=dout;
P11=0;
++nop;
++nop;
adc_cmd();

dout=0xff;
serial_out=dout;
P11=0;
++nop;
++nop;
adc_cmd();

dout=0xfe;
serial_out=dout;
P11=0;
++nop;
++nop;
adc_cmd();
}


start_conv()
{
dout=0xe8;
serial_out=dout;
P11=0;
++nop;
++nop;
adc_cmd();
}

write_reg()
{
dout=0x4a;
serial_out=dout;
P11=0;
++nop;
++nop;
adc_cmd();
dout1=0x00000001;
serial_out1=dout1;
P11=0;
++nop;
++nop;
adc_write();
}

get_adc_data()
{
dout=0x10;
serial_out=dout;
P11=0;
++nop;
++nop;
adc_cmd();

dout1=0xfefefe;
serial_out1=dout1;
P11=0;
++nop;
++nop;
adc_read();

din=serial_in;
adc_data=din >>12;
}


adc_cmd()
{
counter = 0x08;
while(counter)
{
if(serial_out & 0x80)
{
din=1;
++nop;
++nop;
}
else
{
Din=0;
++nop;
++nop;
}
P11=1;
++nop;
++nop;
++nop;
P11=0;//sclk=0;
++nop;
++nop;
serial_out= serial_out << 1;
++nop;
++nop;
--counter;
}
}

adc_write()
{
counter = 0x18;
while(counter)
{
if(serial_out1 & 0x00800000)
{
din=1;
++nop;
++nop;
}
else
{
din=0;
++nop;
++nop;
}
P11=1;
++nop;
++nop;
++nop;
P11=0;//sclk=0;
++nop;
++nop;
serial_out= serial_out << 1;
++nop;
++nop;

--counter;
}
}

adc_read()
{
counter = 0x18;
while(counter)
{
if(serial_out1 & 0x00800000)
{
din=1;
++nop;
++nop;
}
else
{
Din=0;
++nop;
++nop;
}
P11=1;
++nop;
++nop;
++nop;
P11=0;//sclk=0;
++nop;
++nop;
--counter;
serial_out1 = serial_out1 << 1;
++nop;
++nop;
serial_out1 = serial_out1 << 1;
++nop;
++nop;
a=P12;//dout pin 6 from adc
if(a)
serial_in = serial_in | 0x00000001;
--counter;


}

}

here is my code..
i can read the register but if write any number then the register value comes zero.
i want to set my offset and gain value in register.
Back to top
mandar_mahajan



Joined: 08 Jul 2009
Posts: 97
Helped: 1
Location: mumbai


Post17 Nov 2009 13:19   

Re: adc resolution lowering - 24bit to 8 bit


Hi, Frankly speaking it is very hard to understand ur code as it is comment-less.
Following r some basic steps to write the value into registers.
1) STATUS_REG value = 0x000001

2)CONFIG_REG value = 0x000004

//configure cycle count register to compute after 50 conversion cycles.
3)CYCLE_COUNT value 0x000032

//control register
4)CONTROL_REG value 0x000008 //SYNC bit is 1 to sycnhronise adc clock

5)MASK_REG value = 0x800000 // mask all bits other than DRDY.

Also refer article 4.1.7 Register Read/Write from the datasheet.
Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post18 Nov 2009 6:29   

Re: adc resolution lowering - 24bit to 8 bit


ohh m very sorry...
but any way thanks to reply...
ya i knw this values but i cant write in that register...
here in my code m trying to write the 000001 value in the cycle count register as i only require instantaneous voltage value..


write_reg()
{
dout=0x4a;// write command and address for cycle count
serial_out=dout;
P11=0; // clock low
++nop;
++nop;
adc_cmd(); //going to command function
dout1=0x00000001; // 24 bit to write in the register
serial_out1=dout1;
P11=0; //clock low
++nop;
++nop;
adc_write(); //going to write function
}


adc_cmd()
{
counter = 0x08;
while(counter)
{
if(serial_out & 0x80) // input command to sdi pin
{
din=1;
++nop;
++nop;
}
else
{
Din=0;
++nop;
++nop;
}
P11=1;//sclk high
++nop;
++nop;
++nop;
P11=0;//sclk=0;
++nop;
++nop;
serial_out= serial_out << 1;
++nop;
++nop;
--counter;
}
}

adc_write()
{
counter = 0x18; counter for 24 bits
while(counter)
{
if(serial_out1 & 0x00800000) input data to register
{
din=1;
++nop;
++nop;
}
else
{
din=0;
++nop;
++nop;
}
P11=1;
++nop;
++nop;
++nop;
P11=0;//sclk=0;
++nop;
++nop;
serial_out= serial_out << 1;
++nop;
++nop;

--counter;
}
}


hope now u will b clear so plz help me.. u r the only hope for me..
Back to top
mandar_mahajan



Joined: 08 Jul 2009
Posts: 97
Helped: 1
Location: mumbai


Post18 Nov 2009 7:07   

Re: adc resolution lowering - 24bit to 8 bit


write_reg()
{
dout=0x4a;// write command and address for cycle count

//WHAT IS 0X4A? // ADDRESS OF CYCLE COUNT REG IS 0x05.

serial_out=dout;
P11=0; // clock low
++nop;
++nop;
adc_cmd(); //going to command function
dout1=0x00000001; // 24 bit to write in the register

//THIS IS NOT A 24 BIT DATA. IT SHOULD BE 0x000001//

serial_out1=dout1;
P11=0; //clock low
++nop;
++nop;
adc_write(); //going to write function
}

ALSO I DON'T UNDERSTAND P11=0; //clock low .
//transmit data on leading edge of clock
//receive data on trailing edge of clock(failling edge)


ALSO THE SPI INITIALIZATION IS COMMON FOR ALL CASES, SO MAKE A SEPERATE FUNC'N & CALL IT WHEN NEED. & U MUST TAKE CARE OF MISO & MOSI.
I AM ALSO DOUGHTFULL ABOUT UR SPI INITIALIZATION?????
IF THIS IS THE CASE IT WILL CREATE PROBLEMS..
HOPE THIS WILL GIVE U THE THING U WANT. REPLY UR FEEDBACK.
Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post18 Nov 2009 7:16   

Re: adc resolution lowering - 24bit to 8 bit


actually i have used the long datatype,which has 32bit so store the value in 32 bit but sending only 24bit with msb..just see this line..
if(serial_out & 0x00800000)

and to write in the cycle count 0x40write command and 0x05 cycle count so,
according to write/read command value will be
01001010 which is 0x4a...

and i can send the command and getting its related output so there is not a problem in sending and receiving..m having problem in just writting any value in register only...[/code]


Last edited by bhoomi_shah2906 on 18 Nov 2009 7:33; edited 1 time in total
Back to top
mandar_mahajan



Joined: 08 Jul 2009
Posts: 97
Helped: 1
Location: mumbai


Post18 Nov 2009 7:32   

Re: adc resolution lowering - 24bit to 8 bit


Try the following
dout=0x45;// write command and address for cycle count

// 4.1.7 Register Read/Write
// B7 | B6 | B5 | B4 | B3 | B2 | B1 | B0 |
// -----------------------------------------
// 0 |W/R |RA4 | RA3| RA2| RA1| RA0| 0 |
// -----------------------------------------
// | RA[4:0] Register address bits.
// |
// |
// |------->1 = Write register
Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post18 Nov 2009 7:43   

Re: adc resolution lowering - 24bit to 8 bit


i will try but
// 4.1.7 Register Read/Write
// B7 | B6 | B5 | B4 | B3 | B2 | B1 | B0 |
// -----------------------------------------
// 0 |W/R |RA4 | RA3| RA2| RA1| RA0| 0 |
// -----------------------------------------
// according to this

0 1 0 0 1 0 1 0
this will b the register value
b7=0
b6=1 //wr
b5 b4 b3 b2 b1=00101
b0=0


whish is 4a
Back to top
mandar_mahajan



Joined: 08 Jul 2009
Posts: 97
Helped: 1
Location: mumbai


Post18 Nov 2009 8:13   

Re: adc resolution lowering - 24bit to 8 bit


yes it will be 0x4a. for sure.

Added after 1 minutes:

Try increasing ur nop instruction.
increase it by double/tripple.

Added after 17 minutes:

I am using 15 nop's. Just try this . Increase it in adc_cmd();

P11=1;//sclk high
++nop;
++nop;
++nop;
++nop;
++nop;
++nop;
++nop;
++nop;
++nop;
P11=0;//sclk=0;
Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post18 Nov 2009 10:02   

Re: adc resolution lowering - 24bit to 8 bit


still m having same problem...whenever try to write in the register its value comes zero...do any one know y its happening??? whats the problem... i can read the default value of the same register..

Added after 1 minutes:

but i can send the command properly..so it may not b a problem in clock...

Added after 1 hours 21 minutes:

hello sir can you plz send me your code to write the value in register????????
Back to top
mandar_mahajan



Joined: 08 Jul 2009
Posts: 97
Helped: 1
Location: mumbai


Post19 Nov 2009 7:25   

Re: adc resolution lowering - 24bit to 8 bit


Hey did u get the code?

Added after 42 minutes:

I had mailed u.... (PM)
Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post19 Nov 2009 12:35   

Re: adc resolution lowering - 24bit to 8 bit


ya sir i got ur mail...
thank u so so much
Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post20 Nov 2009 14:03   

Re: adc resolution lowering - 24bit to 8 bit


hi...
now i can write the data into registers but the problem is my voltage register value is not varying according to my input...what is the problem?? i have set cycle count as 4000 and selected high pass filter for voltage channel...so,what should i do???
plz help
Back to top
bhoomi_shah2906



Joined: 02 Oct 2009
Posts: 17


Post21 Nov 2009 13:35   

Re: adc resolution lowering - 24bit to 8 bit


hello mandar_mahajan sir plz help me last time as m vry confuse...
i can read,write everything n everything is fine but as u knw m jst taking 12 bit msbs as my output..so at 0.6mv input m getting 3205 and whenever my input voltage goes arnd 13.8 or more output goes to 0 as 12bit value 4096 gets overflow...so sir what should i do for this???? should i do calibration process???? sir plz help me...
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Electronic Elementary Questions -> adc resolution lowering - 24bit to 8 bit
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
12 bit ADC resolution (7)
How to make a 16-bit resolution sinewave for ADC testing (2)
high resolution (15 bit) delta sigma ADC simulation problem (4)
Problem with a SAR ADC with 8 bit resolution (4)
About ADC 24bit (3)
16 bit resolution of microcontroller (3)
resolution of ADC? (3)
comparator resolution in a ADC? (5)
resolution of 12bit SAR ADC (3)
KT/C Noise and ADC Resolution (8)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS