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.