I am new to the Arduino UNO. So far I like the product, but I need clarification.
I know that the UNO can sense either a high or low on the digital IO pins, but this is essentially a voltage measurement relative to the UNO's own circuit ground.
Is there a way that the digital IO pins can look for a high or low (0-5 VDC) in reference to a separate ground?
I need something to record multiple on / off states on an external system. However, this external system is not powered by the arduino. Is this possible?
Yes it is simple to connect the two grounds together. Where you might want / need isolation is where for example one system is connected to a high voltage system like the mains.
I need to be able to make my readings export to excel.
Three ways to do this:-
Use an Arduino Leonardo and make it look like a computer keyboard. Then when you simply write to the PC and it is as if you had typed it on the computer's real keyboard. This also works with the Arduino Micro as well.
Get an SD card and write your data to that in a coma separated value way. Then transfer the SD card to your computer for reading.
Write some sort of helper application on the computer in the language of your choice, Processing is a popular choice. Get this application to read from the serial port and write a CSV file to the hard drive. Then open this in the spread sheet.
OK. I will get an SD shield of some sort. I will need some help more than likely to do the comma separated values. I have read some information about it, and it confuses me. To be continued.
I will need some help more than likely to do the comma separated values.
You write the value, then you write a comma. Continue to do this until you have written a line of spread sheet values and then you write a carriage return '\n'
Repeat for how ever many lines you want. When you create the file name it "something dot CSV"
That is what I understand. But, if I'm not mistaken, I need an SD shield to do this. The arduino UNO on its own can't get a csv file to my PC.
Also, look at my code above. I am not sure of how to type my 5 values into a csv format. As of now, I have the 5 values (4 voltages, and one digital). The voltages are displayed on an LCD and the serial monitor, and the digital signal is just displayed on the serial monitor.?
james_airman:
That is what I understand. But, if I'm not mistaken, I need an SD shield to do this. The Arduino UNO on its own can't get a csv file to my PC.
Of course it can. You are already sending the data to the PC via the serial monitor. You just need something on the PC to write it to the file.
Please read section 7 of the instructions on how to post in the forum, then go back and modify your posting #5 so that the code can be managed properly.
Thanks for the reply. I went back to posting 5. I updated my code too. Can you take a look at my attempt at comma separated values at the end? I have tried researching it, but I am not too confident.
Hi, james, it is not advisable to go back to previous replies and make sketch changes.
Please post a new listing, because when you edited the sketch in reply #5 you have now made the ability of this thread to help someone else a bit difficult.
The flow of your sketch development is now not chronological.
Thanks for correcting me. I have removed my code from post 5. Here it is. Please take a look.
Thanks for the input. It was so simple. I realized that I had already been doing that for some analog inputs. I feel small. I am monitoring if a 28 VDC signal is on or off. I am using a voltage divider to make the voltage safe for the arduino digital IO. I hooked it up this morning, shared the grounds and all is well.
I have one last piece of the puzzle I need help on. I need to be able to make my readings export to excel. Here is my code. It is a bunch of spliced together codes from stuff that I have found online and also some simple modifications by me. Have pity on me, I have only been looking into arduinos since Christmas.
Thanks,
[code]/*--------------------------------------------------------------
Program: voltmeter_LCD
Description: 4 channel DC voltmeter with voltages displayed
on LCD to 1 decimal place
Hardware: Arduino Uno with voltage dividers on A2 to A5.
2 x 16 LCD connected to standard pins used in
Arduino example sketches from IDE.
Software: Developed using Arduino 1.0.5 software
Should be compatible with Arduino 1.0 +
Date: 27 May 2013
Author: W.A. Smith, http://startingelectronics.com
--------------------------------------------------------------*/
#include <LiquidCrystal.h>
// number of analog samples to take per reading, per channel
#define NUM_SAMPLES 10
// voltage divider calibration values
#define DIV_1 11.1346
#define DIV_2 11.1969
#define DIV_3 11.0718
#define DIV_4 11.0718
// ADC reference voltage / calibration value
#define V_REF 4.991
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sum[4] = {0}; // sums of samples taken
unsigned char sample_count = 0; // current sample number
float voltage[4] = {0.0}; // calculated voltages
char l_cnt = 0; // used in 'for' loops
int DSC1 = 8;
void setup()
{
lcd.begin(16, 2);
pinMode(DSC1, INPUT);
Serial.begin(9600);
}
void loop()
{
// take a number of analog samples and add them up
while (sample_count < NUM_SAMPLES) {
// sample each channel A2 to A5
for (l_cnt = 0; l_cnt < 4; l_cnt++) {
sum[l_cnt] += analogRead(A2 + l_cnt);
}
sample_count++;
delay(10);
}
// calculate the voltage for each channel
for (l_cnt = 0; l_cnt < 4; l_cnt++) {
voltage[l_cnt] = ((float)sum[l_cnt] / (float)NUM_SAMPLES * V_REF) / 1024.0;
}
// display voltages on LCD
// each voltage is multiplied by the resistor network
// division factor to calculate the actual voltage
// voltage 1 - A (pin A2)
lcd.setCursor(0, 0);
lcd.print("A ");
lcd.print(voltage[0] * DIV_1, 1);
lcd.print("V ");
// voltage 2 - B (pin A3)
lcd.setCursor(8, 0);
lcd.print("B ");
lcd.print(voltage[1] * DIV_2, 1);
lcd.print("V ");
// voltge 3 - C (pin A4)
lcd.setCursor(0, 1);
lcd.print("C ");
lcd.print(voltage[2] * DIV_3, 1);
lcd.print("V ");
// voltage 4 - D (pin A5)
lcd.setCursor(8, 1);
lcd.print("D ");
lcd.print(voltage[3] * DIV_4, 1);
lcd.print("V ");
// reset count and sums
sample_count = 0;
for (l_cnt = 0; l_cnt < 4; l_cnt++) {
sum[l_cnt] = 0;
}
int read1 = digitalRead(DSC1);
Serial.println("read1,");
delay(300);
Serial.print("A,(voltage[0] * DIV_1, 1),V");
delay(300);
Serial.print("B,(voltage[1] * DIV_2, 1),V");
delay(300);
Serial.print("C,(voltage[2] * DIV_3, 1),V");
delay(300);
Serial.print("D,(voltage[3] * DIV_4, 1),V");
delay(300);
}
Will print the string "A,(voltage[0] * DIV_1, 1),V" to the serial terminal, it will not print the values of any of the variables nor will it print the result of the calculations it contains. It might as well just say:-
"this is just some random crap".
This is what I am talking about. I was told that comma separated values would work, but for some reason I am not understanding on how to set it up. I have no programming experience. Looking at my code, how would you take my 4 voltages, and 1 digital signal and have it print to the serial monitor in such a way that I could use that data in a program such as PLX-DAQ?
Because everything is in quote marks it prints out everything exactly as it is within the quote marks.
Just print the diffrent elements sepratly just like you did with the LCD only to the serial port.