“Mocking” – Minimising Risk

In the last post  for the Timed LED Lighting Controller, I had figured out the circuit and a basic layout and approach that I was happy with. That is to separate the hazardous voltage from the control circuitry by putting it on a separate board. But still, this was not enough. I need to assemble this in a case. No hazardous voltage is allowed to be exposed. The idea of printing a case is attractive but I don’t really want to loose focus of this project. I can always reserve the printed case for revision 2.

Reviewing Samples

I found myself feeling like I as facing a bit of a chicken and egg. Needing a housing to fit the board and having to make the board fit the housing. I also needed sort out a set of terminal blocks and ensure that they are in specification. The only way forward was simply have a look around and order some terminal blocks and cases and just to see what is out there. Photos and technical diagrams are great but to have the actual items in hand is much better. I decided to use Reichelt this time. I had not used them before but they had a good range of terminal blocks of various dimensions and configurations and I could purchase single units which was important for a look-and-see. I settled to take a look at a small selection

Manufacturer Pole Spacing Voltage / Current
Springcon 6 2.5mm 150V / 8A
Springcon 2 2.5mm 150V / 8A
Metz Connect vertical 2 5mm 300V/ 10A
Metz Connect angled 2 5mm 300V/ 10A

The smaller units are not suitable for the hazardous voltages but I will still use them for the connections to the motion detectors (PIR13).

img_0352sWithout wasting too much time, I ordered two housings manufactured by Bopla. When they arrived, it was clear that I could use the smaller of the two (BOPLA KS 430) that I had ordered. There are undoubtedly other housing that would suite but this will do for the moment. I will, of course, have to modify the casing to expose the terminal blocks.

Now that the decision was made for the terminals and housing, I could look back at the layout with more confidence. This also meant a bit of a rehash. I had to add the footprints for the terminal blocks and their outlines to make sure they will fit on the board.

Revisiting the Layout

The next was the housing. This was a little more involved since I am going to stack the boards. I ended up making use of the dimensioning tool in KiCad so I could correctly line up the joining pin-header and the mounting holes.The outcome of this was that I needed to extend the respective boards so that they could get past the “assembly posts” for the housing and also that the terminal blocks will reach the ends of the housing.

boardwithmeasurements

The larger board has given me space to reorganise a few things. I have now collected all indicator LEDs into a single bank of LEDs. This will look a lot neater when they are exposed to the housing surface compared to LEDs that are placed simply where it is convenient on the PCB. The LEDs are to help with bringing the board up and there is nothing to say they need to be populated for the final version.

Going back on the question of Clearance and Creepage, the dimensioning tool as was also useful to verify the distance between the traces where they look a bit close. At the moment, according the the on-line calculators (Creepage.com and ANSI PCB Trace Width Calculator) I have checked, seems to be in specification – further verification is required.

Mocking the Board

On the screen, it was all looking good, but I was still not confident I had covered all the possible issues. It was then I decided to “mock” the board. Simply print it out and paste the images to some card board and cut them out. I could then use a real pin-header to assemble the two parts to see how they would fit.

Of course, I could not stop there. I had to then also punch through the other through-holes and set the terminal blocks that I now had in my possession. At first this was just for a bit of fun, but as it turns out, I discovered some issues with the layout that would have normally gone unnoticed.

img_0348s

The first issue was that I did not realise the mounting holes for the board at each end are spaced differently. From the perspective of the photo above, the mounting holes on the left are set narrower than the mounting holes on the right.

The second issue was that I had not calculated the “Y” location of the mounting holes correctly and they were 1.7mm out.That was easily sorted out since it did not affect any other parts on the board.

measuredboard-terminalspacingThe third issue was with the terminal blocks for the motion detectors.I was trying to get away with the terminal blocks I had received. I need provision for 12 wires. Three for the I²C Bus and nine for the connections to the motion detectors.I was thinking I could butt two six-pole terminal blocks together. However with the way they are modelled in KiCad and the respective footprints, this was not possible as these terminal blocks have a nominal 2.5mm spacing and a 3mm spacing when butted together. So solve the issue,  I went back to KiCad and remodelled the connections to the motion controllers as three sets of three. In the layout I only needed ensure that there is a minimum 3mm spacing between the three-pole terminal blocks.

The Timed LED Lighting Controller is another step forward. This will be one of the more expensive boards I will send off for fabrication so I am very pleased to have spotted those issues with the layout. The goal is to have as few “spins” of the board as possible and the process of mocking the board was a huge help. Just a few more checks and I can send this off to OSH Park!

 

Timed LED Lighting Control – Design

From Logical to Physical

Before I could start to translate the block diagram into KiCad, I needed to be sure about some of the parts I will be using. I want to reuse what I already have installed, so the motion detection module is already a given, along with the LED drivers. The micro controller needs three output pins, three input pins, I2C support as well as the pins for a program header. Since I have worked with Atmel in the clock project and therefore have the tool set I need, I decided for the ATTiny20. The only part I needed to look around for was the relays. As per the block diagram, I decided that the coil would be 12V and the switching contact should be for 240V AC RMS. For the moment I have settled on the JW1AFSN12F from Panasonic.

Translating the block diagrams to KiCad was fairly straight forward. The resulting KiCad diagram pretty much matches the block diagram in so much as the power system, relay driver and the PIR13 interface are modelled in their own sheet. In order to help to keep the 240VAC side separated from the Extra Low Voltage control section as much as possible, I opted to try for a stacked board layout. The two boards will be connected via a pin header and socket (P105 and P107). To simplify this layout I opted to utilise the different notations for the Ground plains. GND for the Extra Low Voltage board and GNDA for the Low Voltage Board.

tl2c-sheet1-main

tl2c-sheet2-powersystemThe Power System comprises of two LDO regulators. One for 12Volt and the other for the 3.3Volt supply. It is expected that the plug pack adapter will probably deliver about 14V – if not, I can always drop the 12V regulator out of the design. It is only provided for extra regulation. As already indicated in the previous post, the 12Volt supply is for the PIR13 modules and relays. The PIR13 modules can handle from 5 to 24Volts as a supply. Because of the distance of the cabling, any voltage drop should be within tolerance. The Micro Controller and therefore the signal lines such as for the I²C bus will be at 3V3 which is compatible with the Raspberry Pi removing the need for any level shifting. The ATTiny20 shares the pins for the I²C bus and SPI bus. At the moment, I have separated these with a couple of resistors as recommended in another article. I have my reservations about this and may yet change this over to a set of jumpers or even a double pole switch.

tl2c-sheet3-pir13

The signal from the PIR13 is open collector. To avoid having a direct connection between the ATTiny20 and the PIR13 modules, I will be installing some MOSFETs I already have from another project.

tl2c-sheet4-led

I am using the same MOSFETs to drive the relays. As a part of this initial design and a lesson learned in previous projects and Contextual Electronics, I will be including test points and indicator LEDs. An additional lesson learned is to not leave any spare GPIO pins unconnected. These can come in handy and for that reason I have even broken them out onto a pin header. I don’t have to populated the pull-down resistors nor the pin headers for these. But they are provided for if I need it.

Laying it out

I originally envisage the layout as a two piece board that will be separated after assembly. The first attempt was a two layer board and was not nice at all, so I shifted the design to a four layer board. This has pushed the price up enormously. The tip came from Chris Gammell to separate the two sections into their own layouts. One as a two layer board (the 240Volt AC section) and the other as four layer. This has reduced the overall cost significantly and now enables to be enlarge them enough for mounting holes and still be cheaper than the original full layout. The trick with this is how to model this in KiCad. I have tried out my own workflow for this:

  • Model the two boards as needed in the Master Layout PCB as 4-layer. This enables matching the mounting holes and pin-headers without having to swap between layouts
  • At the command prompt, copy the Master Layout PCB twice. Once for the 240V board and the other for the Extra Low Voltage (ELV) board.
  • In each new layout file, delete the section that is not needed and re-adjust, if needed the board layout graphics.
    • Adjust the layers for the 240V board from 4-layers to 2-layers.
tl2c-initiallayout
“Master Layout” Both boards side by side

Design considerations and constraints

I am reasonable happy with this initial cut of the layout. However, I am not quite ready to send this off to OSH Park. This project and board contains an element I have not worked with before – Hazardous Voltage. This can not be under estimated. One aspect to this is to separate the Low Voltage (LV to ELV boards onto their own. There is still the question of Clearance and Creepage to consider on the LV board. There are a number of very good essays written some with calculators

Calculators
Trace Width
creepage.com
PCB Trace Spacing
Essays
Creepage and Clearance
Clearance and Creepage Rules for PCB Assembly

So I have a bit of a quandary. I don’t want to send off the board for manufacturing before I have sorted out the safety aspects of the design first. I could send it off as-is but if there is a specific requirement I need to meet, I will have to request another. I can, however, make a compromise. With the tip for splitting out the boards as separate PCB files, I can send off the order for the four layer part and leave the two layer, LV board for further consideration. In the mean time, I can bring up and test the control board since the relays either are not needed for the proof of concept or can be simply wired in for basic testing.

At the moment, I have a small uncertainty about the housing and the terminal blocks. It is much easier for me to choose or to know what to look for when I have some actual samples in my hand. So I have ordered a couple of samples to get a better idea of these parts. It is tempting to consider to print the case. However, this would push out the project and shift the focus to a 3d Printing project. I would prefer to keep on track with the Timed LED Lighting Control hardware and firmware.

In the next post, I hope to have the casing and terminal blocks worked out which means that the board will be ready for fabrication. So hopefully then I will be able to talk about bringing the board up.

Getting Connected

The layout is now done and made the rather gutsy decision to send it off to OSHPark for fabrication. In hindsight, I could have done this cheaper in that I actually opted for a 4 layer board with the ground and power on the inner layers just to get them out of the way. I did try a 2 layer board but with the busses running for the segment and digit lines, it was very tight for space especially around the driver chip.
Layout-4L

I had to create the footprints for both the 7-Segment units and the MAX7221. The MAX7221 has probably the highest risk of fitting since the package description was anything but clear. It was stated as a 24-SOIC Wide with about five variations on the length – none of which can be determined from the part numbers. The part number that I am able to readily obtains is MAX7221EWG or MAX7221CWG. For this, I have selected the set of dimensions that would give me the largest pad size in the assumption this will simplify assembly. The length of the package itself does not seem to impact the placing of the pads, so I am confident, it should be OK.

The ordered boards are shown below. A couple of points, again learned from my experiences with Contextual Electronics – Label the Pin-Headers! it is annoying to have to look back on the schematic each time I want to connect up a board. The other is position the buffer resistors for the LEDs sensibility – As I mentioned in the last post, there could be a good reason to swap out the zero Ohm resistor with something more appropriate. In order to avoid damage to other parts i.e. the plastic of the 7-Segment displays, I have positioned these on either away from the 7-Segment displays or on the Fron-side (the 7-Segment displays are on the back side).

OHPart-Front

OSHPark-Bottom

What’s next?

It is easy to rest on my laurels and think, “OK, I have three or so weeks before I get the boards back, I can concentrate my efforts on the Contextual Electronics course work”. However, there are other things to do

  • Verify the calculations for the Rset
  • Verify the specifications of the discrete LEDs and determine if the zero Ohm resistor is all I need.
  • Consider working on the other branch for the layout of the larger displays.
  • Consider re-working the layout for a 2-layer board to reduce the cost.
  • Start work on the Controller based display module.

The next post will reveal what I have decided to work on.

Branching out

I mentioned in the last post that I will be trying out the display modules. I found it easier to break away from the original TfaC Git Hub project and create a new one dedicated to the research and development for the display module. The new one is simply ClockDisplayModule.

The first consideration I needed was what 7-Segment displays. The original have a digit height of about 19mm. It is not possible to obtain this with the resources I have. So there is my first compromise. A near fit is about 20.32mm or a 15.24mm. In order to accommodate the usage of either of these, since neither is ruled out, I decided to create two branches on the ClockDisplayModule: largeDisplay and smallDisplay for the two 7-Segment sizes respectively.

driverThe first thing I needed was the circuit diagram for connecting the MAX7221.

I decided to model most of the connections as global labels to avoid clutter on the diagram. It also meant I could separate out the various components of the module in terms of the array of 7-Segment displays, the indicator LEDs and the driver itself.

The data sheet for the driver recommends an electrolytic 10μF and a 0.1μF near the V+. The rest is pretty much as per the application notes on the data sheet. At the moment I have selected a 25KΩ for the Rset which controls the current to the LED segments. This may be also subject to review based on the final 7-Segment selected. I will be providing the working for the final calculation.

display-bank

The 7-Segment displays have been modelled using the bus feature of KiCad. The common cathode of the displays goes back to the “digit select” on the MAX7221.

The indicators for the display will be implemented using discrete LEDs rather than any decimal point on the 7-segment display units. Mainly because they are not in a position that I consider useful.

I have not seen the MAX7221 driving discrete LEDs along with any 7-Segment display, but I am keen to try this out. I prefer to use discrete LEDs rather than any decimal point on the 7-Segment units as a matter of position. I believe that I will have to consider the ratings of the LEDs and possibly match them with the display segments to avoid any issues loading the MAX7221 inappropriately.

indicatorsMy participation in the Contextual Electronics course has given me the tip to place some zero Ohm resistors in series with the indicator LEDs. The MAX7221 is capable of limiting the current to the LEDs it is driving through the Rset (R101). However if I can not match the indicator LEDs correctly, I at least have the option of swapping the zero Ohm resistors with something more appropriate.

What’s Next?

The next step will be to lay this all out onto a board. I already have the measurements I will use – that is the same size as the existing display panel – 3.5″x1.3″.

Wired for Action – almost

In the last post, I presented the initial ideas for powering the project. Now it is time to move on and start looking into the individual modules. I was impressed as to how quickly this part progressed since I had done the up-front thinking of the pin and port allocation. So much so, that before I knew it I had most of the schematic done making it unnecessary to span the development over several blog posts.

sch-top-02The high level diagram is now looking more complete with the use of hierarchical sheet pins to connect the respective module. This clearly demonstrates the communication between the modules and again, looks very similar to the initial block diagram. It should be iterated that the up-front work of the block diagram contributed significantly to the creation of this section of the schematic. Since I had previously thought out the pin and port allocation, it was a simple matter of aligning the labels on the sheets so that it is concise and descriptive.

Controller

The controller chosen for this project is the ATMega88p. I have to admit for no good reason other than I have a development board for this processor and have used the ATMega8 before. Unless there is a significant reason to re-think this decision, I will be staying with the ATMega.

sch-controller-01

The controller diagram, at this stage, describes the connection of the Serial Peripheral Interface (SPI) bus and interrupts using hierarchical labels. I have also added a pin header for on-board programming. I do need to clarify this further to be sure that this is the correct connection/mechanism for programming the chip on-board.

RTC Module

It has been mentioned often enough that a pre-fabricated module will be used for the Real-Time-Clock (RTC). This is the RTC-DCF from ELV. This module implements a RTC with built in calendar and has also a module to receive the DCF77 signal. When all things are working, then there is no need to set the time on the final clock appliance. It is envisaged that there will be a manual mode for the clock in cases where the signal is not received.

IMG_1054The symbol for the RTC in KiCad is a custom symbol for this module. Though the original kit is mounted in an Arduino shield type form factor, the module itself can be punched out and either soldered onto the application board or, as I envisage, connect it to the application board via a set of 2×6 pole pin headers.

sch-display-01

This schematic implements the level shifter mechanism to shift the +5V signal from the controller to a 3V3 signal that the RTC requires. The RTC supports a couple of different mechanisms for communication. In this case, I am opting for SPI. The usage of the signal lines look to double up. This is only because when one communication mechanism is chosen (programmed via a DIP switch on the module) the other lines are used to support the extra interrupt features of the module. For the implementation and features I require, not all connections are necessary. The Tx line, for instance will not be required in this case.

Thinking back on the SysML block diagram, the level-shifter was not clearly visible on the block diagram. It was certainly defined in the model and was specified as the type of port on the 3V3 SPI bus. What is also not clear not the SysML model is that the SPI 3V3 bus requires both Vbb and Vcc to operate since it has to convert the signal between the two.

What’s next

I am quite satisfied with the schematic so far. More needs to be done on the controller. The interface buttons and switches need to be added. Also some thought needs to go into the housing since four buttons and a switch are already available. What I am proposing requires some additional buttons for the extra features. I am sure my refurbishment of this appliance can include some modifications. At this stage, I don’t see it a major problem to add these at the back of the housing.

The next significant module is the display module. I have some initial thoughts on this but will save that for a future post.

Module One – Power On!

In the last post, the basic device was layed out in terms of requirements, block diagram and a state machine. It is clearly not 100% complete but I don’t believe that the whole project should be blocked, trying to model absolutely everything. As the project develops and matures, issues will be encoutered and design decisions made, so I am sure no matter how complete the model is, things will be added, changed and removed. The dicipline will be to go back and retro fit these changes. It will be interesting to track if and when these changes are done. This is also interesting from the poin of view of “is this modelling so necessary” and what value it is really brinig to the project. I am happy with the level of modelling so far as it has given me the project organisation I will use, plus the hierarchical layout of the schematics that I will also use.

The aim of the post will be to present the first schematic, the power module. The model shows that this module needs to take some “line” voltage and source to independent voltages, Vdd=5V and Vb=3.3V. I realise it is possible to power the processor also off the 3.3V. This would also reduce the overall cost of the project. Since the object of this exercise is to learn, I thought it more challenging to introduce this extra complexity. Later on, in other projects, this may prove a worth while exercise. I consider this “making haste slowly” .

Top Level Schematic

sch-initial-top-01

The first page of the schematic looks (rather intentionally) like the block diagram. The pages are arranged as a hierarchy with four modules: Power System, Controller, Display Module and Real-Time-Clock module. The initial diagram concerns the power system. This was described on the initial block diagram and providing two lines. Vcc (+5V) and Vbb (+3V3). The first omission on the block diagram has been discovered. The Real-Time-Clock (RTC) requires both Vcc and Vbb to drive the level shifter that needs to be integrated in that module.

Power Rails

The power module, as expected, contains two regulators. I have opted for two fixed single output Low Drop Out (LDO) regulators. The choice is vast and I figure I have to start somewhere.

At this stage, for the 5V regulator, I have chosen the MCP1703T-5002E/CB. I am hoping that 250mA will be enough, though I will need to keep an eye on this once more is known about the display module. I figure that will be the biggest drain on the whole system.

sch-power-01The 3V3 rail is provided with a LD2979. I am confident that this will not require further checking as it can deliver up to 50mA and is only intended to supply the RTC, which, according to the data sheet requires a maximum of 15mA. I have since measured this device at using 6mA on a breadboard configuration.