Ideas for how to use a 12-bit DAC with an 8-Bit DAC?

Status
Not open for further replies.

ChemE

New Member
Folks,

Here is what I am trying to do. I am going to have a PS/2 Mouse input its movement bytes into a 877A. Then have the 877A output a signal to a 12-bit DAC (MCP4922). Before I get into the my question Im going to explain the PS/2 mouse and 877A interaction. (FYI... I am using EPE magazines John Becker PS/2 host code)

When a ps/2 mouse is sending movements to a host (a 877A pic in my case) it sends 3 8-bit bytes. The first byte contains information about the button states (pressed or unpressed), the sign of the X and Y movement and X & Y overflow flags. Bytes 2 carries the movement bits for the X-direction and Byte 3 for Y-Direction. So Bytes 2 & 3 represent the mouse movement with 8-bits. (example: move up one = 00000001, move down one = 11111111

So my problem is mouse movements are represented by 8-bits while the DAC inputs are represeted by 12-bits... The equation for the DAC is:

Vout=Vref*G*D/4096​

where G is Gain which = 1 or 2 and it is up to the user which one to use.

So here are the voltages that I want, the fastest mouse movement up or right will need to generate 1.6v the fastest movement down or left 0.0v and when the mouse is idle 0.8v.

I began to write a program, using assembly, that would translate 8bits to 12bits by using a scaler to so but it seems like a hard way to do this...

  • I figure this must be a common problem with alot of other projects and I am hoping there is an easier way to deal with it.
  • Could anyone help me? Any ideas?

I hate making things harder then they are. If this post wasn't clear ask me for further explaination and I will, Thank you.
 
Last edited:
hi cheme,

When I do a search for MCP 4022 I keep getting a 6bit digital pot???


Regards
 
hi,
Got the MCP4922 datasheet OK.

As you have an 8 bit resolution from the source [mouse] IMO trying to convert to 12 bit would not give any advantage.

I would consider left shifting the 8 bit data byte by 4. That is the least significant bits D3-D0 set as '0''s [ use a WORD reg ],
OR the hi byte, low order bits with the Write Command register.
[effectively dividing the 12 bit by 16]

eg: /A.B,BUF,/GA,/SHDN,[D7,6,5,4, | 3,2,1,0],0,0,0,0

Send this image to the DAC
 
Eric,

Thank you! That is what I should have done from the begining... much easier then trying to translate it. I guess the key learning was:

Moving numbers to the left is the same as multiplying by 2 each time

Example: rlf b'00000001' = 00000010 which is 1*2 = 2
Example: rrf b'00000010' = 00000001 which is 2/2 = 1

Thank you for the help!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…