Thursday, 30 January 2014

Making And Testing Touchololu...

Packaged Touchololu 0.1 PCB From PCBTrain
Here is more detail on the construction of the Touchololu touch panel interface for RepRap Marlin. An emulation of an MCP23017 and capacitive touch I2C interface aka Panelolu 2.

The PCB was designed in Eagle CAD and fabricated by PCBTrain. The PCB is a 1.4mm,   double sided and through hole plated. Intended to connect to a Hitachi HD44780 compatible LCD display. Software, running on a Microchip 16F1829 micro controller, emulates the MCP23017 used in a Panelolu 2 unit and is transparent as far as the LCD display is concerned. So potentially other LCD devices could be connected. If Touchololu configuration was required on alternate devices the Touchololu firmware would need a tweak.

PCBTrain notified a shut down, after I placed the order, over the new year. Adding quite a bit of delay to the order. So rather than 15 working days, it ended up being around a month before I received the PCB. The item was shipped in plenty of packaging and sealed in a pink bubble wrap. Presumably to extend the shelf life of the PCB. A PCBTrain engineer was good enough to contact me as I omitted an Excellon 2 drill file with the PCB layout when placing the order. I tried to use a family firm local to me; however the set up costs were quite a bit higher, although in volume they would have been quite a bit cheaper.

Touchololu Sensor Harness For Capacitive Touch Pads
The harness was soldered to the copper pads prior to placing in the plastic housing. The pads should ideally be 15mm square. However these 35mm (approx) x 10mm pads work well and suit the format of the Curvy Panelolu case. The soldered harness connection to the pad was placed to ensure when the pads are in place in the case they did not interfere with the LCD bezel. The LCD bezel sizes change with each manufacturer. So a little checking and planning is needed to avoid pressing the LCD bezel into the soldered connection when the display is screwed into location in the Curvey Panelolu case. The soldered location on the pad avoided the edge of the pad to help ensure some adhesive on the rear of the copper tape for robust tape retention. As the adhesive can be degraded by the high temperature of the soldering process. Note the second conductor running with the connection to each pad, not terminated. This is a zero volt referenced conductor which serves to stabilse the capacitance of the harness and reduce interference.

Interestingly you can order coloured ribbon cable from Farnell electronics in meter length increments. I used the coloured ribbon cable to allow me to readily identify each of the conductors.


Touchololu Capacitive Touch Pads In Curvy Panelolu Case
The harness was routed in the case and arranged so as not to interfere with the LCD display when its subsequently fitted. The copper tape was smoothed on the plastic to assist with adhesion and remove as much trapped air as practicable.

There are two unused conductors on the harness connected to zero volts. These were reserved for a possible additional connection.  They were trimmed to terminate a little before the nearest connection, rather than near the IDC connector.

The harness needs to be in a stable position, routed away from potential interference such as heavy current or noisy conductors. In this instance the cable is routed behind mounting posts and a fold placed into the ribbon cable. As the Microchip mTouch software library establishes a baseline capacitance on power up. Provided a few simple precautions are followed the software will compensate for the specific routing configuration and subsequent longer term variations should contamination arise.

Prior to installing the LCD display into the case the front was covered with Kapton tape where it might touch the capacitive touch pads.

Touchololu LCD Bezel Insulation Prevents Contact With Pads
Assembly of electronics components onto the Touchololu PCB is relatively straight forward. All of the surface mount components are mounted on the same surface. The remaining components are through hole components. Some care needs to be exercised as the SSOP20 16F1289 has pins which are very closed to each other. However the prototype was assembled by hand, using a standard soldering iron, desolder braid, no clean flux and a magnifying glass.

The surface mount components were soldered in place followed by the connectors. The unit was programmed using a PicKit 3 programmer. When the software had been validated and the voltages on the connections to the LCD verified. The PCB was soldered to PCB header pins previously soldered to the LCD display. The PCB header pins had allowed testing of prototypes as the header pins allowed the display to be directly inserted into bread board.



Touchololu PCB Connected To LCD Display
The Touchololu PCB has a set of connections directly matching the LCD connector connections. A connector can be used if desired but I elected to use a set of straight PCB header pins. Header sockets might be used, depending on the arrangements for the housing for SD card access as these add a little to the height of the connection.

The PCB was positioned to allow a micro SD card to clear the front half of the case. This will allow a slot to be placed in the rear of the Curvy Panelolu case for access to a micro SD card if required. Avoiding the need to modify the top half of the case. The PCB can be supported with a printed (3D printer) support designed to match the display PCB (clearing features as required). A support will reduce the risk of 'dry joints' being formed arising from repeated pressure on the soldered joints if the card is inserted and removed frequently.



Touchololu MCP23017 Emulator PCB Installed On Rear Of LCD
Also available on the PCB is a place for a reset switch for the Sanguinololu (not fitted. in the images shown). If a reset button is to be used, a support should be created for the Touchololu PCB. To reduce forces that would be transferred onto the connection between the PCB and the LCD display module.

Finally the unit was tested using an Arduino UNO. The test software is included in the LiquidTWI library. This code can be used to test a traditional Panelolu 2 unit as well.


Having tested the unit, a ribbon cable was used to connect the Touchololu to Huxley #710. The connector to Huxley #710 is two HARWIN - M20 Series 6 way connectors. These are frequently found inside personal computers. These need HARWIN - M20-1180042 - CRIMP SOCKET. I used  this connector to enable me to test in stages with a prototype and accommodate issues that might have arisen in the PCB layout.

As can be seen on the video, everything worked fine.
I
Touchololu PCB Mounted On Rear Of LCD Display
Testing Touchololu MCP23017 Emulation With Arduino



Touchololu circuit diagram

Sunday, 19 January 2014

Touchololu Touch Button And MCP23017 Emulation ...

Touchololu Touch Panel For Huxley #710
The capacitive touch button interface allowed the smooth lines of the Curvy Panelolu case, developed for Huxley #710, to be maintained. But needed two chips and why have two when one will do? To solve the problem of having an MCP23017 16-Bit I/O Expander  and the touch interface chip. I upgraded the touch controller from a 16F1825 to a 16F1829 device in an SSOP 20 format to obtain more input output pins. This also enabled use of the integrated I2C support and allow emulation of the MCP23017 in software as the 16F1829 has a higher clock speed.

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
Having a micro controller allows extra flexibility to be added. So the firmware allows modification of button response, button sense and base address of the device to be modified using the firmware. So for example the Touchololu micro controller I2C address defaults to 0x20 and can be set through the Touchololu. Note that in 0.1 the software uses the code written to the I2C register in the 16F1829 so shows 0x40 which equals 0x20. The majority of the code is taken up by support for menus and menu configuration options.

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
I developed a PCB in Eagle CAD 6.5 Light to neaten the connection to the display module. The PCB solders to header pins connecting to the LCD display. This should also allow the SD card slot to align with the edge of the box making access through the edge of the box easy with a simple cut out in the lower part of the box. The same should be true for the ribbon cable connection to the printer. I will update the design of the lower part as soon as I get chance. When inserting connections a little care is needed if a support part is not printed to prevent excessive force bending the pins to the LCD.
 
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.


Connections
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).


Circuit Diagram
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.

 Button Test
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.

 Register States
Display the data for each register written by the master device or read by the master device.

 Settings
Allows modification of I2C display address, button delays and buzzer time. The buttons can also be reversed

 Reset
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


Sunday, 12 January 2014

Panelolu 2 Capacitive Button Interface ...


Touchololu Panel Overlay
The Curvy Panelolu 2 case has no buttons and its beautiful lines would be ruined by ungainly knobs and switches. To maintain the Curvy Panelolu 2's clean lines, I interfaced a Microchip micro controller incorporating m-Touch capacitive touch sensor support, in place of the usual rotary knob. The capacitive touch sensors replace all button functions in the case, with minimum space claim. Micro controller firmware then mimics, the usually deployed, rotary knob output so as to interface to a RepRap without host software modifications.


Implementation
Capacitive sensors are usually made up of conductive pads or plates and it is common to form pads on printed circuit boards attached to the back of a case.

The pads act to detect capacitance changes when a target object, such as a finger, passes in proximity to the pad,  as shown in the image below. For reliable detection the pads need to be a minimum size and the supporting panel made of suitable material. The typical recommended size for a pad is approximately 15mm square and the panel material typically used in 3D printers, such as PLA or ABS, is suitable as a supporting panel. My pads are slightly smaller but there is a 'tweak' available to address this. As I don't have conductive filament to hand; to construct the touch pads, I used adhesive backed copper tape (542-5460) on the back of the printed case.

Capacitive touch system used on Curvy Panelolu
To sense the capacitance change reliably, a part from one in my 'bits' box was selected. The circuit is based on a Microchip 16F1825. The device supports 4 capacitive touch channels of which 3 are used, leaving sufficient output pins to simulate the rotary knob 623-4237 (ALPS  EC12E2424407 encoder).

To connect the pads to the PCB in the implementation, an IDC ribbon cable was used for the harness. I found the harness was best protected from external influences by separating each conductor connecting to a pad, with a ground (or zero volt) conductor. A further two conductors, one on each of the extremities of the IDC cable would provide additional screening. Other cable arrangements will work, the main requirement is to ensure that accidentally coupled capacitance is not affecting the wiring harness i.e. fingers at the side of the box un-intentionally selecting a function. The screening conductors achieve this nicely and fixing the cable in place (initially using tape or blue tack) allowed testing of the harness installation.
Location of capacitive sensor plates for Touchololu

Connection are soldered to the pad before fixing the adhesive backed tape to the plastic case. As the heat from your soldering iron is likely to deform the case as a minimum. It's important to avoid placing the connection where the LCD panel will sit as clearances are by design small and solder and wire would get in the way. Kapton tape was placed over the display bezel to ensure the metal bezel does not touch the copper strips.


The neat thing about the mTouch library is that at start up it works out what the starting capacitance is for each of the pads. This means that it will accommodate the wiring harness automatically, adjusting for differences in length or routing. It helps to avoid noise sources and keeping the wiring harness fixed in place ensures that sensing occurs only for the desired items such as fingers. If you leave contamination over the buttons, the code has a 'long term average' feature to allow it to compensate.

Block diagram of Curvy Panelolu configuration
The code for the Microchip 16F1825 is written using the free HiTech C compiler supplied with MPLAB and uses the free Microchip m-Touch library. The code implements a simulation of the rotary encoder, generating signals equivalent to physical rotation. The button press is supported from the central pad. Running the micro controller at 5v provides additional noise immunity over a 3.6v system and at 5v, interfaces directly with the Sanguinololu board used in Huxley #710.

One of the advantages of the capacitive touch sensors interface is that a graphic overlay can be used on the front panel of any desired form, the technique is described below. Care needs to be taken not to create too thick an overlay. As the thickness affects sensitivity of the touch system, although it is possible to make some adjustment in software to compensate. The sensitivity is adjusted from the default in the implementation. As the copper strip I have is 10mm wide and square pads would make the box ungainly. I cut three lengths of 35mm for each button. The up down buttons are typically aligned with a finger in the implementation. Whereas the action / select pad is at 90 degrees to a finger. Were the same sensitivity deployed, the action / select button 'feels' unreliable. Tweaking the sensitivity allowed the same 'feel' to be achieved on all pads.
Curvy Panelolu 2 Capacitive Touch Interface circuit

As can be seen from the block diagram the default configuration of a typical Panelolu interface was extended using a Microchip micro controller. The 16F1825 device selected was one in my bits box although others will no doubt work just as well.


The implementation required only the microchip IC and 3 resistors together with connections to the copper pads. The diagram looks a little more complex as its has the Panelolu 2 basic connections. Although this implementation does not show the card reader connected, as I don't currently use the card reader.

The firmware on the Microchip 16F1825 micro controller emulates the output sequence from the typical encoder switch. The encoder output has two channels which are out of phase with each other so that the direction can be discerned. The firmware on the micro controller has filtering and de-bounce implemented to produce clean signals to feed to the MCP23017.

Construction of panel overlay
In fact if desired it would be straight forward to implement a dial using the capacitive sensor pads arranged in a slightly different manner so as to achieve the same implementation as the rotary encoder. With little additional effort, the push action can be implemented as well to completely mimic the functionality but with much more flexibility.


The panel technique I used is straightforward. First the graphic is printed onto adhesive backed paper. The paper can then be covered with transparent adhesive backed plastic for a wipe clean surface. This material is usually not optically correct, so where some graphic displays are deployed, fringing will be seen . In these cases a window should be cut in the transparent film plastic and optically correct plastic inserted. Alternatives are to print buttons in different colours set into the panel, perhaps being formed from conductive filament.

If you decide to make your own Touchololu panel graphic, the templates are here:
Template For Panel Graphic

Link to Touchololu PowerPoint template
Link to Touchololu PDF template

Link to Button documentation

Marlin had a few bugs in the non interrupt button implementation that I came across when testing out the interface. So there was some debugging of Marlin as well.

A short video showing a test of the capacitive sensor sensitivity


Another short video showing the built unit working with Marlin. Note that in Marlin, the pulses per change was modified from 5 to 1 pulse and the dead zone from 10 to 2 pulses. 

I usually use green LCD displays, this display is a Displaytech 204A series module. In some lighting conditions seems to have less clarity than the green units. Note the 'feature' in Marlin where decreasing the number needs a reverse direction, it's not Touchololu. The drift of my finger is due to the close proximity of the camera and attempting not to block its view of the screen.


There is an update post to follow this...

Sunday, 5 January 2014

Testing Slic3r...

Quick print test with Slic3r this week following the post on the RepRap Pro site that they now use the Slic3r slicer .  There is a new version of Slic3r available as well Slic3r 1.0.0RC2.
First print using Slic3r

Also upgraded marlin to the latest release from the version available 28th December 2013.

I need to tweak the parameters now as there were some blobs that I had managed to tune out with Skeinforge. The default retraction rate from the parameter files supplied by RepRap Pro at 1.6 mm gives blobs. I had previously used at least another 1 mm.

I may give the upgraded slicer software a try as I had problems with managing the different print profiles and having the 0.9.10b  software save the configuration ini file.
Thing 190118 Printed with Slic3r on Huxley #710

The print is a  holder for a filament cleaning sponge, read more about it here.
This print is similar to the classic whistle with included pea as it prints in place. I had to 'crack' the hinge to close it. But it worked first time.


The holder replaces the previous solution:
Original filament  cleaning sponge


Printed in Faberdasherry Squeezed Orange
Sample Part Manufacturing Technical Documentation
Printer : Huxley #710 (RepRap Pro)
Firmware : Marlin 1.0.0 RC2 - 28 December 2013
Software : RepRap Pro Software 811708f - Pronterface
Slicer : Slic3R Release 0.9.10b
Material : PLA - Faberdashery
Material Dia. : 1.77 mm (Msd 1.80 mm )
Nozzle : 0.50 mm
Layer height : 0.30 mm
Layer width : 0.6 mm
Extrusion T : 202 C
Bed T : 60 C
Feed Rate : 30 mm/s
Perimter rat. : 0.5
Cooling Fan : Yes
Bed material: Borosilicate Glass
Design For Manufacture Parameters - Not applicable
Model : Absolute dimensions
Scale : 1:1
Holes : Yes
Layer height : 0.30 mm
Layer width : 0.6 mm
Over hangs : Yes
Support : No
Model Tools
Function: Model checking and model clean up
Tool: NetFab Studio Basic
Version: 4.9

Notes
First print with Slic3r, the part did separate at the hinge. Retraction rate wants increasing from default 1.6mm to reduce blobs. Some minor strings. Default print speed settings for Slic3r slightly faster than previously used with Huxley #710 at 30 mm/s.