Help - Search - Members - Calendar
Full Version: My arduino cyl head temp display
914World.com > The 914 Forums > 914World Garage
underthetire
My very first Arduino micro controller program. I've never used the Arduino language before ( think it c or C+ ? ) anyways, took me a few hours. Still need to order the thermocouple conversion chips, but looks like it will work. You can see when I put my finger over the analog pins, it does change as it should. Total cost will still be less than a single channel VDO gauge, and I will be able to calibrate it for more accurate readings.


https://www.youtube.com/watch?v=9UOUeEh11eg
McMark
Very cool! thumb3d.gif Looks like fun. You might think about ditching the "Cyl. X temp" parts and just put all four temps on one screen, like this

2: 120 4: 120
1: 120 3: 120

I put the cylinders in an orientation that matches the motor. cool.gif
jabberwocky
I was thinking a similar rout as I have programed a few AVG microcontrollers and have been thinking of picking up an adrino. Care to share the code? Are you running type J or K thermocouples and what converters are you going to use?
Good luck finishing out the install.
underthetire
I don't mind sharing the code at all. I'm no expert for sure. I did just finish doing a hold screen if the temps go above 400 and an alarm output for a piezo buzer or lamp. Planning on using K thermocouples since I have rolls of it. Mark I like the single page layout, I was thinking a larger screen in the future. Here is the conversion boards with the AD chips on them.

http://store.makerbot.com/electronics/elec...r-v1-0-kit.html
underthetire
i'll put some more notes in it when I clean it up, but here it is..got a arduino and LCD shield on ebay, with shipping it was like 30 bucks total.

CODE

/*
  
  The circuit:
* LCD RS pin to digital pin 8
* LCD Enable pin to digital pin 9
* LCD D4 pin to digital pin 4
* LCD D5 pin to digital pin 5
* LCD D6 pin to digital pin 6
* LCD D7 pin to digital pin 7
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
  */

// include the library code:
#include <LiquidCrystal.h>
void setup()
{
  Serial.begin(19200);
  Serial.println("Start");
}
void loop()

{
   label:;
  int raw = analogRead(1);
  int celsius = ( 5.0 * raw * 100.0) / 1024.0;

  Serial.print("Celsius: ");
  Serial.println(celsius);

  int fahrenheit = (((celsius * 9) / 5) + 32);
  Serial.print("Fahrenheit: ");
  Serial.println(fahrenheit);
  
  int raw1 = analogRead(2);
  int celsius1 = ( 5.0 * raw1 * 100.0) / 1024.0;

  Serial.print("Celsius1: ");
  Serial.println(celsius1);

  int fahrenheit1 = (((celsius1 * 9) / 5) + 32);
  Serial.print("Fahrenheit1: ");
  Serial.println(fahrenheit1);

int raw2 = analogRead(3);
  int celsius2 = ( 5.0 * raw2 * 100.0) / 1024.0;

  Serial.print("Celsius2: ");
  Serial.println(celsius2);

  int fahrenheit2 = (((celsius2 * 9) / 5) + 32);
  Serial.print("Fahrenheit2: ");
  Serial.println(fahrenheit2);
  
   int raw3 = analogRead(4);
  int celsius3 = ( 5.0 * raw2 * 100.0) / 1024.0;

  Serial.print("Celsius3: ");
  Serial.println(celsius3);

  int fahrenheit3 = (((celsius3 * 9) / 5) + 32);
  Serial.print("Fahrenheit3: ");
  Serial.println(fahrenheit3);
  
  int warning =13;
  pinMode(warning, OUTPUT);
  
  int backlightc = 10;
  pinMode(backlightc, OUTPUT);
  digitalWrite(backlightc,HIGH);
  delay(100);


// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
const int numRows = 2;
const int numCols = 16;
//void setup() {
  // set up the LCD's number of rows and columns:

  lcd.begin(0, 2);
  // Print a message to the LCD.
  lcd.print("Cyl. 1 temp ");
  lcd.setCursor(12,0);
  lcd.print( fahrenheit);
  lcd.print( "F");
  lcd.setCursor(0, 1);
  if (fahrenheit >400) digitalWrite(warning, HIGH);
  if (fahrenheit >400) delay (10000);
  lcd.print("Cyl. 2 temp ");
  lcd.setCursor(12,1);
  lcd.print(fahrenheit1);
  lcd.print("F");
  if (fahrenheit1 >400) digitalWrite(warning, HIGH);
  if (fahrenheit1 >400) delay (10000);
  delay (3000);
  lcd.setCursor(0, 0);
  lcd.print("Cyl. 3 temp ");
  lcd.setCursor(12,0);
  lcd.print(fahrenheit2);
  lcd.print("F");
  if (fahrenheit2 >400) digitalWrite(warning, HIGH);
  if (fahrenheit2 >400) delay (10000);
  lcd.setCursor(0, 1);
  lcd.print("Cyl. 4 temp ");
  lcd.setCursor(12,1);
  lcd.print(fahrenheit3);
  lcd.print("F");
  if (fahrenheit3 >400) digitalWrite(warning, HIGH);
  if (fahrenheit3 >400) delay (10000);
  delay(3000);
  if (fahrenheit <400) digitalWrite(warning, LOW);
  if (fahrenheit1 <400) digitalWrite(warning, LOW);
  if (fahrenheit2 <400) digitalWrite(warning, LOW);
  if (fahrenheit3 <400) digitalWrite(warning, LOW);
  goto label;
}
McMark
At first glance, it looks like you're looping a lot of stuff that you don't need to...
underthetire
QUOTE(McMark @ Jun 29 2010, 09:39 PM) *

At first glance, it looks like you're looping a lot of stuff that you don't need to...


Its more than likely that I am. I wasn't sure if i didn't loop from the beginning of the temp set up if it would still get real time data or not. Not using any of the higher speed of the processing capability so I wasn't to concerned about it. I'll play around tomorrow and see. Like I said it was my first time programming anything like this.
underthetire
Yep, needs to re-read all the temp setup to update. BTW, with the usb plugged in it also shows deg C and Deg F on the monitor (serial) page of the arduino software.
McMark
It's an awesome first project! aktion035.gif
underthetire
QUOTE(McMark @ Jun 29 2010, 10:41 PM) *

It's an awesome first project! aktion035.gif


Thank you mark. Coming from you thats quite a complement. The only way I can learn anything is to just do it. I couldn't and didn't do well in school, but i've made my way through life pretty well just figuring stuff out. If I would have gone to school, working for the company I work for now, I could be making double what I do, even though a bunch of the degreed EE's here are complete idiots. ( some are awe inspiring smart to)
obscurity
I haven't looked at the code too closely but you don't need the lines for "label" or "goto label" it automatically loops all code in the loop.

Arduino is an awesome little micro controller. I would love to see your schemetic and final install pics.
underthetire
QUOTE(obscurity @ Jun 30 2010, 03:36 PM) *

I haven't looked at the code too closely but you don't need the lines for "label" or "goto label" it automatically loops all code in the loop.

Arduino is an awesome little micro controller. I would love to see your schemetic and final install pics.



Thats what I thought it should do, but nothing else I tried worked except the GOTO statement. I know a goto is frowned upon in the C+ language. I just thought of another cool idea for this same unit, I can use a servo with a oil temp sensor to control the cooling flaps as well. My car has headers and the little bellows thing just does not work right with them.
narino
This is AWESOME.

popcorn[1].gif
underthetire
Ok, got rid of the goto, your right didn't need it. Added some notes as well. Any more suggestions would be welcome biggrin.gif

CODE

/*
  
  The circuit:
* Thermocouple amp [url=http://store.makerbot.com/electronics/electronics-kits/thermocouple-sensor-v1-0-kit.html]http://store.makerbot.com/electronics/elec...r-v1-0-kit.html[/url]
* LCD keypad shield [url=http://www.robotshop.ca/dfrobot-lcd-keypad-shield-arduino.html]http://www.robotshop.ca/dfrobot-lcd-keypad...ld-arduino.html[/url] (found on ebay 7.99)
* using LCD keypad shield
* LCD RS pin to digital pin 8
* LCD Enable pin to digital pin 9
* LCD D4 pin to digital pin 4
* LCD D5 pin to digital pin 5
* LCD D6 pin to digital pin 6
* LCD D7 pin to digital pin 7
* wiper to LCD VO pin (pin 3)
*thermocouple amp to analog pin1 (cyl1)
*thermocouple amp to analog pin2 (cyl2)
*thermocouple amp to analog pin3 (cyl3)
*thermocouple amp to analog pin4 (cyl4)
*warning to digital pin 13, also led on arduino
  */

// include the library code:
#include <LiquidCrystal.h>
void setup()
{
  Serial.begin(19200);
  Serial.println("Start");
}
void loop()

{

  int raw = analogRead(1);
  int celsius = ( 5.0 * raw * 100.0) / 1024.0;

  Serial.print("Celsius: ");
  Serial.println(celsius);

  int fahrenheit = (((celsius * 9) / 5) + 32);
  Serial.print("Fahrenheit: ");
  Serial.println(fahrenheit);
  
  int raw1 = analogRead(2);
  int celsius1 = ( 5.0 * raw1 * 100.0) / 1024.0;

  Serial.print("Celsius1: ");
  Serial.println(celsius1);

  int fahrenheit1 = (((celsius1 * 9) / 5) + 32);
  Serial.print("Fahrenheit1: ");
  Serial.println(fahrenheit1);

int raw2 = analogRead(3);
  int celsius2 = ( 5.0 * raw2 * 100.0) / 1024.0;

  Serial.print("Celsius2: ");
  Serial.println(celsius2);

  int fahrenheit2 = (((celsius2 * 9) / 5) + 32);
  Serial.print("Fahrenheit2: ");
  Serial.println(fahrenheit2);
  
   int raw3 = analogRead(4);
  int celsius3 = ( 5.0 * raw2 * 100.0) / 1024.0;

  Serial.print("Celsius3: ");
  Serial.println(celsius3);

  int fahrenheit3 = (((celsius3 * 9) / 5) + 32);
  Serial.print("Fahrenheit3: ");
  Serial.println(fahrenheit3);
  
  int warning =13;
  pinMode(warning, OUTPUT);
  
  int backlightc = 10;
  pinMode(backlightc, OUTPUT);
  digitalWrite(backlightc,HIGH);
  


// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
const int numRows = 2;
const int numCols = 16;

  // set up the LCD's number of rows and columns:
  if (fahrenheit <400) digitalWrite(warning, LOW);
  if (fahrenheit1 <400) digitalWrite(warning, LOW);
  if (fahrenheit2 <400) digitalWrite(warning, LOW);
  if (fahrenheit3 <400) digitalWrite(warning, LOW);
  lcd.begin(0, 2);
  // Print a message to the LCD.
  lcd.print("Cyl. 1 temp ");
  lcd.setCursor(12,0);
  lcd.print( fahrenheit);
  lcd.print( "F");
  lcd.setCursor(0, 1);
  if (fahrenheit >400) digitalWrite(warning, HIGH);
  if (fahrenheit >400) delay (10000);
  lcd.print("Cyl. 2 temp ");
  lcd.setCursor(12,1);
  lcd.print(fahrenheit1);
  lcd.print("F");
  if (fahrenheit1 >400) digitalWrite(warning, HIGH);
  if (fahrenheit1 >400) delay (10000);
  delay (3000);
  lcd.setCursor(0, 0);
  lcd.print("Cyl. 3 temp ");
  lcd.setCursor(12,0);
  lcd.print(fahrenheit2);
  lcd.print("F");
  if (fahrenheit2 >400) digitalWrite(warning, HIGH);
  if (fahrenheit2 >400) delay (10000);
  lcd.setCursor(0, 1);
  lcd.print("Cyl. 4 temp ");
  lcd.setCursor(12,1);
  lcd.print(fahrenheit3);
  lcd.print("F");
  if (fahrenheit3 >400) digitalWrite(warning, HIGH);
  if (fahrenheit3 >400) delay (10000);
  delay(3000);
  
  
}
SirAndy
QUOTE(underthetire @ Jun 30 2010, 06:57 PM) *

Any more suggestions would be welcome biggrin.gif

I put 'code' tags around your code ... shades.gif


As for the CHT display, i did this gauge mockup a few years back. I still think that would be a cool gauge to build ....
popcorn[1].gif Andy

jeffdon
QUOTE(SirAndy @ Jun 30 2010, 09:13 PM) *

QUOTE(underthetire @ Jun 30 2010, 06:57 PM) *

Any more suggestions would be welcome biggrin.gif

I put 'code' tags around your code ... shades.gif


As for the CHT display, i did this gauge mockup a few years back. I still think that would be a cool gauge to build ....
popcorn[1].gif Andy



F-NG cool!!! Your graphic skills rock! aktion035.gif
underthetire
Thanks andy. There is actually a demo program with the arduino to run something similar to that. idea.gif I might have to order a couple more arduinos to play with, they are pretty cheap, and kind of fun for a geek like me.
Lennies914
Very cool stuff Jeff, looking forward to seeing the results.
beerchug.gif
ottox914
When you get it all figured out I want one. I bet lots of other guys here would say the same thing. Think about it.
jaxdream
Don't know what all the costs are for a setup of this nature , but if it is as good or better than a say Dakota Digital at a reasonably priced deal , I would be interested in the final results. Having all 4 CHTemps at display would be a great engine monitor ( one of the priority things to keep an eye on ) to have . Would the microcontroller have the capabilities to read / display AF ratioes with O2 sensors or am I dreaming ??? unsure.gif

Jack / Jaxdream
jabberwocky
QUOTE(jaxdream @ Jul 1 2010, 09:14 AM) *

Don't know what all the costs are for a setup of this nature , but if it is as good or better than a say Dakota Digital at a reasonably priced deal , I would be interested in the final results. Having all 4 CHTemps at display would be a great engine monitor ( one of the priority things to keep an eye on ) to have . Would the microcontroller have the capabilities to read / display AF ratioes with O2 sensors or am I dreaming ??? unsure.gif

Jack / Jaxdream

All of this is possible with audrino or any microcontroler as long as you know your signal outputs and have proper a to d conversion as well as amplidyers as needed. If u know your systems well the code is not to difficult to figure out and the sky is the limit depending on your pacence level. Sorry on any typos I'm on my phone.
underthetire
QUOTE(jaxdream @ Jul 1 2010, 06:14 AM) *

Don't know what all the costs are for a setup of this nature , but if it is as good or better than a say Dakota Digital at a reasonably priced deal , I would be interested in the final results. Having all 4 CHTemps at display would be a great engine monitor ( one of the priority things to keep an eye on ) to have . Would the microcontroller have the capabilities to read / display AF ratioes with O2 sensors or am I dreaming ??? unsure.gif

Jack / Jaxdream



Well, all the parts minus the thermocouple wire, will be less than a hundred bucks. I think that is a pretty reasonable price for a 4+ channel TC display. And yes, AF rations have been done with the arduino, as well as EGT. At the beginning of the second code, shows where to get the AD boards and a punch out of parts. About 15 bucks per channel for thermocouple. O2 sensor would be pretty easy, since they are already an analog voltage output. My megasquirt gives me that data already, do probably not something i'll put in the code.
underthetire
QUOTE(ottox914 @ Jul 1 2010, 05:39 AM) *

When you get it all figured out I want one. I bet lots of other guys here would say the same thing. Think about it.



I have enough side work already in my life to cause me to skip meals. Actually, since i'm not a expert on this stuff, I wouldn't want to sell kits and have to support them. What I can do if anyone is interested, is give you the links where I buy this stuff, and email you the code ( good or bad biggrin.gif ) to load in to the arduino. The rest is pretty simple really. If you didn't want to load your own code I wouldn't mind doing it for you, just pay postage.
narino
QUOTE(underthetire @ Jul 1 2010, 08:24 AM) *

QUOTE(ottox914 @ Jul 1 2010, 05:39 AM) *

When you get it all figured out I want one. I bet lots of other guys here would say the same thing. Think about it.



I have enough side work already in my life to cause me to skip meals. Actually, since i'm not a expert on this stuff, I wouldn't want to sell kits and have to support them. What I can do if anyone is interested, is give you the links where I buy this stuff, and email you the code ( good or bad biggrin.gif ) to load in to the arduino. The rest is pretty simple really. If you didn't want to load your own code I wouldn't mind doing it for you, just pay postage.


I'm with David, I'd love to purchase this as a kit. But the tinkering side of me would also like to build it.

What code is this, C+ ? I'm going to pick up a book, or find a website, and use it as reference to follow how your code works. My code knowledge is limited to basic HTML.

Andy - have you found an "affordable" circular lcd display? I was thinking you could use a square lcd an build a fake circular bezel infront of it. Then program the lcd to only work within a circular area to match. I was thinking of something similar to your graphic but using the stock VDO colors.

Again, great thread Jeff!

beer.gif


narino
This is what I was thinking.

Click to view attachment
SirAndy
QUOTE(narino @ Jul 1 2010, 09:37 AM) *
Andy - have you found an "affordable" circular lcd display? I was thinking you could use a square lcd an build a fake circular bezel infront of it. Then program the lcd to only work within a circular area to match. I was thinking of something similar to your graphic but using the stock VDO colors.

I never looked at pricing the actual components as i went the big /6 route shortly after i made that mockup.

However, i do recall that my image was based on a LED strip that was available at the time. I don't remember prices.
idea.gif Andy
obscurity
QUOTE(narino @ Jul 1 2010, 12:37 PM) *

QUOTE(underthetire @ Jul 1 2010, 08:24 AM) *

QUOTE(ottox914 @ Jul 1 2010, 05:39 AM) *

When you get it all figured out I want one. I bet lots of other guys here would say the same thing. Think about it.



I have enough side work already in my life to cause me to skip meals. Actually, since i'm not a expert on this stuff, I wouldn't want to sell kits and have to support them. What I can do if anyone is interested, is give you the links where I buy this stuff, and email you the code ( good or bad biggrin.gif ) to load in to the arduino. The rest is pretty simple really. If you didn't want to load your own code I wouldn't mind doing it for you, just pay postage.


I'm with David, I'd love to purchase this as a kit. But the tinkering side of me would also like to build it.

What code is this, C+ ? I'm going to pick up a book, or find a website, and use it as reference to follow how your code works. My code knowledge is limited to basic HTML.

Andy - have you found an "affordable" circular lcd display? I was thinking you could use a square lcd an build a fake circular bezel infront of it. Then program the lcd to only work within a circular area to match. I was thinking of something similar to your graphic but using the stock VDO colors.

Again, great thread Jeff!

beer.gif



Take a look at http://www.arduino.cc for a programming reference. It is basically C

You can also look at http://www.freeduino.org/ for more projects that have been done with arduinos and the many variants and clones of the arduino
underthetire
I think i'm actually going to try and fit the display in the middle of the fuel gauge, since I have an extra to cut up. I've seen the arduino with a hacked Nokia LCD color screen, as well as graphic LCD, so I don't see a big problem doing a bar graph display like that. As far as LED displays, I think it would be pretty simple, and bar graph led's are plentiful.

And this will be my eventual goal with arduino based micro processors biggrin.gif


https://www.youtube.com/watch?v=gvH2f-AewX8
jaxdream
Underthetire , a list of parts would be great , as far as the code , heck I'm lucky to get on the web most days , I would have to farm that part out . As far as the the assembly I could probably pull that off, getting it to do it's thing , well that's another story. If your willing to pm me the parts list , that would be great , as I colud start collecting parts ( as soon as the budget allows parts purchace ) it would be great to have a readout of the 4 cylinder temps as well as A/F ratio with out getting a FI setup , plan on using carbs and it would be great to monitor the temps and A/F numbers. Thanks in advance . pray.gif

Jack / Jaxdream
narino

icon_bump.gif

Jeff - How's this coming along?

beer.gif

FRIDAY!
underthetire
Parts list
http://cgi.ebay.com/Arduino-Duemilanove-20...=item3f018b704f

http://cgi.ebay.com/LCD-Keypad-Shield-Ardu...=item3f018b71d5

These are the TC boards, but I have a source for them on my PC at home, with a complete Digikey order page. Think the parts were $1.00 per board, and about $15.00 per channel for the AD chips and parts.
http://store.makerbot.com/thermocouple-sensor-v1-0-pcb.html

I have done nothing since with it other than order some boards, in the process of moving, fuel pump went south on the 914, and my Jeep is spewing coolant as fast as I can put it in. So right now priorities are, Jeep, 914, finish start moving, then probably get back to this little side project.
underthetire
Ok, ripped the whole front of my Jeep off tonight and got the radiator in. And I mean WHOLE front. So at least i figured i'd get some more part numbers for those interested. The boards did go up to $2.00 each from 1, and the full kit from Makerbot went from 16.00 to 49.00 WTF.gif , but doesn't really matter. Get the parts from digi key. The parts order was for 5 channels, I still need to see if the Arduino will support 5 channels, but I think it will.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.