LCD Projector Controller Project Help (n00b)

Hi Everyone,

I have an idea for a project that uses the Arduino to send and receive RS232 codes with an LCD projector. Basically a switcher box so I can press a button and switch from DVD/VCR to my PC. I'm new to the Arduino (and I'm a real electronics rookie) so I'm looking for help knowing what to buy and how I can get started making a prototype. Thanks in advance for your help!

  • Chris

hey

you can send codes serially very easily using the Arudino. First thing to figure out is probably what kind of interface your projector uses, and what the codes themselves are-- do you have them?

D

Thanks for the quick response.

The interface is a nine pin serial that only uses 3 pins (Rx, Tx, and Ground)

The Tech manual for the projector communications settings are here:

19200bps, 8N1 Protocol

Consist of header (7 bytes) + command data (6 bytes)

For example the command to turn the projector on is: BE EF 03 06 00 BA D2 01 00 00 60 01 00

If I hook up the projector to my PC I'm able to send the command through Telnet and a small /net program I wrote but my goal is to operate the projector without turning on a PC.

The projector can also return info like if the temperature is too high.

When I called tech support at Sparkfun they said the Arudino wouldn't be able to receive info, only send it.

hi

you can hook up to that easily using an RS-232 converter chip like the MAX232. Do some poking around on the net and you will find many diagrams for doing this. Don't connect the Arduino pins directly, as RS232 uses higher voltages and the polarity of the signals is also reversed. If you look at the schematic for the first Arduino, you'll see it is RS232.. you could also use that schematic. You probably won't be able to simultaneously use the USB port and the RS232 adapter, as the RX TX connections would be messed up with two items connected to them. Sounds like the perfect application to use a Bare-bones board.

The Arduino will be able to receive codes, but it has a small buffer so you have to check the buffer frequently to see if there is anything in it.

To send the codes, use this:

Serial.print(0xBE, BYTE); // send BE
Serial.print(0xEF, BYTE); // send EF

There's probably a more efficient way fo sending a string of codes, but I'm not sure about how...

D

Good deal,

So my shopping list needs to be:

  1. Pre-Assembled Arduino http://www.sparkfun.com/commerce/product_info.php?products_id=666
  2. MAX232 chip http://www.sparkfun.com/commerce/product_info.php?products_id=316
  3. Four 0.1uF ceramic capacitors
  4. Button Pads http://www.sparkfun.com/commerce/product_info.php?products_id=7836
  5. A project box ?

Anything else besides wire and solder?

hi

yes that's what you'll need, more or less. Those button pads that SF sells are n't complete, you have to have a PCB for them to contact, to make the circuit.

I would suggest buying small parts from your local electronic store or from Digikey if you can bear wading through the datasheets. Things can be done much more cheaply. For example, you can get an Arduino Barebones kit and programming cable for $35 Modern Device. Then your next Arudino projects costs $15 a pop. The chip and capacitors would be about 1.50 at Digikey.

D

PS: more complex, but this article shows you how to make a TTL to 232 adapter for under a buck.
http://www.uchobby.com/index.php/2007/06/11/ttl-to-rs232-adaptor-explained/

Hello again,

Everything arrived and I made an LED blink!!!! WHOO

I tried to do the RS232 communication tutorial here: http://www.arduino.cc/en/Tutorial/ArduinoSoftwareRS232

I double and triple checked the connection making sure I've got the capacitors in correctly, and the serial cable is hooked up right. In my terminal window I don't get the "HI" I'm expecting, I only get gibberish. In the tutorial you should be able to type and have those characters show up in a windows terminal window. I get responses to the keys but just more gibberish. When I disconnect the USB to Arduino Dicimila then the numbers/letters are right in the terminal window.

What might I be doing wrong? Thanks for the help.

  • Chris

Are your baud rates set the same - Arduino board and your terminal window. If you are using a SoftwareSerial port, than 9600 is a fast as it goes.

Here's some screens of the problem I'm having

The first one is my hyperterminal settings:

This is the feedback I get from typing the alphabet:

Here's the Information I get from a com port monitor I have listening to com1

The request/response from com1 typing abc

The read/write requests from com1 typing abc

I've ordered a new Max232 chip in case mine's bad. I also ordered the TTL to RS232 kit mentioned earlier. Thanks again.

Got the new max232 chips and I still have the same problem. is it possible the Arduino itself is bad?

There is an updated SoftwareSerial included in the arduino library. Here's a cut-down version of some code that works for me; I can't seem to find the tutorial that I borrowed it from.

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);


void setup() 
{ 
  Serial.begin(9600);  // start hardware serial 

// set up SoftwareSerial
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  mySerial.begin(9600);

// print via SoftwareSerial
  mySerial.print("software serial startup\n");
} 

void loop()
{
}

See if using the SoftwareSerial library works any better.

-j

Got the new max232 chips and I still have the same problem. is it possible the Arduino itself is bad?

Small tip from experience: nine times out of ten it's not a bad chip that causes problems. Wiring and soldering yes, but every so rarely it's a chip. I can count on one had the number of chips I've had to replace in 15 years of building things.

D

Can you tell us more about how you have it wired and maybe post the code you are using? Did you disconnect the usb cable from the Arduino while you were trying to use the serial pins?

Here's some pics of my setup:


Here's the instructions from the tutorial:
"Connect 5V power and ground from the breadboard to 5V power and ground from the microcontroller. Connect pin 15 on the MAX233 chip to ground and pins 16 and 14 - 11 to 5V. If you are using an LED connect it between pin 13 and ground. Connect a 1uF capacitor across pins 1 and 3, another across pins 4 and 5, another between pin 1 and ground, and the last between pin 6 and ground. If you are using polarized capacitors make sure the negative pins connect to the negative sides (pins 3 and 5 and ground). Determine which Arduino pins you want to use for your transmit (TX) and recieve (RX) lines. In this tutorial we will be using Arduino pin 6 for receiving and pin 7 for transmitting. Connect your TX pin (7) to MAX3323 pin 10 (T1IN). Connect your RX pin (6) to MAX3323 pin 9 (R1OUT). If you do not have one already, you need to make a cable to connect from the serial port (or USB-serial adapter) on your computer and the breadboard. To do this, pick up a female DB9 connector from radioshack. Pick three different colors of wire, one for TX, one for RX, and one for ground. Solder your TX wire to pin 2 of the DB9 connector, RX wire to pin 3 and Ground to pin 5. Connect the TX line from your computer to pin 8 (R1IN) on the MAX233 and the RX line to pin 7 (T1OUT). Connect the ground line from your computer to ground on the breadboard."

This is the code:

//Created August 23 2006
//Heather Dewey-Hagborg
//http://www.arduino.cc

#include <ctype.h>

#define bit9600Delay 84  
#define halfBit9600Delay 42
#define bit4800Delay 188 
#define halfBit4800Delay 94 

byte rx = 6;
byte tx = 7;
byte SWval;

void setup() {
  pinMode(rx,INPUT);
  pinMode(tx,OUTPUT);
  digitalWrite(tx,HIGH);
  digitalWrite(13,HIGH); //turn on debugging LED
  SWprint('h');  //debugging hello
  SWprint('i');
  SWprint(10); //carriage return
}

void SWprint(int data)
{
  byte mask;
  //startbit
  digitalWrite(tx,LOW);
  delayMicroseconds(bit9600Delay);
  for (mask = 0x01; mask>0; mask <<= 1) {
    if (data & mask){ // choose bit
     digitalWrite(tx,HIGH); // send 1
    }
    else{
     digitalWrite(tx,LOW); // send 0
    }
    delayMicroseconds(bit9600Delay);
  }
  //stop bit
  digitalWrite(tx, HIGH);
  delayMicroseconds(bit9600Delay);
}

int SWread()
{
  byte val = 0;
  while (digitalRead(rx));
  //wait for start bit
  if (digitalRead(rx) == LOW) {
    delayMicroseconds(halfBit9600Delay);
    for (int offset = 0; offset < 8; offset++) {
     delayMicroseconds(bit9600Delay);
     val |= digitalRead(rx) << offset;
    }
    //wait for stop bit + extra
    delayMicroseconds(bit9600Delay); 
    delayMicroseconds(bit9600Delay);
    return val;
  }
}

void loop()
{
    SWval = SWread(); 
    SWprint(toupper(SWval));
}

Then I use the settings I show above to setup Hyperterminal. I've resetup the Arduino on a different PC to see if that was the issue.

Here's the instructions from the tutorial:
"Connect 5V power and ground from the breadboard to 5V power and ground from the microcontroller. Connect pin 15 on the MAX233 chip to ground and pins 16 and 14 - 11 to 5V. If you are using an LED connect it between pin 13 and ground. Connect a 1uF capacitor across pins 1 and 3, another across pins 4 and 5, another between pin 1 and ground, and the last between pin 6 and ground. If you are using polarized capacitors make sure the negative pins connect to the negative sides (pins 3 and 5 and ground). Determine which Arduino pins you want to use for your transmit (TX) and recieve (RX) lines. In this tutorial we will be using Arduino pin 6 for receiving and pin 7 for transmitting. Connect your TX pin (7) to MAX3323 pin 10 (T1IN). Connect your RX pin (6) to MAX3323 pin 9 (R1OUT). If you do not have one already, you need to make a cable to connect from the serial port (or USB-serial adapter) on your computer and the breadboard. To do this, pick up a female DB9 connector from radioshack. Pick three different colors of wire, one for TX, one for RX, and one for ground. Solder your TX wire to pin 2 of the DB9 connector, RX wire to pin 3 and Ground to pin 5. Connect the TX line from your computer to pin 8 (R1IN) on the MAX233 and the RX line to pin 7 (T1OUT). Connect the ground line from your computer to ground on the breadboard."

Your 232 Chip wiring looks a little fishy (seems it was written for the max3323 which has a different pin config). According to the datasheet (check the bottom of page 7) for the chip your using T1IN = pin 11, R1OUT = pin 12, T1OUT = pin 14 and R1IN = 13. Have a look at this tutorial over at sparkfun. Pins 7, 8, 9, and 10 should not be connected to anything.

hey

I notice a couple things from the Sipex schematic that might not be right with your circuit:

  • You have no filter cap on pin 16 to ground
  • your caps are huge... they say to use .1Uf or 100nF
  • pins 11,12,13,14 are inputs and outputs. They shouldn't be connected to +5, so...disconnect . Maybe you will burn the chip after all. :cry:

Probably the caps: those are about 100 times larger than they should be. The MAX323 is an upgrade over the 232 as it uses smaller caps, which are cheaper for manufacturing.

D

PS: isn't electronics fun?

Success! Thanks for all the responses.

I switched the caps from 1uf to .1uf like Daniel suggested. That and following the right schematic (D'OH) is working now, double WHOO!

Now I put in the turn on rs232 codes and the projector turns on great. I struggled getting the baud speed right. After I reread tron22's post I realized I couldn't use softwareserial (The projector runs at 19200). Now I just have the codes writing byte by byte Serial.print(0xBE, BYTE); Serial.print(0xEF, BYTE); and it works.

Now I'd like the the different codes to execute only when I press a button. I've looked at button tutorials and I'm having trouble understanding how to make it go.

This is the code I'm trying to use. (Right now I'm trying to make one button toggle between on/off but when I actually make the controller I'd like discrete buttons for | on | off | video | pc | volume up | volume down |). Using this code the projector just keeps turning itself on and off. Is it okay for the arduino to be constantly be sending codes or is there a way to make it wait for a button press? Ideas and info are as always greatly appreciated!

#define switchAPin 12
int analogValue = 0;    // variable to hold the analog value
// int inPin = 12;   // choose the input pin (for a pushbutton)
int ledPin = 13;
int val = 0;
byte rx = 2;
byte tx = 3;
int switchAState = LOW;
int currentSwitchState = LOW;

void setup() {
  pinMode(rx,INPUT);
  pinMode(tx,OUTPUT);
  // pinMode(inPin,INPUT);
  // digitalWrite(tx,HIGH);
  Serial.begin(19200);
  pinMode(ledPin, OUTPUT);
  pinMode(switchAPin, INPUT);
}

void loop() {

  // deal with switchA
  currentSwitchState = digitalRead(switchAPin);
  if( currentSwitchState == LOW && switchAState == HIGH ) // push
    Serial.print(0xBE, BYTE);
    Serial.print(0xEF, BYTE);
    Serial.print(0x03, BYTE);
    Serial.print(0x06, BYTE);
    Serial.print(0x00, BYTE);
    Serial.print(0x2A, BYTE);
    Serial.print(0xD3, BYTE);
    Serial.print(0x01, BYTE);
    Serial.print(0x00, BYTE);
    Serial.print(0x00, BYTE);
    Serial.print(0x60, BYTE);
    Serial.print(0x00, BYTE);
    Serial.print(0x00, BYTE);
  if( currentSwitchState == HIGH && switchAState == LOW ) // release
        Serial.print(0xBE, BYTE);
    Serial.print(0xEF, BYTE);
    Serial.print(0x03, BYTE);
    Serial.print(0x06, BYTE);
    Serial.print(0x00, BYTE);
    Serial.print(0xBA, BYTE);
    Serial.print(0xD2, BYTE);
    Serial.print(0x01, BYTE);
    Serial.print(0x00, BYTE);
    Serial.print(0x00, BYTE);
    Serial.print(0x60, BYTE);
    Serial.print(0x01, BYTE);
    Serial.print(0x00, BYTE);
   switchAState = currentSwitchState;
}

excellent! Now maybe you'll write it up as a tutorial for the playground? these forum posts tend to get lost.

D

I'd be happy to. I'll take pics and put up a shopping list too. But I need help with the programming. Is there a good tutorial on making buttons execute code? The LED on/off doesn't seem to help.

hoffmangler,

You and I have been working on similar projects it seems. I started with all the software backend for control of buttons and such - including an LCD to display results of button presses and navigating a menu to send projector commands. Setting up the actual serial connection was next on my list.

I ended up adding a bunch of debug code in my sketch to figure out why my serial interface was not working, I was going the SoftwareSerial approach - but trying to send straight to the projector - not going through a MAX chip ( in the mail now though )

I'll clean up my code again and post it here. I played a lot with buttons and such and have created an interface with a rocker button to navigate a menu on LCD (16x2), a momentary button to 'select' menu options, two toggle swtiches (SPST) one for ON/OFF the other PC/DVD input select. All works great - however haven't implemented the serial thing yet. In my loop() the buttons fire functions which then will do the serial dance.

Will post in the next couple days... tomorrow probably, as I'm still at work now :wink:

here is a snippet of how I manage button pushes - there may be a better way though. I am using Analog pins for the buttons, at first I was using Digital, then something wasn't working so I switched to Analog - results weren't as expected, but then figured out how to make it do what I wanted it to.

I have the projector toggle switch SPST center pin going to +5v, and the other pin going to the Arduino Analog Pin 3. I also have the analog pin 3 jumpered to ground with a 47K resistor. This brings pin 3 to ground when 'power off' but to 5v when 'on'.

int powerSel = 3;          // power select switch is ANALOG PIN 3
int statusPw = 0;          // holds temp status of powerSel switch
int hiReset = 900;          // reset button status when value falls below hiReset - prevents accidental repeat of button input
int powerSelReset = 0;  // has button status been reset? 1 yes, 0 no 

void power_ON()
  {
      digitalWrite(ledPin,HIGH);        // turns on LED
      lcd_clear();
      lcd_goto(0);
      delay(10);
      Serial.println("Power ON        ");    //  currently just set to send debug strings back to my serial monitor
      lcd_puts("Power ON        ");      // prints to LCD panel on control surface, feedback to user
      powerSelReset = 0;         // resets the powerSelReset to '0' so that the command isn't executed twice
      digitalWrite(ledPin,LOW);
  }

void setup() 
{
  lcd_init();
  Serial.begin(9600);
  menu_show(0);  
}

void loop()
{

statusPw = analogRead(powerSel);    // reads the input of powerSel

if (statusPw < hiReset)
   {
     powerSelReset = 1;
    }

if (statusPw >= hiThreshold && powerSelReset == 1)
    {
      digitalWrite(ledPin,HIGH);      // turns on LED
      power_ON();
      digitalWrite(ledPin,LOW);      // turns off LED
    }
}

I cut and pasted all these snippets from my full sketch, so if somethings don't look like they are doing anything, that is why. I tried to remove most of the erroneous code that doesn't apply to the button example. I'll post a more complete rendition hopefully tomorrow, if not next week.