South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« on: July 15, 2011, 06:47:58 am » |
Hi all, new around here and I don't get have an arduino but I plan to order in the next couple of days. I want to measure three voltages (around about 2x2.5v and 1x5v) and output to a screen that I already have that interfaces via RS232 Is this possible - if so what would be the best way to start? I'm new to programming  Thanks
|
|
|
|
« Last Edit: July 15, 2011, 06:56:30 am by dtokez »
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 75
Posts: 6969
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #1 on: July 15, 2011, 07:04:03 am » |
Yes it's very possible, dead simple in fact. In a nutshell the code will be
Serial.print ("Input 1:"); Serial.println (analogRead(pinNumber1)); Serial.print ("Input 2:"); Serial.println (analogRead(pinNumber2)); Serial.print ("Input 3:"); Serial.println (analogRead(pinNumber3));
There will be more but that's the guts of the matter. When you get your hardware and start writing code we can answer more completely.
______ Rob
|
|
|
|
« Last Edit: July 15, 2011, 07:06:13 am by Graynomad »
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #2 on: July 21, 2011, 09:39:24 am » |
Hi and thanks for the help! My Arduino is on its way  So am I correct in thinking that I can just connect the voltages to be measured straight to the analogue pins with no extra circuitry? Thanks
|
|
|
|
|
Logged
|
|
|
|
|
New Jersey
Offline
Edison Member
Karma: 25
Posts: 2443
|
 |
« Reply #3 on: July 21, 2011, 10:17:28 am » |
So am I correct in thinking that I can just connect the voltages to be measured straight to the analogue pins with no extra circuitry?
Yes, as long as the voltages are indeed <= 5V, otherwise you'll need a voltage divider. Don't forget to connect the grounds together too.
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 37
Posts: 6042
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #4 on: July 21, 2011, 02:40:51 pm » |
You need to connect the ground of the signal to arduino ground too. Plus if your display is RS232, it communicates with +- 12V so that needs to be shifted down to 0V-5V for arduino unless it also outputs in 0V and 5V. Can you provide a link to your RS232 display?
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #5 on: July 27, 2011, 05:52:23 am » |
|
|
|
|
« Last Edit: July 27, 2011, 09:32:41 am by dtokez »
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 37
Posts: 6042
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #6 on: July 27, 2011, 11:57:53 am » |
That screen doesn't speak rs232. Do you mean you have a serial pack for it?
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #7 on: July 27, 2011, 12:31:53 pm » |
Hi, I planned to use it in parallel mode if possible? I am following this tutorial, I get back-light on the screen but nothing else at the moment 
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 37
Posts: 6042
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #8 on: July 27, 2011, 01:36:46 pm » |
Hi, I planned to use it in parallel mode if possible? I am following this tutorial, I get back-light on the screen but nothing else at the moment  Which tutorial? Show a picture of your connections. We don't have crystal balls.
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #9 on: July 27, 2011, 06:24:54 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #10 on: July 28, 2011, 01:06:34 pm » |
Right, I have now followed a different tutorial... http://www.ladyada.net/learn/lcd/charlcd.htmlAnd it works now do you think someone could advise me on the best way to get it reading voltages & displaying them? One thing I have noticed is you have to hit the reset button to get it to run when you first power it up? Thanks 
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 37
Posts: 6042
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #11 on: July 28, 2011, 02:06:52 pm » |
Not sure why you need to reset for it to run. Can you post your code? Your question is two-fold: reading values and displaying them. You need to provide details of what you're reading with a spec sheet for each sensor. That is a starting point. Once reading value is good to go, then we'll talk about displaying them.
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #12 on: July 28, 2011, 07:26:50 pm » |
Hi Liudr, Sure, this is the code (its from the arduino examples section) /* LiquidCrystal Library - Hello World Demonstrates the use a 16x2 LCD display. The LiquidCrystal library works with all LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. This sketch prints "Hello World!" to the LCD and shows the time. The circuit: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 * LCD D4 pin to digital pin 5 * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) Library originally added 18 Apr 2008 by David A. Mellis library modified 5 Jul 2009 by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe modified 22 Nov 2010 by Tom Igoe This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal */
// include the library code: #include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); }
void loop() { // set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): lcd.setCursor(0, 1); // print the number of seconds since reset: lcd.print(millis()/1000); }
I have just drawn up a quick schematic of what I hope to achieve and attached it to this post, please forgive the messy wiring I have not done many before  Basically, the connectors marked BMS & BCU are to allow connection from a wiring harness with two hall effect sensors installed (only one socket will be populated at a time). I want to measure 5 voltages. Four of which (v.ref1, v.ref2, v.out1 and v.out2) will be selected using switches, with two outputs. This will enable me to switch between each sensor on the loom. On the LCD I would like to display the main supply voltage (5v) and either v.ref1 & v.out1, or v.ref2 & v.out2 (2.5v). The higher the resolution the better really, but at least 0.00v. Thanks for your time, I really appreciate it 
|
|
|
|
« Last Edit: July 28, 2011, 07:30:59 pm by dtokez »
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #13 on: July 29, 2011, 10:48:28 am » |
Well I have just had another play, and reloaded the code. It now runs without having to reset 
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #14 on: July 29, 2011, 01:26:23 pm » |
Hi again  could someone help me modify this code to work without the dividers? the voltages that I plan to measure will be less than 5v. #include <LiquidCrystal.h> LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int analoginput = 0; float vout = 0.0; int value = 0; float R1 = 1000.0; // !! resistance of R1 !! float R2 = 470.0; // !! resistance of R2 !! float vin = 0.0;
void setup(){ // declaration of pin modes pinMode(analoginput, INPUT); lcd.begin(16, 2); delay(100); }
void loop(){ // read the value on analog input value = analogRead(analoginput); vout= (value * 5.0)/1024.0; vin = vout / (R2/(R1+R2)); lcd.setCursor(0,0); lcd.print(" "); lcd.setCursor(0,0); lcd.print(vin, 3);
lcd.setCursor(11,0); lcd.print("Volts"); delay(1400);
}
|
|
|
|
|
Logged
|
|
|
|
|
|