Shop OBEX P1 Docs P2 Docs Learn Events
Matrix Orbital 0821 driver questions — Parallax Forums

Matrix Orbital 0821 driver questions

hydoskeehydoskee Posts: 10
edited 2007-06-17 20:08 in Propeller 1
This is my first time trying to write something like this, but I have a Matrix Orbital 0821 display that I'm trying to interface with the propeller chip.
The data sheet for the LCD is here: www.matrixorbital.ca/manuals/LCDVFD_series/LCD0821/LCD0821_140.pdf

I have a few questions about how to go about this project:

1. Is the rx/tx on the LCD -> Prop side necessary, or can I get by using just the Prop tx -> rx LCD connection.
2. What's the proper propeller syntax/object to send byte data? For example, the BASIC command to clear the screen is PRINT#1,chr$(254);chr$(88), and I'm not 100% sure how that translates to spin. I tried making a DAT block and BYTE objects containing these, and then using Simple Serial's tx method to put it up, but I just got jibberish.

Thanks for any suggestions or resources you can point me to!

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-11 18:26
    Has the TTL modification been done, what speed are the jumpers set to?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • hydoskeehydoskee Posts: 10
    edited 2007-06-11 18:30
    No modifications, and I think the speed jumpers are set to 19_200.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-11 18:32
    And you had this working with a stamp?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • hydoskeehydoskee Posts: 10
    edited 2007-06-11 18:33
    I've been able to get it working with an atmega8, not a stamp, though.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-11 18:37
    Gotcha, well Im thinking it may be one of two things, 19_200 is at the end of what simple serial can do, so you may want to switch to using FullDuplexSerial. Also if your ATmega was the 5V variant, there may be an issue with the 3.3V of the Propeller not being able to fully trigger the input of the 0821, in which case you may need to do some level shifting.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • hydoskeehydoskee Posts: 10
    edited 2007-06-11 18:53
    So I'm relatively new to both microcontrollers AND basic electronics, but if I use the propeller serial tx pin to control a transistor pulling 5v, and essentially use it as a relay for the serial, is that a valid way to translate propeller -> 5v serial signals? Is there a better way?

    I was getting SOME garbage on the LCD when I was using simple_serial and 3.3v, so I suspect the solution is likely that I need to use the FullDuplex library.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-11 19:37
    You've got the basic idea correct, use an NMOS or npn with the drain (or collector) tied through a resistor up to 5V, the spot between the resistor and transistor is the part connected to the display. In this arrangement you may need to use inverted mode for the serial driver. Actually this reminds me, the display may be expecting inverted mode, try this first since before any of the other things since it's a simple solution.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • hydoskeehydoskee Posts: 10
    edited 2007-06-12 13:52
    I created a not gate using a transistor, the propeller's serial 3.3v to the base, and 5v output. It inverted the output AND raised it to 5v, and I didn't get anything useful out of the LCD, so that told me immediately that it wasn't in inverting mode. So it now looks like the LCD needs it's driver written with the full duplex serial library.

    As for that:

    Is an RX pin required, or can i get away with only Propeller tx -> LCD rx connected?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-12 16:36
    You don't need to connect anything to the Rx if you aren't receiveing anything as is the case with this display.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • hydoskeehydoskee Posts: 10
    edited 2007-06-13 00:33
    I think I got one step closer. I used the full duplex serial spin library to get it working a little better, but my issue is still the following:
    The clear screen command is "send decimal 254, send decimal 88", and so I run
    (where Serial is a full duplex serial object)

    Serial.dec(254)
    Serial.dec(88)

    and the screen is cleared.

    The data sheet says to run 254, 70 to get an "F" on the screen.
    When I run
    Serial.dec(254)
    Serial.dec(70)

    i get
    " % $"

    Other letters are equally confusing, but F had characters I could easily print using a qwerty.


    I'm running in mode 0 (for the start function), and 19_200.

    Any help is very appreciated!
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-13 14:41
    254,70 is the command to turn the backlight off, not display F, try simply sending 70.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • hydoskeehydoskee Posts: 10
    edited 2007-06-13 15:21
    1. Shouldn't that command have turned the backlight off, then, instead of just printing garbage?
    2. I tried that too, but I was getting lightly more nonsensical stuff, so I assumed that the line in the datasheet "254 must be printed before each command" applied to letters as well.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-13 15:26
    No, commands are different than data,
    try Serial.tx('F')

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Mike CookMike Cook Posts: 829
    edited 2007-06-13 22:48
    hydoskee,

    When you send:

    Serial.dec(254)· ' Command
    Serial.dec(88)··· ' Clear Display


    What is actually going to the 0821 is, in hex:

    0x32 0x35 0x34 0x38 0x38

    I believe you want to send:

    Serial.tx(254)·· ' Command
    Serial.tx(88)···· ' Clear Display


    Which will send, in Hex:

    0xFE 0x58

    Attached is an·archive that I used a Matrix Orbital LCD2041 in, I believe the commands are the same for the LCD0821. The LCD2041 is a 4 line by 20 character display, so you will need to modify the program a bit to fit the line and character count for your display.

    Also I believe all Matrix Orbit displays expect RS-232 serial data, so if you are not using a level shifter on the Propeller side to send data to the display be sure that the data that the Propeller is sending is INVERTED, and at the correct baud rate that the display is expecting. On my setup, data from the Propeller is going directly to the display, so I'm using the INVERTED option in the serial object and the display is set for 19200.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike

    Post Edited (Mike Cook) : 6/13/2007 11:47:52 PM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-13 23:55
    Thanks Mike for providing a more robust answer, I caught part of it, but you got it entirely.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • hydoskeehydoskee Posts: 10
    edited 2007-06-14 22:53
    I had already tried that. My code is as follows, and all I get are nonsensical characters.

    Also, Serial.tx('F') generates an error (in syntax).


    {{Debug For Matrix Orbital LCD0821}}


    OBJ
    Serial : "FullDuplexSerial"

    PUB Main
    Serial.start(17,18,1,19_200)
    Serial.tx254)
    Serial.tx(88)
    Serial.stop
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-14 23:10
    Ah sorry, I meant Serial.tx("F")

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Mike CookMike Cook Posts: 829
    edited 2007-06-15 00:53
    hydoskee,

    Try the following.........

    I don't see the following in the code you posted, either you left it out, of your post,·to be brief or you are not using it. I believe you will need a crystal to use the serial object. (Paul correct me If I'm Wrong!) I could not get it to work until these two lines were added, i.e. I was getting garbage characters on the display:
    CON
      
      _clkmode = xtal1 + pll16x                             ' use crystal x 16
      _xinfreq = 5_000_000                                  ' 5 MHz crystal (sys clock = 80 MHz)
      
      
    


    Note: I'm using a Propeller ProtoBoard w/5 MHz crystal and a LCD2041 display. The commands for your LCD0821 should be similar to the LCD2041

    Here's the rest of the code:

    OBJ
      Serial : "FullDuplexSerial"
    
    PUB Main
      Serial.start(17,18,3,19_200)                             ' hydoskee's LCD0821 on pin 18
      'Serial.start(6,7,3,19_200)                               ' Mike's LCD2041 on pin 7
      Serial.tx(254)
      Serial.tx(88)
      serial.str(string("Hello"))
      'Serial.stop
    


    I've attached this in the test.spin file, try this and see if it helps, works on my LCD2041


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike

    Post Edited (Mike Cook) : 6/15/2007 1:18:38 AM GMT
  • hydoskeehydoskee Posts: 10
    edited 2007-06-15 14:05
    I actually hadn't set the _clkmode or _xinfreq variables.

    Although, I did after you mentioned that, and I was still getting jibberish. I have the following setup:

    I'm using this as my crystal www.sparkfun.com/commerce/product_info.php?products_id=540

    {{Debug For Matrix Orbital LCD0821}}
    
    CON
      _clkmode = xtal1 + pll1x 
      _xinfreq = 32_768_000
    
    
    OBJ
     Serial : "FullDuplexSerial"
    
    PUB Main
      Serial.start(17,18,1,19_200)
      Serial.tx(254)
      Serial.tx(88)
      Serial.stop
    
    
    



    And when I run it, I get a little guy that looks like he shot me once in space invaders. No cleared screen, though.

    Thank for the ongoing help troubleshooting this.
  • Mike CookMike Cook Posts: 829
    edited 2007-06-15 14:30

    Three things that might clear this up.

    1. Your LCD0821 what pin, on the propeller chip, is it connected to and is it set for TTL or RS-232 serial? I'm assuming your display is set for RS-232 serial and connected to pin 18 of the Propeller. If that the case in the following line:

    Serial.start(17,18,1,19_200)

    Is only inverting pin 17 and not pin 18. To invert pin 18 use:

    Serial.start(17,18,2,19_200)

    or to invert both RX/TX use:

    Serial.start(17,18,3,19_200)



    2. Paul will have to comment on the 32KHz crystal, I've always used the suggested 5Mhz crystal. Not sure if FullDuplexSerial.spin has a frequency limitation/requirement.

    3. If you use Serial.stop, immediately after sending data to FullDuplexSerial.spin, from what I have found the object will be stopped before it has a chance to completely output the serial data. In the above attached test.spin, that was the case so that's why it was commented out.




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike

    Post Edited (Mike Cook) : 6/15/2007 2:35:58 PM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-15 15:47
    I wouldn't suggest using a RTC crystal, it's too slow for the PLL to lock onto and multiply. The crystal must be between 4 and 8 MHz (yes I know the SpinStamp uses a 10MHz crystal, this is the very limit of the range of the PLL therefore it may not work at temperature extremes, Im about to start testing these things).

    The problem with using the internal clock for serial is in order for it to function properly you need to measure what the RC circuit is oscillating at, this varies from chip to chip.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 6/15/2007 4:49:58 PM GMT
  • hydoskeehydoskee Posts: 10
    edited 2007-06-17 19:43
    It works! I found a 4mhz crystal lying around my workbench, and I plugged that in. It looked a little better, and then I took Mike's suggestion of commenting out my "serial.stop", and changing the mode to 2.

    It works perfectly now, and I can set about modifying Mike's code to fit my LCD screen, or if I even wanted to code up my own from scratch to get a little more familiar with the Spin language, I'm at a very good place to do that.

    Thanks so much for all your help!

    Follows is my code that actually works!

    
    {{Debug For Matrix Orbital LCD0821}}
    
    CON
      _clkmode = xtal1 + pll8x
      _xinfreq =   4_000_000
    
    OBJ
     Serial : "FullDuplexSerial"
    
    PUB Main
      Serial.start(17,18,2,19_200)
    
      Serial.tx(254)       ' Clear Screen, go to home
      Serial.tx(88)
      
    
      Serial.tx(254)       ' Backlight On
      Serial.tx(66)
      Serial.tx(0)
    
        
      Serial.tx("H")
      Serial.tx("e")          
      Serial.tx("l")
      Serial.tx("l")
      Serial.tx("o")
      Serial.tx(" ")
      Serial.tx(" ")
      Serial.tx(" ")
      'newline
      Serial.tx("W")
      Serial.tx("o")
      Serial.tx("r")
      Serial.tx("l")
      Serial.tx("d")
      Serial.tx("!")
    
      
    
    
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-17 20:08
    It's great to see that you figured out how to make it·work properly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.