Continue to Site

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.

how to represent 16 bit data into 12 bit data?

Status
Not open for further replies.

srinivasa

Newbie level 6
Joined
Jul 7, 2010
Messages
11
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
bangalore
Activity points
1,383
Hi

can any one give me information how to convert a 16 bit digital data into 12 bit data.

thanks in advance
srinivasa
 

By upgrading from a PIC to a real micro. Otherwise 16 = 2x8.
16->12 is a lossy compression by cutting off the low 4 bit you are within 0.025% if it is an analog value.
Provide more information to get better answers.

Bob
 

Hi

Thanks for reply, in my micro controller there are two 16-ADC are there. now i want to subtract the these two 16 bit outputs(ADC1-ADC2) and then convert the result into 12-bit output. if u have any idea how to do it ,please give the information

thanks
srinivasa
 

To turn 16 bit data to 12 bit data you shift right four times. This does lose you resolution of course. You can do 16 bit arithmetic with an 8 bit micro so you can do your subtraction first. There will probably be 16 bit functions/macros for the micro so you don't have to write it all yourself (not that it is difficult). What is the micro?

Keith.
 

Hi

Thanks for reply,my micro controller is c8051f064 ,it is a 8 bit micro controller. am i writing in assembly, what i understood from your reply is that we can right shift 4 times the 16 bit data ,can u explain this point how it is getting converted to 12 bit data

Thanks
srinivasa
 

I am not an 8051 expert but there are some useful resources around. Try this **broken link removed**

16 bit data can represent unsigned numbers from 0 to 65535. 12 bit only covers 0 to 4095. So, you need to divide by 16 to convert them. A right shift moves every data bit along one place to the right and therefore divides the number by 2. Do that four times and you have divided by 16.

Ideally an 8051 expert would chip in here, but there seems to be no "shift" in the 8051, only rotate. In that case you use RRC - "rotate right through carry" but you need to watch out for the carry bit. In doing a 16 bit shift you shift the two 8 bit bytes in turn, using the carry bit to shift between the bytes. You need to be careful to clear the carry bit before you start otherwise you could end up with a 1 appearing in the most significant bit. Mind you, you could always just clear the MSbit afterwards.

Keith.
 

    srinivasa

    Points: 2
    Helpful Answer Positive Rating
you simply declare two "unsigned short" (16 bits) that hold the results of your adc.

then create a "signed short" (16 bits) that holds the differential. and then right shift the signed short by 4 will give you the most significant 12 bits.
 

hey keith, u r replying like an 8051 expert. and saying that u are not an expert. i wonder about u man.


reqards
kj
 

kj,

I have programmed loads of different microcontrollers but not they 8051. They are usually similar so you just need to find the instruction set to find the instructions available.

My first micro was the Signetics 2650 if anyone remembers it!

Keith
 

You youngsters!

I think my first micro was the Intel 4040 but before that I worked on monsters like the Eliot 903 and 905. They used boards full of transistors as their processor!!!

Brian.
 

I thought there would be someone here who could beat me! I do remember PDP8s though and my wife started mainframe programming on an IBM with 32k of RAM. I remember when hard disks were 5MB.

Keith.
 

The earliest hard disk I encountered was 10Mb but it took 5 of us to lift it into a truck to transport it. I remember the disk itself being about 1 metre wide, mounted upright in a metal skeleton frame and turned by a cloth belt and large finned AC motor in the bottom corner. I can't remember the manufacturer but it was probably Burroughs. When switched on there used to be an eerie shriek as the belt slipped until the disk was up to speed.

I also remember giving a hard disk a oil change! Not the bearings but the damper pot on top of the head actuator motor. They used to use oil filled pistons, similar to the things used to make doors close gently, to prevent head overshoot when seeking on the disk surface.

Brian.
 

10Mb - I used to dream of having a 10Mb disc ...

Apologies to Monty Python (but I am a Yorkshireman).

Keith.
 

so sad,in india we didnt get enough oppurtunites to work with those kind of devices. i came to know about a think called micro controller, only while studying a diploma.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top