Re: ADC simulator
Hi, this is how it should work:
First choose a Vref (5V for example)
Now, to get the digital equivalent from the analog voltage you do the following math:
Vref = 255 (for 8 bits ADC; 4095 for 12 bits and so on)
Vanalog = x
x = Vanalog(255) / Vref
So you put in your dip switch the bynary number "x". Keep in mind that ADC rounds numbers, if you got 128.5 or more it wil be 129 on the ADC output; in the other hand if you got 128.4 or less it will be 128 on the ADC output.
An example to clarify things:
Vref = 5
Vanalog = 2
5 = 255
2 = x
x = 102;
So you put in your dip switch 01100110 = 102
Hope i could help.
mcoster