Posts Tagged ‘smart house project’

New CAN Main Board

I made a few adjustments to the board layout and also to the pcb-gcode setting and milled another circuit board. This one turned out nicely, even with a couple hiccups. First, the board wasn’t taped to the fixture exactly level, so a corner with nothing important didn’t mill through the copper (it was only the board outline). Then a phantom E-stop signal stopped the machine before it was done and had to restart from the beginning (I upped the debounce value to correct this). I thought it was another beverage coaster while watching it mill, but let it finish and it turned out fine. I ran the drill routine with a .035″ bit and everything but the screw terminal block and power jack fit. I was able to make the terminal block fit by sanding down the edges of the pins, but the power jack I’ll just use some wires and plug later.

Freshly milled CAN Main board, version 0.2.

Since the majority of components fit, I soldered this one up to give me an idea of what the next round of changes need to be. The main one is to increase the size of the pads to make it easier to solder and to increase the isolation path around them to prevent bridges to the ground plane. I’ll also have to change the through holes to the right size in the Eagle component library I made. At least the spacings were all right so everything still fit. Another change will be to the text ratio so the thin areas of copper don’t peel off when milled. They probably would have been fine if the second pass wasn’t done, but whatever.

Just needs a power connection and it’s ready to go.

Anyways, the CAN Main board only contains the basic circuit to run a 18F4580 micrcocontroller with the MCP2551 CAN transceiver; power from a 7805, 20MHz crystal oscillator, ICD plug, reset button, CAN status LED and then the rest of the pins are brought out to female headers to plug in a shield. I also included an area for the CAN bus termination resistor and three capacitors with jumpers, and a place to connect the cable shielding to the board’s ground. There is a jumper to bypass the 7805 regulator to use a 5V wall wart directly which are more common these days.


Troubleshooting a CAN Circuit

I’ll bet the term troubleshooting came from someone who had trouble, then started shooting. At least that’s what I would do if I still lived in an area where I could shoot something (damn neighbors). I’ve been trying for weeks to get the K-Node circuit to work with any of my other CAN capable boards, with no avail. First, I thought the bus had too much noise, and used the oscilloscope to find a extra 60 Hz wave causing mayhem. This was removed without success and then thought a shitty clock signal was to blame. It only slightly was inhibiting communication (it only caused a few errors, but not enough to totally block the message).

Anyways, turns out the CAN transceiver was screwed up beyond use. The MCP2551 chip is very sensitive to whatever, and fries when either of the bus wires are disturbed. I should have known, but didn’t. The previous post outlines my attempt at clearing up any extra noise on the bus. Then thought it could have been an inaccurate clock to the microcontroller. I bought some nice 20Mhz oscillators and replaced the crystal/caps on both the SpartaNode and K-Node boards, without success.

So before I threw both circuits, the scope, and all the other equipment I have out the window, I replaced the MCP2551 IC. Of course it worked right away. Guh, I suppose the lesson here is to make sure the CAN bus wires are secured very, very well and to absotively, not-arino hot swap the wires. I’ll pretend it wasn’t all for waste since the random, mysterious communication errors don’t show up during testing. Now that I can send a message between the K-Node and SpartaNode, I can run the CAN bus through my house and really test the system.

The Physical CAN bus

May 21, 2012 4 comments

I made some long overdue progress on my Smart House project that uses CAN bus. Up till now, the physical bus were two scrap wires I twisted together and soldered on a couple pins for plugging into breadboards. This wasn’t going to be an option once it was time to run the actual wires through my house, since it will be more than a few feet. A search for a single twisted pair, around 18 AWG and unsheathed yielded nothing, unfortunately. I settled on some security cable, which is two conductor 22 AWG, shielded and sheathed, as well as readily available for cheap at any hardware or big box home store.

Noisy noise on CAN bus.

For a test bus, I randomly cut a piece 12 feet long and soldered on 120 ohm resistors to each end, then connected to the K-node and SpartaNode. Of course it didn’t work, and probing with an oscilloscope showed a nice 60 Hz wave causing interference. The wave was present with or without power on and also near or far from other wires. The interference wave’s amplitude varied from about 1 volt peak to peak, to over 3V when moved around and was superimposed on any CAN messages on the bus. I suppose Murphy’s electrical law was in effect; the one about a wire being an antenna when you don’t want it to be.

How to get cap values.

The good news is the book, CAN System Engineering, held the solution. By using three capacitors per end, all the 60 Hz wave was removed and a crisp CAN message was able to travel just like in the test setup. The values of the capacitors are the same for both ends and depend on the length of the bus. For mine, I needed a 68pF cap between the CAN High and Low wires, and two 220pF caps from each to ground. I soldered these to the board (but just realized I shouldn’t have, d’oh) and added a place to connect the cable shield. The two nodes are still showing a communication error, so the same CAN message is being repeated for a response, but the at least you can see it’s nice and clean looking. I suspect it is a software issue.