Showing posts with label LCD-Display. Show all posts
Showing posts with label LCD-Display. Show all posts

7/03/2013

Test run with RC Surfer/ Homemade Spot Welder

I'm currently doing at least two projects at a time (and more in the queue) which I will elaborate later on in this blog.

Spot Welder

Spot welder test
The first project is a homemade spot welder which I'm building together with Knudt and Sebastian for the Hamburg Makerspace Attraktor. The device will be used for connecting rechargeable battery cells or join together thin sheets of metal. The whole thing consists of a 1 Farad/ 16V Capacitor (originally used for car hifi), a 13.8V/ 2A power supply, some Mosfets and an Arduino with a graphical display (at the moment it's a Nokia 5110 LCD display). The Arduino will do the controls, while the Mosfets will handle the power dissipation to the electrodes.
On the right there is a picture of an early test. You can see the capacitor in the background, on the breadboard there is an Arduno Nano and the Nokia LCD display. We are using scrap steel "electrodes" at the moment but will possibly change this with real tungsten welding electrodes.Oooh, and obviously no XBees involved this time.

RC Surfer

Years ago I bought a so called "RC Surfer" for cheap (you have to google this because mine is disassembled and I can provide no photo in action).

Cheap were also the contents of this RC controlled surfer. There was a motor driver with a relay, a 27 MHz radio control and a servo controlling the rudder. The power control was only "on" and "off" and the servo reaction to the input on the remote control was at least working.
There was no feedback of voltage or temperatures and no extra features like light etc.

 

At the moment I'm working on the new motor controls. I have a prototype L298 motor driver board which supplies at least 2A to the original dc brushless motor I'm still using. It consumes about 1A so I'm happy with the L298 for now. You can control the motor speed by using the PWM on the Arduino and connect it to the enable pin on the L298. You can also power the motor forward and backward what was not possible with the original motor driver.
The first test run worked quite well and the next addition will be the rudder control with a new servo. At the moment I'm using a joystick out of a scrap PS2 control - later I will command the RC Surfer with my android phone and a bluetooth connection. If that doesn't work, I will use a XBee/ RC combination with a traditional remote control.
Possible features might be telemetry which sends data like current used, voltage, temperatures, cam etc. Or what about a water canon?

to be continued...





.

7/27/2011

Temperature-Sensor Network with RTC and LCD Part V

Wow. More than a month since my last entry. Time is flying by. About 50 days since I started the project and my rechargeable batteries (I had to change the first three after a few days, because one cell was dead) still work in my outside sensor. My RTC is wrong by about 1.6 seconds per day and the deviation is very constant so this error can be erased by software. To compare the temperatures I used a Clock with inside/ outside temperatures I bought some time ago. The temperatures were accurate and so I finally assembled a device which I can buy for about 20 Euros in any electronics store. You might ask why so much effort for such little outcome? Wait for adding an ethernet shield, more Xbees, door bell/ mail alert, light and rain indicators and so on. And everything is broadcasted in the network!

LCD display with date, time, inside- and outside-temperature
For the last part there is unfortunately a lot of code to sift through. I made as many comments as possible - if there are any questions just put it in a comment on the page.

void loop() {

  DateTime now = RTC.now(); // new RTC object named "now"
 
  // get time and date from the RTC DS1307

  int hour = now.hour();
  int minute = now.minute();
  int second = now.second();

  // print time and date on the first line of the LCD
  // and make some adjustments regarding leading zeros
  // time display will change every second

    lcd.setCursor(0, 0);

  if (hour < 10) {
    lcd.print("0");
    lcd.print(hour,DEC);
  }
  else {
    lcd.print(hour,DEC);
  }
  lcd.print(":");
  if (minute < 10){
    lcd.print("0");
    lcd.print(now.minute(), DEC);
  }
  else {
    lcd.print(now.minute(), DEC);
  }
  lcd.print(":");
  if (second < 10){
    lcd.print("0");
    lcd.print(now.second(), DEC);
  }
  else{
    lcd.print(second, DEC);
  }

  int month = now.month();

  lcd.print("  ");
  lcd.print(now.day(),DEC);
  lcd.print(".");
  if (month < 10) {
    lcd.print("0");
    lcd.print(now.month(), DEC);
    lcd.print(".");
  }
  else {
    lcd.print(now.month(), DEC);
    lcd.print(".");
  }

  // wait one second to show off as a "real" clock ;)
  delay (1000);

  // here we are reading the serial port, that means everything that comes from the XBee Coordinator
  // the packet size (I/O Data Sample) is expected to be at least 23 bytes
  if (Serial.available() >= 23) {

    // look for the start byte, in this case I chose part of XBee end device address for easy parsing
    // this is a quick and dirty solution and you are welcome to make a better code for this
    // and of course you have to adjust the code for your XBee end device
    if (Serial.read() == 0x6F) {

      // blink debug LED to indicate when data is received
      digitalWrite(debugLED, HIGH);
      delay(50);
      digitalWrite(debugLED, LOW);

      // read the variables that we're not using out of the buffer
      for (int i = 0; i<9; i++) {
        byte discard = Serial.read();
      }
      // read the two bytes for the analog value
      int analogHigh = Serial.read();
      int analogLow = Serial.read();

      // combine high and low analog value, because it's in two bytes
      analogValue =  analogLow + (analogHigh * 256);

      // calculate temperature from TMP 36
      // 1.2V/ 1024 (10 bit ADC), 0°C is 500 mV, 10mV/ °C temperature coefficient
      float temperature = (((1.171875*analogValue)-500)/10);

      // we take 10 analog temperature samples and calculate the average

      temperature_sample=0; // reset temperature_sample value to zero

      for (int i=0; i<10; i++) {
        // calculate the temperature from the AD22100K
        // 5V/ 1024 (10 bit ADC), 1.375 V at =0°C, 22.5mV temperature coefficient per °C
        temperature_read = (analogRead(0)*0.0048828125 - 1.375) / 0.0225;
        temperature_sample = temperature_sample + temperature_read;
      }
      temperatureInside = (temperature_sample/10);

      // print inside and outside temperature in the second row of the LCD
      // display will only change when data is received

      lcd.clear();

      lcd.setCursor(0, 1);
      lcd.print("IN ");
      lcd.print(temperatureInside,1);
      lcd.print(" OUT ");
      lcd.print(temperature,1);

    }
  }
}


There are still some things to consider and to change in the future. There is for example no adjustment for negative temperatures in the display, the parsing with the XBee address could be improved, the back light could be adjusted by software.

6/24/2011

Temperature-Sensor Network with RTC and LCD Part IV

Are you ready to continue? I have to give an advance warning because the project becomes a bit confusing regarding the Fritzing-Schematics.
Nevertheless I will post the final add-on for the base station just to be complete: the 16x2 backlight LCD. If you are not sure about how to connect a 16x2 LCD there is a fantastic site which will give you full information about this topic: How to connect Arduino with a character LCD. In the meantime this is the current version of the breadboard. 
If you followed up to this point it will be no big effort to connect the last item!

Although we haven't built the remote sensor yet, I will start to show the sketch so you have a break building circuits.

Let's start with some information about the project and the configuration of the Xbees - I already mentioned the base station XBee configuration here.

Sketch Part I: project description, explanation how to configure the XBees (this is done via X-CTU and/ or terminal program):

/* REMOTE AND LOCAL TEMPERATURE SENSOR WITH:
ARDUINO UNO, TMP36, AD22100KT, RTC DS1307, TWO SERIES 2 XBEES
AND 16*2 LCD-DISPLAY
Ver 0.1
by Markus Ulsass
http://lookmanowire.blogspot.com/
*/

/*
*** XBEE CONFIGURATION ***
 

 RECEIVER: (BASE STATION)
 COORDINATOR
 ATID 2001 (PAN ID)
 ATDH 0
 ATDL 0
 ATAP 1 API mode enable
 ATSP AF0 sleep period according to longest sleep period on end device

 SENDER: (REMOTE SENSOR )
 END DEVICE
 ATID 2001 (PAN ID)
 ATDH 0
 ATDL 0
 ATD0 2   pin 0 in analog in mode with TMP36
 ATIR 3E8 sample rate 1000 millisecs (hex 3E8)
 ATSM 4   sleep mode cyclic sleep mode
 ATSP AFO sleep period (AFO = 2800 ms * 10 = 28 seconds)
 ATST 7D0 time before sleep 2 seconds (hex 7D0 = 2000 ms)
 
*/

As mentioned before you should already be familiar with the configuration of the base station ("RECEIVER"), I will now explain the settings for the remote sensor:
  • ATID 2001: We select the same PAN ID for the end device, else we would likely have serious communication problems between coordinator and end device
  • ATDH 0, ATDL 0:  We leave both destination addresses at 0 (no broadcast) to send any information directly to the coordinator
  • ATD0 2: Analog Pin 0 (physical pin 20) is set to analog input mode. Remember the XBee will look for a maximum of 1.2 volt input so you might have to use a voltage divider depending on your analog sensor
  • ATIR 3E8: The periodic I/O Sampling Rate is set to 1000 milliseconds (that's 3E8 in HEX), this means a sample is sent every second from the remote sensor to the coordinator, given that the end device is awake
  • ATSM 4: We set the Sleep Mode to "4" which means we enable the cyclic sleep mode for the XBee end device
  • ATSP AF0: The Sleep Period is set to the maximum of 28 seconds hence we set the parameter to AF0 (HEX) or 2800 milliseconds. Because the sleep period is multiplied by 10 we get our 28 seconds.
  • ATST 7D0: This value sets the Sleep Timer which decrements the given parameter before the end device falls asleep again provided there is no RF signal received. For testing purposes we set this value to 7D0 (HEX) which is 2000 milliseconds. Later we could decrease this value to save energy. For the time being I will keep this value this high, because we could easier get access to the XBee if something goes wrong.
Sketch Part II: including libraries, declaring and initializing values:

// include the library for liquid crystal code:
#include <LiquidCrystal.h>

// include the library for DS1307 RTC connected via I2C and Wire Library
#include <Wire.h>
#include <RTClib.h>

RTC_DS1307 RTC;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

int debugLED = 13;            // for debugging purposes only
int analogValue = 0;          // declare and initialize analogValue for remote sensor
float temperatureInside = 0;  // declare and initialize temperatureInside for local temperature

Not a lot to explain, just the settings for the several devices connected and some values set for later use.

Sketch Part III:Setup:

void setup() {
 
  pinMode(debugLED,OUTPUT); //debugging LED set to output

  Serial.begin(9600); // start serial transmission with 9600 baud
  Serial.flush();     // flush the serial port

  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);

  // start Wire and RTC
  Wire.begin();
  RTC.begin();

  // check if RTC is running
 
  if (! RTC.isrunning())
    Serial.println("RTC is NOT running!");

Again the comments should be sufficient to explain the code. If there are any open questions regarding the language check the reference on the Arduino homepage.

I think that might be enough for this time. In the next part we will continue with the sketch and will start with the remote temperature sensor.

6/12/2011

Offroad: XBee Coordinator API + Arduino UNO + RTC +Temperature Sensor + LCD-Display AND Remote XBee (Sleep Mode with low power consumption) + Temperature Sensor - PART I

What a long headline you might think - but this actually describes very well my longer absence to the blog.

I'm sorry to be again off-road to the book, but before starting with the last Connect-Port experiment in Chapter 7 I still have some things on my to-do list that developed from the preceding chapters of the book.

With the knowledge of all the things learned until now I was eager to implement my first own little project to get a simple temperature sensor network (one outside/ one inside temperature) with a real time clock (RTC) and displaying everything on a LCD-display working.
Base Station (breadboard version)

It's consisiting of:


Base Station:
  • XBee in Coordinator API mode
  • connected to an Arduino UNO
  • Temperature sensor connected to Arduino (AD22100)
  • LCD-Display (16*2) connected to Arduino
  • Real-Time-Clock (RTC DS1307) connected to Arduino 
 Remote Sensor:
Remote Sensor
  • XBee End Device Sleep Mode
  • TMP36 temperature sensor connected
  • Voltage regulator MCP1700 (with very low quiescent current <2µA)
  • running on three AA rechargeable batteries



Part II will be on describing the Base Station.