Show Posts
Pages: [1]
1  Using Arduino / Displays / Re: problem displaying floating point number with 'LCD3wire' on: July 19, 2012, 06:15:25 am
Thanks Bill  ( and those before )  smiley



2  Using Arduino / Displays / Re: problem displaying floating point number with 'LCD3wire' on: July 18, 2012, 06:51:17 am
HI Bill,
 I probably will persist with FM's library -  I do have an interest in using the most stable and most used library. And I'm not worried about a steep learning curve.  every step of this arduino process has  been a learning experience and it has been fun!    it was just after rewiring a perfectly good project just for a few extra pins which I don't really need I was getting frustrated and wanted something to work!
 I have had another play with Fms library

 after reinstalling Fm's library and trying out a simple sketch (below) I get the dreaded brown box with the following error.

liquidCrystal_SR3W does not name a type

Code:
#include <LiquidCrystal.h>

LiquidCrystal_SR3W lcd(8, 7, 9,  3, 2, 1, 7, 6, 5, 4);

void setup()
{
  lcd.print("hello, world!");
}

void loop() {}

 cheers
 Jim
3  Using Arduino / Displays / Re: problem displaying floating point number with 'LCD3wire' on: July 17, 2012, 05:42:59 am
Hi All,
Just reporting back - 
I tried using FMs New LiquidCrystal library but struggled to find a 3wire example that I could mash into my project.  I say 'mash' because all of my projects are bits and pieces of examples that I play with until they work.       smiley-red
 
While trying to figure out NewLiquidCrystal I stumbled across ShiftRegLCD123 and thought I would give it a go.   It had everything I needed and was simple enough for me to understand smiley  http://code.google.com/p/shiftreglcd123/
 
 Thanks everyone.
 
4  Using Arduino / Displays / Re: problem displaying floating point number with 'LCD3wire' on: July 15, 2012, 07:20:08 am
Hi everyone,
 Thanks for your replies and input. 

I used float instead of int as I would wanted to make the most of the accuracy of the ds18b20.  For my project  1 degree (C )change  could make a difference.    I didn’t realise it was so memory heavy!

This is going to sound crazy but I tried to find the source of the 3LCDwire library -  and I can’t remember where I found it.   But I the code I started with was example  24.3 from here.
http://tronixstuff.wordpress.com/2011/01/08/tutorial-arduino-and-monochrome-lcds/

  the printIn ();   issue.    The code from the example above  uses PrintIn();  which was confusing for me as I was happily using println();  from the original liquidcrystal library.    I think this has been cleared up now.

Rather than dig myself deeper  into a problem I will try the fm’s new-liquidcrystal library - 

I notice the shift registers used in the  ‘3 wire Shift register schematic’   the shift register is  74hc595n -  I am using  a ’ 4094 8-bit Tri-state Shift Register Latch CMOS IC’   will  this work the same?  74hc595n?

  I will try and find some time to try it out tomorrow night and report back -  hopefully with success smiley-wink

  Thanks again,
  Jim
5  Using Arduino / Displays / Re: problem displaying floating point number with 'LCD3wire' on: July 14, 2012, 07:24:33 am
HI Michael,
thanks for taking the time to try and find a solution.

 the values I'm working with are between about 20.00 and 100.00

I have to admit I don't really understand your code  smiley but I have tried it on my project and unfortunately with no change.     

I'm thinking I may try a different 3 wire LCD library.  and upgrade to IDE 1.0

6  Using Arduino / Displays / problem displaying floating point number with 'LCD3wire' on: July 13, 2012, 10:25:35 pm
Hi All,
I hope you can help me with something.  please forgive me if I don't explain things very well,  I'm very much an arduino newbie.   I am using Arduino 0022
 
I have a project that reads three temperature sensors ( ds18b20) and among other things displays the temperatures on a 20x4 LCD. 

I was using the liquidcrystal.h library and all was working well.  I then decided to use LCD3wire.h library with a shift register to free up some pins.   I eventually figured out the LCD addressing ( third row being lcd.cursorTo(1,20); etc)     

The problem I have is that I can't get the temperatures to display on the LCD.  stored as Float point numbers  eg.  (T1).  I can serial print fine so I know they are working. 

Making a few changes from liquidcrystal.h I thought this should work. 

lcd.cursorTo(2,0); 
lcd.printIn("Collection :");
lcd.print(T1);

 hope you can point me in the right direction.
 

Cheers

7  Using Arduino / Programming Questions / Re: execute once within loop? on: September 17, 2011, 06:23:15 am
Hi Rob,
 thanks for that,  I will give it a try and see how I go smiley

 cheers
Jim
8  Using Arduino / Programming Questions / execute once within loop? on: September 17, 2011, 05:09:42 am
HI everyone,
 
I hope you can help me with something.  please forgive me if I have left out some important info,  I am a complete newbie to arduino and this ( my first project)  is also  
a learning project for me.   The sketch below is a mash up of various other sketches -  I welcome any suggestions to improve it  smiley
 
What the sketch is for:
recording temperature of two points on a alcohol distillation column, one at the top and the other half way down the column. display them on an lcd screen and log the data  
on a sd card.  
then switch two servos that open gate valves at specific times (actually specific temperatures) which allow the flow of alcohol vapor into different condensers.
 
 
what I would like to add to this sketch is the switching of two servos 'once' when the differences in the two sensors are at a defined point.  
I can get it all to work but The problem I'm having is with turning the servos only once. they turn every time the loop executes.  I have played around with  
 
for (int i = 0; i < 1; i++)
{
servo()
}
 
but can't get it to work as desired within the main loop ( is this because the int i; is reset back to 0 at the start of each loop?)  
 
I have also used it in 'setup' which worked once of course but this isn't much use to me.  
 
thanks in advance for your help smiley  
 
cheers
Jim

 The code so far is
Code:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SD.h>
#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>
#include <Servo.h>

RTC_DS1307 RTC;

File myFile;

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 12

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;

LiquidCrystal lcd(4, 5, 6, 7, 8, 9);

Servo myservo;

int angle = 180;    // variable to store the servo direction
int angle2 = 90;
int angle3 = 0;

void setup(void)
{
  lcd.begin(16, 2);
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");
  pinMode(10, OUTPUT);
  myservo.attach(3);  // attaches the servo on pin 3 to the servo object

 
    if (!SD.begin(10)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
 
  myFile = SD.open("test.txt", FILE_WRITE);
 
  Wire.begin();
  RTC.begin();
 
  // Start up the library
  sensors.begin();
 



  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  Serial.print("Parasite power is: ");
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");


  // show the addresses we found on the bus
  Serial.print("Device 0 Address: ");
  printAddress(insideThermometer);
  Serial.println();

  Serial.print("Device 1 Address: ");
  printAddress(outsideThermometer);
  Serial.println();

  // set the resolution to 9 bit
  sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
  sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION);

  Serial.print("Device 0 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer), DEC);
  Serial.println();

  Serial.print("Device 1 Resolution: ");
  Serial.print(sensors.getResolution(outsideThermometer), DEC);
  Serial.println();
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  Serial.print("Temp C: ");
  Serial.print(tempC);
}

// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
  Serial.print("Resolution: ");
  Serial.print(sensors.getResolution(deviceAddress));
  Serial.println();   
}

// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
  Serial.print("Device Address: ");
  printAddress(deviceAddress);
  Serial.print(" ");
  printTemperature(deviceAddress);
  Serial.println();
}

void loop(void)
{
 
 
  sensors.requestTemperatures();

  float T1 = sensors.getTempC(insideThermometer);
  T1 = T1 + sensors.getTempC(insideThermometer);
  T1 = T1 + sensors.getTempC(insideThermometer);
  T1 = T1/3;
 
  float T2 = sensors.getTempC(outsideThermometer);
  T2 = T2 + sensors.getTempC(outsideThermometer);
  T2 = T2 + sensors.getTempC(outsideThermometer);
  T2 = T2/3;
 
 // int X = 1;
 
//  if (T1 > T2+2 && X > 0 )
//{
 //   myservo.write(angle);              // tell servo to go to position in variable 'pos'
//    delay(1240);
  //  myservo.write(angle2);
  //  X = X - 1;
//}

 
  Serial.begin(57600);
  DateTime now = RTC.now();
    myFile.print(now.hour(), DEC);
    myFile.print(':');
    myFile.print(now.minute(), DEC);
    myFile.print(':');
    myFile.print(now.second(), DEC);
    myFile.print(", ");
   
   
  Serial.begin(9600);
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.print(", ");
 
  myFile.print("inside, ");
  myFile.print(T1);
  myFile.print(",");
 
  Serial.print("Inside, ");
  Serial.print(T1);
  Serial.print(", ");
 
  myFile.print("Outside, ");
  myFile.println(T2);
  myFile.print(", ");
 
  Serial.print("Outside, ");
  Serial.println(T2);
  Serial.print(", ");
 
  lcd.setCursor(0, 0);
  lcd.print("inside ");
  lcd.print(T1);
 
  lcd.setCursor(0, 1);
  lcd.print("outside ");
  lcd.print(T2);
 
 
  delay(2000);
 
}

      
9  Using Arduino / Sensors / Re: addressing individual ds18b20s in a multiple device sketch on: July 31, 2011, 06:54:08 am
Thank you  Robtillaart,

 that gets things back on track smiley

 
10  Using Arduino / Sensors / Re: addressing individual ds18b20s in a multiple device sketch on: July 30, 2011, 10:21:38 pm

 The code I started with was the alarmhandler.pde  (Miles Burton )  I have pasted it below.   I used the straight Burton code without my additions as they don't relate to this  (I'm sure my additions will feature in another post asking for help soon smiley-wink  )

thanks

Quote
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;

// function that will be called when an alarm condition exists during DallasTemperatures::processAlarms();
void newAlarmHandler(uint8_t* deviceAddress)
{
  Serial.println("Alarm Handler Start");
  printAlarmInfo(deviceAddress);
  printTemp(deviceAddress);
  Serial.println();
  Serial.println("Alarm Handler Finish");
}

void printCurrentTemp(DeviceAddress deviceAddress)
{
  printAddress(deviceAddress);
  printTemp(deviceAddress);
  Serial.println();
}

void printAddress(DeviceAddress deviceAddress)
{
  Serial.print("Address: ");
  for (uint8_t i = 0; i < 8; i++)
  {
    if (deviceAddress < 16) Serial.print("0");
    Serial.print(deviceAddress, HEX);
  }
  Serial.print(" ");
}

void printTemp(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC != DEVICE_DISCONNECTED)
  {
    Serial.print("Current Temp C: ");
    Serial.print(tempC);
  }
  else Serial.print("DEVICE DISCONNECTED");
  Serial.print(" ");
}

void printAlarmInfo(DeviceAddress deviceAddress)
{
  char temp;
  printAddress(deviceAddress);
  temp = sensors.getHighAlarmTemp(deviceAddress);
  Serial.print("High Alarm: ");
  Serial.print(temp, DEC);
  Serial.print("C");
  Serial.print(" Low Alarm: ");
  temp = sensors.getLowAlarmTemp(deviceAddress);
  Serial.print(temp, DEC);
  Serial.print("C");
  Serial.print(" ");
}

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();
  
  // locate devices on the bus
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  // search for devices on the bus and assign based on an index
  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
  if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1");

  Serial.print("Device insideThermometer ");
  printAlarmInfo(insideThermometer);
  Serial.println();
  
  Serial.print("Device outsideThermometer ");
  printAlarmInfo(outsideThermometer);
  Serial.println();
  
  // set alarm ranges
  Serial.println("Setting alarm temps...");
  sensors.setHighAlarmTemp(insideThermometer, 26);
  sensors.setLowAlarmTemp(insideThermometer, 22);
  sensors.setHighAlarmTemp(outsideThermometer, 25);
  sensors.setLowAlarmTemp(outsideThermometer, 21);
  
  Serial.print("New insideThermometer ");
  printAlarmInfo(insideThermometer);
  Serial.println();
  
  Serial.print("New outsideThermometer ");
  printAlarmInfo(outsideThermometer);
  Serial.println();

  // attach alarm handler
  sensors.setAlarmHandler(&newAlarmHandler);

}

void loop(void)

  // ask the devices to measure the temperature
  sensors.requestTemperatures();
  
  // if an alarm condition exists as a result of the most recent
  // requestTemperatures() request, it exists until the next time
  // requestTemperatures() is called AND there isn't an alarm condition
  // on the device
  if (sensors.hasAlarm())
  {
    Serial.println("Oh noes!  There is at least one alarm on the bus.");
  }

  // call alarm handler function defined by sensors.setAlarmHandler
  // for each device reporting an alarm
  sensors.processAlarms();

  if (!sensors.hasAlarm())
  {
    // just print out the current temperature
    printCurrentTemp(insideThermometer);
    printCurrentTemp(outsideThermometer);
  }
  
  delay(1000);
}


11  Using Arduino / Sensors / addressing individual ds18b20s in a multiple device sketch on: July 30, 2011, 07:09:45 am
Hi everyone,
This is my first post here, I am very new to Arduino so please forgive me if I have left out any important info that will help you help me.

I have been working on a project using two ds18b20 temperature sensors.  Without going into detail (unless you want to know smiley )   I am using the sensors to turn on servos.   I have mashed together various bits of code I have found and feel like I’m making real progress which has been very exciting.

I have been using the Miles Burton - Dallas temperature control library.  In particular the alarm handler and multiple sketches.    Two  ds18b20 sensors in parasitic mode.

So far I have figured out I can turn on servos using the alarm feature but what I would like to do is to be able to compare the results of the two sensors.     for example: if sensor A is equal to sensor B...

I can manipulate the code to effect both the sensors but can’t figure out how to address each sensor individually.   Can you point me in the right direction?

 Cheers
Jim



Pages: [1]