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.

Adc scaling when convert analog to binary

Status
Not open for further replies.

derser

Member level 1
Member level 1
Joined
Sep 24, 2008
Messages
33
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,502
Hello Friends

Sometime we have problems with scaling
the analog signal before connect to ADC.
Here I upload help file in PDF format.
And I can think it will be useful to many of us.
 

Attachments

  • adcscaler_СКАЛИРАНЕ.pdf
    21.8 KB · Views: 223
Last edited by a moderator:

That's very useful for me. I do not understand some value in formula such as Gain,Samples,Vref . Could you please explain me again. Thanks.
Ps; I'm using assembly language.
 

Wow, what a complication.

When using microcontrollers with inbuilt ADC, it is much easier to do integer math. If you are, for example, measuring a car battery and your uC has 10 bit ADC, using 5V reference (assuming that your voltage stabilizer has exactly 5V on it's output) all you have to do is to take a resistor divider for sampling your battery voltage, calibrate it that with 20,48V input, your divider has %v on its output. Make 2 (two) consecutive readings,...

Hope that this lights some bulbs ;-)
 

When measure DC voltage is OK. But AC voltage measurement gave some error.
 

Thanks for your reply ZASto. I used one diode for half wave rectifier,two resistor for voltage divider and one series resistor for current limiter,connected to PIC's Analog input pin AN0 and read ADC value.But I don't know how to convert adc value to get actual AC voltage. I used this formula (volt per count = 220/adc count at 220v) to get volt per count value. I keep that value in EEPROM and multiply adc input by that volt per count value to get actual AC voltage. But I got some error of reading. Could you please show me correct formula for that. Thank you.
 

Thanks for your help ZASto. Now I'm facing problem of 10-bit multiplication. Any asm code for that? Thanks.
 

Multiplication?
For what reason?
Ordinary adding will do the trick. Presume that you wish to read voltages up to 30.69V (it is 10.23*3)

Code:
voltage = 0
for i = 1 to 3
  voltage = voltage + adcin 1
next i

whole = voltage / 100
decimal = voltage - (voltage / 100) * 100

:cool:
 

Thanks ZASto. Are you using basic language? I used assembly language. That's different. What so ever your code is useful for me. Thanks you.
 

Well, I do use Basic :cool:, to be more precise, Proton+
I also "speak" C and Pascal, but I'm most comfortable in Basic (much less typing than in C).
I hope that you figured out, from the code that I posted, that there are multiple ADC reads. It enhances precision if you are measuring slow processes such as battery charging/discharging.
 

But I don't know how to convert adc value to get actual AC voltage. I used this formula (volt per count = 220/adc count at 220v) to get volt per count value. I keep that value in EEPROM and multiply adc input by that volt per count value to get actual AC voltage. But I got some error of reading
For that purpose you need to apply 220v ac to circuit.
And measure adc volts at pin AN0.
Let us say volts at AN0 are 1.70 v dc.
With following formula, we can calculate reading for different mains volts.
1.70/220=0.0077273
Now if we need to calculate ADC v for 250 v mains.
ADC= 0.0077273*250=1.9318 v dc.
If mains volts are low e.g 165 v then ADC=0.0077273*165=1.2750 v dc.
And for 1.2750 v ADC resolution will be( for 10 bit if you are using vref=vdd, 5/1023=0.0048876),
1.2750/0.0048876=261
In asm this value should be like, MOVLW .261 or SUBLW .261 depend upon code.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top