Show Posts
Pages: 1 ... 30 31 [32] 33 34 ... 44
466  Using Arduino / Networking, Protocols, and Devices / Re: I2C LCD -- changing startup screen problem on: April 18, 2011, 11:19:11 am
This new code compiles, but it still only loads the first 2 characters to the splash screen.  I tried sending a 32 character length text like:
Code:
lcd.writeStartUpScreen("Greetings folks! here is the rst");
but it only gets the 'Gr' and the rest of the display is vertical bars.
I just heard back form MatrixOrbital, they said:
Quote
I understand it appears that the start screen of your LK162-12 is not being changed correctly by your Arduino controller.  If the display is having trouble receiving any characters it will NAK the data line, I believe the Arduino endTransmission function will indicate this.

As for the command, you might try padding the string with spaces to make it 32 characters long, the size of the screen. 

So I've tried the padding, but 'NAK'???  --does it send some kind of signal back that I can check to see if it's not getting the message?  I feel pretty sure it's something in the transmission/timing, but I don't know what.  Any other suggestions?
467  Using Arduino / Networking, Protocols, and Devices / Re: I2C LCD -- changing startup screen problem on: April 17, 2011, 07:08:20 pm
What happens if you change
Code:
Wire.send(message);
to
Code:
Wire.send(message, strlen(message));
?
...it doesn't compile, it gives me this error:
Quote
C:\Documents and Settings\x\Desktop\arduino-0022\libraries\LCDI2C_LK162\LCDI2C_LK162-12.cpp: In member function 'void LCDI2C::writeStartUpScreen(char*)':
C:\Documents and Settings\x\Desktop\arduino-0022\libraries\LCDI2C_LK162\LCDI2C_LK162-12.cpp:111: error: invalid conversion from 'char*' to 'uint8_t*'
C:\Documents and Settings\x\Desktop\arduino-0022\libraries\LCDI2C_LK162\LCDI2C_LK162-12.cpp:111: error:   initializing argument 1 of 'void TwoWire::send(uint8_t*, uint8_t)'

I'm using this line in my sketch:
Code:
lcd.writeStartUpScreen("Hello");

And this is the the CPP file from the library:
Code:
/*
 
 LCDI2C v0.4 3/Mar/2009 dale@wentztech.com  http://wentztech.com/Radio
 PORTED FOR Matrix Orbital LK162-12 display 10/Sept/2010 by Brian Brumfield, brian@thebrumfields.com
 
 What is this?
 
 An arduino library for use with the web4robot.com i2C LCD Display in I2C more
 
 Uses I2c Wires interface
 
 Uses Analog pin 4 - SDA
 Uses Analog pin 5 - SCL
 
 
 Usage:
 
 see the examples folder of this library distribution.
 
 
 */


#include <Wire.h>


#include <string.h> //needed for strlen()

#include <inttypes.h>

#include "WConstants.h"  //all things wiring / arduino

#include "LCDI2C_LK162-12.h"


#define LCDI2C_MAX_STRLEN 40
#define LCDI2C_PRINT_STR_DELAY 20


//--------------------------------------------------------

// (don't change here - specify on calling constructor)

//how many lines has the LCD?

int g_num_lines = 2;

int g_num_col = 16;

// Defalt address of the display

int g_i2caddress = 0x50;

int g_display = 0;


//stuff the library user might call---------------------------------

//constructor.  num_lines must be 1, 2, 3, or 4 currently.

LCDI2C::LCDI2C (int num_lines,int num_col,int i2c_address,int display){

g_num_lines = num_lines;
g_num_col = num_col;
g_i2caddress = i2c_address >>1; // ** 7 bit address
g_display = display;

if (g_num_lines < 1 || g_num_lines > 4){

g_num_lines = 2;

}

if (g_num_col < 1 || g_num_col > 40){

g_num_col = 16;
}

}

// Send a command to the display that is not supported

void LCDI2C::command(int value) {

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(value);
Wire.endTransmission();
delay(CMDDELAY);
}

//     I added this:
// Send 2 commands to the display that is not supported
void LCDI2C::command2(int val1, int val2) {

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(val1);
Wire.send(val2);
Wire.endTransmission();
delay(CMDDELAY);
}



// Write Start-Up Screen

void LCDI2C::writeStartUpScreen(char message[32]) {
Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x40);
Wire.send(message, strlen(message));
// Wire.send(message);
Wire.endTransmission();
delay(CMDDELAY);
}


//Used by the print library to get information to the display

void LCDI2C::write(uint8_t value) {
Wire.beginTransmission(g_i2caddress);
Wire.send(value);
Wire.endTransmission();
delay(5);
}




//send the clear screen command to the LCD

void LCDI2C::clear(){

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x58);
Wire.endTransmission();
delay(CMDDELAY);  


}

//send the Home Cursor command to the LCD      ********** Not Working ***************

void LCDI2C::home(){

setCursor(0,0); // The command to home the cursor does not work on the version of the dislay I have
// So we do it this way.
}


//Turn the LCD ON

void LCDI2C::on(int value){

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x42);
Wire.send(value);
Wire.endTransmission();
delay(CMDDELAY);  
}


// Turn the LCD OFF

void LCDI2C::off(){

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x46);
Wire.endTransmission();
delay(CMDDELAY);

}


//Turn the Underline Cursor ON

void LCDI2C::cursor_on(){

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x4A);
Wire.endTransmission();
delay(CMDDELAY);

}


//Turn the Underline  Cursor OFF

void LCDI2C::cursor_off(){

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x4B);
Wire.endTransmission();
delay(CMDDELAY);

}


//Turn the Underline Cursor ON

void LCDI2C::blink_on(){

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x53);
Wire.endTransmission();
delay(CMDDELAY);

}


//Turn the Underline  Cursor OFF

void LCDI2C::blink_off(){

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x54);
Wire.endTransmission();
delay(CMDDELAY);

}


//Move the cursor left 1 space

void LCDI2C::left(){

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x43);
Wire.endTransmission();
delay(CMDDELAY);

}


//Move the cursor right 1 space

void LCDI2C::right(){

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x4D);
Wire.endTransmission();
delay(CMDDELAY);

}


// initiatize lcd after a short pause

//while there are hard-coded details here of lines, cursor and blink settings, you can override these original settings after calling .init()

void LCDI2C::init () {
delay(1000);
Wire.begin();
on(5);
clear();
blink_off();
cursor_off();
home();
}

void LCDI2C::setCursor(int line_num, int x){

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x47);
Wire.send(line_num);
Wire.send(x);
Wire.endTransmission();
delay(100);

}

int LCDI2C::keypad (){

int data = 0;

//  Send Keypad read command
Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x26);
Wire.endTransmission();
delay(CMDDELAY);

//  Connect to device and request byte
Wire.beginTransmission(g_i2caddress);
Wire.requestFrom(g_i2caddress, 1);

if (Wire.available()) {
data = Wire.receive();
}


return data;
}

unsigned char LCDI2C::init_bargraph(unsigned char graphtype)
{
switch (graphtype)
{
case LCDI2C_THICK_VERTICAL_BAR_GRAPH:
Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x76);
Wire.endTransmission();
break;
case LCDI2C_THIN_VERTICAL_BAR_GRAPH:
Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x73);
Wire.endTransmission();
break;
case LCDI2C_HORIZONTAL_BAR_GRAPH:
Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x68);
Wire.endTransmission();
break;
case LCDI2C_HORIZONTAL_LINE_GRAPH:
Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x16);
Wire.send(0x01);
Wire.endTransmission();
break;
default:
return 1;
}

return 0;
}

void LCDI2C::draw_horizontal_graph(unsigned char column, unsigned char row, unsigned char direction,  unsigned char len)
{
Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x7C);
Wire.send(column);
Wire.send(row);
Wire.send(direction);
Wire.send(len);
Wire.endTransmission();
}

void LCDI2C::draw_vertical_graph(unsigned char column, unsigned char len)
{
Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x3D);
Wire.send(column);
Wire.send(len);
Wire.endTransmission();
}

void LCDI2C::load_custom_character(unsigned char char_num, unsigned char *rows)
{
unsigned char i;

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x4E);
Wire.send(char_num);
for (i = 0; i < LCDI2C_CUSTOM_CHAR_SIZE; i++)
Wire.send(rows[i]);
Wire.endTransmission();
}

unsigned char LCDI2C::set_backlight_brightness(unsigned char new_val)
{
if ((new_val < LCDI2C_MIN_BRIGHTNESS)
|| (new_val > LCDI2C_MAX_BRIGHTNESS))
return LCDI2C_VALUE_OUT_OF_RANGE;

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x99);
Wire.send(new_val);
Wire.endTransmission();
return 0;
}


unsigned char LCDI2C::set_contrast(unsigned char new_val)
{
if ((new_val < LCDI2C_MIN_CONTRAST)
|| (new_val > LCDI2C_MAX_CONTRAST))
return LCDI2C_VALUE_OUT_OF_RANGE;

Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x50);
Wire.send(new_val);
Wire.endTransmission();
return 0;
}

// Overload
void  LCDI2C::printstr(const char c[])
{
byte len;

while (*c)
{
len = min(strlen(c), LCDI2C_MAX_STRLEN);
Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x15);
Wire.send(len);
while (len--)
Wire.send(*c++);
Wire.endTransmission();
if (*c)
delay(LCDI2C_PRINT_STR_DELAY); // More to send.  Wait a bit
}
}

468  Using Arduino / Networking, Protocols, and Devices / I2C LCD -- changing startup screen problem on: April 16, 2011, 09:29:55 pm
My I2C LCD display by matrixorbital is all working except for 1 thing:  The command to change the start up screen only sends the first 2 letters to the display, and makes the rest of the startup screen a bunch of vertical bars.
This is the line that sets the startupscreen:
Code:
lcd.writeStartUpScreen("Welcome");
But this will make the startup screen look like this:
We|||||||||||||||||||||
||||||||||||||||||||||||

It's supposed to handle up to 32 chars. (16 x 2 display)
I can change the "Welcome" to any else, and it will only change the 'We' on the splash screen, and leave the bars.


here's a snipet from the library that doing the work:
Code:
// Write Start-Up Screen

void LCDI2C::writeStartUpScreen(char message[32]) {
Wire.beginTransmission(g_i2caddress);
Wire.send(0xFE);
Wire.send(0x40);
Wire.send(message);
Wire.endTransmission();
delay(CMDDELAY);
}

I've sent about a dozen other commands to the LCD, and they all work.
Here's the manual:  http://www.matrixorbital.ca/manuals/LK_series/LK162-12/LK162-12_Legacy/LK162-12_220.pdf
I've about given up!  But I'd like to get rid of the vertical bars...
I've got 2.6K pull-ups on the SDA & SCL.
This is my 1st experience with I2C.
Hope there's a simple solution to this, I've tried everything.
469  Using Arduino / Networking, Protocols, and Devices / Changing default settings with my new MatrixOrbital LCD on: April 15, 2011, 01:44:12 pm
I have gotten my I2C LCD to work if I temporarily short the reset pins.  My test sketch does things like print "hello world", it turns the backlight on/off, shows seconds counting...  It all works.  But when I power down the display and then power it up again, nothing works.  But, shorting pins 3 & 4 when I first power it up, makes it work.
I understand that this manual override changes the baudrate, & I2C address.  Evidently one of them is not correct.
The manual for my LCD:
http://www.matrixorbital.ca/manuals/LK_series/LK162-12/LK162-12_Legacy/LK162-12_220.pdf

It says,
Quote
Manual override should only be required in one instance. If for some reason the module is set at a baud rate
which cannot be produced by the host system and all communication to the display is lost, then the user
should follow this simple procedure:
1. Turn off the display
2. Put a jumper on pins 3 and 4 of the keypad connector (R3 and C1).
3. Power up the display. The baud rate is now set to 19,200.
4. Remove the jumper and change the RS-232 port settings to the desired baud rate.
5. Turn off the display.
6. Power up the display.
Refer to the “Set RS-232 Port Speed” command (section 6.1.14) for acceptable baud rates.



So I look at section 6.1.14:
Quote
6.1.14 Set RS232 port speed (254 57 [speed])
This command sets the  RS232 port to the specified [speed]. The change takes place immediately. [speed] is
a single byte specifying the desired port speed. Valid speeds are shown in the table below. The speed can
be manually reset to 19,200 baud in the event of an error during transmission (including transmitting a value
not listed below) by setting the "manual override" jumper on the module during power. This command is
ignored until this jumper is removed again.
Speed Value Speed
FF Hex 1200 baud
81 Hex 2400 baud
20 Hex 9600 baud
0F Hex 19200 baud

...but how do I do that?  I'm using a library, so I don't really know how to do this manual sending of commands.

Here's the library:
http://arduino.cc/playground/Code/LCDi2c
...the link on that page is broke: the library for the LK162-12 is here:
https://public.me.com/digid

In the documentation it says you can do unsupported commands with this:
Code:
command(command) Write a command not supported yet in the library to the display

I can't figure out how to do this...

Extra info: My test sketch that works when I short pins 3 & 4 for manual override
Code:
#include <Wire.h>
#include <LCDI2C_LK162-12.h>
LCDI2C lcd = LCDI2C(16,2,0x50,0);             

void setup(){
lcd.init();
delay(10);
lcd.clear();
lcd.set_contrast(255);
}

void loop(){
  lcd.clear();
  lcd.print(" WELCOME FOLKS!");
  delay(2000);
  lcd.clear();
  lcd.print(millis()/1000);
  lcd.print(" seconds now...");
  delay(1500);
}
470  Using Arduino / Motors, Mechanics, and Power / Re: Pull down resistors keep motors disabled during power-up on: April 12, 2011, 11:52:53 pm
Yes.  When the Arduino starts up the pins are inputs (apart from TX and pin 13) which means they will float.  A pull down of 10k will be fine.

When the pins are output they can source 20 to 30mA if necessary to overcome any pull-downs so 10k is neither here or there.

However the internal pull-up resistors on the Arduino are between 20k and 50k I think.  Best to have your pull-downs an order of magnitude smaller than that, namely 2k2, to ensure they always 'win' should the pins be configured as inputs with internal pull-ups.  That's still only 2.3mA load.

...thanks, that helped me understand what's happening a little better.
471  Using Arduino / Motors, Mechanics, and Power / Pull down resistors keep motors disabled during power-up on: April 12, 2011, 01:08:44 am
Code:
Pull down resistors keep motors disabled during power-up
I see the Adafruit motor shield says this.  Can I add 10K resistors  to my SN754410 on pins 2 & 7 that connect to my Arduino and keep the motor from turning on at startup?
If my 2 motor control pins are 10 and 11, then I'd just add in two 10k resistors from 10 & 11 to ground? That won't interfere with the normal motor operation?
thanks
472  Using Arduino / Motors, Mechanics, and Power / Re: Anyone familiar with the SN754410 on: April 11, 2011, 10:08:56 pm
hmmm.  That's not the answer I hoped for!  smiley-roll
I reckon I'll work in some extras...
473  Using Arduino / Motors, Mechanics, and Power / Anyone familiar with the SN754410 on: April 11, 2011, 09:43:47 pm
http://www.sparkfun.com/datasheets/IC/SN754410.pdf

I'm not good at deciphering datasheets, but it seems like this chip has diodes in it that would work for kickback filters on my little Sparkfun gearmotor.
The diagram on page 2, where it says, "typical of all outputs". --wouldn't those 2 diodes on the right work as kickback diodes?
I'm trying to work kickback diodes into my pc board, but it would be SO much easier if I didn't have to...
thanks
474  Using Arduino / Networking, Protocols, and Devices / I2C LCD & Keypad on: April 05, 2011, 10:18:11 am
I really like the looks of this:
http://www.matrixorbital.com/Intelligent-Display-Character-LCDs/c39_3/p73/LK162-12/product_info.html

I've never worked with I2C before.  I see there are libraries for other keypad/lcd units like the one from byvac.  Would I be able to use this one from matrixorbita. with that library?  If not, would a person be able to get one of these units up and running with the Arduino?
475  Using Arduino / Displays / Re: Shiftreg alternate IC for SRLCD on: April 03, 2011, 11:26:05 pm
THANKS RARON!
I had given up in SRLCD--I thought I messed up somewhere on my home brewed pcb.  Finally just gave it up, but I tried the new schematic on my breadboard, and it's working great!
476  Using Arduino / Networking, Protocols, and Devices / Re: Bluetooth mate vs. Bluetooth modem? on: April 03, 2011, 09:04:52 pm
Sorry, I just keep thinking you guys know everything, and that you'll know exactly what I'm talking about...
http://www.sparkfun.com/products/9358
http://www.sparkfun.com/products/582
477  Using Arduino / Networking, Protocols, and Devices / Bluetooth mate vs. Bluetooth modem? on: April 02, 2011, 06:41:07 pm
What is the difference between the bluetooth modem gold, and the bluetooth mate gold??? Which would you want if for example you wanted to control your arduino remotely with your android phone to do something?
478  Using Arduino / Networking, Protocols, and Devices / Re: tx & rx pins doing double duty for keypad columns on: April 02, 2011, 05:12:06 pm
Results:
You can use the Serial connect to your pc even though two columns are connected to D0 & D1.
However, there can not be any instance of "Serial.whatever" in your code, or else those two columns will not work.  This is acceptable for troubleshooting.  If serial is needed, just uncomment Serial.Begin(9600), and insert the Serial.print command where ever you need it...
479  Using Arduino / Motors, Mechanics, and Power / Re: Driving a solenoid on: April 02, 2011, 09:24:57 am
Sorry, I just remembered you mentioned this just recently:
Quote
The resistor wired between the arduino output pin and the gate of the mosfet is to protect the output pin from large current spikes as the mosfet gate capacitance is charged or discharged initially when commanded on or off. Once the mosfet gate is fully charged or discharged there is no DC current flow from the output pin and the gate. This should be a rather small resistor value so as not to slow down the switching transition time too much, 300-1,000 is a good range to use.
480  Using Arduino / Networking, Protocols, and Devices / Re: tx & rx pins doing double duty for keypad columns on: April 01, 2011, 10:34:27 am
You can also connect a keypad to an analog port, - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1170140545/4 -

Google for variations.

I just tried this last night.  With the said configuration, they are very reliable for digits 1 through 6, roughly, but the higher analog readings start getting messed up with some resistance from the keypad contacts (I think that is the problem).  I'm using SparkFun's 4x3 keypad, brand new.  For example, if I press key 4, I get a reading of 195, and no matter how lightly or hard I press it, it only fluctuates from 193 to 197, that's very close tolerance.  But if I press key 0 lightly or hard, I can get a reading from 890 to 940, roughly.  You see the problem.  I think I will try to figure out what resistor values are needed to get an analog reading span from 0 to about 500-600, sometime when I have a free hour or 2, unless someone knows how to calculated this in their head...
Pages: 1 ... 30 31 [32] 33 34 ... 44