Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

General Programming Question

Status
Not open for further replies.

wuchy143

Member
Hi,

I'm trying to make a digital amplifier. I'm able to get it to work(sort of) but here is my issue:

The ADC samples the input port and converts it to a digital value from 0x8020 to 0xFFFF(decimal equiv --> 32800 to 65535). I then pass off the data to the DAC which has a lower limit of 0x0000 and an upper limit of 0x0D54(0 to 3412 in decimal).

I feel like I should be able to figure this out but I've been stuck thinking of ways to manipulate the ADC values so they match up with the DAC input values so my output gives me a full swing in desired voltage.

Are there any tricks out there to do something like this? Thanks!
 
You'll have to read the data sheet to understand what those ADC values represent (for example, do they represent a bipolar value or single-ended?). It's possible that a simple linear transformation (multiply the value by a number and add another number) will convert it to a range that is suitable for the DAC. You then just pick two points to find the constants of the transformation. Example: suppose the transformation is y = m*x + b where x is the ADC reading and y is the ADC value. If you want x = 0x8020 to be the DAC value of 0 and x = 0xffff to be y = 0xd54, you just write

0 = m*0x8020 + b
0xd54 = m*0xffff + b

and solve for m and b.
 
The ADC is bipolar. Reference voltage for DAC is 1.2v so it's capable of ADC'ing +/- .6V. :)

Thanks my friend. It now works great. Apparently I should have paid attention more to Linear Transformations in school. Awesome!
 
Apparently I should have paid attention more to Linear Transformations in school.
This is one of the hard parts of education. You no doubt studied all about this stuff in school (it's common in grammar school and high school freshman algebra in the US), but it's hard for the students to make a connection between real world problems like this and the dry textbook stuff. However, now that you've seen a real application, you'll probably never forget the technique.

Another example: the basic algebra classes teach the distributive property of numbers: a*(b + c) = a*b + a*c. Yawn. But one day my daughter asked me what some simple multiplication was and I startled her by figuring it out in my head. I don't remember what the problem was; let's assume it was 18*12. I immediately answered 216 and she was mystified how I did that. Then I told her that it's the same as 18*(10 + 2) = 180 + 36. A light bulb went off in her head and she really understood the utility of the distributive property for the first time. This is that "aha!" moment teachers would love to create in their students...
 
Status
Not open for further replies.

Latest threads

Back
Top