April 2008

You are currently browsing the monthly archive for April 2008.

Weeks ago, while I was trying to interface my mainboard with a DC motor controller board, I had to dive into the i2c protocol. Serial com. couldn’t make the deal, as I plan to connect several daughter boards, thus need to address them. Although RS485 was also possible, it implied a lot of changes, particularly on the PC side where I’d need an adaptor…

Anyway, just as blinking a LED, i2c is a must-have protocol. Several links helped me a lot, like this one explaining the whole theory, step-by-step, message-by-message. But the most helpful documentation still remains PIC 16F88 datasheet, and the Application Note AN734A which explains quite well how to implement an i2c slave as a state-machine. An interesting post is also explaining this very same App. note has a lot of bugs. I wouldn’t say “a lot”, still there’s a little bug about clock stretching: CKP must be set to high when receiving a NACK. Anyway…

So, this time, this is about setting an i2c communication bus between two PIC 16F88, using Jal v2. The first thing to note is 16F88 implements SSP (Synchronous Serial Port), but not MSSP (Master Synchronous Serial Port). This means 16F88 can’t be just configured to act as a i2c master, all of this must be done in software. Good news is jal v2 standard libraries come with an i2c module, which can handle all the i2c protocol subtleties, from a master point-of-view…

This jal v2 master implementation isn’t based on interrupts: since it’s the master which decides to take control of the bus, there’s no need to react to external event… except when using Multi-Master i2c bus. To help this, 16F88 can be configured to generate interrupts on START/STOP bits (which defines when the bus is available or not). A Multi-Master i2c bus seems great but I didn’t give a try, regarding all the debugging time it took me to set a “simple” 1-Master/1-Slave bus.

So, the master part is ok, now the slave part. This is where things are getting tough. Particularly without any oscilloscope or digital probe/analyzer. 16F88 can be configured as a hardware slave i2c. An IC address must be set, it must be the same as the one the master is using… This is what I’ve first thought, but it’s not actually exactly true ! Actually, SSP must be configured so SSPADD contains a 8-bit address, that is, with the 8th bit setting read/write address type. Whereas in Jal, IC address is coded on 7-bits. This means, for instance:


Jal slave i2c master
(declared slave address)
Hardware i2c slave address
0x2E = 0b00101110 0x5C = 0b1011100
That is, if the slave is declared to have 0x5C address, the master will have to talk to 0x2E as jalv2 is actually shifting 1-bit while building a write- or a read-address. As usual (and as everyone seems to report), i2c com. problems mainly come from address issues.

Setting a i2c bus is quite easy, from a hardware point of view. SDA and SCL pins must be connected on each side, on a bus using pull-up  resistors to +5V. Different values can be used, they’re determining the stability and the bus speed. I’ve successfully tried 2.2K and 3.3K, these are standard values.

Finally, here’s a two small Jal programs to test this i2c bus. The master 16F88, also connected via UART, gets a character from serial (from a PC), echoes it and send it to slave 16F88. This ones gets this char, process it (char = char + 1…). The master then gets the result and send it back to the PC. So, if you type “a”, you’ll get “a” as echo, then “b” as the slave’s results.
PIC 16F88 i2c Master PIC 16F88 i2c Slave
simple_i2c_master.jal simple_i2c_slave.jal
I’ve just build another board, using toner-transfert-system (TTS). Last try required lots of trials/errors, still leaving unanswered questions… This time, the first try was perfect. Here’s my ultimate recipe:


    • I use glossy photo paper for laser printer (135g/m2)
    • wash your PCB board with soap, then with window cleaner (or detergent with alcohol).
    • sandpaper your board with ultra thin paper (600, one used for body car)
    • wash again the board with soap, then with window cleaner. It must absolutely be dry.
    • preheat the board, with your iron (max temperature, mine doesn’t heat a lot)
    • place the paper on the board. Be careful, it’ll instantly stick to the board.
    • iron the paper. Apply a lot of pressure, all over the board, for ~15min (yes a long time, but it may depend on your iron)
    • continue with the iron tip, and redraw all the circuit (black tracks will appear through the paper), for ~5min.
    • Ironing time: ~20min
    • then place the board on hot water, no soap. Soak it for 30min.
    • peel-off the paper. Most can easily be removed, only the last layer, where the toner sticks, will mostly remain on the board.
    • soak it again for 1h
    • peel-off again the paper. You may need to remove very small portion of paper, between the tracks. Leave the paper on  the tracks, it won’t bother while etching since tracks remain accurate. This can be time-consuming, but be precise. Also don’t be paranoid, the toner really stick well to the board and won’t be removed easily
    • once done, dry the board. Check if you’ve missed some paper.
    • clean the board with window cleaner. While it won’t remove toner, it’ll help to remove paper residue and get an accurate board.
    • you’re done. You’ll then need to etch the board. Once done, remove the toner using acetone (nail polish remover works well)

Here’s some pictures:

Once all paper has been peeled-off, here’s the global result: tracks are still covered with paper, but the whole seems accurate. Zooming shows tracks are perfectly accurate, even holes in pads. Text is too fuzzy won’t be rendered well if left as is. Using window cleaner can help removing extra paper residue.
Paper on tracks is clearly visible here. Important is the way limit between tracks and copper is clean, accurate. After etching, here the result. Everything looks nice. There are two pen traces which I’ve added. The big trace on top of the board isn’t consistent at all. Using a PCB pen is definitively not reliable…
Once cleaned… Great… Even text is readable :)
Tired of using a PCB pen to build my boards… Too time-consuming, not really repeatable, dirty… So, I’ve tested this method and here some results and thoughts.This method consists in printing circuit using a laser printer. The paper is then ironed on the copper side of a board. The toner is transferred: you have a nice circuit drawn on your board. Because the toner is composed by small plastic particles, it protects tracks while etching the board. Results: a amazing PCB board, easy, cheap, fast.That’s theory…Originally, this method seems to be first used by Thomas P. Gootee. While it exists commercial and expensive paper doing this (Press’n Peel for instance), he observed he could get the same results using some glossy photo paper, used for inkjet printers. The kind of paper is the key factor. And the iron temperature too. And also the ironing time. And the way you peel off the paper. And how you prepare you board. And also how you soak your paper. Lots of parameters, few data…

I’m not comfortable using glossy paper for inkjet on a laser printer. It can stick on the fuser and ruins the printer. Some people mentionthis. Others pretends to nice results using normal, standard paper. Some also have amazing results using mailing label backing paper, or glossy photo paper for laser printer. For now, I have tried standard paper, label paper and glossy photo paper for laser printer(see following results, except for label paper: I didn’t even managed to print on it…).

Everyone seems to report it. The board has to be clean. Very clean. Some are saying it’s important to prepare it using sand paper (or the like) so the toner has something to grip to. I’m always following those advices: clean the board with soap, use very thin sand paper, clean it again with soap, then clean it again with window cleaner to help drying it. It’s ready.

About my iron, it’s an old one. It doesn’t heat a lot. I tend to iron a lot of time, while I’m not sure it’s a good idea. I think it depends on how the toner has been fixed onto the paper.

While I was trying to build a new SirBot Mainboard, I took several pictures to report what I’ve done, what failed and what has been quite a success…


My first attempt was using standard paper. This was a on very small testing board, and results were amazing. Then I tried on a real PCB (photo). Several times. At least 4 times (maybe 5). And it always failed…Anyway, whatever the paper type is, the board has to be a little bit larger than the paper. Ironing will be easier and everywhere the same (hopefully).
Again, whatever the paper, the board has to be cleaned and prepared usingsandpaper. I use very thin sand paper, one used to sand body car. I clean it using soap and ultimately using window cleaner (or something with alcohol): it helps to get a dry board.
The paper is then put down on the board, toner side on copper side. Pre-heat the board (using another paper, without any dust or the like). While you stick the paper to the board, be sure you’re right because the toner will instantly grip the board.
Iron the paper. Use a lot of pressure, everywhere. For this board, I’ve tested different ironing times: 5min to 12min, all attempts have failed…Iif you’re not ironing enough, some tracks won’t stick to board (I’ve observed). If you iron too much, tracks will get fuzzy (I’ve never observed it). I think ironing this board (10cm x 10cm) for at least 10min is ok.
So far so good… One ironed, put the board on water. Hot, cold ? With ot without soap ? Some say putting the board a cold water help the toner to fix the board. I’ve experimented it: the toner also seems to diffuse on the paper, make it harder to remove. But remember, that’s a standard paper, so it may be ok for other type of paper. Soap can also help to remove the paper. I tend to put the board on medium hot water (same temp as for dishes), with a little soap…
After 15min, the board shows bubbles on its surface: every piece of paper without toner gets unstuck (remember, standard paper). This clearly shows how well the toner has fixed the board. That’s promising… You may not observe those bubbles using glossy papers.
You can then start to gently rub the paper. You should be able to easily remove most of the paper. Only the last layer will cause problems (and still cause problems…).
You should not doing this, but who could resist… Just be sure not to damage any tracks.
Finally, after 30-45min, you can get this type of results. Some paper is still stuck onto the board. And won’t be removed, even after soaking it overnight.Now, 2 options:

  • you used standard paper: the remaining paper makes tracks fuzzy, dirty. You can’t remove it without damaging them. Like the paper, you’re stuck…
  • you used glossy paper for laser printer: there’s also remaining paper (less, though), but tracks still look thin. That’s ok, you can probably etch the board :)
This picture shows tracks covered with paper, using standard paper. Some tracks are damaged, but the most important thing here is tracks are fuzzy, due irregular paper residues. If etched, you won’t get a workable result…Now, may I iron the board too much ? Not enough ? Some tracks did not stick to the board. I tend to say “not enough”. This is plausible as my iron doesn’t heat a lot. Next time I’ll try ironing it at least 20min…
Another one… this time using glossy photo paper for laser. While there’s still paper on tracks, those are accurate, well limited and quite consistent. Having paper residue is not a problem, it’s the way it sticks that is important.
Some tracks were damaged (still). I needed to double-check the board andcorrect those errors with a PCB pen. Note, on this pictures, one pen trace doesn’t mean one error: I redraw some of the tracks too make them larger. There were maybe 3 errors for the whole board. I think µI didn’t iron enough.Once ready, put the board into etchant. I continually move the board into the etchant (for 18min for this one), to be sure the board is etched everywhere, equally (hopefully).
Tadaaaa ! Nothing to say except tracks are nice…
Clean the remaining toner. People say it cannot be removed without acetone. I use nail cleaner without acetone, and it works perfectly.
Tadaaa (again) ! Ready for soldering !
A nice looking result. I can even read “SirBot Project   Mainboard” and the very small date “2008-04-08″.
So, what to say ? Using standard paper won’t produce good results ? For sure, at least for me. A glossy photo paper for laser printer is the minimum required. This is also a very first result. I needed a lot of attempts and I’m not even sure this is all repeatable. Probably the tricky ironing step needs for experiments. For now, I need to solder components on my new “half-professional looking” PCB…
Eagle is a great tool to design PCB board. I’ve used it to design my new mainboard. In its non-profit version, you can build board with two layers (bottom, top). But I only have single sided copper boards. So I used to deactivate, declare as forbidden the top layer. Often, Eagle can’t create 100% routes, so I manually creates vias and straps (straps are wires, not tracks, maybe not the correct english word). Quite annoying, time consuming…
Following is a simple tutorial to let Eagle build its own vias and straps to reduce manual actions. This is a two steps approach
    1. Since I want to have the minimum straps, I declare the top layer as forbidden. This forces Eagle to create as tracks as possible on the bottom layer.
    2. Then (and if not 100% routing done), I activate the top layer, but declare it as costly. Eagle will finish its work, still creating bottom tracks, and adding small top tracks through vias, which I can then convert (consider as) to straps.
Just a reminder here. Since I use a PCB pen, which can’t produce accurate results (because of the pen and I), I configure Eagle to create quite large tracks. 32mil works for me. This constraint will help while actually drawing tracks.
Same things while drilling holes. Drilling is quite critical, it can easily destroy your board.
So, first, top layer is deactivated. This is defined in the Design rules menu entry.
One eagle has done its job, 79.8% routing is done. Not one top tracks is created. Still several routes need to be created. Here’s the second step…
This time, the top layer is activated…
… but it has a high cost compared to the bottom. Without this setting, Eagle will long top tracks, which can’t considered as short straps. [Edit: cost value on top layer must also be set to 99 -- or the like -- for all Optimize tabs, otherwise Eagle will create long route during optimisation]
Now 100% routing is done. Several short top tracks were created (red). Most can be considered as straps.
  And some definitively can’t… This is where I still need manual work. For instance, few top tracks are going under components here. Since wires (straps) are quite thick, there’re problems here. This occurs when Eagle directly connect tracks with pads. I didn’t find yet where to forbid this.
I need to move the bottom tracks outside of components, and recreate the straps. There’s still manual intervention, but let Eagle optimizing routing produces better results than humans can do (as least me…).