Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 01, 2024, 01:35:25 01:35


Login with username, password and session length


Pages: [1]
Print
Author Topic: [advise needed] arduino with external adc and lcd  (Read 4327 times)
0 Members and 1 Guest are viewing this topic.
sphinx
Hero Member
*****
Offline Offline

Posts: 917

Thank You
-Given: 613
-Receive: 269



« on: February 16, 2017, 12:52:16 12:52 »

The thought of this project is to work on a power suppply for showing values of  set volt and ampere and read values of actual values of volt and ampere.
It is a work in progress so not finished so far. i added all files and for proteus and arduino and its libraries.

I made a project for arduino with an external a/d and lcd to show values on it. At the moment lcd functions are commented out for use with a terminal to show values
for further calcuations. I am having some issues with the converted values of a/d not showing right values. I am wondering if this is caused but proteus, and should i buy
some adc and test with them in real world. My computer might be a bit slow for using with Proteus.
Logged

laws of physics are not laws at all, just assumptions and formulas that work as long as we don't figure something new that wrecks the calculations. the infinite onion try to peel that one
hexadec
Junior Member
**
Offline Offline

Posts: 55

Thank You
-Given: 67
-Receive: 113



« Reply #1 on: February 17, 2017, 01:15:08 13:15 »

I don't have version 8.5 or later so I can't open your files, but I would suggest that you don't waste any more time on this in a simulator and build the real hardware.
Proteus is well known to be full of bugs and inaccuracies and will alow you to do things with electronics that would never work in real life.
The hardware is also cheap and easy to breadboard...that would be my way of moving forward.

Sorry I can't help further at this point.
Logged

Sponge.

I'm allowed to have it 'cos it's not sharp.
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1200

Thank You
-Given: 550
-Receive: 409



« Reply #2 on: February 17, 2017, 06:22:42 18:22 »

How many channels would need to measure, I presume 1 volts and 1 amps ?
If it's a dual voltage like 2 volts and 2 amps then I would say they would need to be isolated from each other as no doubt the output channels of the power supply would not be common ground. I tried proteus with the MCP3424 but found it to slow. I did a meter with a MCP3426(16bits) which is 2 channels with a max input to the ADC of 2.048 and just used a resistor divider to bring it into that range and a differential op-amp for the current and calculated the current with the gain and I can say it was more accurate than my fluke meter.
I will have a look at your code and setup a bit later and let you know. I've also used an ADS1115 cheap ADC from E-bay with good results.
I would build real hardware rather than trust proteus. I start off with proteus to get a rough working project then swap to real hardware and continue   
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #3 on: February 18, 2017, 03:37:38 03:37 »

I ran your simulation, what I can see on your terminal is rubbish, it seems you must first fix this issue in order to see the values correctly. make sure your baudrate is correct. I think you should put some text to verify you are OK..

Posted on: February 18, 2017, 06:32:27 06:32 - Automerged

I dunt know much about arduino, but make sure your clock and arduino compiler are on the same page... I see that you use Serial.begin(9600);
just make sure your clock is correct in both compiler and proteus...
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1200

Thank You
-Given: 550
-Receive: 409



« Reply #4 on: February 18, 2017, 09:24:51 09:24 »

I could not compile your code it gives an errors, I've already got the libraries installed. I'm trying to read through your code to try to understand why it will not compile.
Code:
../main.ino:38:1: error: 'MCP3421' does not name a type
 MCP3421 MCP = MCP3421();
 ^
../main.ino: In function 'void setup()':
../main.ino:65:3: error: 'MCP' was not declared in this scope
   MCP.init(0x68,3,3);
   ^
../main.ino: In function 'void loop()':
../main.ino:70:9: error: 'MCP' was not declared in this scope
   while(MCP.ready()==0);
         ^
../main.ino:74:6: error: 'MCP' was not declared in this scope
   l1=MCP.getLong();
      ^
../main.ino: In function 'void sprintDouble(char*, double, byte)':
../main.ino:110:17: warning: zero-length gnu_printf format string [-Wformat-zero-length]
   sprintf(str,"");
                 ^
../main.ino:129:36: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     while( frac1 = frac1 / 10 & cnt--  )
                                    ^
../main.ino:108:8: warning: unused variable 'sgn' [-Wunused-variable]
   byte sgn=0;
        ^
make: *** [main.o] Error 1

Error code 2
I did run it with the hex file and this is the output
Code:
  Voltage @ pin A1 1999906
  Voltage @ pin A2 1499984
  Voltage @ pin A3 999984
  Voltage @ pin A4 700000
  Voltage @ pin A1 700000
  Voltage @ pin A2 1499984
  Voltage @ pin A3 1499984
  Voltage @ pin A4 700000
  Voltage @ pin A1 700000
  Voltage @ pin A2 1499984
  Voltage @ pin A3 1499984
  Voltage @ pin A4 700000
  Voltage @ pin A1 700000
  Voltage @ pin A2 1499984
  Voltage @ pin A3 1499984
  Voltage @ pin A4 700000
  Voltage @ pin A1 700000
  Voltage @ pin A2 1499984
  Voltage @ pin A3 1499984
  Voltage @ pin A4 700000
  Voltage @ pin A1 700000
  Voltage @ pin A2 1499984
  Voltage @ pin A3 1499984
  Voltage @ pin A4 700000
  Voltage @ pin A1 700000
Even tried to compile in Arduino IDE but same errors ??
I use this in my code so every time I need to print something to the serial for debugging so when it's working you could leave it in and rather than keep highlighting out each Serial print command you just highlight out one line and nothing get's printed.
Code:
#define ENABLE_SERIAL //Add // to disable and remove for debugging at the top of your code.

then add this to the setup code so you can see that the baud rate is correct and working
  #ifdef ENABLE_SERIAL
  Serial.begin(57600); //which ever baud rate you need or want
  Serial.println("");
  Serial.println("=====================================");
  Serial.println("I'M WORKING");
  Serial.println("=====================================");
#endif //#ifdef ENABLE_SERIAL

Then in your loop anything you want to print to the serial port you jys add your code example below
      #ifdef ENABLE_SERIAL
      Serial.print("VOLTS 1"); // so you know what your readig
      Serial.println("Volt_reading1,2 "); //display the incoming voltage
      #endif //#ifdef ENABLE_SERIAL
So then you just remove or add // to enable or disable with one line of code.
I've attached the start up project that I first used for mine, But the only difference is this in real hardware I used an MCP3426 which is the 16bit 2 channel version and this is only because ISIS does not have the sim model for it. The readings in ISIS take a bit to update but real time they work quite well, There may be better ways of setting it up to read faster but I'm just learning how to use these devices as I've always used the ADS1115 where you can find good examples to get them working great. I did see a few for the 18bit MCP3424 but everyone set's them up differently to read and becomes confusing. I am thinking of getting one of these ordered to play with as there easy to solder than the ADS1115 at home I do have a couple of the ADS1115 breakout boards what I use for prototyping but don't like to use them in the final design hence why I used the MCP3426 bad boy  
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
sphinx
Hero Member
*****
Offline Offline

Posts: 917

Thank You
-Given: 613
-Receive: 269



« Reply #5 on: February 18, 2017, 09:33:01 09:33 »

I ran into problems with serial terminal sending rubbish, it took ALOT of time to figure out what caused this.
Compare the arduino settings pictures, from what i could figure out it looks like the CLKDIV8 has to be set
as "unprogrammed" otherwise serial terminal wont work. have a look at the other two pictureswith voltage data
and compare.

i left the most of the settings as unprogrammed not sure on what they could cause. the only ones i changed
was the last three since first one is clock settings since those are suppose to be 16MHz, the other two i set to
default and it seemed to work fine.

Posted on: 2017-02-18, 10:47:02 - Automerged

@ wizpic i am not getting any errors while compiling my code on software version 1.8.1 from arduino.org
Logged

laws of physics are not laws at all, just assumptions and formulas that work as long as we don't figure something new that wrecks the calculations. the infinite onion try to peel that one
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1200

Thank You
-Given: 550
-Receive: 409



« Reply #6 on: February 18, 2017, 09:37:28 09:37 »

I'm using 1.69 will see about updating it to 1.81 and try again, The trouble I found when they update versions that some old code will not compile in the newer version which is what I ate as it takes some time to sort out and figure out why.

Your getting what I'm getting when I run the HEX file.
You've still not answered how many channels you wan to read ?
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
sphinx
Hero Member
*****
Offline Offline

Posts: 917

Thank You
-Given: 613
-Receive: 269



« Reply #7 on: February 18, 2017, 10:46:23 10:46 »

@ wizpic

about your first post,  this is a work in progress so i know i would have to look at where things would be measured and which should
be isolated from others.

this is first project i made with arduino so i started with the version which was 1.8.1

Posted on: 2017-02-18, 11:10:49 - Automerged

from a quick glance at issues with arduino compiler could be that later versions might be a bit pickier with upper and lower
case in defining libraries, calls, functions and variables.
Logged

laws of physics are not laws at all, just assumptions and formulas that work as long as we don't figure something new that wrecks the calculations. the infinite onion try to peel that one
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 4658

Thank You
-Given: 832
-Receive: 4301


There is no evidence that I muted SoNsIvRi


« Reply #8 on: February 18, 2017, 11:28:47 11:28 »

just a quick observation.
I have been working with a WEMOS D1 and different Versions of Arduino from 1.6.x upto 1.8.x
Problems I have had are hard to pin point mostly Libraries not loading using 1.8 dropping down to 1.6 worked for some projects.

I have Not used Proteus for a while, but Labcenter was having problems when using any Arduino above 1.6, not seen any fix for this, anywhere, so would say its ongoing. I would use the version that loads via Proteus.

Logged

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
sphinx
Hero Member
*****
Offline Offline

Posts: 917

Thank You
-Given: 613
-Receive: 269



« Reply #9 on: February 18, 2017, 02:37:26 14:37 »

from what i can see in the schematic i can use a 4 channel a/d converter since all references are to output ground
so no need for keeping them insulated from each other.
Logged

laws of physics are not laws at all, just assumptions and formulas that work as long as we don't figure something new that wrecks the calculations. the infinite onion try to peel that one
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1200

Thank You
-Given: 550
-Receive: 409



« Reply #10 on: February 18, 2017, 02:56:39 14:56 »

Sphinx what I meant by isolation, is you have a dual power supply these are normally isolated from each other say 0-30V 0-2.5amp x 2, then you could not use 1 MCP3424 has they would be become common ground. If you wanted to measure voltage and current from each supply you would need 2 x everything or one Arduino and 2 x digital I2C isolators with 2 x MCP3424 one for each power supply again these would need to have there own 5V supply. If you only wanted to measure one voltage and one current then you would only need to use 2 channels  of the MCP3424 which is a waste, unless you used the other 2 channels to read each potentiometer that sets the voltage and current so you could work out max voltage/current been set.

Are you wanting just to the Arduino to display the voltage/current readings or designing a power supply  controlled by the Arduino ?
Have you seen this one form here that uses Arduino and graphic displays, you may be able to pick up some tips
http://www.ianjohnston.com/index.php/projects/57-project-021-home-built-bench-power-supply
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
sphinx
Hero Member
*****
Offline Offline

Posts: 917

Thank You
-Given: 613
-Receive: 269



« Reply #11 on: February 18, 2017, 03:07:56 15:07 »

i know what you are meaning with isolation and that it can cause sometimes severe problems i remember that from my first design ever i did
i ran in into problems with it. but in my case i am only measuring on one side.

i am only looking for to measure and display values so far, the analog potentiometers work fine so far even though i would like to have
a fine tuning pot as well.
Logged

laws of physics are not laws at all, just assumptions and formulas that work as long as we don't figure something new that wrecks the calculations. the infinite onion try to peel that one
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC