An Engineers Perspective * IN DEVLOPMENT *

By Andrew Lohmann, Webspace since 1997

Electronics

Electronics, Software & Robust Design

by Andrew Lohmann 12/08/09, Changed; 25/07/2010, 15/06/2011
Caveat; I don’t do all that I say necessarily, Or say all that I do, And sometimes I only say what I wish I had done. We see these in each other and ourselves, just need to keep them in mind.

Just get to the Electronics
Software
Useful Links & Technical stuff

Engineering Management
* It is important that when we come up against a problem that we are honest with ourselves in our criticism. It does not help to avoid criticising our tools, or others in fear of litigation, as if that would occur, but firstly be honestly critical of ourselves.
* Concentrate on one aspect for a while but periodically break-off, reassess you priorities, and work on what becomes highest priority also work on some of the low priority issues periodically. Reassess your priorities every two weeks or at a convenient breakpoint. This is called prato-analysis, or more commonly summarised as the 70% of the costs of problems are caused by 30% of the problems -  70/30 rule, which fits to all sorts of things. For example 70% of costs are due to 30% of the problems.

* Half-split – As taught in fault finding – A system with a fault is first splitting and each half is
tested to see which half the fault exists in, then the half of the system with the fault is split again repeatedly until the fault is isolated. Always keep an eye on the whole system, and back-track if necessary. This is a powerful technique in all decision making.

* Understand what motivates ourselves. If your starving you would kill for food, the next priority is to find shelter and warmth, next sex, to when we feel very safe; empathy.

* Sustainability – In the “Garden of Eden” people mainly live on fruit and veg without harming fish and animals or each other, And in any case nature is abundant and therefore all-for-giving. Most of us don’t live this way and our ethics and ways of life have changed to reflect that, but compassion and fairness in the way we work is good. Having Pacifist tendencies, but not being a push-over works well.

This can be applied were a problem arises; Ask for more time, Concession in the requirement, Reassessment of the requirement, Or reassessment of the system. In conclusion talk don’t just struggle on potentially digging a bigger hole for yourself, you might just need a another pair of eyes to look at it.

Self management & Inspired working

* Examples of understanding of motivation are; The last two examples are of workers being self managed. The first two examples are from my time a college studying Diploma in Engineering Management.

The Hawthorn experiment in the 1920′s USA, – After running many experiments changing the environmental conditions in a factory for a selected group verses the control, the factory. What ever was done hot/cold/comfortable, good/poor lighting which cost a few million dollars investigating it was found that the group selected always preformed better, against the control. The conclusion being that the selected group considered themselves special.

Or the gang working in National Coal Board which was very productive. Workers were organised into gangs charged with cut coal and bringing it to the surface. The lesson learnt was copied by Japanese quality circles, Volvo and others.

 And I have recently been told of another called Sixes combined with job and go in British Rail. Six blokes would work on six sleepers at a time moving up six sleeper lengths together. A new worker would be carried for a week, then after that if he got behind eventually catching up with the gang as they finished there break and moved on. Self managing. They went when the job was done hence either home early or late when the job was done hence no cost overrun.

Although we are in a post industrial era, banks and creation of money (credit + interest) have superseded manufacturing in the UK. My hope is for industry and self worth will return to the UK.

Inspiring people to make things that they are proud of:* When I was a young Design Engineer I found that identifying and borrowing people with particular skills from other departments, means that products are made with enthusiasm because the people who make them had a hand in designing them.  Whether I could do it better myself is not the point. An additional benefit is that people tell you things, you discover informal work arounds, which being aware of you can design out or formalise. Or look into what was intended in the original and advise.

* Answer technical problems promptly avoid “I am busy now”, of cause if you are really busy and can’t break off say so but come back to the enquirer. Don’t avoid the question, but if necessary say I don’t know, and pass it on or share the problem, invariably  it needs to be, and can be resolved.

* Leading quietly by example, then enjoy seeing others copy and claim it themselves. This is much more effective than complaining or swearing. But a good swear and moan can help you, just be careful such is rarely productive or ultimately as pleasing as the first setting a positive example. Actually moaning just lets a bully know they got under your skin, when that happens they can rarely stop themselves doing it again.

* Remember that its only work, don’t take any of it personally, express your concerns at the appropriate time, and do as required in good faith. Take responsibility for excepting another’s concerns and for your own mistakes. Actually taking blame, tong in cheek perhaps, for everything that goes wrong makes everyone else happy and it gets the job done and defuses situations.

Bakelite Radio (1950's)Bakelite radio, Ultra MW/LW, built in loop aerial. Purchased in 1954 for £16, pictured working 55 years later.

The heater current supplied by a resistor and NTC resistor in series with the mains supply. This is evident because the Ultra light initially comes on, then dims, then comes up bright just before the sound comes through, finally returns to a medium intensity. Small valve radio’s like this usually have a live chassis (connected to live or neutral supply). This radio does not suffer with audio mains hum, that others like it can, though the supply voltage mains ripple would be quite high.  The sound reproduced is warm mellow, as if there were a large loudspeaker and substantial baffle (Valve sound, which I think, was developed by Philips). Inherent triode valve distortion was enhanced to create sub-harmonics that gives the impression that the radio has a good low frequency performance.

Electromagnetic Compatibility;

There are a number of strategies minimising emissions and susceptibility to radio emissions. I intend discussing these points using various examples and small detours into other areas of electronics. It is necessary to separate circuit function, stability and electromagnetic comparability, though the symptoms can be similar. All these things interact.

Filter (bandwidth limit) at the boundaries, use passive filtering, LC or RC, as opposed to active filtering, is very important. Also keep the bandwidth limited to what is required through out the circuit. Avoid high Q filter circuits.

Transistorised Hi-Fi often use to suffer with susceptibility to lights being switched on causing clicks and radio pick up or breakthrough. The problem was that a bipolar junction transistor could rectify radio interference. A fix that Electronics technicians, in the 1970′s used with amplifiers was to fit a 100nF ceramic capacitor between the Base and Emitter pins of the first transistor. I have also seen 100pF capacitor fitted similarly built into a design for an Eagle amplifier.

Positioning of components is also important.

Place associated components together. Keep path lengths short. The main point here is that you have to prioritise and choose were you can make compromise. Therefore spend time on the PCB layout to minimise the track lengths, bends, and maximise the track thickness where there are fast voltage and current transitions. Insure that the 0V return current follows the same path as the signal current. That way you can minimise the amount of compromises.

PCB design make a ground plane, and spend time minimising and fragmentation of that plane. If you need to add tracks in a ground plane make them short and bring them back to routing layer(s) as soon as possible. Therefore minimise or avoid make holes in the plane layer. Actually the best is to have two power plane layers, and two outer routing layers. putting the planes on the outside, apparently can cause buckling when soldering in an oven, but also components make holes in the planes which should be avoided as this would be fragmentation.

One tip, if you can probe your circuit with an oscilloscope with the ground connection to any where on the 0V plane and there is no difference in the waveform observed then you have understood and got a good PCB layout. You should also find that waveforms don’t ring, but some overshoot may be acceptable. Think about this before you manufacture your PCB. I shall discussing this latter.

Radio’s like the Ultra above would be physically laid out so that the power input rectification and filtering is followed by the output valve progressing through the detector, IF, mixer, and RF input. So the power supply is near where the signal is largest at the output, and furtherest away from the RF input where the signal is smallest.

Home made Oscilloscope based on a Practical Wireless design of about 1973. I worked on the design over a number of years, improved it greatly. By 1977 it was evident that I had learnt a lot but this was never going to be a particularly good Oscilloscope primarily because of the low intensity of the CRT, and I stopped working on it. The bandwidth is increased from 10KHz to nearly 1MHz, High voltage CRT supply was changed to a high frequency type, low noise, sine wave, with proportional control, to eliminate Z-modulated mains-hum, and voltage increased. Input transformers relocated to under the chassis back left as far away from the CRT as possible to eliminated X and Y axis modulation. Improved trigger and time base. Grounded everywhere, and all modification made with recycled parts. The next improvement would have been to fit a larger transformer, which would have had to be nearer the CRT, and I had some Mu metal to screen that, as everything was under stress.

 

Grounding strategy – Using one point (star ground) or grounding everywhere.

A star point, connection to chassis tends to give very good low noise performance but there will be resonant frequencies. Alternatively grounding everywhere gives a higher noise, because there may be varying current across chassis that inject low level voltage into the circuit, but resonances are likely to be less this configuration is currently more in favour. I recommend that you pick and choose.

For example Radio’s like the Ultra above, have a steel chassis which is signal ground (0V). When ever 0V (possibly live or neutral) is required there is a short connection to a nearby point to chassis. My hope made oscilloscope is also bonded every where.

Compensation – Ensure that the circuit is compensated properly and is therefore stable;

Below is an example of a super regenerative radio receiver. I made something like this in the 1970′s and it worked well with good sensitivity. But I did not fit the reaction capacitor in fear of there being too much positive feed back and the circuit could broadcast. This is an example of a circuit that it is nearly unstable, not only is there RF positive feedback via C2, but there is also positive gain feedback in the audio signal from the detector fed into the transistor base. Diodes and transistor would be low voltage drop type Germanium such as 0A91, and Transistor OC44. The circuit below is from memory and may be inaccurate, the original circuit can be found at; http://www.mds975.co.uk/Content/trfradios02.html

Circuit oscillation or instability occurs when there is a phase shift of 360′, and the loop gain is at least one. The first circuit below is a phase-shift oscillator, such circuits don’t always oscillate. The capacitors and resistors are usually transposed but I have drawn it this way to illustrate a point. Phase shift oscillators are sometimes formed inadvertently see below second. If you analyse the circuit (left below) as a DC circuit there is negative feedback (180′ phase shift). When you include the capacitors and resistors, they can produce up to a 90′ phase shift each, this is an important point. The circuit oscillates at a frequency that occurs when the sum of each phase shifting component, which includes propagation delay within the transistor, is an additional 180′ . We can stabilise this circuit, that is prevent it from oscillating, by increasing the value of one capacitor say C1 to the point were it’s phase shift predominates, and there can no longer be as much as  180′ phase shift.

                    

The second circuit is an Inverting amplifier has input and output filtering, formed of R4, C2, and R3, C4. Also R2 and C1 form an active filter. R1 and R3 have been chosen to be high enough to avoid amplifier instability. The operational amplifier is un-conditionally stable, that is it is stable with R2 = 0, maximum feedback, which is where the loop gain would be highest. This circuit may become unstable though with R3=0 so that C4 is directly connected to the amplifier output, in this case the propagation delay is increased but the loop gain would not have reduced enough for the loop gain to remain below one. If the value of C4 is reduced below 1nF this particular amplifier would become stable again. It is also likely that this amplifier would become stable with C4 increased to 100uF or more as the loop gain would again be reduced. This is because the operational-amplifiers behave like transconductance amplifiers in that there gain is reduced when driving a large load. The other condition where the amplifier becomes unstable is where R1 = 0, it is important that capacitive loading be kept away from an amplifiers summing junction (the negative input).

The consequence of adding small capacitance to the output or input of an op-amp will be that the amplifier will amplify transients, causing the output to be less accurate.
Alternatively adding large value capacitors is done with voltage regulators, but you need a small series resistance to prevent the capacitor Q from being too high, and causing the amplifier to become unstable.

If their are varying currents flow through the ground or high EM fields nearby, Adding capacitors to inputs and outputs is not the proper solution. Increase the distance, sort the varying currents, and add electrostatic (aluminium/copper/gold for HF) or magnetic (soft iron for LF) screening, are good strategies.

Be careful of symbolic circuits such as those showing photo diodes connected directly to operational amplifier summing junction. Photo diodes do have capacitance and a series resistor may be added to avoid directly connecting the diode directly to the amplifier. You can put the ac summing junction at the -input by also connecting the feedback capacitor (which you usually must have to meet amplifier stability criteria), and the dc summing junction at the diode instead if you wish.

This is interesting lesson from my first year at collage – C4 looks like positive feedback, but due to the propagation delay through the germanium transistor (storage time) at the IF frequency of 10.7MHz, there is actually negative feedback. The transistor it self has capacitance and miller capacitance between the Collector and base, is cancelled out by the addition of C4.

Examples of enclosures – grounding every were or at one point. Power Inductor can induce current into enclosure, keep them away from metal enclosures.

Control Loop Compensation – more too come.

You may avoid control loops or minimise the need for a control loop, for example by;

    Use a permanent magnet or shunt wound motor which have very good self speed regulation. In the case of a PM motor the speed is proportional to the voltage supply and somewhat independent of loading.

    Use a stepper motor, but take care to optimise ramp up rate when getting the motor to the desired speed. If the speed is increased to slowly the stepper motor may resonate for the shaft to continue rotating.

    Use feed-forward techniques to minimise the the amount of feedback. That is adjust the voltage, in anticipation of load changes.

Two control loops, is very effective, inner fast tight response, and an outer slow for accuracy. Example Temperature controller see manufactures of thermo-electric devices. Note that there maths are based on current but use voltage drive that is slightly self regulating like the DC permanent magnet motor above.

Picture of a PID controller compensation and the equivalent software. to come

How to find the constants for PID controller.
    If you buy a second hand car lean on each corner then release that corner in turn – the car should rise, fall then rise and stop this is critically damped, and the shock absorbers are ok. But if you design to over damp the control loop will be stable under a range of component tolerance, in this case the car should rise more slowly then just stop, if you set it just right that would be in the same time this is usually the best setting, but in the case of the car someone has filled the shocks with treacle or heavy grease as they are worn-out.

Include some high frequency filtering – this ultimately should be a factor of 1/5th to 1/10th the value of integral constant. It will compromise the loop stability but it is necessary.

Start without any Integral (Capacitor removed) or differential constant (capacitor shorted)
1) Reduce the loop gain (constant or resistor) until the loop is just stable, the loop is therefore simply a proportional control. The loop error as a very broad guess might be 2%.

2) Halve the loop gain.

If this is meets the requirement then don’t go any further. You a proportional controller (P only).

3) Add the differential capacitor (or constant) and progressively reduce it’s value until the loop is just stable. Double the capacitor value, and fix it at that.

The loop is now stable just over damped. To give yourself more margin you can quadrupling the capacitor and halving the resistor again. If that achieves the requirement leave it at that Proportional Differential controller but with no Integral control term.

I have to not got a good strategy for the Differential control but the following works somewhat. Though it is rarely necessary.
4) Progressively increase I and reduce the D constant and progressively reduce loop gain P until you can go no further. Then give yourself a factor of two to four margin by reducing I and increasing D and P.
 
A P and PD controllers can be set empirically quickly, but PID is a bit more fiddly to set-up, and I am not sure of the best method. Using the above method increases the frequency of the loop jitter and reduces its amplitude.

A method of finding the approximate value of the Differential term (capacitor) is to increase  the gain as (1) measure the free running frequency. Halve the gain (2), then fit a capacitor which gives a time constant equal to the period of oscillation, or double that period. then proceed to (3).

Look at Wikipedia on PID control you will see that they show you how to derive the terms for critical damping, whereas I have describe how you achieve over-damping, gives you a good solution with a margin for variation in load and tolerance. What you need to consider and experiment with is how the the PID will behave after the item under consideration has had a number of years use. For example shaft encoders often have shaft sealing which will wear in quickly and the amount of motor effort need to turn the encoder will reduce.

Two Control Loops – inner and outer;

Consider being in a room with the heating on and the room thermostat handy. My strategy for getting the room to a comfortable temperature is. The out-loop usually should have a longer time-constant than the inner loop to prevent oscillation.

1) If I am cold and I can hear the heating going, then;
2) If I find the room becomes warm enough before the thermostat clicks off, then I turn the thermostat down until it just clicks off.
3) Alternatively if the room does not reach the desired temperature before the thermostat clicks off, then guess how much warmer you would like it then increase the temperature setting of the thermostat by that amount.
4) Go to (1) if not satisfied. What you are doing is the outer control (nudge up/down the integral part of PID) with, importantly, limits necessary to prevent the set point (thermostat in this case) running away.

This gives you a good understanding, but usually controllers are not simply on/off control. As I said nudging the set point is the integral term. To avoid set point running clamp the set point so that it can not be set more than a chosen amount greater or lower than the parameter under control within the inner loop. You might be tempted to add a value to the parameter under control to drive the set point, but be wary of integrator drift, that would likely leave you with an unresolvable error.

AnemometerPictured is a Gill 3-axis Anemometer which senses wind speed, pressure, and direction data using ultrasonic transmitters and receivers. It is likely that as part of the wind speed, pressure, and direction sensing transmitters and receivers are transposed, periodically during the measuring cycle.I worked on an environmentally monitoring project some years back, for another company which incorporated a Gill Anemometer. My part in this project was to develop the electronics for an infra-red spectrometer, for sensing quantity of CO2, NO, Oxygen. The spectrometer was formed from an under driven low voltage filament lamp at the top of the Anemometer and a long wavelength temperature controlled infra-red light sensor below. There was also a rotating disk with a number of light filters, which was speed controlled. CPLD included edge triggered phase-locked-loop which switched from frequency comparison when the motor speed synchronised. The CPLD also included synchronisation of a trimming for the sample and hold circuits. Much of this could have been implemented with less circuitry, and a difficult to drill index pulse removed, and using a micro-controller but this refinement was beyond the remit of the work. Various trimmer potentiometers were replaced by automatic trimming circuits, which also provided an ageing and temperature compensation feature.

Synchronous noise and Resonance – Stability and EMC related issues from another prospective
Consider soldiers marching, they break step when crossing a bridge to avoid resonances, and high amplitude synchronous noise. Applying this to stability is worth bearing in mind.

In a Switch mode power supply there is a high current gate plus snubber and any other parasitic capacitance pulse at switch on that appears across the source current sense resistor. This could misleadingly trigger current limiting or control limiting. This pulse can be filtered with an RC filter, but usually (in current mode controllers) the pulse is gated out or ignored, and an attempt to add RC filtering would spoil this feature. Alternatively voltage mode control with feed-forward similarly resolves this issue, by not using the current ramp in the sense resistor within the control.

Resonance and noise in stepper motor drive;

One phase on – the motor steps from one pole to the next.

Two phase on – the motor steps to a position less precisely determined between the two poles. Consequently the step is less precisely and the noise and resonances are reduced.

Half step – The motor is stepped to one phase on then two phase on repeatedly. The size of each step is reduced so the resonance and noise is reduced. the frequency is higher and the resulting velocity ripple can be filtered more.

The current drive could be by series resistor from a high voltage supply, this is the most stable drive method, but of cause wastes power.  The most efficient method is to use switch mode method from a high voltage supply;

- current source switching between supply current or allowing the circulating current is the most efficient, but the least stable because as the motor shaft moves the current might actually increase, in addition the switching frequency tends to be low, and consequently the current control is not very tight.- current source switching between supply current or dumping the current back into the supply as opposed to allowing it to circulate current is less efficient, but stability is good because as the motor shaft moves the current might have actually increase is dumped, in addition the switching frequency tends to be high so consequently the current control is good.

ST application notes cover these issues very well though I am unsure whether they are still available.

 

 

 Decca made in England, transistor VHF/MW/LW radio purchased from Strange of Sevenoaks in 1962/1963.
 Originally was returned for repair a number of times, but actually only the VHF band is any good. AC and AF series germanium transistors – absolutely leading edge, at the time.
Aerial The aerial broke so I replaced it. I also replaced PP9 battery supply with a mains power supply based on a 6.3V heater transformer. Used daily, and unaffected by mobile phones in close proximity.

Best tools for the job

If you are working on a leading edge design there may be no accurate test instrument as good as the instrument you are designing. If you don’t have the required test equipment for the particular job. Either way spilt the system up into parts that you can test in different ways so that you can figure out logically the likely performance in the parameter you are interested in. In this case build up a pattern of cross checks that give you a subjective confidence. Continue to build up the system you are developing cross checking in the way I have described, and reviewing what you had done previously until the work is complete and you can say what you have achieved and how much confidence you have in its performance.

In conclusion you best tool is logic, and to develop an ability to look at things in alternative ways. Nothing is absolute even the accuracy of a measurement, but by building up a pattern of measurement with tolerances you will come to a high degree of certainty.

Worst Case Design and understanding tolerancing

This about understanding shades gray, when you can do that you are well on the way to answer the meaning of life and everything. To start with sum the squares of the effect of all your tolerances, then a figure of merit can be calculated from the root of that number.

If you try calculating the values of resistor that you require in a network such as a Whetstone bridge using Supper-position, or Maxwell’s circulating currents the outcome is a set on non-preferred value resistors. So what they taught you at school was no use then, So what you do is create a model which you can repeatedly try preferred values of resistors and use the values that best give the lowest merit number using the least squares.

Well that was a lot of work but you can write a basic program to do that.  Eventually you should by inspection see what parts of the circuit need to be checked for tolerances, power rating etc. Do some sums with a calculator pen and paper entering preferred values. All circuits with resistor networks can be split down to two or three resistor networks which come down to a voltage source with an impedance, which you then load with the next resistor network. In fact if you can avoid resistor networks that is even better, resistors age and have temperature coefficients.

My point is that the best lesson in tolerancing and getting a feel circuit function and actual behaviour is to the maths, until you feel it without having to go through everything to prove it. Once you are there use a simulator if you want.

If you do start with a simulator, have a guess and do some arithmetic to support your guess first, Use the simulator to test your guess. If there is a disparity prototype it and see which is correct and analyse it to understand why.

I recommend that you download and use any spreadsheet or other model a switch mode power supply coil maker and controller manufacturing provides they are well tested and good. But give yourself some margin the IC makers tend to specify to just the limit.

I find thermal modelling from data sheets difficult. An IC won’t dissipate much without an area of copper. Hardly anything can be dissipated if the IC is faced down, face up is better, and with the board stood vertically is best. I have found exposed tinned or silvered copper better than with solder resist. Tinned or silvered copper does go matt white quickly. I have heard others contradict my observation on removing solder resit so try it for yourself.

Software – Unlike my advice on simulators above use PCLint at the outset it will cane you relentlessly unless you behave and write good clear C.

Write software in a way that is readable
Put all you constants and switches in the headers. If you want to change anything use those switches.

Use a good Compiler for example Cosmic C.

Use a propriety micro it will have fewer erratas, Freescale (Motorola) particularly work on eliminating all erratas on the propriety products. Don’t expect the same generic processors like ARM or PowerPC.

Avoid writing anything in assembler, you should not need to. Optimiser within Cosmic, which is normally selected, is impressive both on speed and code size.

Use Lint to check the readability and function of your code. Don’t be put off because it is the oldest software tool you will ever come across, and quite cheap. I think it is the by far the best, subset includes MIRSA used by the motor industry.
SPLint is the free version but it is worth buying PCLint.

They will tell you to lint everything before you try running the code it will pick-up, or make it plain to you what is unclear and could be wrong. You will find that after sorting out what arises your program will probably run, importantly it will do what you would expect of it. Of cause if you are unsure what you wanted you will still be unsure what you get.

If there is a disparity between the compiler and PCLint, and you are certain of that, then suspect the compiler.

In writing C write your code to be reusable with switches defined locally and globally.
I have nested C code for a serial port within another file written in C, in this way the same core code can be RS232, RS485 with turn round control, have Xon/Xoff flow control, and have modem controls. As far as I can tell this is not recommended but even so I do recommend doing this because it makes all the code in all the projects you are running feel the same.

Useful links:
  http://www.cherryclough.com/  I came across this company at Electronics Weekly sponsored show in June 2009. They have an excellent understanding of EMC issues and solutions.

http://www.gimpel.com/html/ PCLint C programming checker, 
http://www.splint.org/ SPLint (Virginia State University - you may come across other interesting projects)http://www.cosmic-software.com/ A robust C compiler
http://www.freescale.com/ Very good micro-controllers such as HCS12
http://www.st.com/stonline/ ST microelectronics Switch mode power supply ICs including voltage mode (they invented it), Stepper motor drivers.
http://www.nxp.com/ Philips - Switch mode power supply ICs including voltage mode,
http://www.linear.com/ Linear Technology Current mode switch mode power supplies, and design spreadsheets. See LT1072 (obsolete)
http://www.diodes.com/ Zetex design spreadsheets
http://www.coilcraft.com/ very good power density wound components and very good design spreadsheets.

My page on Windmill for power generation

I have used the following tools on this page;

*    Electronics WorkBench National Instruments – Circuit diagrams.

 My CV

Follow

Get every new post delivered to your Inbox.