Our new official repo is on github
LCD Smartie version 5.6 is released!
Download it now: https://github.com/LCD-Smartie/LCDSmartie/releases

Question concerning Matrix Orbital displays

General discussion about LCD Smartie.

Moderators: _X7JAY7X_, caesar, IFR, mattcro, limbo, Fast351

Post Reply
firestorm_v1
Posts: 16
Joined: August 3rd, 2006, 2:53 am

Question concerning Matrix Orbital displays

Post by firestorm_v1 »

Does anyone have a listing of all the commands that LCD Smartie sends to the MO display in order to prep it for use?

The reason I am asking is that I have a BS-2 microcontroller I am writing code for to "mimic" a Matrix Orbital display and I want to make sure that I have all the relevant code in the microcontroller and that it operates correctly. (I'm bored, have the parts and can't afford one.. :P )

Thanks in advance

Matt
_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

Here is a list of the commands I used. Actually you only need about half of them. The cursor on/off, block cursor, backlight brightness, buttons, etc. are not needed for basic display. However, if these functions read in data like the brightness command reads in the brightness, it needs to be there so the display doesnt think its a character.

To see the commands I used go here http://www.freewebs.com/x7jay7x

J
mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post by mattcro »

When I developed my PIC backpack a while ago (and for the same reasons), I did just that - logged the command that Smartie sends as it starts up. See this thread for the list and a bunch of other info about MO commands.

There are a couple of other threads on this forum about making PIC and Atmel microcontroller backpacks, with command sets etc. Do a search...

Matt
firestorm_v1
Posts: 16
Joined: August 3rd, 2006, 2:53 am

Post by firestorm_v1 »

Wow! That is awesome work. My design will be far less complex, as I won't be using the contrast or the backlight control. I was looking through the MO command list yesterday but was getting concerned as I didn't want to lose bargraph functionality. I assume that LCD Smartie uses the custom chars to define bargraphs?

When all is said and done, I will post here as well as with schematics and pictures if so desired. :) I'm really excited, I can't wait till I have money for the parts so I can start building.
mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post by mattcro »

I built mine up slowly, starting with just a few basic commands like cursor position, clear display etc, then added custom character handling and backlight PWM and so on. I think Jay (X7JAY7X) independently did nearly the same thing, and a couple of others (ch424, Rafael and maybe more) have done similar projects.

I'm interested to see how it pans out with the Basic Stamp - I've never used a Stamp, just plain old PICs.

If you implement the commands I listed in that thread (minus backlight) you'll be able to do most (maybe all?) of the typical Smartie screens.

Your code will still need to accept the backlight, contrast, autowrap/scroll etc MO commands even if it doesn't actually implement them, because Smartie sends a whole lot of those commands on startup and shutdown. Jay and I discussed this in the same thread linked to before.

Smartie uses custom characters for the bar graphs, Winamp spectrum plugin etc. I don't think it uses any of the MatrixOrbital built-in bargraph features (which also use custom characters internally I guess).

You should have spotted it already, but this thread has info on my LCD project. If you can understand the C program code, you can get some ideas on how to do the command handling.

Have fun!
Matt
_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

If you want some code written in basic let me know.

J
firestorm_v1
Posts: 16
Joined: August 3rd, 2006, 2:53 am

Post by firestorm_v1 »

I did a rather extensive breakdown of all the various commands in the display however I have a bit of a more rudimentary problem which hopefully is just my newbie-ness dealing with the BS2..

I'm finding problems with the BS2 reading the commands that LCD Smartie sends, Either I'm not reading them at the right timing, or not formatting the data correctly.

What I might start doing until TI sends me the MAX232s (to solve another problem), I might code this in qbasic 4.5 and see if I can at least start coding it.

Another problem could be that the BS2 might not be fast enough to handle the serial data coming in.


Also, does anyone know that the cursor locate command 254,71,col,row,20chars is always followed by 20 characters (assuming that you have told LCD Smartie that you're using a (2 or 4)x20 display?

Does LCD smartie send a code for character 0 (BIN: 00000000)?

Thanks in advance, this is turning out to be quite fun.
_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

I have never worked with BS but I would assume they are fast enough for 9600bps. LCD Smartie sends the whole line data for a display that is where the 20 characters are coming from for a 20 line lcd. Is this what you mean?

Every character is sent using ASCII. Character 0 is actually decimal 48, binary 0011 0000.

J
firestorm_v1
Posts: 16
Joined: August 3rd, 2006, 2:53 am

Post by firestorm_v1 »

Sorry, posting while under the influence of lack of sleep and caffiene not good for posts making sense.. :P

Assuming a 4x20 display:

What I mean is that when the cursor locate command is sent, (254,71) is it always followed by 20 characters or is it only followed by 20 characters when the column paremeter is "1"?

Another question:

When LCD Smartie starts up, i get the following commands:
254 , 78 , 12 , 18 , 18 , 12 ,
254 , 78 , 1 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31 ,
254 , 78 , 2 , 16 , 16 , 16 , 16 , 16 , 16 , 31 , 16 ,
254 , 78 , 3 , 28 , 28 , 28 , 28 , 28 , 28 , 31 , 28 ,
254 , 78 , 4 ,
254 , 78 , 5 ,
254 , 78 , 6 ,
254 , 78 , 7 ,

(ignore the commas)
Understanding that 254,78 is the custom character definition command and should be followed by a character to define (0-7, right?) and then 8 bytes which is the actual character to define.
On the first line, I would expect to see a 254,78,0,(data bits here) but I never see a character "0" (binary 00000000, not "0"). Is this a flw in my reader application or am I not seeing something that LCD smartie is sending?

Since y'all have done it before, how did you all detect the binary 0?

I really appreciate your help with all this, thanks a million guys!
_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

Its been a while, from what I remember there should be a custom character zero. LCD smartie will send custom characters (bar graph characters) and GPO states at startup. Are you manually writing code for reading in bits from serial (bit-banging) or are you using a UART? To detect zero it shouldnt be different than any other data. You will have 1 start bit, then 8 zeros, then the stop bit.

Its hard to say but from the data you posted I would say that you skipped a few bytes starting with the "0".

J
firestorm_v1
Posts: 16
Joined: August 3rd, 2006, 2:53 am

Post by firestorm_v1 »

I'm cheating.

I have an old toshiba lappy running Hyperterminal capturing to a flat text file. I run that flat file through a small qbasic script and it turns out all the characters into their decimal character equivalents.

I am guessing that I can't detect the character 0 because qbasic is having problems with it? The other 254,78 commands are formatted correctly like follows:

254 , 78 , 1 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31 ,
Attn,define character command, character,Byte1,2,3,4,5,6,7,8

the first command shows up as:
254 , 78 , 12 , 18 , 18 , 12 ,

I think that's missing some things.. :P

I'm going to try and write a listening app and see where that gets me.
_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

I have found that hyperterminal plain sucks for this. If you search hard enough you can find an app that will show you the raw data. I dont remember the name of it off hand. There is a few VB6 example com port applications that read in characters. With very little changing they can be used to show raw decimal data.

J
firestorm_v1
Posts: 16
Joined: August 3rd, 2006, 2:53 am

Post by firestorm_v1 »

And a quickly whipped up qbasic application reveals the hidden characters I was looking for.. :)

I promise I'm not an idiot.. :P

Thanks for clearing up that WTF moment I was having.. :)
firestorm_v1
Posts: 16
Joined: August 3rd, 2006, 2:53 am

For anyone else's refrence

Post by firestorm_v1 »

These are the ASCII codes that are sent when LCD Smartie is initialized, in case anyone else needs these codes too:


254 , 86 , 1 'Sets GPIO #1 to OFF
254 , 86 , 2 'Sets GPIO #2 to OFF
254 , 86 , 3 'Sets GPIO #3 to OFF
254 , 86 , 4 'Sets GPIO #4 to OFF
254 , 86 , 5 'Sets GPIO #5 to OFF
254 , 86 , 6 'Sets GPIO #6 to OFF
254 , 86 , 7 'Sets GPIO #7 to OFF
254 , 86 , 8 'Sets GPIO #8 to OFF
254 , 84 'Blinking Cursor OFF
254 , 88 'Clears Display and Homes cursor
254 , 75 'Underline cursor off
254 , 82 'Auto Scroll OFF
254 , 68 'Auto Line Wrap OFF
254 , 65 'Keypad Auto transmit without Polling ON
254 , 96 'Keypad Auto Repeat OFF
254 , 66 , 0 'Sets Display always on
254 , 80 , 0 ' I have no freaking clue and it's not documented.
254 , 152 , 0 ' Another not documented code. :P
254 , 78 , 0 , 12 , 18 , 18 , 12 , 0 , 0 , 0 , 0 ' Define custom character 0
254 , 78 , 1 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31 'Define custom character 1
254 , 78 , 2 , 16 , 16 , 16 , 16 , 16 , 16 , 31 , 16 'Define custom character 2
254 , 78 , 3 , 28 , 28 , 28 , 28 , 28 , 28 , 31 , 28 'Define custom character 3
254 , 78 , 4 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 'Define custom character 4
254 , 78 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 'Define custom character 5
254 , 78 , 6 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 'Define custom character 6
254 , 78 , 7 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 'Define custom character 7

I pulled all this information from the MO instruction manual for the PK202-24-USB LCD display.
_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

Command 152 is backlight brightness. The number immediately following it is the brightness in a range of 0 to 255.

Command 80 sounds familiar but dont know off the top of my head.

J
mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post by mattcro »

254, 80, x sets the contrast to x (in the range 0-255) where 0 is pale and 255 is dark. I didn't implement this on mine - I just have a variable resistor.

254, 152, x sets and saves the backlight brightness (0-255 range again). This way, the display starts with the saved setting on powerup. My implementation treats this just like a regular backlight command (153) and doesn't bother saving. Command 145 does the same set-and-save for contrast.

You'll have to look at the manuals for several different displays to get all the commands, depending of what features they support. I looked at MOS-AL162 and LK204 datasheets for researching my backpack.

Whaddayaknow, I too made a quick-n-dirty logger in QBasic a while ago when I was doing something similar...

It's possible the Stamp is having trouble keeping up with the data flow - you tend to get dozens of bytes at a time with no delay between bytes. I guess the Stamp does bit-bang UART (you can specify any pin to use for serial port, right?) so it's quite possible it will get "drowned". You may have to settle for a slower baud rate like 2400.

Those 20 bytes after the "set cursor to home" command are probably space characters (ASCII 32 decimal) to blank whichever line of the display.
_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

What does the BS run at (4Mhz?)? Even bit banging it should easily handle 9600bps if it has a decent clock rate. There sometimes may be no delay between bytes, but the rules of RS232 still apply (start bits and stop bits). If you do the math, 9600bps data is coming in at .00010416 seconds a bit, 4mhz is .000000025 seconds a clock cycle. That is plenty time to crunch data. Unless there is a really slow clock cycle and instruction execution time is high it shouldnt miss data.

J
mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post by mattcro »

Yeah, but remember the Basic code is interpreted by the onboard PIC/SX (might be some sort of object code...) and read from serial EEPROMs, so you only get something like a few thousand instructions per second. I don't really know the ins and outs, but remember reading about problems reading RS232 data at higher speeds. I assume the RS232 functions are pre-compiled or internal to the microcontroller to get the best execution speed.

edit: here it is: BASIC Stamp RS232 Notes. Looks like it may be possible to use hardware handshaking - does Smartie use RTS/CTS?
_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

I am not a BS expert, but I thought the code in the eeprom was loaded into the Micro on bootup. So the speed of the serial eeprom has nothing to do with instruction time. Here are some specs I got off parallax website for the BS-2

Processor Speed 20 MHz
Program Execution Speed ~4,000 instructions/sec.
RAM Size 32 Bytes (6 I/O, 26 Variable)
EEPROM (Program) Size 2K Bytes, ~500 instructions
I/O Pins 16 +2 Dedicated Serial
Voltage Requirements 5 - 15 vdc
Current Draw at 5V 3 mA Run / 50 ?A Sleep
PBASIC Commands 42
Size 1.2"x0.6"x0.4"

There is a dedicated serial port on the BS-2. I assume its a UART. At 4000 instructions a second that is .00025 seconds (average) each instruction. If no long delay is given between serial bytes at 9600bps it could cause problems like mattcro said. Can anyone with more experience with basic stamps verify this?

J
firestorm_v1
Posts: 16
Joined: August 3rd, 2006, 2:53 am

Post by firestorm_v1 »

That sounds about right, X7JAY7X, but I'm going to see if I can slow down the comms on the BS2 to about 2400ish and see what develops.
firestorm_v1
Posts: 16
Joined: August 3rd, 2006, 2:53 am

Post by firestorm_v1 »

Well crap, I forgot.. Port 16 is hardcoded by the BS2's "firmware" to stay at 9600. In order to get another serial port working, I need money to buy the parts to get those ports operational.

BTW, my MAX232s came in, now I need the support hardware. Payday isn't till two weeks away. :( Well, guess I'm stalled again untiL i get paid.
Post Reply