USB Pendant Hacking

I’ve been knee-deep in USB and LCD hacking, playing around some concepts for a control pendant for my CNC mill.  It was a good excuse to exercise my rusty skills on the EZ-USB microcontroller, which I haven’t used in years, but was the basis for many projects from the past.

The first experiments were to make a generic HID (Human Interface Device) input/output device, connected to some buttons and LEDs on the evaluation board that I was using.  By using hidcomp, a nice plugin for EMC2, I was fairly quickly able to tie some buttons to jog controls on my mill with some rudimentary speed controls.  This will form the most basic functionality for my pendant, which will have a couple of these nice Happ subminiature joysticks.

[youtube FAst1QSOH3U]

Once that was working, I wanted to try to get the LCD functionality in hidcomp to work, so I could output EMC2 info like axis positions onto a display.  The first hurdle, which easily chewed up many hours, was trying to get HID Feature Reports to work with the EZ-USB framework.  Feature Reports are a way for HID devices and the host to exchange configuration information.  In this particular case, the hidcomp package expected to receive a feature report indicating the size of the LCD.  After a lot of digging into the HID documentation and the HID usage tables combined with some critical modifications to the EZ-USB framework, I finally had success convincing the hidconfig program to see my device as having an LCD.

Next step was to find a suitable display to hack onto the EZ-USB board.  A couple of years back, I picked up a cheap display from SparkFun for another project, which I never got around to working on.  So, it sat in a box for a couple of years, and I thought it would be a good idea to dust it off and put it to use.   I had many other displays that I considered, but various constraints like required supply voltages, different logic levels, etc., conspired against them.

The display is serially interfaced, basically a 9-bit version of SPI. I figured the best first step was to just throw it on some I/O pins on the EZ-USB and bit-bang it.  In fairly short order, I was able to port one of the pieces of sample code from SparkFun and get the display painting the screen in different colors.  The down side to the bit-banging is that it’s extremely slow.  Unfortunately, the 8051 microcontroller in the EZ-USB does not have any hardware-assisted 9-bit SPI-like mode.  The closest it has is an 8-bit mode, known as “serial port mode 0.”  After much brainstorming, I could not come up with a practical, workable way to use the 8-bit mode to my advantage.  After giving up on that approach, I decided if I re-ordered my I/O usage I could optimize bit-banging as much as possible.  Using the bit-accessible I/O, I knew I’d save a lot of instructions for things like strobing the clock line.  I kept the data pin on a non-bit port at the highest bit, so I could simply left shift the data through the port for each phase of the bit-banging.  If I end up using one or more of these displays on my final pendant design, I may end up using a CPLD to create a hardware 9-bit shift register to further optimize driving this display, as even with my optimizations it’s a bit sluggish.

Anyway, here it is, with a simple configuration set up from hidconfig to have it show X, Y, Z axis positions, their homing status, and some system run status.

[youtube 8v1zxzE_kgk]

Related Posts

Project Frankenmill – Part 33, Claustrophobia

Final positions for the DIN rails and wire management have been nailed down. It’s much more tight than one should really wire a panel like this, but…

Project Frankenmill – Part 32, You’re Gonna Need a Bigger Boat

It seems to be a rule that no matter what size electronics enclosure you have, you will always have at least 10% more stuff that you need…

Project Frankenmill – Part 31, Full Pull

While I still haven’t gotten into the detail of squaring and tramming, I’ve been intensely curious to see if the new Z axis would be happier with…

Project Frankenmill – Alpha and Omega

Since 2009, I’ve been messing around with CNC machines. I started out with a small manual milling machine from Grizzly, and converted it to CNC using a…

Project Frankenmill – Part 30, Do You Even Lift Bro?

Hauled the column back down to the shop and mounted it back on the machine. Sure is a lot heavier than it used to be! Muscling things…

Project Frankenmill – Part 29, More Machining and Motion

Had some productive time in the shop during the holiday. First step was to make the counterbores for the M6 cap screws a bit deeper. Easy to…

This Post Has One Comment

  1. Hi,
    i am building similar panel, but I am dealing with USB descriptors problem. I can send data to the EMC, but not OUT. I dont know where is the bug, whether in descriptors or somewhere else. Would you mind to send me your working USB descriptors. It would be very helpful for me.
    Thanks

Leave a Reply to Rob Cancel reply

Your email address will not be published. Required fields are marked *