XLCD

From ShapeOko
Jump to: navigation, search

XLcd

A module to display important data on a LCD Display as serial Proxy. It can handle and program 32(4x8) Buttons and a rotary encoder for your makros or control ur Shapeoko. Created by Frank Herrmann (xpix)

Some time ago, we designed and built version 1.0 of Xstepper. Unlike other existing GRBL-based CNC solutions, Xstepper is an all-in-one device. The possibility of controlling the machine in a headless state may be possible, and the first step toward doing so is some sort of visual display. This module aims at solving part of the problem!

But how? The good people coding GRBL don’t have the on-chip memory to code in an LCD interface for GRBL. Add to that the severe lack of available IO and this seems to rule out this type of expansion. However, there is always a workaround.

This module spies on the serial communication between the arduino and PC using an ATmega328P. Simultaneously the MC polls the position of the spindle from the XStepper. The returned data is then parsed and displayed on a local LCD. You can choose to display the debug screen, work position or machine position using the on-board button.

Schema XLCD Seriel zu PC-GRBL (1).png

Also we can handle a 4bit or I2C LCD. We add a connector for 32(4x8) Buttons, they can use for actions or macros to control ur Shapeoko. Also possible and planed is to handle a SD Card Connector via I2C:

http://wyolum.com/announcement-i2sd-a-disk-drive-for-arduino/

to plan a headless Shapeoko machine with XStepper/XLcd Modules.


The XLcd includes the following features:

Version 0.1:

  • ATMega328u (DIL Package)
  • USB Connections using USB-FTDI
  • ICSP-Connector for flashing the firmware
  • Connector for External Buttons for spindle, reset, etc...
  • I2C Connector

Version 0.2:

  • add 2 Connector for External Buttons line C and D
  • use pin 8/9 for better serial emulation
  • stable connect to grbl

Bug Fixes

This Board are in beta phases, sometimes we realize we are not perfect :) And yes, this is hard to know :) Ok, please check your Boardversion and read this articles for workarounds to fix these Bugs:

Version 0.20


Build Instructions

Pinout's

The ML20 Header are for connect your Buttons. XLCD are so designed, then he can manage up to 7 buttons on one analog pin. You can connect up to 14 Buttons to Pin A0(A) and A1(B).Also i designed a little header to connect A2(C) and A3(D).

A Button/switch will close the line to GND and the function will activated.

If you want to code your own subroutines for buttons. Please have a look to this file: https://github.com/xpix/XLCD/blob/xlcd-0.2/serialspy/config_buttons.ino

More about this topic, see in header Firmware.

Here the pinout for XLCD's Header:

XLCD Pinout.png

Schema / Board Plans

This branches are created for every revision. Please download schema and board file for your Revision for solder:

Bill of Material (BOM)

Qty Value              Device             Package            Parts        Description                                                    
1                      DUOLED2X5          DUOLED2X5          LEDTX/RX     DUO LED                                                        
1                      ML20               ML20               BUTTONS      HARTING                                                        
1   0-220R             R-EU_R1206         R1206              R2           RESISTOR, European symbol                                      
3   0.1uF              C-EUC1206          C1206              C1, C12, C13 CAPACITOR, European symbol                                     
2   1.2k               R-EU_R1206         R1206              R9, R17      RESISTOR, European symbol                                      
2   1.8k               R-EU_R1206         R1206              R10, R18     RESISTOR, European symbol                                      
1   10K                R-EU_R1206         R1206              R3           RESISTOR, European symbol                                      
1   10K                TRIMPOT3362U-2     3362U-2            R1           Various small potentiometers for "set- and-forget" applications 
2   110                R-EU_R1206         R1206              R6, R7       RESISTOR, European symbol                                      
1   16 MHZ             CRYSTALHC49S       HC49/S             Q2           CRYSTAL                                                        
2   18pF               C-EUC1206          C1206              C14, C15     CAPACITOR, European symbol                                     
2   2.2k               R-EU_R1206         R1206              R11, R19     RESISTOR, European symbol                                      
2   2.7k               R-EU_R1206         R1206              R12, R20     RESISTOR, European symbol                                      
2   2k                 R-EU_R1206         R1206              R4, R5       RESISTOR, European symbol                                      
2   3.3k               R-EU_R1206         R1206              R13, R21     RESISTOR, European symbol                                      
2   3.9k               R-EU_R1206         R1206              R14, R22     RESISTOR, European symbol                                      
2   4.7k               R-EU_R1206         R1206              R15, R23     RESISTOR, European symbol                                      
2   680                R-EU_R1206         R1206              R8, R16      RESISTOR, European symbol                                      
1   Analog             PINHD-1X2          1X02

Firmware

Flash and configure Firmware

Here i describe the realy easy way with Arduino IDE and an Arduno UNO. It exists a LOT of solutions, to flash the firmware to the chip. This is only one way :)

To flash the xlcd Firmware you have to use a normal Arduino IDE, cuz you have to change some preferences in sourcecode. Please read this steps and use a normal Arduino to flash the Atmega328P chip:

 * LiquidCrystal: https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home
   (Important: Delete the old LCD library before you install this one!)
 * SimpleThread: https://dl.dropboxusercontent.com/u/46359709/simpleThread.rar
 * AltSoftSerial: http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
 * Encoder: http://www.pjrc.com/teensy/td_libs_Encoder.html

Restart your IDE and load this sketch: xlcd/serialspy/serialspy.ino. Try to compile :)

Configure

Please edit follow Section and configure firmware:

// MODE ------------------------------------------
#define MODE_PROXY   // works as proxy between PC and GRBL
//#define MODE_SPY   // works only as spy on the TX line 
                     // (no buttons, no serial console, no interaction with grbl) 

// Serial speed ----------------------------------
#define PC_SERIAL       19200
#define GRBL_SERIAL     9600

// LCD -------------------------------------------
#define LCD_ADDR		   0x27  // I2C LCD Address
//#define LCD_4BIT

#define LCD_cols			20
#define LCD_rows			4

For you is only important to set LCD as 4bit or I2C. Please choose the right one, if you want to use an I2C LCD (4pins to connect to LCD) then u need to know which address has your LCD on I2C bus. Don't forget to set the right cols and rows. (16x2, 16x4, 20x4, ...)

If you put LCD direct on board with 16 in header, then u have to change to LCD_4BIT.

//#define LCD_ADDR		   0x27  // I2C LCD Address
#define LCD_4BIT


Save and try to compile/upload :)

First tests

First tests are very important, you solder the last houres or last Day and you dont want to destroy ur work :) First of all connect ur FTDI Adapter to the PC Serial connector and put an Jumper on "+5V" between Pin 1 and 2. This means, the xlcd module get Power from Adapter:

 1 2 3
 =-= * +5V

Now you can connect the serial interface with serial client in arduino with 19200. Please check variable 'PC_SERIAL' in serialspy.ino for correct speed.

Switch Pulldownmenu to 'New Line (NL)' and Speed to '19200': Xlcd sc pulldown.jpg

After a second you see this screen and xlcd reset the grbl device:

<XLCD 0.20>
<All commands for XLCD start with a colon ':'>
<Call help with ':?'>

Grbl 0.8c ['$' for help]

ok

Also every second u see status messages from grbl. We don't need this now, please switch this off with this command:

:i -1
<Interval: -1>
ok

XLCD Config menu

Display menu with all possible functions.

Command: :?
Result:
<XLCD 0.20 MENU>
<:b nr	Call Button nr>
<:i ms	Set or get interval in microseconds>
<:s	show button values>
<:r	Reset device>
ok


XLCD Config buttons

"Learn Buttons" measure the voltage for every button and save this value persistent in EEPROM. You call this function only one times. Xlcd want that you press every button one time.

Command: :l
Result:
<Please push button: 0 ...>
(press A0)
<Set Button: 0 to: 241>
<Please push button: 1 ...>

Button macros

If you want.. (and i know u want :) You can write own macros for every button. Please check this file: https://github.com/xpix/XLCD/blob/xlcd-0.2/serialspy/config_buttons.ino#L50

You can only call a button, if the machine/grbl in idle mode.

All Buttons are numbered:

A0(A) = 0 ... 7; 
A1(B) = 10 .. 17
A2(C) = 20 .. 27
A3(D) = 30 .. 37

An example to send command for start 'Homing' if user press button 'A1' and display a message on LCD:

// macro for second button on pin 'A'
void call_button_1() {
   // Example call Homing
   grblSerial.println("$H"); # call $H on grbl serial line

   // stop all background threads
   simpleThread_group_stop(group_one);
   
   // Display action on LCD
   myLCD.clear(); # clear LCD
   myLCD.print("Homing ..."); # print some text

   // wait one second
   delay(1000);

   // restart all Background thtreads
   simpleThread_group_restart(group_one);
};

You can use all c++ arduino code things, but remember you have to compile and upload every change in this File. Some explains:

grblSerial: This is the alternative Serial line, connected via pin D8/D9 to RX/TX from grbl. All the prints and read work on this line. I.e. u want to send some command.

grblSerial.println("G1 X100.00"); // move machine in x-direction for 100mm

myLCD: To control the LCD Screen, you can clear and display some text. But remember, in background works a thread he get information from grbl and try to display this to LCD screen. This mean, u can display something but it will replace from this thread. You have to stop all Threads and then display some text. Wait one second and restart the threads:

simpleThread_group_stop(group_one);
myLCD.clear();
myLCD.print("Some Text ...");
delay(1000);
simpleThread_group_restart(group_one);

Easy or? i will write some usefull macros and publish these in a special thread.

USB2TTL

History

You can read all articles in the [1] about the idea and the first prototype board. We tried to make a board with all connectors and a CPU in thru-hole/smd(1206) design, easy to solder but clearly designed and open hardware.

Pics

Videos

http://www.youtube.com/watch?v=O_s020OhUaQ http://www.youtube.com/watch?v=VSstTS_I-tA

Forum Discussion

http://www.shapeoko.com/forum/viewtopic.php?f=11&t=1904&hilit=xlcd