Author Topic: quick questions about DAC on arduino and psu's  (Read 2564 times)

0 Members and 1 Guest are viewing this topic.

Offline KilroywashereTopic starter

  • Regular Contributor
  • *
  • Posts: 105
  • Country: ca
  • He has the stink of oil and electric circuitry...
quick questions about DAC on arduino and psu's
« on: March 24, 2019, 02:12:58 am »
Hey i'm building something  just wanted to make sure i understood the design .....


On J1, J2 and J3 the arduino will read the "voltage"  once one of the junctions have a complete circuit? ( not that good of a design what happens if you hook up more than one junction?? )

is a 1k and a 220 r going to work as protection for the 0-5v pin?

This is the guys code

void setup()
{
  Serial.begin(9600);
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.setCursor(0, 0);
  lcd.print("RPS");
  lcd.setCursor(0, 1);
  lcd.print("-Circuit Digest");
  delay(2000);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Voltage = ");
}
int voltage;
void loop()
{
  int A1 = analogRead(A0);
  voltage = map(A1,0,1024,0,22);
  Serial.println(voltage);
  lcd.setCursor(10,0);
  lcd.print(voltage);
  delay(1000);       
}

it does not like int voltage; .... but thats not my issue  what is my issue is


int analogPin = A3; // potentiometer wiper (middle terminal) connected to analog pin 3
                    // outside leads to ground and +5V
int val = 0;  // variable to store the value read

void setup() {
  Serial.begin(9600);           //  setup serial
}

void loop() {
  val = analogRead(analogPin);  // read the input pin
  Serial.println(val);          // debug value
}

this code works for 0-5 v ..... and turns it into  0 to 1023 ......


uhhh im getting confusing i think.....  I, assuming that i would have to use some protection  if i want to get larger than 5v say i wanna get to 20v .... I can assume that i also have to make up some code to account for the difference


Im new to the lcd stuff  but i pick up things fast



Schematic 2 seems to be a better job ( cant seem to get it working right i only have a 1x16 lcd .... only tryed to get it to work once but thats beside the point....



Ok well i know i yammed on alot ...... but i think you know what im talking about....
He is part of the dead...he has no place here. He has the stink of oil and electric circuitry about him. He is obsolete...
 

Offline KilroywashereTopic starter

  • Regular Contributor
  • *
  • Posts: 105
  • Country: ca
  • He has the stink of oil and electric circuitry...
Re: quick questions about DAC on arduino and psu's
« Reply #1 on: March 24, 2019, 02:32:54 am »
Arduino is your smallest problem. First, you are overvolt-ing your regulators. 7812 has a rated max 35V input, and any sane designers will leave some extra margin.
24V AC, with 10% input fluctuation, can get up to 26.4V, then under zero load, the full wave rectifier outputs 36.07V (assuming diode drop is 0.7V each), and that's apparently not good.
Your adjustable regulator's output is not ground referenced, so is its voltage divider. That will blow your Arduino and you won't get the anticipated regulation.

And where is the groundhan  point of your Arduino?


Not my design  and was not building this ...  I was intrested in how he was hooking up his arduino and lcd

My power supply is much better this guys.....
He is part of the dead...he has no place here. He has the stink of oil and electric circuitry about him. He is obsolete...
 

Offline KilroywashereTopic starter

  • Regular Contributor
  • *
  • Posts: 105
  • Country: ca
  • He has the stink of oil and electric circuitry...
Re: quick questions about DAC on arduino and psu's
« Reply #2 on: March 24, 2019, 02:35:31 am »
This is what i wanted to build but i wanted a lcd display
He is part of the dead...he has no place here. He has the stink of oil and electric circuitry about him. He is obsolete...
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2762
  • Country: us
Re: quick questions about DAC on arduino and psu's
« Reply #3 on: March 24, 2019, 03:03:59 am »
This is what i wanted to build but i wanted a lcd display

Get a cheap eBay voltage meter module for less than shipping and you are good.

You can do the same with Arduino, but as you've said, you need a voltage divider. A 10k low side and 39k high side gives you 4.9:1 ratio, so you can sense up to 22.05V (with minimum USB voltage 4.5V on your Arduino).

I recommend to use the internal 1.1V reference voltage instead of V_USB as your ADC reference, so you need to scale your input to less than 1.1V. I would use a 220k high side and a 10k low side. That give you 23:1 ratio, so you have a max 25.3V input range.

I would not use such a small (1.1V reference) ADC range.  Use the 0-5V ADC input range and set your voltage divider to map the max voltage to the ADC's 5V maximum.  That will give the maximum sensitivity for the ADC.

Edit-  Why bury your signal down in the noise??  It makes no sense.
« Last Edit: March 24, 2019, 03:07:26 am by MarkF »
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2762
  • Country: us
Re: quick questions about DAC on arduino and psu's
« Reply #4 on: March 24, 2019, 03:20:32 am »
I would not use such a small (1.1V reference) ADC range.  Use the 0-5V ADC input range and set your voltage divider to map the max voltage to the ADC's 5V maximum.  That will give the maximum sensitivity for the ADC.

Edit-  Why bury your signal down in the noise??  It makes no sense.

You get all resolution regardless Vref setting. It's a hardware feature, not software scaling.

As for noise, it all boils down to placement and filtering.

I said sensitivity.  Not resolution.
Mapping 0-5V to 1024 bits would be better than mapping 0-1.1V to 1024 bits.  Larger voltage bins.
To each his own.....
 
The following users thanked this post: Kilroywashere

Offline KilroywashereTopic starter

  • Regular Contributor
  • *
  • Posts: 105
  • Country: ca
  • He has the stink of oil and electric circuitry...
Re: quick questions about DAC on arduino and psu's
« Reply #5 on: March 24, 2019, 03:27:16 am »
I would not use such a small (1.1V reference) ADC range.  Use the 0-5V ADC input range and set your voltage divider to map the max voltage to the ADC's 5V maximum.  That will give the maximum sensitivity for the ADC.

Edit-  Why bury your signal down in the noise??  It makes no sense.

You get all resolution regardless Vref setting. It's a hardware feature, not software scaling.

As for noise, it all boils down to placement and filtering.

I said sensitivity.  Not resolution.
Mapping 0-5V to 1024 bits would be better than mapping 0-1.1V to 1024 bits.  Larger voltage bins.
To each his own.....

I think i will go with the 5v  and go with  220k high side and a 10k low side  ... so are you guys saying that  the "noise" from the power supply will mess with my  bits?? or did i misunderstand?
He is part of the dead...he has no place here. He has the stink of oil and electric circuitry about him. He is obsolete...
 

Offline KilroywashereTopic starter

  • Regular Contributor
  • *
  • Posts: 105
  • Country: ca
  • He has the stink of oil and electric circuitry...
Re: quick questions about DAC on arduino and psu's
« Reply #6 on: March 24, 2019, 04:07:38 am »
I think i will go with the 5v  and go with  220k high side and a 10k low side

Then you just found yourself the worst combination.

I said sensitivity.  Not resolution.

5V is not accurate as it comes from the external with unknown quality of regulation. 1.1V is internal bandgap.
And noise in this case is mainly AC noise, so a digital RC filter takes care of it. Something like y+=k*(x-y), where k=1/tau/fs will work well.


ok.... so whats the "best" combo, and why?   cuz now im lost ..... you did say to me that 1 v  220k high side and a 10k low side was good....

( I dont know where i would find the 1v .... i know there is a 3v and a 5 v rail on the atmega , do i have to make my own 1v  you said its internal so its gata be in there)

Im kinna confused now.....  why does noise matter when talking about a voltage divider and lcd.....?

Anyway i have an idea why but... I guess ill try to find out about this internal 1 volt reference...

Thank you guys for your time i do appreciate it
« Last Edit: March 24, 2019, 04:18:53 am by Kilroywashere »
He is part of the dead...he has no place here. He has the stink of oil and electric circuitry about him. He is obsolete...
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2762
  • Country: us
Re: quick questions about DAC on arduino and psu's
« Reply #7 on: March 24, 2019, 04:30:45 am »
Go ahead and use the internal 1.1V reference.  Set your voltage divider accordingly.

I don't use the Arduino Uno much and thought it's internal reference was 5V.  Leave the Analog Reference pin unconnected.
 
The following users thanked this post: Kilroywashere

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2762
  • Country: us
Re: quick questions about DAC on arduino and psu's
« Reply #8 on: March 24, 2019, 04:47:20 am »
If you are trying to measure up to 24V, you can pick:
   Vin = 25V
   R1 = 22K
   R2 = 1K
   Vout = 1.1V
using standard resistor values.

Reference:  http://www.ohmslawcalculator.com/voltage-divider-calculator
Input any 3 to get the fourth.

Edit-
I would not pick high resistor values.  You need to be able to charge the internal sample-and-hold capacitor.  The datasheet says a 10K or less impedance. 

Read the ATmega328P datasheet chapter 24.
http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061A.pdf

I assume the internal 1.1V reference is selected by default.  But, you need to check the Arduino library for it's settings.
« Last Edit: March 24, 2019, 05:27:59 am by MarkF »
 
The following users thanked this post: Kilroywashere

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2762
  • Country: us
Re: quick questions about DAC on arduino and psu's
« Reply #9 on: March 24, 2019, 06:43:36 am »
I TAKE IT ALL BACK.
My initial thoughts on what the default reference voltage was were correct.

The default analog reference for the UNO is 5V.  The AVcc is connected to Vcc (5VDC).
See  https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/

If you want to use the internal 1.1V reference, you need to call  analogReference(INTERNAL);
during initialization.  The analog reference will apply to all analog inputs.

I would use the default reference with the following resistor selections:
   Vin = 25V
   R1 = 12K
   R2 = 3K
   Vout = 5V
which has a 1.6mA current draw @ 25V excluding the Arduino.  You may need to lower those values if your peek voltage is lower.

Use which ever reference you like or try them both.
« Last Edit: March 24, 2019, 06:45:38 am by MarkF »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: quick questions about DAC on arduino and psu's
« Reply #10 on: March 24, 2019, 09:15:01 am »
Check out the specs of the internal reference (Datasheet section 32.8. ADC Characteristics).  Its min. 1.0V typ. 1.1V max. 1.1V, which is +/- 0.1V or 9%.  Unless the ATmega328P's  5V supply is worse than that (+/-0.45V), or has a significant time-varying load on it you are better off using the Arduino default 5V supply as reference.  If you use the internal reference, you will have to calibrate, and the datasheet has no data on its temperature stability.

Also, its only a 10 bit ADC, which is barely good enough for a three digit meter.    If you want to do better you'll need an external 16 bit or better ADC, a precision reference IC and very good design and board layout skills to give the ADC and reference a clean enough supply and avoid digital noise polluting the analog ground so the ADC LSBs are actually worth something for other uses than as a random number seed.

 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 5570
  • Country: va
Re: quick questions about DAC on arduino and psu's
« Reply #11 on: March 24, 2019, 09:34:35 am »
For example:
Btw, you may get a good advice on the arduino forum too..
Readers discretion is advised..
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2418
  • Country: us
Re: quick questions about DAC on arduino and psu's
« Reply #12 on: March 24, 2019, 10:04:24 am »
Not my design  and was not building this ...  I was intrested in how he was hooking up his arduino and lcd

Nothing magic about the LCD setup. Here's one of the many writeups on it:
https://www.arduino.cc/en/Tutorial/HelloWorld
It's the same interface for all the very common HD44780 LCD displays, whether they're 1x16 or 4x20.

And if you want to understand the controller chip:
https://www.sparkfun.com/datasheets/LCD/HD44780.pdf
« Last Edit: March 24, 2019, 10:08:09 am by Nusa »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf