electronicramblings.com

Archive for April, 2013

Neilson Danish Bar….do you remember????

by on Apr.26, 2013, under FOOD!!!

Neilson Danish Bar

Do you remember this bar????

I do and would like to taste it again. Oh well, things I like, seem to disappear from the market.

 

Leave a Comment more...

Truck Temperature Gauge ATtiny85 DS18S20 DS18B20 LCD

by on Apr.13, 2013, under Arduino, ATtiny, Electronic Projects

Well, finally built something useful with the ATtiny85.

Again this is more for reference then a how to.  So please use with a grain of salt.

I used the Halogen M16 Light housing as a template for the PCB boards.  Bought these from Ebay a few years ago to attempt to build a simple LED tachometer for my Cruiser(2006 Kawasaki Vulcan Nomad), but instead found a cheap 2″ gauge to do the job, so the lights were just sitting in my archives till I decided to build a temperature sensor for my Ford Ranger.  Will be mounting this gauge on the windshield column using the OH Shit!!! handle. When I get the bracket built will have pictures of the actual install.  Below this is the Lamps housing.  Can’t find it on ebay any more.  So if anyone know where to find them, let me know…I have a few ideas of what to put in them next. 🙂

April 13 iphone4 2013 141-800

The interesting thing I found is the M16 Lamp has a glass lens over the actual bulb.  Not like the other M16 bulbs I have in my home that have the bulb open to the air. (M16 EXN 12VDC 50 Watt is the lamp with a glass shield over the bulb)

So to protect my display on the LCD I decided to get a glass shop to cut me couple of circles of glass that I would silicon into the face of the housing.  This will make the unit able to be used on my Cruiser as well as my truck.

This is more of a picture post, hope is give you ideas of doing your own gauge.  If you do one, let me know as I do like seeing how other have done there projects.

Housing parts:

April 13 iphone4 2013 147-800

 

Electronics assembled reading for hiding way into the housing.

 

April 13 iphone4 2013 157-800

 

Back View, So you can see how the electronics are held into the housing.

 

April 13 iphone4 2013 160-800

 

 

 

 

April 13 iphone4 2013 163-800

 

Finished display. Now the hard part, figuring out how to mount without harming the original molding in the Truck.

April 13 iphone4 2013 167-800

 

 

Thoughts on other setups for this configuration: 

Oil Temperature
Oil Pressure
OBDII Readings(this one will take a lot of work, will have to go a at least a ATmega328 chip for this one)
Any other gauge one can think of!

Other configuration ideas:
No CPU in the gauge housing, but just a SPI LCD display and a electronics box under the dash to do all the gathering of information and controlling of the displays.

Boards:
Eagle Cad Boards:  ATtinyx5 LCD 8×2 V3

Note on board build:
Did not install the reset circuit, or the resonator. Not needed for this project. The Main board was setup for just project.(One Wire DS18S20 or DS18B20 temperature sensors)
If you use these boards, add in extra set of headers for external wiring, I got lucky and was able to solder my external wires to the pins on the header.
The boards were setup with through hole parts for two reasons, I was home etching the boards, and I have a lot of parts I wanted to use up. If I were to manufacturer these boards I would go to surface mount.

Sketch Notes:
Used the Arduino Digispark interface 1.03, BUT did not load into the ATtiny85 the boot loader!
The interface has most of the libraries need to do this project.  The rest of the libraries are in previous post. Please look back to find them. (Post)

Till next time, thanks for your time.

Sketch:

/*
April 12, 2013
Digispark Arduino interface 1.03 used to compile
Digispark(Tiny Core)
ATtiny85 Clock PLL-16Mhz
LCD control PCF8475A ([A]extended address chip) wired to use the DFRRobot Library
Eagle board “ATtinyx5 ***** V3”
(Actually uses a header for 8×2 LCD)

I2C LCD connects to SDA, SCL +5v, Gnd
Uses a 8×2 I2C LCD Backlight Display

DS18x20 x2 Temperature chip on pin P4
4k7 pullup between pin P4 and +5v.
Hard code addresses of sensor to make code smaller and easier.

Pin connections of ATtiny85
P0 = SDA Pin 5
P1 = Pin 6
P2 = SCL Pin 7
P3 = Pin 2
P4 = DS18B20 Pin 3
P5 = Pin 1

*/

#include <OneWire.h>
#define ONE_WIRE_BUS 4 // DS18B20 is on P4
#include <TinyWireM.h> // I2C Master lib for ATTinys which use USI – comment this out to use with standard arduinos
#include <LiquidCrystal_I2C.h> // for LCD w/ GPIO MODIFIED for the ATtiny85
#define GPIO_ADDR 0x38 //LCD address, PCF8475A extended address

OneWire ds(ONE_WIRE_BUS);
LiquidCrystal_I2C lcd(GPIO_ADDR,16,2); // set address & 16 chars / 2 lines

//DS18S20 temperature senor MAC address
byte addr[8]={0x10, 0x22, 0xE1, 0x48, 0x00, 0x08, 0x00, 0xBE};//long sensor cable [outside]
//DS18S20 temperature senor MAC address
byte addr1[8]={0x10, 0xEC, 0xA7, 0x48, 0x00, 0x08, 0x00, 0x47};//Short sensor cable [inside]

//
int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract;
char buf[20];

int HighBytea, LowBytea, TReadinga, SignBita, Tc_100a, Wholea, Fracta;
char bufa[20];

//________________________________________________________________________________
void setup(void) {
// set up the LCD’s number of rows and columns:

TinyWireM.begin(); // initialize I2C lib

lcd.init(); // initialize the lcd
lcd.clear();
lcd.noCursor();
lcd.backlight(); // Turn on the backlight

// Print a message to the LCD.
lcd.setCursor(0,0); // First position (0) and first line (0)
lcd.print (“Arduino “);
lcd.setCursor(0,1); // First position (0) and second line (1)
lcd.print (“Dual”);
delay(3000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print (“Temp”);
lcd.setCursor(0,1);
lcd.print (“Gauge”);
delay(4000);
lcd.clear();

}
//________________________________________________________________________________

void loop(void) {

sensorRead();
delay(4000);
sensor2Read();
delay(4000);

}

//________________________________________________________________________________

void sensorRead()
{
byte i;
byte present = 0;
byte data[12];

ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end

delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.

present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad

for ( i = 0; i < 9; i++)
{ // we need 9 bytes
data[i] = ds.read();
}

LowByte = data[0];
HighByte = data[1];
TReading = (HighByte << 8) + LowByte;
SignBit = TReading & 0x8000; // test most sig bit
if (SignBit) // negative
{
TReading = (TReading ^ 0xffff) + 1; // 2’s comp
}
Tc_100 = (TReading*100/2);

Whole = Tc_100 / 100; // separate off the whole and fractional portions
Fract = Tc_100 % 100;

sprintf(buf, “%c%d.%d\337C “,SignBit ? ‘-‘ : ‘+’, Whole, Fract < 10 ? 0 : Fract);
lcd.clear();
lcd.setCursor(0,1);
lcd.print(buf);
lcd.setCursor(0,0);
lcd.print(“Outside”);
}
//________________________________________________________________________________
void sensor2Read()
{
byte j;
byte presenta = 0;
byte dataa[12];

ds.reset();
ds.select(addr1);
ds.write(0x44,1); // start conversion, with parasite power on at the end

delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.

presenta = ds.reset();
ds.select(addr1);
ds.write(0xBE); // Read Scratchpad

for ( j = 0; j < 9; j++)
{ // we need 9 bytes
dataa[j] = ds.read();
}

LowBytea = dataa[0];
HighBytea = dataa[1];
TReadinga = (HighBytea << 8) + LowBytea;
SignBita = TReadinga & 0x8000; // test most sig bit
if (SignBita) // negative
{
TReadinga = (TReadinga ^ 0xffff) + 1; // 2’s comp
}
Tc_100a = (TReadinga*100/2);

Wholea = Tc_100a / 100; // separate off the whole and fractional portions
Fracta = Tc_100a % 100;

sprintf(bufa, “%c%d.%d\337C “,SignBita ? ‘-‘ : ‘+’, Wholea, Fracta < 10 ? 0 : Fracta);
lcd.clear();
lcd.setCursor(0,1);
lcd.print(bufa);
lcd.setCursor(0,0);
lcd.print(“Inside”);

}

Leave a Comment more...

Digispark ATtiny85 LCD I2C DS18S20 DS18B20 Temperature Monitor

by on Apr.01, 2013, under Arduino, ATtiny, Electronic Projects

Well this has been a great adventure!!!

I wanted to build a simple interior and exterior temperature sensor for my truck. This was a bigger adventure than I expected.  I started off by doing research of a the three main components that I wanted to use ( ATtiny85, DS18x20,LCD,).  I stumbled upon the Digispark project on Kickstarter and what they have done.  Searching more I found a article published in a magazine called the “The Shed” that used the Digispark to accomplish the reading of the DS18x20 temperature chip, but could not do negative number very well.  (The project in The Shed magazine/DigiStump forum also had a max/min and relay control).  So will look at that code later for running my smoker.

As I was still searching for code snippets that would work for me, I decided to build up the circuit that matched the DigiSpark on my trusty bread board minus the relay control.  The reason I am going with the DigiSpark circuit is that I am going to use the Arduino 1.03 Digispark inteface. It already has a lot of the libraries need for this small processor.  I WILL NOT be loading on the boot loader, so in fact you get 2k more space if you need it. Just have to modify the Arduino interface files to reflect that.

April 01 2013 049

I have a lot of older DS18x20 chips around so that is why I am using them up in projects.  (I have a vast archive of semiconductors and components from when I ran a repair and design company, oh so long ago….)  In the picture you may notice two arduino boards, and one with a shield with a mess of wirewrap on it, that is my dedicated Arduino as a ISP with my hand built ATtiny85/84 programmer shield.

When starting with the ATTiny and wanting to use the Arduino interface, this is the place.  They did a lot of great work there.

Now this is where the adventure truly started…..  Bricking the ATtiny 85 on the first try.

I followed the direction given by the MIT people, but then thinking I am smarter than the average bear I decided to program the fuses myself using one of the many AVR programmers I have with the AVR Studio software.  That is where I went wrong….word of warning….never set the reset fuse!!! I did and could not program the ATtiny flash or the fuses.  So this is where I learned of the High Voltage Programming circuit and software to fix the fuses. You can find a good write up this here.  So seeing that this must be a problem out here I made a Arduino shield up for this to.

Zip of the Attiny LV and HV Programmer shield I put together.

ATTINY Fuse Fix

 

After getting my Attiny85 unbricked, I still had to program the Clock fuse to what I needed. I could have figured out what was needed using this web page as a reference. Fuse Calculator And then used the HV circuit to set the fuses.  But, still a wanting to do it my way!  I went back to my trusty AVR programmer, and finished programming my ATtiny85 to have a clock speed of 16mHz (PLL).

Now we are cooking with fire….  This is where I was at, a ATtiny85, LCD 16×2 with a I2C backpack, and handful of DS18x20 chips.  I decided not to write any code at this time, but modify The Shed’s code to match my components to see if my wiring was working.  I always like to start from a known point and then really screw it up after that!  Well, some god’s of electronic adventures was good to me and we had a temperature show up on the LCD. And better yet it changed.  The bad part is it had a problem reading negative temperatures, so had to start working out a method that would give me a negative value. (It gets dam cold around here in the winter. Alberta, Canada) And the sketch below is the code that will do the job.  You will also see that I have hard coded in the DS18x20 addresses.  Did this so the correct reading matches up with the text on the LCD.

I then layed out a board fast, etched, drilled and stuff in a couple of hours to test out my new code.

A wack of Pics showing a semi completed project:

April 01 2013 046 April 01 2013 045 April 01 2013 044 April 01 2013 041

 

April 01 2013 047

I am including my eagle cad drawing for the project as well as the library folder from the Arduino 1.03 Digispark interface.   The PCB is pretty dam poor designing, I am not good at doing 2 sided boards at home yet.  Something like 12 jumpers one has to solder in on this one, however, it only took me 30 minutes to do the schematic and PCB layout.

Zip of my files:

Digispark_DS18x20_LCD_2_sensors_march_2013_v4_

The next one will use the 8×2 display and be more modular. Thinking of going with a power supply board, ATTiny board and LCD interface board that match the 8×2 8 pin dual row header.

 

Till next time, thanks for your time.

 

 

Sketch:

/*
April 01, 2013

electronicramblings.com
Digispark Arduino interface 1.03 used to compile code
Digispark(Tiny Core)
ATtiny85 Clock PLL-16Mhz
LCD control PCF8475A ([A]extended address chip) wired to use the DFRRobot Library
Eagle board “LCD 8×2 dual DS18x20 Ver2.brd”
(actually uses a header for 16×2 LCD) Was going to use a 8×2 but it was damaged.

I2C LCD connects to SDA, SCL +5v, Gnd (Don’t forget the 4k7ohm pull up resistors for the SDA SCL pins)
Uses a 16×2 I2C LCD Backlight Display

DS18B20 x2 Temperature chip on pin P4
4k7 pullup between pin P4 and +5v.
Hard code addresses of sensor to make code smaller and easier.

Pin connections of ATtiny85
P0 = SDA Pin 5
P1 = Pin 6
P2 = SCL Pin 7
P3 = Pin 2
P4 = DS18B20 Pin 3
P5 = Pin 1

*/

#include <OneWire.h>
#define ONE_WIRE_BUS 4 // DS18B20 is on P4
#include <TinyWireM.h> // I2C Master lib for ATTinys which use USI – comment this out to use with standard arduinos
#include <LiquidCrystal_I2C.h> // for LCD w/ GPIO MODIFIED for the ATtiny85
#define GPIO_ADDR 0x38 //LCD address, PCF8475A extended address

OneWire ds(ONE_WIRE_BUS);
LiquidCrystal_I2C lcd(GPIO_ADDR,16,2); // set address & 16 chars / 2 lines

//DS18S20 temperature senor MAC address
byte addr[8]={0x10, 0x22, 0xE1, 0x48, 0x00, 0x08, 0x00, 0xBE};//long sensor cable [outside]
//DS18S20 temperature senor MAC address
byte addr1[8]={0x10, 0xEC, 0xA7, 0x48, 0x00, 0x08, 0x00, 0x47};//Short sensor cable [inside]

//
int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract;
char buf[20];

int HighBytea, LowBytea, TReadinga, SignBita, Tc_100a, Wholea, Fracta;
char bufa[20];

//________________________________________________________________________________
void setup(void) {
// set up the LCD’s number of rows and columns:

TinyWireM.begin(); // initialize I2C lib

lcd.init(); // initialize the lcd
lcd.clear();
lcd.noCursor();
lcd.backlight(); // Turn on the backlight

// Print a message to the LCD.
lcd.setCursor(0,0); // First position (0) and first line (0)
lcd.print (“Arduino “);
lcd.setCursor(2,1); // First position (0) and second line (1)
lcd.print (“Temp Sensors”);
delay(4000);
lcd.clear();

}
//________________________________________________________________________________

void loop(void) {
sensorRead();
sensor2Read();
delay(3000);

}

//________________________________________________________________________________

void sensorRead()
{
byte i;
byte present = 0;
byte data[12];

ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end

delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.

present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad

for ( i = 0; i < 9; i++)
{ // we need 9 bytes
data[i] = ds.read();
}

LowByte = data[0];
HighByte = data[1];
TReading = (HighByte << 8) + LowByte;
SignBit = TReading & 0x8000; // test most sig bit
if (SignBit) // negative
{
TReading = (TReading ^ 0xffff) + 1; // 2’s comp
}
Tc_100 = (TReading*100/2);

Whole = Tc_100 / 100; // separate off the whole and fractional portions
Fract = Tc_100 % 100;

sprintf(buf, “%c%d.%d\337C “,SignBit ? ‘-‘ : ‘+’, Whole, Fract < 10 ? 0 : Fract);
lcd.setCursor(0,0);
lcd.print(buf);
lcd.setCursor(9,0);
lcd.print(“Outside”);
}
//________________________________________________________________________________
void sensor2Read()
{
byte j;
byte presenta = 0;
byte dataa[12];

ds.reset();
ds.select(addr1);
ds.write(0x44,1); // start conversion, with parasite power on at the end

delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.

presenta = ds.reset();
ds.select(addr1);
ds.write(0xBE); // Read Scratchpad

for ( j = 0; j < 9; j++)
{ // we need 9 bytes
dataa[j] = ds.read();
}

LowBytea = dataa[0];
HighBytea = dataa[1];
TReadinga = (HighBytea << 8) + LowBytea;
SignBita = TReadinga & 0x8000; // test most sig bit
if (SignBita) // negative
{
TReadinga = (TReadinga ^ 0xffff) + 1; // 2’s comp
}
Tc_100a = (TReadinga*100/2);

Wholea = Tc_100a / 100; // separate off the whole and fractional portions
Fracta = Tc_100a % 100;

sprintf(bufa, “%c%d.%d\337C “,SignBita ? ‘-‘ : ‘+’, Wholea, Fracta < 10 ? 0 : Fracta);
lcd.setCursor(0,1);
lcd.print(bufa);
lcd.setCursor(9,1);
lcd.print(“Inside”);

}

 

_________________________________________________________________

Keywords: Dallas Maxim Temperature ATtiny ATMEL AVR Studio I2C IIc

 

 

2 Comments more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...