|Touchololu Touch Panel For Huxley #710|
Having previously developed the touch sensors, the remaining area to be addressed was to develop software to support the emulation. It would have been possible to implement a new protocol in Marlin but the decision was taken to make the unit hardware compliant, where practicable, with the Panelolu 2 display and the Liquid TWI software interface for Arduino; i.e. as per the Adafruit Arduino LCD interface hardware based on an MCP23017.
Implementing a full emulation of the MCP23017 is possible but time consuming and probably not
necessary as it's usual that only a subset of available features are used in an application. So an analysis of the Liquid TWI software enabled only the registers used on the MCP23017 to be concentrated on. The analysis revealed 6 registers addressed through Bank 0 addressing scheme. Being IODIRA = 0x1F, INTFA = 0x1F, GPIOA = 0xXX, GPIOB = 0xXX, OLATA - 0xXX and OLATB = 0xXX. The last two depend on the data written to the port. i.e. OLATA is the LCD display data and control lines.
|Touchololu I2C example nibble write to LCD|
The MCP23017 register handling within the 16F1829 micro controller is performed in the interrupt service routine in order to respond in a timely manner to the I2C data. The micro controller has a hardware I2C decoder and data capture register which will generate an interrupt when a byte has been sent by the host device. By activating the appropriate interrupts a software routine keeps track of the Read or Write requests and then performs the necessary action in the micro controller to emulate functions usually carried out by the MCP23017. For example MCP23017 PORT B writes are moved to the micro controllers PORTC as the micro controller does not have 8 data bits available on the input / output pins for any other port.
I decided not to implement LED's as I find the display sufficiently informative of the status of the system.
To assist with debugging, a full set of the MCP23017 registers is maintained in the micro controller memory. With only those functions needed, having support code written for them. Being re-programmable updates can be made to extend support if needed.
|Touchololu I2C Connection To Host|
Testing of the code was performed using both Marlin on the Sanguinololu and also using an Arduino with test code provided with the Liquid TWI library. The test code in the Liquid TWI library runs the I2C display at different communication speeds. This was to expose the Touchololu software of the MCP23017 emulation too at least two pieces of software.
|Touchololu 0.1 Programming With Microchip PicKit 3|
The PCB for the 16F1829 has a connector to allow connection of PicKit 3 programmer. Alternate programmers such as an Arduino or ICD can also be used. The programmer can not be left in place when testing the capacitive touch functions as they use PORTA of the micro controller which includes some of the connections to the programmer.
Two other connectors are used on the PCB, the ribbon cable connector in the image shows the connection to the adhesive copper pads.
|Touchololu 0.1 Module Connected To LCD Display|
The off board connectors are both intended to be IDC connectors The connector on the left of the image connects to the Sanguinololu board. Touchololu only needs 4 connections. +5, 0v for power and SDA, SCL for I2C. The connections shown also allow for a micro SD card to be connected as per the Panelolu design. I have not had chance to test this yet as the micro SD socket was not available. The correct size buzzer was also not available however this was easily tested (note the buzzer is managed by Touchololu not Liquid TWI).
The SD card support is taken directly from the Panelolu design and whilst the design is intended to use capacitive buttons there is no reason the user interface could not use the same button deployed in the Panelolu implementation 623-4237 (ALPS EC12E2424407 encoder) with a small tweak to the code. A double sided PCB layout was selected to enable screening of the capacitive channel connections. The capacitive channel connections were routed to the opposite side of the PCB to the I2C data lines and power supply. A standard decoupling capacitor has been located physically close to the micro controller. The capacitive touch interface application note AN1334 recommends series resistors in line with the capacitive touch sensor pads and 1K Ohm resistors were used on the test PCB as these had worked successfully on the prototype.
|Touchololu Circuit Diagram|
Inspection of the circuit diagram reveals that the connection from the I/O port to the LCD is not a straight bit order match between the two devices. Bit 2 of the I/O port on the micro controller is connected to bit 7 of the LCD. This is driven by the Adafruit design and probably slows down the Liquid TWI software and thus Marlin on the Sanguinolou quite a bit. As every nibble has to be adjusted for order and byte position. This was one of the reasons that a new driver was considered when starting the project.
Internal Touchololu software
I wrote some firmware to support configuration of the Touchololu panel in order to allow some changes to be made to the panel. So for example buttons can be tested and the up down buttons reversed if desired. Here is a summary of the functions implemented.
The status of the capacitive touch buttons is displayed on the screen. This can be used to identify any potential issues with the touch buttons or button wiring.
Display the data for each register written by the master device or read by the master device.
Allows modification of I2C display address, button delays and buzzer time. The buttons can also be reversed
Performs a software restart of the micro controller firmware
Accessing and exiting configuration menus
Press the Up and Down buttons simultaneously.
|Touchololu 0.1 panel software|
|Testing Touchololu 0.1 With Arduino|
|Sanguinololu Configuration With Touchololu 0.1|