Sunday 11 September 2016

Repairing a ZX Spectrum 128K +2 (serial no U-043583) - Part 5

In part 4, I re-checked the onboard power supply voltages and made some adjustments to the +12V supply which was measuring a low 10.98V but even with +12V on the 12V line the ghost image still remained.

The final fix was found when someone on world of spectrum suggested the TV might be displaying both the composite video and the RGB video signal resulting in the two images on the screen. Initially, I thought the  cable I had bought was only wired for composite but on rechecking (this time measuring for resistance rather than continuity, oops!) it turns out the RGB pins are also wired.

The SCART to HDMI converter that I am using has no means of forcing selection of RGB or composite video in on the SCART input so as an experiment I connected an alkaline battery to the SCART "blanking" pin 16 to force RGB selection and the ghost image was gone.

Finally, it is now fixed and the display looks amazing!

Fixed display with no ghost image




Saturday 10 September 2016

Repairing a ZX Spectrum 128K +2 (serial no U-043583) - Part 4

In part 3, I checked the inputs to the TEA2000 composite video chip and could not see any obvious issues other than the low voltage on the 12V input.

I decided to check and replace some components on the onboard powersupply to see if they were causing the low 10V voltage measured on the +12V supply.

The onboard powersupply uses a ZTX650 transistor TR9 which looked okay but I decided to replace it with a ZTX651 which is an acceptable replacement for the 650 and I also replaced electrolytic caps C41 (100uF) and C23 (22uF) in case they were starting to fail.

Measuring the voltages I still get similar results so TR9 and the caps do not seem to be the cause of the low voltage on the 12V supply.

I measured
  • -12.34 (-12V)
  •  10.98 (+12V)
  • -5.03 (-5V)
  • 4.96V (+5V)
I posted on world of spectrum and it was suggested I check resistors R54(1K) and R55(1K8) which form the sense/feedback resistor network that drives TR8. Both resistors checked out okay and I noticed that the two resistors form a voltage divider so I decided to experiment. Replacing R55 with a 2K2 resistor results in 12.3V on the +12V supply. This does not fix the display problem but I have decided to leave it in for now.

Finally, I have decided to order a replacement TEA2000 to see if the IC is faulty. 

Saturday 3 September 2016

Repairing a ZX Spectrum 128K +2 (serial no U-043583) - Part 3

In part 2, I used a CART to HDMI adaptor as my LG TV does not like the composite video output from my spectrum 128K +2 but now I get a ghost image effect which is not present on the RGB output.

Composite video display with shadow



I got the oscilloscope out and started probing the composite video circuitry.
Spectrum 128 2+ composite video circuit

TEA2000

The TEA2000 is the IC in the spectrum that takes the RGB output from the ULA and generates the composite video output. Let's check it out.

The TEA2000 requires a 12V input on pin 11. I measured a fairly steady 10V which is a bit below 10.8V in the minimum spec in the datasheet. I do not think this is the cause of the ghost image so I will come back to look at the 12V supply later.

TEA2000 pin 11 12V input - 10V measured

 
The ramp input on pin 15 looks okay to me.

TEA2000 pin 15 ramp input



I measured the output on pin 6 which looked in spec but I am not sure if this is what the signal is supposed to look like or not.

TEA2000 pin 6 composite video output


I measured resistors R32 and R31 in-situ and they both measured the correct resistance according to the circuit diagram. Diodes D1 to D11 also seem okay when measured in situ and C3 is not shorted.

I can't see any obvious fault so will need to keep looking.



Repairing a ZX Spectrum 128K +2 (serial no U-043583) - Part 2


In part 1 I fixed the manufacturing fault which resulted in no output on the composite video but the resultant image was terrible.

Spectrum composite video on LG 32LB650V
The screen is covered in dots which do not move and seem to only appear on alternate lines. I do not think these dots are caused by a fault reading from memory as they also appear on the spectrum's border which is not read from memory.

I tried a SCART to HDMI convertor and the dots are gone so it turns out my LG TV (model 32LB650V) does not like the composite video from the spectrum. Maybe it is confused by the progressive PAL signal?



SCART to HDMI adapter ghost image
The dots and lines are gone but now there is a ghost image on the composite video.


Composite to SCART adapte

At this point, I tried another spectrum +2 using the SCART to HDMI adapter and got a perfect image so this ghost image must be due to a fault with the spectrum.

I lashed up a temporary RGB cable and tried that via the SCART to HDMI adapter and the ghost image was not present to I think the problem is something to do with the composite video circutry. Part 3....





Sunday 21 August 2016

Repairing a ZX Spectrum 128K +2 (serial no U-043583) - Part 1

I bought a ZX spectrum 128K +2* from ebay (serial no U-043583) which whilst it seemed to be mostly working had a terrible picture on the UHF output and no output on the composite video. So I set about trying to repair it.

Issue 3 of the ZX Spectrum 128K +2 had a number of transistors fitted the wrong way around during manufacture. So let's check those out.

* Not the black amstrad ZX spectrum +2A and +2B

Incorrectly fitted TR4


TR4 is often fitted incorrectly which prevents a composite video signal being present on pin 1 of the RGB connector. Sure enough the TR4 on this +2 is fitted the wrong way round. Note the silk screen is incorrect for this transistor.

TR4 fitted the wrong way round



TR4 is a TN3904 transistor. The collector should be connected to 12V, the base to diode D7 and the emitter to composite video out. If the transistor is fitted the right way round then testing for continuity with a multi-meter will show the collector connected to pin 11 of the TEA2000 IC (12V).

2N3094

If the transistor is fitted the wrong way round it is very easily corrected by unsoldering the part and putting it back the right way round.

TR9

TR9 forms part of the circuitry which generates the 12V required by the TEA2000 composite video IC. The TR9 is a ZTX650 NPN transistor and when fitted the right way round the emitter should be connected to ground. I have read reports of this being often fitted the wrong way round but on this +2 it is fitted correctly.


ZTX650
TR9 fitted right way round

Spectrum 2+ TR8 and TR9 schematic from service manual


Incorrectly fitted TR8 

TR8 also forms part of the circuitry which generates the 12V required by the TEA2000 composite video IC. TR8 is a 2TX213 PNP transistor and when fitted the right way round the emitter should be connected to +5V and the collector to resistor R29.

TR8 was fitted the wrong way round in this spectrum and this was corrected by unsoldering the transistor and fitting it back the right way round. Again, the silk screen is incorrect and indicates the wrong way round for the part.
TR8 fitted wrong way round



Incorrectly fitted TR5 

TR5 forms part of the circuitry for generating the Vsync signal which is required when using an RGB output. TR5 is a TN3904 transistor and when fitted the right way round the collector is connected to 5V and emitter to resister R57.

TR5 is fitted the wrong way round in this spectrum and can be corrected by turning it around but given this problem should not affect the composite video signal I have left it as is for now and will fix it later when I want to use the RGB output.

TR5 fitted wrong way round

 

 
TR5 Spectrum 2+ schematic from service manual

 

How to check a transistor is not faulty

The diode test mode on a multi-meter can be used to check a transistor. The transistor should be unsoldered from the circuit prior to testing.

A good diode should display a voltage drop ranging between 0.5 to 0.8 volts when forward biased and OL when reversed biased.

Composite video 

With the transistors swapped round I now get a picture on the composite video output but it is rather poor! Part two.....










Sunday 10 July 2016

Architecture v3.0 bus pin layouts

First draft layout for the two bus connectors for Architecture v3.0
  • DIN 41612  
  • 64 pins each

CPU bus

A1 - A8 = Left Bus (A1 LSB)
A9 - A16 = Z Bus (A9 LSB)
A17 = C_flag
A18 = V_flag
A19 = Z_flag
A20 = N_flag 
A21 - A30 = not used

A31 = GND
A32 = +5V

B1  = +5V
B2  = GND
B3  = CTRL_0  (LD_GEN_REG_1)
B4  = CTRL_1
  (
LD_GEN_REG_2)

B5  = CTRL_2  (LD_GEN_REG_3)
B6  = CTRL_3  (LD_GEN_REG_4)
B7  = CTRL_3  (OE_GEN_REG_1)
B8  = CTRL_4  (
OE_GEN_REG_2)
B9  = CTRL_5  (
OE_GEN_REG_3)
B10 = CTRL_6 
(OE_GEN_REG_4)
B11 = CTRL_7  (LD_ALU_FLAGS)
B12 = CTRL_8  (INC_PC)
B13 = CTRL_9  (SEL_ALU_OR_Z)    Selects between the Z bus or ALU as input to the ALU flags. Use of the Z bus allows the flags to be loaded after previously being saved to memory.
B14 = CTRL_10 (LD_INT_ENABLED)
B15 = CTRL_11
(/OE_L_TO_R_BUS)  Used to output a register value on the data (right) bus

B16 = CTRL_12 (SEL_ALU_OP_1)    Select ALU operation
B17 = CTRL_13 (SEL_ALU_OP_2)    Select ALU operation
B18 = CTRL_14 (SEL_C_IN_1)
B19 = CTRL_15 (SEL_C_IN_2)
B20 = CTRL_16 (/OE_ALU)    Place ALU output onto the Z bus.

B21 = CTRL_17 (ALU_INV_R)  Invert the ALU right input. Used to perform subtraction using the adder
B22 = CTRL_18 
B23 = CTRL_19 
B24 = CTRL_20 
B25 = ALU_OUT_V    V output from ALU
B26 = ALU_OUT_C    C output from ALU
B27 = ALU_OUT_Z    Z output from ALU
B28 = ALU_OUT_N    N output from ALU  
B29 - B32 = not used

External bus

A1 - A16 = Address Bus (A1 LSB)
A17 - A24 = Data Bus (A17 LSB)     aka the ALU right bus
A25 = Clk
A26 = Inv_Clk
A27 = read
A28 = write
A29 = not used
A30 = not used
A31 = GND
A32 = +5V

B1 = + 5V
B2 = GND
B3 = Interrupt
B4 = IRQ_0
B5 = IRQ_1
B6 = IRQ_2
B7 = IRQ_3

B8 - B32 = not used

Architecture v3.0

Version 3.x of Juno incoporates yet more major changes to the physical architecture of the system.

The two primary changes are the use of two physical buses and switching from through the hole (DIP) ICs to SMD (SOIC)

The two physcial buses are
  • CPU bus - contains CPU specific signals such as  CPU control signals. All CPU cards connect to this bus and the external bus.
  • External bus - contains CPU external signals. All CPU and non-CPU boards connect to this bus.

 CPU bus

The CPU bus carries signals which are internal to the CPU and each CPU board connects to the common CPU bus via a single DIN41612 64 pin connector. The signals carried on the common CPU bus include
  • CPU Left Bus (ALU right input)
  • CPU Z Bus (ALU output)
  • CPU control signals e.g. load register etc
  • Status Register - ALU flags V, C, Z & N and the status flags Interrupts Enabled and Supervisor Mode 
  • CPU clocks - non-inverted and inverted clock signals
  • CPU reset
  • Power
  • misc. board to board signals as required 

Common External bus

The common External bus carries signals which are required external to the CPU and each external board connects to the bus via a single DIN41612 64 pin connector. The signals carried on the common external bus include
  • Address bus
  • Data bus (the data bus also acts as the ALU right bus)
  • External control signals e.g. read, write
  • External clocks 
  • Power
  • Interrupts

 

Standard Physical board design 

Notes on physical PCB board design
  • Board size 160mm * 100mm
  • CPUBUS position 0.1 1.95 (Eagle package MAB64)
  • EXTBUS position 6.2 1.95 (Eagle package MAB64)
  • 4 * power supply de-coupling caps 10uF (Eagle package E5-5)
  • Add a title 'Juno PC <board>' (Eagle layer tDocu, vector font, size 0.07, ratio 8%)

Eagle PCB design setup

Notes on Eagle PCB design
  • Design Rule - eC_2Layer_PClass6_BaseCopperO18_eCDefault
  • Minimum width 0.15mm
  • Net classes
    • default 0.15mm
    • PWR 0.20mm
  • Bottom layer flood fill GND

 SOIC

A Small Outline Integrated Circuit (SOIC) is a surface-mounted integrated circuit (IC) package which occupies an area about 30–50% less than an equivalent dual in-line package (DIP), with a typical thickness that is 70% less. They are generally available in the same pin-outs as their counterpart DIP ICs. The convention for naming the package is SOIC or SO followed by the number of pins.

Saturday 14 May 2016

Setting up RaspberryPi as an Internet accessible Linux server using SSH

Raspberry Pi Linux server (junopc.ddns.net)

Brief instructions fro setting up a raspberry pi using DDNS so you can logon remotely from the internet using an SSH key.

Following instructions assume you have installed Raspbian and are using the default username 'pi' and the dafult hostname 'raspberrypi'

Step 1 - enable SSH on raspberry pi

Enable SSH by either
a) Login and run sudo raspi-config and enable SSH; or
b) create a file called 'ssh' (no file extension) in the boot partition. This is handy approach if performing a headless setup
Create a file named 'SSH' to enble SSH

 Step 2 -  check SSH (and change default password)

Next check you can log in via SSH using a username and password from a client device on the same local network before setting up an SSH key.
On a windows PC you can use PuTTY to connect via SSH.
The default settings on the raspberrypi are:
  • Host Name: raspberrypi
  • Port: 22
  • Connection type: SSH
If you have not changed the default username and password login as
  • login as: pi
  • password: raspberrypi
Note you will likely getting the following warning message:
SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

Change default password

This is really good advice. Change the default password before making your Raspberrypi accessible from the Internet. Do this even if you plan on disabling the use of  clear text passwords for SSH as one tiny mistake and you risk getting hacked.

 Step 3 - create SSH key 

Create an SSH public and private key for each client machine that you will be connecting from. The private key is used by the client to identify itself and the raspberrypi uses the public key to authenticate the client.

For a windows PC you can use PuTTY and its SSH Key Generator PuTTYgen to generate an SSH key

PuTTY Key Generator


Set a key passphrase to protect the private key and save both the public and prive key on the client machine

Step 4 - add the SSH public key to raspberrypi authorized_keys

Import the SSH public key into the user's authorized_keys file ~/.ssh/authorized_keys on the raspberry pi.
 There are a number of ways to do this, for example
  • use WinSCP to edit the SSH public key file ~/.ssh/authorized_keys
  • Copy and paste the public key into the file. The text should look something like

ssh-rsa AAAAB3NzaC1yc2E.....

NB if using PuTTY Key Generator copy the 'public key for pasting into the openSSH authorised keys file' not the saved public key

Step 5 - test SSH login

Test you can now remotely log in using the SSH key.

Step 6 - disable SSH login using clear text passwords

Now increase security by disabling the ability to log in using SSH clear text passwords and restricting which accounts can log in via SSH.

Firstly, create a backup copy of the default config file in case you mess up
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original 

Edit the sshd_config file
sudo nano /etc/ssh/sshd_config

Make the following changes

Change
#PasswordAuthentication yes
to
PasswordAuthentication no

Add the line
AllowUsers pi

Restart the SSH server for the changes to take effect
service ssh restart

Finally, check you can SSH connect using the cert and cannot SSH using a clear text password (username pi & password).

NB view the SSH log using journalctl -u ssh.service

 Step 7 - Create DDNS

Sign up to a DDNS service such as no-ip and register a DNS name for the raspberrypi

Step 8 - Enable DDNS on your router

Enable DDNS on your internet router so that if your IP address changes the DNS record will be updated with your new IP address. 
On my BT HomeHub the DDNS setting is under Settings > Advanced > Broadband > DDNS
Enter the DDNS details and confirm the connection to the DDNS serivce

Step 9 - Enable port forwarding for SSH

On your router enable port forward for SSH (port 22) to raspberrypi

Step 10 - Test ability to connect from the internet to RaspberryPi

Everything should now work and you should be able to connect to raspberrypi as user 'pi' using your DDNS hostname and your SSH private key and passphrase.

Sunday 27 March 2016

Arduino TEA 5767 FM radio

An FM radio using a TEA5767 FM radio module and an Arduino

Main parts

The main parts used are
  • TEA 5767 FM Stereo Radio Module for Arduino 76-108MHZ (http://www.aliexpress.com)
  • TOOGOO(R) Keypad Shield Board  (amazon)
  • Arduino
  • FM aerial
  • Headphones / speakers

The TEA5767 FM module provides the stereo FM radio recevier and headphone outputs. The receiver is controlled by the Arduino via I2C. 

The TOOGOO keypad shield provides a two line display for displaying the current frequency and signal strength etc. It also provides the buttons that are used to control the radio.

TEA5767 FM Stereo Radio Module

 The datasheet for the TEA5767 can be found here datasheet

Source code

My source code for the project can be found at the Git hub repository source code

The software radio supports 5 modes which are cycled through using the up and down keys

  1. Signal mode - the display shows the current frequency and signal strength. Volume is controlled with the left and right keys
  2. Manual mode - left and right keys change the tuned frequency
  3. Scan mode - left and right keys scan for the next radio station
  4. Preset mode - recall a saved preset radio station. Use left and right keys to select the preset and the select key to recall it
  5. Programme mode - save the current radio station as a preset. Use the left and right keys to select the preset and the select key save

Presets are saved in the Arduino EEPORM so they are not lost when the power is turned off. 

The software includes a library of functions for controlling the TEA5767. This library works with the TEA5767 in I2C mode therefore the BUSMODE pin needs to be connected to ground to select ITC mode. The IC address is 11000001.

The most fiddly operation provided for by the library is setFrequency(double freq)which sets the radio frequency. The radio uses a Phased Lock Loop (PLL) and to tune the radio to a wanted frequency the corresponding PLL word must be calculated. This is a 14bit word that is sent to the programmable divider. 

The PLL word for high side injection mode is calculated as follows

    // calculate PPL word for high side injection
    // PPL = 4 * freq(Hz) + 225kHz / clock(Hz)
    frequencyB=round( ( 4*( (freq*1000000)+225000) ) /32768);

My library only uses the high side injection mode when tuning the radio. According to the datasheet the function should tune the radio to both the high side and low side and then select the one with the strongest signal but in practice I've found using only the high side seems works fine for demo purposes. 

Wiring

The wiring should be connected as follows
 
TEA5767 wiring
 * SCA to Arduino SDA
 * SDL to Arduino SDL
 * VCC to 5V
 * GND to GND

LCD wiring
 * R/W (pin 1) to GND
 * VCC (pin 2) to 5V
 * V0 (pin 3) to variable resistor (contrast)
 * RS (pin 4) to Arduino digital pin
 * E  (pin 6) to Arduino digital pin 9
 * D4 (pin 11) to Arduino digital pin 4
 * D5 (pin 12) to Arduino digital pin 5
 * D6 (pin 13) to Arduino digital pin 6
 * D7 (pin 14) to Arduino digital pin 7