Code Monkey home page Code Monkey logo

frc-lcd-display's Introduction

FRC-LCD-Display

๐Ÿ”ท The source code here demonstrates how to set up a 4x20 LCD panel display with the Roborio (for FRC First Robotics Competition).

All you have to do to use it is add the code that I've written, and then run the command LCDwriteString(String s, int line); where String s is the string to write to the display, and int line is line number (1-4).

p1 p2 p3


First the hardware:

โ–ช๏ธ We're using a display like the one in the photo

photo1.

p5

โ–ช๏ธ Note that it comes with a backplate thing mounted on it. This backplate already has all of the connections between the LCD display and the I2C protocol.

photo2

โ–ช๏ธ The connectors on the back of the LCD display do not match the connectors on the RoboRIO. The RoboRIO has the pins in a different order. Also note that the LCD display requires 5V, not the 3.3V on the RoboRIO I2C connector. We're just using 5V from a digital IO pin. You could also use the 5V from the Voltage Regulator Module.


CODE

Background information

๐Ÿ’ฅ WPI Documentation The WPI documenation is completely useless. The source code is no help either.

It's easy to make an I2C object: lcdDisplay = new I2C(I2C.Port.kOnboard, 0x27); The address of most LCD panels is 0x27. It's a lot harder to write to the display since the only thing that the documentation tells you is boolean write (int registerAddress, int data). There is no explanation of what the register address should be, no examples of this being used anywhere. (I finally figured it out, see below.)

๐Ÿ’ฅ LCD Panels are all driven by the Hitachi HD44780 driver. This page provides details, explains the display addressing, and lists the commands that are build in.

๐Ÿ’ฅ There are some very useful code examples here:

๐Ÿ’ฅ Finally, I realized that my python code ๐Ÿ (which I got from someone else's Raspberry Pi repository) could be directly ported to Java. It worked!!!


How the code works

  • It turns out that the register to write the I2C data is ALWAYS 0 (I'm talking about the WPI I2C.write() command). Why? This is either the I2C controller or the register on the I2C device. So it seems that the LCD display only has one (external facing) register.
  • However ... internally, there are TWO registers: a command register and a data/display register. The registers are INTERNAL and are selected by using the Rs bit or not.
  • Commands are always written 4 bits at a time. Why? This is because it's the way that everyone does it. (Originally it was so that you need fewer data lines connected to your display.)
  • Commands have to be "strobed" using the En bit for them to take effect.
  • Commands do not execute instantaneously, so you need a short delay between them.
  • There is a sequence of initialization commands that must be done to set up the display after it's been powered on before it can be used.
  • Many of the other commands (cursor movement, etc.) I have not tried.

frc-lcd-display's People

Contributors

salamander2 avatar

Watchers

Blarry Wang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.