News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Bryce

Understanding Retro Electronics

Started by Bryce, 12:54, 24 March 17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bryce

Hi all,
     as there are several users here that are starting out in electronics, I thought I'd mention this here. Dave over on the EEVBlog has just posted a short tutorial video explaining the basics of logic gates and boolean algebra. For anyone looking to understand how their CPC works, this is one of the basics which needs to be understood, so if you have 30 Minutes to spare, it's well worth watching: https://www.eevblog.com/2017/03/24/eevblog-981-introduction-to-digital-logic/

Bryce.

Edit: Maybe I should make this a "sticky" thread and I will add further useful videos and documents that I know of.

Bryce

#1
Hi all,
     just recently I've been asked the same or similar questions by several new electronics enthusiasts, who've usually just bought their first oscilloscope. So I thought I'd do a short electronics tutorial to explain the situation. So what's the question:

Why is the square wave clock signal in my CPC not square?

The answer to this is a mixture of several factors, so here's a basic explanation:

Harmonics
Most square waves aren't perfectly square to start with. They are the sum of a bunch of sine waves. The fundamental frequency (16Mhz in the case of the CPC clock) plus many harmonics of that frequency. Harmonics are signals which are a multiple of the fundamental frequency, so for example with the CPC clock:

Fundamental Frequency = 16Mhz
2nd Harmonic = 32Mhz
3rd Harmonic = 48Mhz
4th Harmonic = 64Mhz
5th Harmonic = 80Mhz and so on...

This is what a real square wave (40Mhz) looks like on a Spectrum Analyser. You can clearly see the fundamental frequency (1) and it's associated harmonics right up to 500Mhz.


[attach=1,msg144677]


From the diagram below (only showing uneven harmonics) you can see that by adding all the harmonics together, you get a rough square wave. Each harmonic is or should be (if you haven't messed up your design) a little lower in amplitude than the frequency before it. The more harmonics you include, the more defined the square wave becomes. The edges get steeper and the top line becomes straighter. So this mixture of frequencies, not just a simple square wave, is what your oscilloscope is actually trying to measure.


[attach=2,msg144677]


Scope issues
So let's assume your shiny new scope has a bandwidth of approx. 60Mhz (the stated bandwidth is never exact). On the CPC clock, your scope will effectively be showing you the sum of the fundamental frequency plus the harmonics up to the 4th (64Mhz), but all further harmonics are too high a frequency for your scope to handle (or will be seriously attenuated). As seen in the diagram above, this isn't enough to give a well defined square wave. This also answers another frequently asked question: Why do I need a 100Mhz scope if I only intend measuring signals up to 16Mhz? ...well that's why. For sine waves the stated bandwidth is what you can accurately measure with the scope, but for square waves you need to be able to measure higher frequencies than the square waves fundamental frequency to get an accurate picture. You can test this effect on your scope by switching on/off the 20Mhz bandwidth limit. This will show you the effect that ignoring the upper frequencies has on the displayed shape.

The next issue is what's known as the rise time of the scope. Every scope has a certain rise time, ie: how fast the scope can keep up with a sharp signal rise. Even if your scope is able to handle higher frequencies, it may not be able to react to them. The very popular Rigol low-cost scopes have a rise time of about 3.5ns, so even if your scope has the bandwidth to capture lots of harmonics and you are measuring an ideal square wave with really sharp edges, the scope will show a 3,5ns slope on either side because that's the fastest it can update.
The last scope issue only applies to digital scopes. Older analogue scopes took the entire raw signal and fed it to the CRT. Newer digital scopes take samples of the signal at certain intervals and average out what happened in between the samples. So the more samples your scope can take per second, the more accurate the displayed square wave will be. However, even low-cost scopes such as the Rigol now offer at least 1GSa/s, which means that a 16Mhz signal is sampled around 62 times per wave which is more than enough to give an accurate picture.

Here's a look at a 4Mhz square wave on a 100Mhz scope. The square is relatively accurate because it can capture up to the 25th harmonic.


[attach=3,msg144677]


Now a 40Mhz square wave, where effectively, the scope is only able to display the sum of the fundamental frequency and its 2nd harmonic.


[attach=4,msg144677]


So... If I broke the bank, sold the wife and bought myself a >€200K 9Ghz 10GSa/s HP Agilent Keysight scope would I then see a perfect square wave? The answer is sadly still no.
For the same reason your scope couldn't show a perfect square wave, the electronics in your CPC wasn't able to produce one in the first place. The transistors that make up the clock circuitry also have their limits when it comes to the frequencies they can handle. They also have limits to the time they need to switch on or off. Additional problems such as capacitance in the tracks of the PCB will mean that even the best intentioned square wave will have been considerably rounded off due to these factors. In extremely high speed systems, very expensive parts are needed to be able to create accurate clock signals at extremely high frequencies and even the PCB track layout will be optomised to reduce capacitance.

But my $2 Chinese logic analyser shows me a perfectly square clock signal!
Of course it does. Logic analysers only measure the voltage at intervals and display them as high or low depending on the reading. Then they draw a vertical line between the high/low dashes. This isn't a representation of what the wave looks like, just a digital state readout.

So does it matter that my clock signal is all curvy?
Usually not. The clock really only has two states, on (1) or off (0). The electronics doesn't really care whether it's rounded or not. All that matters are the two thresholds for 0 and 1. As long as the clock is going below the voltage threshold for a 0 and above the threshold for a 1 at the correct frequency and the duty-cycle (high/low ratio) is approx. 50%, it is doing its job properly. The only time the waveform shape is critical is if a single waveform was somehow crossing the thresholds more than once per cycle, if the clock wasn't crossing one of the thresholds at all, or if the clock had "jitter" (the wave length of each wave was varying). To counter act multiple crossings, designers will usually use gates with hysterisis (known as Schmitt Triggers) to filter out the unintended crossing.


[attach=5,msg144677]


I hope that explained a bit about reading digital signals with a scope. Questions are of course welcome.

Bryce.

Further reading[/attach][/attach][/attach][/attach]

keith56

Fascinating post! I've been watching many of the eevblog videos recently, and am planning to buy an oscillosocpe soon, so your post has no doubt saved me a lot of time and confusion!

I'd be interested in seeing other posts or links to other tutorials on fault finding 1980's type hardware.
Chibi Akumas: Comedy-Horror 8-bit Bullet Hell shooter!
Learn ARM, 8086, Z80, 6502 or 68000 with my tutorials: www.assemblytutorial.com
My Assembly programming book is available now on amazon!

||C|-|E||

Great great contribution! Thanks!!  :-*

LambdaMikel

My first oscilloscope was one of these "SeedStudio DSO Nano V3 Pocket Digital Storage Oscilloscope". I bought it because it was cheap (90 $), and because I was just starting with electronics last year. I wasn't even aware of its bandwidth... until I connected it to CLK on the CPC and only saw a Sine Wave  ;D The scope is fine for audio / analog signals I suppose, but not for digital. Now I have something better - a Hantek DSO6072P that can go up to 70 Mhz. It is only twice the price of the DSO Nano, and I am totally happy with it (couldn't believe the prices of some Tektronics scopes  :o ). The CPC CLK is sharp as square with it, and I am happy. Unbeatable for the price. I would say - if you want to do digital electronics, don't buy a DSO Nano. A digital logic probe will serve you better.

Gryzor

Look at that, it's not even 10am yet and I already learned something. I'm tagging this day as 'productive'.


I don't have much use personally, but it's very interesting because if nothing else it helps me better understand the vids I watch :)


Thanks!

Bryce

I intend doing more short electronics tutorials over time as there seems to be quite a few people here looking to learn more electronics, but only if the subject has a direct relation to the CPC or retro repair. If there's any particular subject that anyone wants covered, then send me a PM.

Bryce.

@Gryzor: Sorry about that, I hope you had at least already got your first coffee in?

Bryce

As there was some discussion here recently about the tapedeck and what all the op-amps there are doing, here's a pretty good video from Dave over on the EEVBlog that's well worth watching:
https://www.youtube.com/watch?v=7FYHt5XviKc

Bryce.

tjohnson

Very useful post, thank you for taking the time to post this, please keep them coming.

talrek

Very good initiative !!!! I like it !

kribjo

#10
This is great Bryce.  :)


I don't know much about electronics, but posts like this which is both informational and educational are really appreciated. Thank you.


I hope you continue with posts like this (electronics stuff).


Bjørn

Bryce

#11
Humble Beginnings...

I just had another one of those annoying "electronics is such an expensive hobby" discussions with someone who seems to think that you need to spend a five figure sum on electronics equipment before you can build your first flashing LED circuit. You don't! In fact you'll often learn a lot more by NOT having a shed load of fancy equipment that you don't know how to use properly anyway.
So I went back into my store of old bits, just to let you know what I started with:

My first soldering iron. This actually belonged to my dad, but I used it for 4 or 5 years until I finally got to buy myself something more fitting for electronics. Yes, that small coin is a 2 Euro, just so that you can appreciate the size of this beast. At the time I was around 7 years old and this thing was almost the length of my arm. The handle is wooden and it's so heavy that I had to balance it by supporting the hot end with a screwdriver. Temperature control? Yes, it had hot (on) and cold (off) :)

[attach=1,msg148699]

This is my first meter. No true RMS here, no data logging, min/max or anything even close to the options available today. It was my 8th birthday present and it was a mini-revolution for me. I was one happy 8 year old.

[attach=2,msg148699]

This is my first scope. A lightening fast 10Mhz dual channel scope (actually it's a stereoscope, not a dual channel scope). I cut the neighbours grass for a whole year to afford this wonder of scientific measurement. It doesn't do SPI/I²C/UART decoding, it doesn't connect via USB. In fact it doesn't even have a defined trigger or any sort of measurement features, but it was enough.

[attach=3,msg148699]

All three are still working. I wouldn't use them today, because I have better equipment, but I want to point out that you don't (despite advice from some experts) need the latest and greatest equipment to start out in electronics. The equipment above is all I had available when I designed and built my first ROMBoard, first radio, first transmitter and even some of my first test equipment to expand my measurement capabilities.

If you have the resources available to buy fancy equipment, then buy what you want (and learn how to use it properly), but even if you don't, a €50 scope, €20 meter and €15 iron will get you a long way and if you do decide to stick with the hobby you can upgrade along the way when your resources allow.

Bryce.

||C|-|E||

That must be the biggest soldering iron I have ever seen , Jesus!!  :-\  How did you manage to work with it? My first iron belonged to my dad too, but it was really small, so at least I could use it in an easy way. I still use it to cut plastic and it is here with me, in UK  :laugh:


The scope and the multimeter are really nice too. Actually, my first meter was very similar to that one, but less classy. The case was pale blue.

LambdaMikel

Quote from: Bryce on 11:45, 28 August 17f you have the resources available to buy fancy equipment, then buy what you want (and learn how to use it properly)

... "learn to use it properly" is a good point I think... fancy equipment also has a pretty steep learning curve that might be overwhelming for the beginner. Sometimes less is more.

Bryce

If anyone is looking for a really really cheap multimeter, this one is easily the best in the extreme cheap range: http://www.ebay.de/itm/Digital-Multimeter-Spannung-Strommessgerät-9999-Zählung-AC-DC-Amperemeter-AN8008/232447770807

I wouldn't use it to measure anything close to the 1000V they claim or even 240V, but for low voltage electronics it's ideal. Make sure you get the AN8008 version and not a lesser featured 8002/4/6 version. It's got a really crisp LCD display and it seems to be pretty accurate. It has all the usual volts, amps (down to µA!), resistance, diode test and can even measure capacitance and frequency/duty cycle. It's no Fluke, but for the price it's a very good meter to get you started.

Bryce.

Bryce

Another short retro-relative video from Dave for all those itching to design some retro hardware:


https://www.youtube.com/watch?v=rfaCFEqk05M

Bryce.

Bryce

Another interesting video from Dave about retro computer hardware. This time he explains how PC analogue joysticks work.


https://www.youtube.com/watch?v=hMBbnWjbUAU


Bryce.

Btw: This isn't how the BBCs did analogue joystick reading.

Bryce

Another good video from Dave. This time showing how to find a shorted power rail on a massive board full of TTL chips:


https://www.youtube.com/watch?v=11YX-yByl10


Bryce.

Bryce

#18
Power supplies

It's been a while, so once again I thought I'd write a small piece to explain an aspect of retro electronics that I get asked quite often. This time I'd like to talk a bit about power supplies. The differences between Analogue PSU's and Switched Mode Power Supplies (SMPS) and why SMPS's (especially cheaper ones) aren't recommended for powering retro gear.
So what's the difference and why are there two different types of PSUs? The first noticeable difference is the weight. Any Amiga fan out there will tell you that there are "Heavy Amiga PSUs" and "Light Amiga PSUs". The heavy ones are analogue, the light ones SMPS. Both supply 5V and +/-12V so why have two different types? Let's see...

This is what's in an analogue PSU (5V) and how it works:

[attach=1,msg159178]

Starting from the left, the 220V AC mains comes in at JP1 (there's most likely a common mode choke / fuse / MOV / PTC and other bits, but this is a very simplified description). The transformer then reduces the 220VAC to about 15VAC in this example. A transformer is nothing more than a chunk of laminated iron with two or more copper coils wrapped around it. The ratio of the turns of coil determines the value of the secondary (output) voltage. So if the secondary coil has half as many turns as the primary (input) coil, the voltage would be halved. Two important things to know: Transformers only work with AC, not DC (the voltage needs to be constantly changing value) and (very important for this discussion) the size of the iron core required is relative to the frequency of the varying voltage. Mains AC is 50Hz in Europe, so a big chunk of iron is required. The higher the frequency, the smaller the core can be.
After the voltage has been stepped down, it then needs to be rectified (converted to DC). This may be done by a single bridge rectifier component (B1) or by discrete diodes (a bridge rectifier is just 4 diodes in a single package), depending on what the designer preferred (or what was cheaper). The voltage will still have a small amount of ripple (a varying wave on top that is in time with the AC frequency) and this can be reduced with capacitors (C1 and C3). The voltage at this stage is still unregulated, meaning that it's value still depends on the original input voltage. So if the 220V were to increase or decrease, the 12VDC would do the same. Obviously not good, so the next stage is the regulator. This component (or circuit) will take a voltage and regulate it to an exact, stable voltage. The output will always be the same whether the input voltage varies or not  as long as the input voltage is sufficiently higher than the required output voltage. Exactly what our CPC needs. The last stage of the PSU is some more capacitors. These help the regulator do its thing by stabilising the output in moments where the CPC suddenly pulls more or less current from the PSU.
Here's a picture of the inside of an Amstrad MP-1 which contains an analogue PSU. The transformer is pretty obvious, the rest is on the PCB at the front. Amstrad chose discrete diodes for the rectification and the regulators can be seen attached to the heatsink on the right.

[attach=2,msg159178]


Switched mode power supplies.

[attach=3,msg159178]

At first sight, this might look quite similar to the analogue PSU above and it uses many of the same components. However, it works completely different. The first big difference you'll notice is that the rectifier is now before the transformer. But, but... you said transformers only work with AC...?? This is where that controller IC and that big transistor comes into play, but we'll get to that in a minute.
Starting again from the left, the 220VAC mains comes in through JP1, but this time it's immediately converted to DC with B1 and a pretty big capacitor (C1) stores this energy. This is what makes SMPS's so dangerous to work on. This capacitor can store a massive amount of energy at very high voltages (about 310VDC from a 220VAC mains source). R1 is called a "bleed resistor" and its job is to discharge the capacitor when the power goes off, however this part is not present in many cheap SMPS's although its cost is tiny. So touching the contacts of any parts on the primary side of the transformer could result in instant death if you are unlucky, even if the device has been turned off for days! Moving quickly along... R2 and D1 create a local low voltage to power the controller and a few other components on the primary side. The controller is the bit that does all the magic. It switches TR1 on and off very quickly (usually some frequency above 100kHz) which creates a sort of artificial high frequency AC. In reality just a square wave, but this is enough to keep the transformer happy that it's AC. But because the "new AC" is at a very high frequency and also current limited (R3 does this), the transformers core (and windings) can be considerably smaller than in an analogue PSU. The output of the transformer is then rectified with just one diode (because the "new AC" doesn't go negative) and a capacitor (C5) for smoothing.
The regulation is also done by the controller. By monitoring the output voltage, the controller can vary the pulse width of the transistor on/off times to make minor voltage adjustments. The feedback is done via an opto-isolator so that if something went badly wrong, there is no direct connection between the scary voltages and the output connector. This monitoring is also the reason why some SMPS's need a certain current to flow before they will start. If the current isn't detected by the monitor, the controller thinks something is wrong and shuts down.
To summarise, an SMPS converts the AC to DC, then creates a new high frequency AC and transforms this down to the voltage required and regulates the output voltage by adjusting the pulse width on the input to the transformer.

Here's a picture (not from me) of a homemade SMPS designed very similar to what I've just described. The 8 pin IC is the controller and the 4 pin IC next to the transformer is the opto-isolator. He has also used discrete diodes for the rectifier. As you can see, the transformer is considerably smaller than those in an analogue PSU.

[attach=4,msg159178][/attach][/attach][/attach]

Bryce

This is of course the simplest version of an SMPS. There are fancier solutions that use 4 transistors in a bridge configuration to create a more realistic AC signal (that goes negative) or produce more than one output voltage (such as in the Amiga light PSU). Good SMPS's will also have many additional components such as capacitors and inductors to further filter and clean the output signal even more and proper input protection too.

Advantages and disadvantages.
The main advantages of an SMPS is the fact that they are a lot lighter, less bulky, cheaper and a lot more efficient. Their size and shape is also more flexible. This was needed to allow new designs. Take for example a modern TV, just a few cm deep. Without SMPS's the TV would always have to be wide enough to house the analogue PSU transformer. Regarding cost, it's not just the cost of the iron and copper in the transformer has been reduced, but also the transport costs due to less weight. All this made SMPS's pretty popular and finding a decent analogue PSU is getting more difficult every year.

But there are disadvantages too. As the switching frequency is relatively high (compared to the 50Hz mains), they tend to be noiser, transmitting spurious signals all over the place. For this reason they are usually housed in a metal case, but they also have conducted EMC (ie: the frequencies travel out of the unit along the output wires). This is usually reduced by filtering the output through capacitors and inductors.

But these are used all over the place without an issue, why is using one on a retro computer any different?
Modern equipment is usually better screened against high frequencies. Their power input is also filtered with capacitors and inductors to stop high frequency noise. Our retro computers were designed to stop the 50Hz ripple expected from an analogue PSU using a few capacitors, but they have no protection against the high frequency spikes that come from an SMPS. These spikes can be considerable, causing bits to flip, CPUs to crash and even over voltages which could cause ICs to die. Another complication is the fact that a 50Hz ripple can be filtered with almost any electrolytic capacitor, the value isn't all that important, so anywhere between 100µf and 470µf might be used and will do a half decent job. With higher frequencies it's a different story, the filtering components in commercial devices will have been chosen to filter the exact switching frequency of SMPS in the device. If a different SMPS is installed, the filtering may no longer be sufficient. When you buy some cheap SMPS, you have no idea what frequency it switches at (or even if it remains at a single stable frequency), so trying to filter out these spikes can be extremely difficult.

So what's the difference between the cheap and expensive SMPS's?
The cheap ones save where they can. Metal housing - gone. Bleed resistors - gone. Safety components - gone. Minimal filtering and the cheapest of components. The biggest danger here is that the cheap capacitors used may reduce the high frequency spikes for a few weeks, but they quickly degrade and the noise gradually gets worse. The unprotected CPC will work as expected until (without warning) things get too bad and the CPC suffers.

As usual, if you have any questions, write them down, tie them to a brick and hurl them through my livingroom window.

Bryce.

Anyone interested in better understanding how transformers work should check out:
Faraday's Law, Lenz's Law, Eddy Currents and the Skin Effect.

Bryce

Just a quick explainer here: I've had a few people ask me what these strange looking components on some 464's are. (with some interesting descriptions: "Those brown things with a set of balls"... "The capacitors with tits", etc).These are LC Filters in a single package (often wrongly called Pi Filters, when technically they are T-Filters). Inside there are 2 inductors with a ferrite core (the bumps) and a capacitor. Their function is to remove high frequency noise from the keyboard lines to stop electrical interference being mis-interpreted as a key press.

Here's what they look like on the PCB and a diagram of what's actually inside. If they need to be replaced on a 464, you can bridge the outer two pins together and leave the centre pin disconnected and most likely not have any issues.


Bryce.



ComSoft6128

#21
Hi Bryce,

Forgive my ignorance on this subject but a question.
With a standardised design and (I assume) standardised components why would this be necessary on some machines and not on others?

Cheers,

Peter

Bryce

They either added them to comply with some emmissions regulations in some country/region, or they really were having issues and decided to add them later. My bet is that they added them for compliance.
There's no such thing as a "standard design" though. Electronics is like making a cake, all the ingredients might be great on their own, but every mixture will give different results.

Bryce.

Andrew Musson

Just come across this, great source of information on retro electronics. Thanks for posting.

Bryce

#24
Some more questions that seem to pop up regularly, so I thought I'd put a post here to cover it:

Question: What's the cheapest scope I can buy that's good enough to repair a CPC.

Answer: The scope should have an analogue bandwidth of minimum 50MHz, this is enough to at least probe the clock signal (although it will look like a badly shaped sinewave) and test any digital signals. If you can afford more bandwidth (70MHz or 100MHz, then get them instead). It should have at least two channels so that comparisons are possible and if possible a screen grab feature so that you can post results online. The rest of a scopes features can be useful, but rarely necessary to repair a CPC.

This question is often accompanied by the "Do I need a logic probe / analyser?" question. I would say no. I have a logic analyser, but they are more useful for debugging a new design, it's extremely rare that you would need one for a repair.

Which Scope should I get?: If it's any of the following: No-name, based on an Arduino, Available as a kit, described as "pocket scope" then save your money, these are all junk. There are reputable manufacturers that sell very low cost scopes, especially if you don't mind it being a USB scope that requires a computer to be connected.

Some current decent USB scopes are:

Hantek 6052 - 50MHz (costs around €140)

Hantek 6082 - 80MHz (costs around €180)

If that's still outside your budget, Owon have a 25MHz USB scope, that is the very lowest acceptable spec to measure CPC signals and the clock signal will be just about recognisable, the Owon VDS1022 can be found for around €75.

If you prefer a full scope with screen and lots of knobs to turn, you will need to raise your budget closer to €300.

Bryce.

Powered by SMFPacks Menu Editor Mod