Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

adc resolution lowering - 24bit to 8 bit

Status
Not open for further replies.

bhoomi_shah2906

Member level 1
Joined
Oct 2, 2009
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,589
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???
 

mandar_mahajan

Full Member level 2
Joined
Jul 8, 2009
Messages
134
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,298
Location
mumbai
Activity points
2,090
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..
 

bhoomi_shah2906

Member level 1
Joined
Oct 2, 2009
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,589
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
 

mandar_mahajan

Full Member level 2
Joined
Jul 8, 2009
Messages
134
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,298
Location
mumbai
Activity points
2,090
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.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
48,299
Helped
14,233
Reputation
28,727
Reaction score
12,925
Trophy points
1,393
Location
Bochum, Germany
Activity points
279,668
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.
 

bhoomi_shah2906

Member level 1
Joined
Oct 2, 2009
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,589
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.
 

mandar_mahajan

Full Member level 2
Joined
Jul 8, 2009
Messages
134
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,298
Location
mumbai
Activity points
2,090
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;
}
}
 

bhoomi_shah2906

Member level 1
Joined
Oct 2, 2009
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,589
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??
 

mandar_mahajan

Full Member level 2
Joined
Jul 8, 2009
Messages
134
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,298
Location
mumbai
Activity points
2,090
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]
 

bhoomi_shah2906

Member level 1
Joined
Oct 2, 2009
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,589
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???
 

bhoomi_shah2906

Member level 1
Joined
Oct 2, 2009
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,589
can anyone tell me how to convert 2's complement register value in binary form???
 

bhoomi_shah2906

Member level 1
Joined
Oct 2, 2009
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,589
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...
 

mandar_mahajan

Full Member level 2
Joined
Jul 8, 2009
Messages
134
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,298
Location
mumbai
Activity points
2,090
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..
 

bhoomi_shah2906

Member level 1
Joined
Oct 2, 2009
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,589
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.
 

mandar_mahajan

Full Member level 2
Joined
Jul 8, 2009
Messages
134
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,298
Location
mumbai
Activity points
2,090
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.
 

bhoomi_shah2906

Member level 1
Joined
Oct 2, 2009
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,589
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..
 

mandar_mahajan

Full Member level 2
Joined
Jul 8, 2009
Messages
134
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,298
Location
mumbai
Activity points
2,090
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.
 

bhoomi_shah2906

Member level 1
Joined
Oct 2, 2009
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,589
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]
 

mandar_mahajan

Full Member level 2
Joined
Jul 8, 2009
Messages
134
Helped
7
Reputation
14
Reaction score
5
Trophy points
1,298
Location
mumbai
Activity points
2,090
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
 

bhoomi_shah2906

Member level 1
Joined
Oct 2, 2009
Messages
40
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,589
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
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top