Archive for the ‘ Controller Area Network ’ Category

SPI Backpack PCB for Liquid Crystal Displays: Part 4 LCD library

Adafruit’s LiquidCrystal backpack library doesn’t use the Arduino SPI library to send data to the 74HC595 chip. They just shiftOut bits directly, which works fine if the only device is the backpack.  However, the fazjaxton CAN library does call the SPI library.  This caused major problems when switching back and forth between CAN and LCD because the clock rates were way different.

I decided to investigate the LCD 74HC595 SPI implementation by Juan Hernandez from the Arduino playground which uses the Arduino SPI.  It took quite a bit of time to get that library working because Hernandez uses a different pinout connection from the ‘595 chip, and did not have the LCD backlight control.  Since I already have the PC board cut for the Adafruit pinout, I had to figure out how to rearrange the Hernandez code.  Once I finally got his HelloWorld-SPI demo working though, it was simple to add the backlight bit, and I could modify the head end sketch to match. I changed the LCD code to use the same SPI clock rate as the CAN and they play together very well now.

This is the backpacked head end with new code displaying light level and temperature from remote station 31.

LCD display at head end node

LCD display at head end node

SPI Backpack PCB for Liquid Crystal Displays: Part 3 Assemble and Test

The completed printed circuit board needs to be stuffed with components.

Populating a PC board is best done by placing the shortest components first and the tallest components last.

So first to go on are the Z wires. These connect traces on the bottom to traces on the top.  They are necessary because this homemade board does not have plated through holes.

Z wires

Z wires

The next higher parts are the resistors.

Adding resistors

Adding resistors

Next capacitors, chips, and the crystal.  Some of the leads have to be soldered on the top and on the bottom of the board.  Again, this is because I do not have plated through holes.

Add capacitors and chips

Add capacitors and chips

Now I attach the CAN connector, the contrast pot, and the header that mates with the LCD. These are the tallest parts

Add connectors, headers, and the contrast pot.

Add connectors, headers, and the contrast pot.

Finally, some rainbow wire to connect the backpack to the Arduino.  Also the backlight switch transistor at this time because it took a while to find one in my junk box.

Add wiring and the backlight switch transistor

Add wiring and the backlight switch transistor

Finally solder it onto an LCD display and see if it works.

It does!

Remote light level and temperature on the display

Head end prototype showing light level and temperature from the remote

Head end prototype showing light level and temperature from the remote

The project needs quite a bit of work on the software to be effective. The two SPI functions seem to interfere with each other.  Suspect a library conflic.

SPI Backpack PCB for Liquid Crystal Displays: Part 2 Print to Finished PCB

In this part I’m showing a method for transferring the laser printouts to double sided PC board material.

Double sided printed circuits must have the top and bottom masks perfectly aligned.  I begin by using a sharp scribe to pierce the exact center of each corner hole on both the bottom and top layer printouts.

Starting holes for alignment

Starting holes for alignment

Next I insert one of these tiny nails (3/4″ #18 gauge) into each corner of the bottom mask.  I could use sewing pins but nails have flat heads which keeps them standing up during the next steps.

Alignment nails

Alignment nails

The next photo shows the bottom layer printout with alignment nails inserted into the mask’s corner holes. If I was making a board without convenient holes, I would add holes to the Eagle drawing outside of the board area and just trim them off after completing alignment.

Bottom mask with alignment pins

Bottom mask with alignment pins

Now I take the top layer mask and carefully slip it face down onto the alignment nails, smooth it out and tape the top edge. The tape maintains the mask alignment from here on.

Top mask aligned with bottom mask

Top mask aligned with bottom mask

Next I removed the four nails.  In this photo you can see how the two masks align face to face. Holding the aligned sheets up to a strong light should show any problems.

Top and bottom masks aligned

Top and bottom masks aligned

I’ve scrubbed the blank PC board material with fine steel wool and wiped it down with lacquer thinner. It cannot have dirt or fingerprints.  Now that my masks are aligned I can position the blank over the bottom printout. I use bits of Kapton tape, though the board should stay put without tape if the paper is not moved before applying the Iron. I cut the blank about a quarter inch oversize on all sides to make this step easier, the excess will be trimmed off after etching.

Blank PC board on mask

Blank PC board on mask

It’s time to heat up the Iron. I use the highest setting, which I think is still a little cool.  I let it sit on the mask/board/mask sandwich for two minutes to make sure the copper is hot enough to melt the toner. There’s a slab of MDF underneath the paper so my workbench doesn’t get cooked.

Ironing the toner onto the board

Ironing the toner onto the board

I remove the Iron and immediately use a small rubber roller (brayer) to press the mask firmly onto the copper.  Not sure this step is necessary but I think it helps even out the transfer when the Iron face is not perfectly flat, or the Iron temperature may not be even across the face.  When the board has cooled a bit, turn it over, repeat the heating and rolling process on the other side.

Rolling out the toner

Rolling out the toner

When the board has cooled enough that you can handle it, trim away most of the paper but leave a little bit around each edge. Be careful at this stage, pulling the paper off will ruin the toner transfer.

Finished mask transfer

Finished mask transfer

Next the paper has to be carefully removed from the board in such a way that all the toner is left on the copper.  I put the sandwich into a tub of warm water with a small amount of dish soap. In a half hour or so, the paper will begin to disintegrate.  Just rub the paper gently with fingers, center towards the outside, and it sloughs off easily.  If a bit is stubborn, give it more soak time. You must remove all the paper from the areas that will be etched.  Paper left on the masked areas is OK.

Removing the paper from the toner

Removing the paper from the toner

This is the transferred board dried and ready for inspection.  The toner is somewhat delicate so you can’t touch it.  I use a visor magnifier and check all traces for complete coverage.  Repairs can be made with a fine point Sharpie pen though I believe a typewriter correction pen would work better.  Sharpie ink is too thin.

I painted the quarter inch of excess copper around the board edges with typewriter correction fluid and it stood up well to the etch bath.  Also have to watch for smudges in the mask.  My old laser printer has a tendency to drop toner in random places, I have to scrape these off with the scribe.

Toner transfer finished

Toner transfer finished

Finally into the etch bath.  I’m using the aerated cupric chloride method as learned from Jim Williams. I have a good size aquarium pump feeding four air stones at the bottom of a 4 inch square etch tank.  There’s about a pint and a half of Muriatic acid in there. I pull the board out every minute to check progress. In this photo it’s about 2/3 done on one side. At that point I turned the board over so the other face got the bubbles.  Took about 15 minutes to do both sides.

Into the etch bath

Into the etch bath

It can be difficult to see when all the copper is removed.  You have to inspect both sides carefully.  Here I placed the board fresh from etching onto a florescent light so I can see through it.  The alignment is looking pretty good as evidenced by light through the pad holes, and I’m not seeing any shadows where the copper was removed.

The etched board

The etched board

All that is left now is to clean off the toner with Lacquer thinner, trim it to final size with my big garage sale tin snips, and drill  holes with a #64 bit in a Dremel tool.  This composite photo shows the top and bottom after drilling.  You can see the pad alignment around the drilled holes is very good.

Completed board ready for components

Completed board ready for components

SPI Backpack PCB for Liquid Crystal Displays: Part 1 Design & Print

In my previous posts here, I constructed Controller Area Network shields using single sided PC boards.  They work well, but now I want to combine the MCP2515 CAN driver circuit with a 74HC595 serial-parallel converter so that an LCD display and CAN network can share the SPI buss.  This is more complex than the CAN shield alone so a double sided PC board is in order.  The two circuits I’m referencing are both available in Eagle board files.  After about a week of learning Eagle and dozens of Auto route passes, the following design emerged.

I’m using a laser printer toner transfer method to lay out PC boards.  This  board is the same physical size as the common 16×2 LCDs, 3 1/8″ x 1 3/8″.   Ironing on the toner spreads it a little so I need a design that has plenty of clearance.  Since there are no plated through holes, I need to minimize vias, and force wiring to the bottom layer if it is not possible to solder the component on both top and bottom. It amazes me how nudging a component a couple of millimeters can drastically change Eagle’s routing.

Image

There are many web pages describing how to etch PC boards using laser printer toner as resist material.  There is an active forum on Yahoo with lots of information.  Results reported vary a lot depending on the printer and paper used.  All toner formulas are not equal.

Laser toner is ground up plastic with black material mixed in.  Letters are formed by electrostatically attracting toner particles to the paper, then melting it in over a heated fuser roller. It is possible to re-melt the toner and transfer some of it to the copper surface of a blank PC board.  The paper that works best is high quality photo grade stock, but thin.  This type of paper has a high clay content to make the surface glossy, and ink that hits the clay drys immediately and won’t smear. Slick magazines like these qualities, so many people use magazine paper to print their PC board patterns.

My laser printer is an old Lexmark 4039 10+. It has an extra dark setting that makes toner transfer easier, and has a rear single sheet paper feeder and front exit slot. This gives a very straight paper path so the printed copy doesn’t curl up.  Here is a photo of the two prints needed to make my LCD backpack.  The paper is torn from an old Digikey microcontroller catalog. Note: always cut the torn edge off with scissors before running through the printer else it will catch inside and jam. Don’t Ask Me How I Know This.

Image

It’s difficult to visualize how the top and bottom of the design (top photo) is going to work when applied to the PC board (Don’t Ask Me How I Know This either).  Eagle has a “mirror” button in the print requester.  You use this when printing the top layer, but not when printing the bottom layer.  If you did it right the two prints will match up when placed face to face.  Why mirror the top and not the bottom? Remember that both images are mirrored when they are transfered to the PC board – so the top gets mirrored twice resulting in a non mirrored resist, and the bottom gets mirrored once resulting in a reversed image. Eagle knows this. Any text Eagle puts on the bottom layer is automatically backwards on your screen but prints correctly on the PC board.

SPI Sharing

Adafruit recently announced an LCD “backpack” that has decoders for SPI and I2C communications between an Arduino and an LCD display.  As is their policy, they open sourced their modified LCD library and made the schematic available.  The SPI portion of the device uses only a single 74HC595 eight bit serial to parallel chip, which I happened to have a few of.  So I decided to try sharing the SPI buss between the MCP2515 and a liquid crystal display.  This means I can add a display to one of the nodes by using only one additional pin on the Arduino.  With the help of Adafruit’s example code (and a very similar entry in the Arduino playground) I have a 16×2 LCD breadboarded using pin 9 as slave select for the ‘595 chip.

Arduino breadboard with SPI liquid crystal

Arduino breadboard with SPI liquid crystal

In this photo there are only five wires connecting the Nano to the CAN chip and the LCD.

Adafruit’s library can turn the LCD backlight on and off also, so you can blink the display to draw attention.  This particular LCD doesn’t have a backlight though.  Also I commented out all the I2C stuff in the library and saved 1k of memory.

Next step:  cut a PC board with the CAN chips *and* a 74HC595.

CAN Polling network

I added a variable to Kevin Smith’s library, the remote frame bit requests a response from other nodes on the buss.  With this I was able to implement a polling scheme. The master requests a data update every 10 seconds and only then will the remote transmit routine readings.  This cuts down chatter on the buss.  I also partitioned the 11 bit id field into a 5 bit node identifier and a six bit data type indicator.  Each remote station will be assigned a unique identifier, in this photo, the remote is number 31.

Remotes can still broadcast autonomously, for instance a notification that a door is opened will be sent immediately to all master nodes.

Wish I knew more about C++ to deal with these libraries.

CAN Polling network

Master polling the remote for data

More Adventures with CAN

I’ve now etched and assembled three of the CAN transceiver modules, two with shield headers and one without as a breakout.  I probably should have made them all breakouts because you can’t easily get at the Arduino pins when the transceiver is plugged in.  I had to epoxy the headers to the transceiver board because on the single sided board there isn’t enough copper for good physical support.  Also discovered the bearings in my Dremel tool are going bad. In the good news department, my Cupric Chloride bath worked OK on the second batch of boards after about five hours of air bubbling to regenerate after I dumped in two feet of number six wire to get the Cupric  concentration up.  I’m not a chemist, I don’t know what I’m doing, but it works.

Two Arduinos are now wired together in a CAN network. One is reading a photocell, also an LM34 temperature sensor and it’s transmitting those measurements every second to the other node.  At the destination, temperature and light readings are shown on a 16×2 Liquid Crystal display. The software is based on one of FazJaxton’s examples.

There is 100 feet of CAT5 cable between the two transceivers in the photo. Only the blue pair is connected, CAN doesn’t need a ground.  In a home monitoring network, CAT5 is a logical choice as it is easy to find. and the other pairs could be used to feed power to the remote sensor nodes.  Don’t know if CAN will coexist with 100bT Ethernet, will have to try that some time.  Another possibility is standard telephone wire (IW) but would have to find the twisted kind.  Most telephone wiring is two pair and only one pair is used.  So if the stars are aligned correctly, you could use the other pair in your existing phone jacks for CAN.

Two node CAN network

It’s a bit of a pain to develop two Arduino nodes at the same time as the USB serial ports keep moving around every time you unplug a cable which confuses the IDE.

Maybe tomorrow a third node.