quick questions about DAC on arduino and psu's - Page 1
Forum section: electronics / projects

author: Kilroywashere
author_rank: Regular Contributor
timestamp: March 24, 2019, 02:12:58 am
content: 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 codevoid 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 isint analogPin = A3; // potentiometer wiper (middle terminal) connected to analog pin 3// outside leads to ground and +5Vint val = 0; // variable to store the value readvoid setup() {Serial.begin(9600); // setup serial}void loop() {val = analogRead(analogPin); // read the input pinSerial.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 differenceIm new to the lcd stuff but i pick up things fastSchematic 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....

author: Kilroywashere
author_rank: Regular Contributor
timestamp: March 24, 2019, 02:32:54 am
content: Quote from: blueskull on March 24, 2019, 02:29:26 amNot my design and was not building this ... I was intrested in how he was hooking up his arduino and lcdMy power supply is much better this guys.....

author: Kilroywashere
author_rank: Regular Contributor
timestamp: March 24, 2019, 02:35:31 am
content: This is what i wanted to build but i wanted a lcd display

author: MarkF
author_rank: Super Contributor
timestamp: March 24, 2019, 03:03:59 am
content: Quote from: blueskull on March 24, 2019, 02:45:05 amI 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.

author: MarkF
author_rank: Super Contributor
timestamp: March 24, 2019, 03:20:32 am
content: Quote from: blueskull on March 24, 2019, 03:12:19 amI 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.....

author: Kilroywashere
author_rank: Regular Contributor
timestamp: March 24, 2019, 03:27:16 am
content: Quote from: MarkF on March 24, 2019, 03:20:32 amI 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?

author: Kilroywashere
author_rank: Regular Contributor
timestamp: March 24, 2019, 04:07:38 am
content: Quote from: blueskull on March 24, 2019, 03:47:07 amok.... 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

author: MarkF
author_rank: Super Contributor
timestamp: March 24, 2019, 04:30:45 am
content: 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.

author: MarkF
author_rank: Super Contributor
timestamp: March 24, 2019, 04:47:20 am
content: If you are trying to measure up to 24V, you can pick:Vin = 25VR1 = 22KR2 = 1KVout = 1.1Vusing standard resistor values.Reference:http://www.ohmslawcalculator.com/voltage-divider-calculatorInput 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.pdfI assume the internal 1.1V reference is selected by default. But, you need to check the Arduino library for it's settings.

author: MarkF
author_rank: Super Contributor
timestamp: March 24, 2019, 06:43:36 am
content: 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).Seehttps://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/If you want to use the internal 1.1V reference, you need to callanalogReference(INTERNAL);during initialization. The analog reference will apply to all analog inputs.I would use the default reference with the following resistor selections:Vin = 25VR1 = 12KR2 = 3KVout = 5Vwhich 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.

author: Ian.M
author_rank: Super Contributor
timestamp: March 24, 2019, 09:15:01 am
content: 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.

author: iMo
author_rank: Super Contributor
timestamp: March 24, 2019, 09:34:35 am
content: For example:Btw, you may get a good advice on the arduino forum too..

author: Nusa
author_rank: Super Contributor
timestamp: March 24, 2019, 10:04:24 am
content: Quote from: Kilroywashere on March 24, 2019, 02:32:54 amNothing magic about the LCD setup. Here's one of the many writeups on it:https://www.arduino.cc/en/Tutorial/HelloWorldIt'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