Monday 6 July 2009

ByVac Serial LCD displays

I bought a nice 4x20 LCD display on eBay which had a Serial LCD Controller made (or distributed) by ByVac. There were some teething troubles (mostly to do with timing), but managed to get it working nicely in the end. If you happen to get one on ebay or something, then feel free to use this code for arduino:

#include "NewSoftSerial.h"
#define lcdTxPin 6

#define lcdRxPin 5 //we ignore what the LCD tells us
#define LCD_LINE1 0x80

#define LCD_LINE2 0xC0
#define LCD_LINE3 0x94
#define LCD_LINE4 0xD4
#define LCD_SET_LINE1 "ac80\r"
#define LCD_SET_LINE2 "acc0\r"
#define LCD_SET_LINE3 "ac94\r"
#define LCD_SET_LINE4 "acd4\r"
#define LCD_BACKLIGHT_ON "ab1\r"
#define LCD_BACKLIGHT_OFF "ab0\r"
#define LCD_HIDE_DISPLAY "ac08\r"
#define LCD_SHOW_DISPLAY "ac0C\r"
#define LCD_MOVE_CURSOR_LEFT "ac10\r"
#define LCD_MOVE_CURSOR_RIGHT "ac14\r"
#define LCD_SHOW_BLINKING_CURSOR "ac0F\r"
#define LCD_SHOW_UNDERLINE_CURSOR "ac0E\r"
#define LCD_HOME "ac02\r"
#define LCD_CLEAR_SCREEN "ac01\r"
#define LCD_HIDE_CURSOR "ac0C\r"
#define LCD_SCROLL_LEFT "ac18\r"
#define LCD_SCROLL_RIGHT "ac1E\r"

NewSoftSerial softSerial = NewSoftSerial(lcdRxPin,lcdTxPin);


void setup()
{
softSerial.begin(9600);
pinMode(lcdTxPin,OUTPUT);
pinMode(lcdRxPin,INPUT);

LCDInit();

LCDCommand(LCD_CLEAR_SCREEN);
LCDCommand(LCD_HOME);
LCDWrite("Hello World");
}

void loop()
{
}

void LCDInit()
{
softSerial.print('\r');
delay(50);
softSerial.print('\r');
delay(50);
softSerial.print('\r');
delay(50);
}

void LCDSetCursorPos(int line, int pos)
{
//set the cursor pos - combine line and pos
softSerial.print("ac");
softSerial.print(line+pos,HEX);
softSerial.print("\r");
delay(10);
}

void LCDWrite(char* s)
{
softSerial.print("at'");
softSerial.print(s);
softSerial.print("'\r");
delay(5);
}

void LCDCommand(char* command)
{
softSerial.print(command);
delay(5);
}

Friday 3 July 2009

More Arduino Fun

OK, I've lost interest in my plant waterer for the moment. So I've been trying to think of other things I can do. I decided i'd like a small machine that lets me do stop-motion photography with my beloved Canon EOS 40D, and Arduino seemed like a good place to start. I could use the Canon SDK and write a windows app to do it, but sometimes it's nice to have a bit of hardware that you can bring with you.

First step then was to get hold of a cable release (being the easiest way to get hold of the right plug for the camera). Canon's own-brand remote switch, RS-80M3 is staggeringly expensive for what it is, but I located a 3rd party Jue Ying controller on ebay that did the job nicely for about a 10th of the cost, albeit without the elegant metal surround on the plug. As you can see from the photo, the internals are extremely basic - three metal contacts. White is ground, yellow is focus and red is shutter.





To protect my camera from everything else, I used two opto-isolators to do the switching, and activating them is just a matter of setting some digital pins on the arduino high for a brief period.






Now all I need to do is wire up a pretty LCD display to let me set the shooting interval and my job is done. I've decided to use a rotary controller to adjust settings - coding that should be fun, hope it arrives soon.



Monday 29 June 2009

Clonezilla

I needed more space on my laptop, so I decided to change the hard drive drive. I didn't feel like installing a whole new OS and all that shenanigans. Clonezilla was the solution. I was able to mirror the contents of my old hard drive to the new drive with no problems whatsoever!

I just downloaded the ISO and burnt it to DVD, which has a bootable version of linux. Booted from the DVD, told it what disk was the source and what was the target, and off it went. Took about 2 hours for a 180Gig hard drive. Marvellous.

Tuesday 23 June 2009

The Ultimate Plant Waterer



On a whim, I bought an Arduino Duemilanove together with an Ethernet Shield, just to see what it could do. I decided to build an automatic plant waterer, and it turned out to be great fun and dead easy. It monitors soil mosture levels, and waters the plant when the level hits a certain threshold. The Ethernet shield lets me provide a simple web server (using Arduino's Ethernet Library) which let me check on my plant remotely and water it manually if I felt it needed it.


The trickiest part was driving the LCD display, which was a Seetron 216 Serial LCD module. The problem was that the display was expecting RS232 signals, not TTL, so I had to write a new version of the SoftwareSerial library to cope with it. I ended up bodging the SoftwareSerial library to create a new library called Seetron216LCD, which wrapped the various commands for the LCD display (eg. newline, clearscreen etc) and made it very easy to use. I found I had to drive the LCD at 2400 baud to avoid getting dodgy characters. I'll make the library available when I've got a moment to tidy it up.


Below is a schematic done with TinyCAD (a nice bit of freeware and just what I was looking for). The moisture sensor bit is based on a circuit design from iFlower (a blog by a guy called angelo). I opto-isolated the pumping circuit which was probably overkill.