RenumKiCadPCB V0.205 Bug Fix

I was hoping to produce a version of RenumKiCadPCB in a few days but moved things up after I got a bug report (plus fixed code!) from Sean Happel. Long story short a function I wrote to scan for component fields like F0, F1, and so on, didn’t care if the field started on a new line.

V0.205 fixes this bug with Sean’s code and now updates the netlist file. Previously RenumKiCadPCB updated the board and schematics but left the netlist alone since I figured it was trivial to regenerate the netlist. Admittedly this was pretty stupid of me as I often forgot to update the netlist before importing it.

Here is the source, manual, and Windows executable for V0.205: RenumKiCadPCBV0.205

So, now all the relevant files are updated with the proper reference designations.

There may be other bugs in the code: stress testing on Olimex Diylaptop project fails. order to debug a large project like that I have decided to make some relatively significant changes to the code so the updated files will not be committed if there are errors unless directed by the user. In other words, if there are errors in the input files, the user will be asked to commit the changes or abort updating the files.

I hope to release V0.206 once I have fixed that *and* figured out why Diylaptop fails. Of course, if other bugs are reported I’ll fix those first.

The Kicad “pour error” still seems to be present in Kicad V5 nightly builds, however I don’t know how to fix the error in V5.

Also, it seems to me the best time to run RenumKiCadPCB is prior to routing the board rather than just before making the Gerbers, which is what I have been doing. That way any missing component issues will beresolved early. No sense routing a board if the schematic and PCB have different parts!

I have suggested to the folks at KiCad to assign someone to incorporate RenumKiCadPCB into the code base. This should be easy enough to do but I lack c++ and GUI skills so I can’t do it alone. If there is anybody out there willing to do encourage the KiCad development group, please do.

Similarly, I would welcome anybody with c++ or GUI programming skills to put a wrapper on the code. A GUI would likely widen its appeal.

Thanks for using the code, and thanks for the bug reports!

 

RenumKiCadPCB V0.204: Bug Fix

Thanks to Phil Guiet for finding this bug and providing me with the Kicad files to track it down!

I was unaware that you can change the layer names in PCBnew. Well, I knew you could change the layer names but I wasn’t aware that the file structure would carry those names instead of F and B (Front and Back).

Therefore if you changed the top and bottom layers to something other than F or B RenumKiCadPCB would crash – which is never good. Now the software keeps track of which layers the modules are on, regardless of name. And it should no longer crash.

This is the link to V0.204 (source, manual, and a Windows EXE) RenumKiCadPCBV0204

Please let me know of any other bugs.

Compiling RenumKicadPCB/Linux Mint

User Jano has found that the compilation instructions for RenumKicadPCB under Linux Mint should include -lm (see https://documenteddesigns.com/2017/03/27/renumkicadpcb-v0203/)

“I just compiled and used your utility successful! Thanks. Just a note to compile I needed to ad -lm at the end of the gcc order: gcc RenumKiCadPCB.c -o RenumKiCadPCB -lm my system is linuxmint 18.3, after that it worked perfectly.”

My understanding is that -lm usually includes a library module (i.e. -lmMingw32) and I’m not a gcc guru so I don’t know what the -lm by itself does, but if you have problems give it a try.

Thanks Jano!

Hand Assembled SMD Board

I figured I’d post a photo of a board I’m working on.

It is an I2C to 20×4 LCD /keyboard  interface with support for an ESP8266-01 module plus the serial interface modules.

I ordered the solder paste screen from Elcrow and figured I’d give it a try. A couple years ago I picked up a convection toaster over from Walmart and modified it so the fan would run always on.

There are lots of tutorials and such about making a complex controller for “toaster oven reflow” but my approach is simple: I figured out the setting on the temperature dial so the solder melts then I made two marks on the dial: that point and a bit cooler.

I “pre-heat” the board at the cooler setting then move the dial to the “melt” setting for about 5 minutes, then move back to “pre-heat” after the solder melts, then after a couple minutes and shut the unit off.

This seems to work fine. My view is that the fixation with temperature ramps and the like is because those parameters are for volume production and that makes a huge difference if you are making a thousand units an hour.

This board was manually assembled using my technique. I had a bit of problem with the solder paste, probably because I used a silicone spatula (for cooking) rather than a proper spreader. The solder paste was about 3 years old but kept in the refrigerator.

DSCN0118

The picture was taken straight out of the oven, after I removed a bridge across Q1. The assembly is not perfect but that is mainly because of hand assembly and solder paste application, not the oven. In particular, I’d be happier if U4 was aligned properly but the soldering seems OK.

The board was designed and laid out with Kicad.

RenumKicadPCB V0203

I wasn’t expecting to post a new version so soon but while preparing some features I discovered an actual bug! Here it is RenumKicadPCBV0203

The bug showed itself when sorting on reference designations and the component orientation was not typical. Unfortunately the Kicad file formats are not very well documented and I did not realize that the reference designation offset was relative to the module’s angular rotation, not absolute. Therefore if the ref des offset was 0.1, 0.2, that doesn’t mean it was 0.1 to the right and 0.2 down relative to the module – it means it was 0.1, 0.2 relative to the original grid of the component. Its actual location is a trigonometry problem which is simple enough to figure out once you figure out what is going on.

So, the adjustment is

X offset = (( Ref_X_Offset * cos( modangle )) + ( Ref_Y_Offset * sin(modangle )));

Y offset = (( -Ref_X_Offset* sin(modangle )) + ( Ref_Y_Offset * cos(modangle )));

In addition to this bug fix, I removed the “Verbose” and “Show Change Array” menu options and instead create three log files:

  1. _coord.txt, which shows the module or reference designation coordinates and their “rounded to grid function;
  2. _update.txt which shows the nets, reference designations, etc., which will be renamed, and to what
  3. _change.txt which is just the reference designation change plan and show how modules were renamed by the code.

These files are pretty small and making them does not seem to have a significant impact on run time. They make it a lot easier to figure out the decisions the software made and its easier to ask for a file than to ask someone to “cut and paste” from a DOS terminal screen.

Besides the obscure bug corrected in the V0203, which I discovered, I am not aware of any errors made in sorting, file updating, etc.. Thus far unexpected results are not the fault of the software but a mismatch between the options used and the design. I actually found the bug because my “test project” ice-zum, has the reference designation for C1 in the place of C2 and vice versa so when sort on modules it showed C2 C1. It was only while correcting that design mistake I realized there was an unrelated bug.

I also cleaned up the code “map to grid” is done only once.

As always feel free to contact me if you have any issues, can’t get it to work right, etc..

 

RenumKicadPCB V0.202

Note: RenumKiCadPCB has been updated several times to enhance usability and fix bugs. Please check documenteddesigns.com for the most recent version.

 

This RenumKiCadPCBV0202 is the updated Windows 64 application and source code for V0.202 of RenumKiCadPCB.

I moved sorting from the confusing “jog” implementation to a grid based implementation. All module and ref designation locations are rounded to the nearest specified grid point (X, Y) prior to sorting. So a module at 23.1235, 19.568 would be sorted as 23.25, 19.50 if the grid is specified as 0.25.

Note that this does not actually move modules or text: RenumKiCadPCB only changes the names of things not their positions.

Also the “Sort on” default has been changed to “Sort on Modules” based on feedback I received from Nick Barton of Black Magic Amplifiers.

Although I usually sort by Reference Designations, Nick – who is a pro – believes “Sort on Modules” is a far more typical use case.

As always, you can change the “Sort on” parameter from the menu and since V0.201 these choices are “sticky” and saved for the next use.

Note that, unless reference designations, module coordinates are somewhat arbitrary and this may lead to strange results. For example if a diode has the cathode as the origin, two diodes side by side with one rotated (see below)

diodeexample

would be seen as separated by 1 cm (1/2″) on the Y axis whereas the reference designation text would be “on grid” and properly dealt with.

Dealing with “Bad” Renumbering

While there may be bugs in the code (please contact me directly if there are) most reports of “bad” renumbering are due to two reasons:

  1. Sorting of reference designations instead of modules or modules instead of reference designations; and
  2. Sorting of too fine a grid (or jog in older versions).

RenumKiCad PCB approaches the problem mathematically and if you have placed parts or reference designations 1 mm apart on the sort axis and the sort grid (or jog) is less than 1 mm it will see the parts as being on different lines and number them accordingly.

Remember – the software doesn’t know if you have done a coarse through hole design on a 2.54 mm (0.1″) grid or an ultra-fine pitch layout with 0.1 mm (0.005″) grid, nor does it know whether you have your module origins all in the “right place”.

The options to sort on modules or reference designation and to change the grid are there to provide flexibility.

So if you get a “bad” sort order, try changing the sort target from modules to reference designations and/or adjust the sort grid.

Usually increasing the sort grid fixes things up to a point as making it too large has the opposite effect as all parts will appear to be at the same point.

So try increasing it to 0.25, 0.5, or 1 until you get the desired result. Because the sort works on the original data you can simply run RenumKiCadPCB over and over again on your design until you get what you want.

Always make backups of the original.

I don’t know of any bugs which would ruin your project but I am not responsible – or even want to feel bad – if it does.

The only way I can improve this software is if you provide feedback. Please let me know if you use it and, especially if there are any issues.

 

RenumKicadPCB V0.201

Note: RenumKiCadPCB has been updated several times to enhance usability and fix bugs. Please check documenteddesigns.com for the most recent version.

I have added a feature to RenumKicadPCB. The program now stores parameters in a file called Renumparameters.txt in the directory it is invoked from. This means you don’t have to keep reentering the path to the file, etc..

Here is a zip file with the instructions for use, source code, and a windows 64 executable renumkicadpcbv0-201

RenumKiCadPCB V0.200

Note: RenumKiCadPCB has been updated several times to enhance usability and fix bugs. Please check documenteddesigns.com for the most recent version.

 

This file RenumKiCadPCBv0200 is V0.200 of RenumKiCadPCB.

RenumKiCadPCB processes a KiCad PCB file and renumbers all the component reference designators ending in numbers based on where they are located on the PCB. It then processes the schematic hierarchy and updates the component reference designators to match. This makes working on a board much easier since you can locate all the components.

V0. 200 includes a number of improvements including a rudimentary text based menu driven interface as well as the original command line. Some command line arguments have been changed to make more sense and some defaults have been changed as well.

V0.200 was also developed on MinGW instead of Cygwin so there is no need for a separate DLL – the executable is stand alone.

To run to the program simply type RenumKiCadPCB (command line arguments are now optional).

I have made and tested the file on Windows (executable included) and Ubuntu Linux. It should work on Apple but I have not tested it.

I hope to port the code over to a proper GUI once I figure out how to set up the compiler, etc..

Let me know if there are any issues, bugs, feature requests.

 

 

V0.103 RenumberKiCadPCB

Note: RenumKiCadPCB has been updated several times to enhance usability and fix bugs. Please check documenteddesigns.com for the most recent version.

This RenumKiCadPCB.V0103 is an updated version of RenumberKiCadPCB. Earlier today I posted v0.102 and 0.103 updates net names to correct some (but not all) issues associated with netlist imports and pours.

Since I take a second pass on the file to update nets it takes about 100mSecs longer.

Thanks to Andy_P at https://forum.kicad.info/ who tested the program and correctly identified that it did not handle hierarchical sheets.

The program has been extensively rewritten to support hierarchies and (I believe) “channels” or the same sheet repeated with different reference designators.

I also added the option to -c output a change list and leave the files alone and a -y option so you don’t have to type Y/N to run the program.

Thanks also to PCB_Wiz on https://forum.kicad.info/ who graciously proved a link to this project https://github.com/FPGAwars/icezum/tree/master/src-kicad (which is a beautiful project by the way).

After running V0.101 on PCB_Wiz’s icezum project, it seems to work fine. There is an issue if I then create a schematic netlist from the updated files and import that into PCBNew and run the DRC. One netlist is flagged no connects even though they appear to be connected. The name of the problem net is neither in the original (pre-run) PCB file or the post run file.

I lack the KiCad skills to determine if this is a problem with my code or the way the original files were made (I have had KiCad complain about files it alone had made)

It appears to be easy enough to correct but the project is too complex for me to understand. Note that this only occurs if you recreate the netlist.

If anybody has a similar problem and can reproduce it on a minimal project I can probably fix the code if there is a bug.

Please let me know if there are any issues.

 

Pinger: Hardware Design Documentation

What is Pinger?

Pinger is device which:

  • monitors Internet connectivity over WiFi by pinging a website;
  • keeps a log of when connectivity is lost and regained;
  • resets an attached router or modem through 1 “wet” (electrically powered) connection and 1 “dry” electrically isolated connection; and
  • is fully configurable via a web interface.

Besides being a useful device the software includes code which:

  • gets Internet time and displays it in human readable form (i.e. 2016/07/9 11:32:21);
  • shows basic use of HTML and a web interface (but my HTML code is awful); and
  • shows how to use the SPIFFS file system.

Background & Ancient History

Pinger is a project I started a number of years ago when I had unreliable wireless Internet based on 3G wireless. It not only cost a fortune ($400/month for 30GB) it was slow and a few times a week I’d have to reset my router. This was a pain in the butt, but something I could do. Unfortunately it is not something I could do while I was away from my home.

I started working on a solution with an Arduino and a Ethernet shield but, but I got new Internet service before I finished up so the need went away. A little while after that my friend Gabriel was complaining he lost Internet service regularly but his ISP refused to believe it. I figured a “logger” might help him out but his ISP replaced his modem and the problem went away.

One of the projects I have been working on for some time now is a control system for my geothermal hydronic heating system.The way the system is set up I can in principal control the temperature in each room individually but the control system I got when I installed the hydronics was too primitive to do that. As a result I have 3 zones, but, since I have a large house that means in the winter some rooms are too hot due to passive solar heating and some are too cold. I needed a system which could measure the temperature in each room and control the heat that way.

The problem was wiring 12 thermostats and 15 control valves would be a nightmare.

I recently started using the ESP8266 which is a complete 2.4GHz WiFi solution as well as a programmable microprocessor. I immediately realized I could use the ESP as a wireless thermometer (think Nest without the hype) and as a wireless control valve controller.

I settled on using the WeMos D1 mini because they as cheap – $4 on AliExpress – and as close to the ESP8266 as you can get. I originally chose a Beaglebone to use as the hub but when the Raspberry Pi 3 came out I decided it was cheaper and good enough.

As I started writing my code I realized I had to learn a lot about programming the ESP8266. I noticed a thread on reddit which discussed a commercial product similar to my Pinger project and I figured I would learn most of what I needed by completing Pinger on an ESP8266.

Pinger Hardware Design

Even though the software is fully written I’m going to start off with the hardware design.

Why Did You Use Through Hole Components?

I was an early adopter of Surface Mount Technology (SMT) when I was a design engineer. There are many reasons to use SMT:

  • SMT parts are often cheaper and more available;
  • SMT parts are smaller and therefore you can use a smaller (and therefore cheaper) PCB;
  • you can install SMT parts on both sides of the board; and
  • it is much cheaper make an SMT product on a modern assembly line.

However SMT is not ideal for hobbyists:

  • SMT ICs are hard to place by hand without damaging the leads;
  • you either need a PCB to make your project or you have to buy adapter boards if you want to build on a perfboard;
  • it is hard to solder the board properly with a soldering iron;
  • you have to know what you are doing to solder using paste/reflow;
  • it is hard to spot or repair bad solder joints; and
  • it can be very hard to use a multimeter and other basic test instruments on SMT components.

So, just to be clear I am a big fan of SMT and I have a reflow oven and all the stuff I need to do SMT, including a large inventory of parts and adapters. However most people don’t so if I am going to publish a design I’ll make an effort to use through hole parts as much as possible.

Why Kicad and Arduino-Eclipse

The schematics and boards were designed in Kicad 4. Kicad isn’t perfect but it is free and very capable. I used Eagle for a while but started running into limits with their free license. I can afford to license Eagle but you never know when the license terms are going to change. Besides how would you open the files?

Because the software consists of several modules and is a few thousand lines long (I do use comments) I switched from the Arduino development platform to Arduino-Eclipse V3.  Eclipse is not a perfect IDE but it is a huge step up in quality from the Arduino IDE. I may take the tine to verify my source compiles with Arduino once I’ve finalized the code since most hobbyists are more comfortable with Arduino.

Suppliers

I mostly use Digikey as my parts supplier. When I was a practicing engineer you almost had to beg suppliers to sell you small quantities of parts and it was often easier to beg for free samples from applications engineers than actually buy the things. Besides gouging you on price you might have to wait 16 weeks or more for the parts.

In contrast, Digikey is happy to sell to anybody with a credit card. They have a vast inventory and you get the same price breaks as anybody else. Canada is a wasteland for electronics but if I place my order with Digikey before about 3PM I will have my parts in hand by 5PM the next day. They are awesome and no they aren’t paying me to say that.

I ordered my PCBs from Seeed Fusion and should get them in about two weeks because I paid for express delivery. I’ve used Seeed in the past and their boards are good value for money.

Design Documentation

As usual, I ordered all the parts from Digikey before submitting the PCB for manufacturing in order to to make sure all the packages were what I thought they were. The way I do that is I print out the top layer of the board at 1:1 and plug the parts into the paper. In this case I discovered I had put the two relays too close to each other and that is a lot easier to correct in the CAD file than the actual PCB.

Once I get the boards back I will assemble one and verify the hardware design. Chances are the schematic is correct but I have been known to screw up the layout. As soon as I verify the layout I’ll publish the full KiCad files.

Until then this PingerSchematic is a link to a PDF of the schematic. The picture above is the PCB layout and this PingerReference contains a complete parts list including ordering information from Digikey as well as an explanation as to why I selected those components.

Print out both files and study them before building anything. You should be able to assemble the project on a standard perfboardO except for the relays, barrel connectors, and wire to board connectors where you might have to drill extra or oversized holes. Drill the holes before you start installing parts. Try and get a perfboard at least 4″x4″ with plated through holes and “pad per hole”.

Note that the “dry” relay can handle AC including dangerous voltages. I am not responsible for any use of this design.

What’s Next?

I should get the boards in a couple weeks. After I prove the layout and publish the Kicad files I will have another look at the software and ensure the I/O assignments, etc., are correct for the PCB. Then I will publish the full software source listing as well as a binary file you can simply program into your ESP8266-12 breakout board. I have not figured out the procedure for programming from a binary yet but I will publish that as well.

Please note that this document and related materials are released under the Creative Commons Attribution-NonCommercial 2.0 license. Please see https://creativecommons.org/licenses/by-nc/2.0/ca/ for details/limitations.