ADC 20 - Documentation question

Post general discussions on using our drivers to write your own software here
Post Reply
Posts: 0
Joined: Wed Jul 31, 2013 8:47 pm

ADC 20 - Documentation question

Post by jbmckim » Wed Jul 31, 2013 9:05 pm

In c# I'm able to communicate successfully with the ADC 20. Now I'm trying to parse/format the raw data returned by the device and the documentation (and lack of c# examples) have me scratching my head.

The doc says:
To convert from ADC values to volts, first obtain the minimum and maximum ADC
values for the selected channel by calling the HRDLGetMinMaxAdcCounts function in
the driver. Next, scale the ADC value to the voltage range you specified when you
called HRDLSetAnalogInChannel. You can calculate the voltage range
programmatically by using
Vmax = 2500 mV / (2^r)
where r is the range constant you supplied to HRDLSetAnalogInChannel (0 for ±2500
mV, 1 for ±1250 mV and so on).
Why do I need the call to GetMinMaxAcdCounts if r is simply the value input in SetAnaologInChannel?

I'll just add that since the examples hard code the values in the conversion rather than calculate them as described, it results in a good bit more of work than it seems like I should have to put up with for an appliance I paid for.


Site Admin
Site Admin
Posts: 3583
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: ADC 20 - Documentation question

Post by Martyn » Thu Aug 01, 2013 6:11 am

Vmax = 2500 mV / (2^r)
This is just giving the actual maximum for the chosen range. As you have to use r to set the channel you may as well use r in the calculation of the value returned when you read a channel. r could be linked into an enumeration for a drop down combo selection box in C#, so that selecting a voltage range in the drop down gives a value for r which can be used in two places
This is required because the returned values can change depending upon the conversion time that you have chosen for the channel

So using this the final voltage read from a channel will be

Code: Select all

volatge=AdcValue * (2500/(2^r)) / MaxAdcCount
Technical Support Manager

Post Reply