Commodore VIC-20 Expansion

After getting my Commodore VIC-20 working with SD2IEC  (Was a blown 7406 hex inverter) it’s now time to build a 32k expansion.

Found a great write up on Ruud’s Commodore site.   A schematic is provided which gives the  VIC-20 32k of expansion memory using 62256  (32k x 8 RAM) and a 6264 (8k x 8 RAM)  chips.

Setup the schematic in Autodesk Eagle and created a PCB. If you are looking to do this you might want to import the Commodore  library for Eagle which contains all the common parts including the edge connector.

Sent the gerber files to PCBWay, 10 boards for $5. Bargain!

Datasheets for the semiconductors:

 

SD2IEC for Commodore 64

After winning a cheap bid on a Commodore 64 off eBay  the other day I’ve looked into  building a SD2IEC.

The SD2IEC is a storage device using an SD card and interfacing with the IEC bus using a ATMega644 microcontroller.

I used most of the information from 16 Bit Dust .  Looking at the schematic I already had most of components.

I already had a SD Card with a built in 3.3 voltage regulator so did’t need to add this into the build. Also used the ATMega1284

 

 

First step is to program the microcontroller with a bootloader.   Having already built a USB Tiny ISP it was a simple step to program it. Schematic for this I got from AdaFruit

Bootloader files are available from sd2irc.de  

Download /bootloader/newboot-0.4.1-binaries.zip, extract the files and write

newboot-0.4.1-larsp-m644p.hex  to the microcontroller. I used avrdude:

avrdude -c usbtiny -p m1284 -e -V -U flash:w:newboot-0.4.1-larsp-m1284p.hex

avrdude -c usbtiny -p m1284 -U lfuse:w:0xd7:m -U hfuse:w:0xd2:m -U efuse:w:0xfc:m

 

Next comes building the circuit. I used a veroboard and there were not that many components to add.  Didn’t have to use R1-R6 as they were already on the SD Card.

 

Data cable pinouts

Power cable pinout

Not as pretty as the bought ones but it didn’t cost me anything to build and was a fun project.

After assembling copy the S2IEC firmware to the root of the SD Card. Power on and the red LED will flash for two seconds while it looks for a valid firmware. The green LED should then flash while it accesses the card. When it starts to flash the firmware the green LED will flash rapidly.

To test if the computer is successfully connecting to the SD2IEC device you can use the following simple program:

10 OPEN15,8,15:INPUT#15,A$,B$,C$,D$

20 CLOSE15

30 PRINT A$,B$,C$,D$

 

This will print the current SD2IEC firmware to the screen.

Building TZXDuino

To load programs on the AZ Spectrum you need a cassette player…or so I thought.

 

Came across TZXDuino which lets you play files from the SD card using an Arduino and a amplifier.

 

Rigged this up in a morning and it works beautifully. I updated the code to use a LCD 16×2 without I2C.

Its fairly easy to build and uses:

  • Arduino Mini Pro
  • SD Card
  • LCD 16×2
  • 5 x buttons
  • LM386 amplifier (Circuit from StackExchange)

 

 

Programming the 28C256

Not having a programmer for this chip I decided to  use my Arduino. After trying out various projects on the internet I eventually came across TommyPROM which uses 74LS164 serial to parallel shift registers. Wired up to my Arduino Uno, fired up TerraTerm  and uploaded the diagnostic ROM to the 28C256.

The 28C256 is a reflashable  EEPROM and almost the same pinouts as the 27C256 (OTP)

To replace the 27C256 with the 28C256 you need to go the following:

From StackExchange:

Comparing them side by side you can see the differences:

  • The ’27 has: a. pin #1, Vpp which in circuit is not used (either Gnd or Vcc) b. pin #27, A14 which is a driven address line.
  • The ’28 has: a. pin #1, A14 is a driven address line. b. pin #27, /WE Which must be tied high in circuit.

 

When you place the ’28 in circuit you must:

  • Lift pin #1 of the ’28 so it does not contact the Vpp pad
  • Lift Pin # 27 of the ’28 so that it does not contact the A14 Pad
  • solder or join or bridge the lifted pin 27 to Pin #28 of the ’28 (tying /WE high)
  • connect the PAD at Pin location #27 on the board with a blue wire to the lifted pin #1 of the ’28.

 

Spectrum RGB DIN to SCART Pinouts

After looking on the internet there seems to be a lot of confusing information on the pinouts for building a DIN to SCART cable. I’ve looked through the harlequin schematic and SCART pinouts and it should be as follows:

Spectrum Harlequin RGB DIN to SCART
DIN  ———–> SCART PIN – SCART Function
Pin 1 ———–> pin 5, 9, 13, 17 Ground
Pin 2 ———–> pin 8 — Switching (need +5V to +8V for on @ 16:9 or +9.5V to +12V for on @ 4:3)
Pin 3 ———–> pin 16 — Blanking (need +1V to +3V to select RGB mode)
Pin 4 ———–> pin 11 — Green video
Pin 5 ———–> pin 2 (Right), pin 6 (Left) audio
Pin 6 ———–> pin 15 — Red video
Pin 7 ———–> pin 7 — Blue video
Pin 8 ———–> pin 20 — Composite sync

ZX Spectrum Harlequin

After spending a good few hours reading up on retro computers and wanting to relive my childhood I’ve decided to give the ZX Spectrum Harlequin a go.

Yes, I know its probably cheaper to buy a complete assembled board or even a ZX Spectrum from eBay, but where is the fun in that!

There are many blogs and sites out there with a wealth on info so this should be a fun journey.

From ByteDelight:

A couple of years ago, Chris Smith reverse engineered the ZX Spectrum ULA (you can obtain the ZX Spectrum ULA Book to read about that).
Chris also developed the Harlequin: a ZX Spectrum 48K clone based on parts that replace the ULA, so no ULA is needed.
ZX Spectrum fans continued on this development which resulted in the design that is now known as the ‘Harlequin Superfo’. The current rev G is the most stable one.
You can now assemble a complete and 100% compatible ZX Spectrum 48K clone yourself!

 

I’ve decided to try and do this as cheaply as possibly and source the components from various locations.

First order of business. Order stuff!

  • Ordered Harlequin PCB from eBay for £15

  • Ordered ZX Spectrum case and keyboard from eBay for £10
  • For the parts list I started of with a bill of materials that Sergey Kiselev posted on his blog.

I already had some of these components  so managed to trim the list down. The remainder of the items I ordered from Mouser and eBay.  (Components mostly from China shipping time will be long but prepared to wait)

Link to my  Spectrum Harlequin BOM with prices.

I’ve also ordered a AT28C256 instead of the EPROM as this lets you reprogram the chip. The AT27C256 is a OTP.

Next, while I wait for parts I need to look it an Arduino based EEPROM programmer. Simple EEPROM Programmer from this site looks interesting.

 

 

3.5″ TFT Touchscreen for Raspberry Pi

I recently purchased one of these cheap 3.5″ TFT displays for the Raspberry Pi from eBay for £10 and spent many hours trawling the web trying to get it working.

 

 

 

This is a summary of all the steps I needed to follow from various sources.

Running the latest Debian Stretch Lite

First step is to install the Waveshare drivers:

wget http://www.waveshare.com/w/upload/9/9d/LCD-show-151020.tar.gz
tar xzvf LCD-show-151020.tar.gz
cd LCD-show
sudo ./LCD35-show

Raspberry Pi will then reboot.

Create udev rules:
sudo nano /etc/udev/rules.d/95-ads7846.rules

Add:

SUBSYSTEM==”input”, KERNEL==”event[0-9]*”, ATTRS{name}==”ADS7846*”, SYMLINK+=”input/touchscreen”

Reboot the Pi again.

Install dependencies for pygame

sudo apt-get install python-pip git libsdl-dev libsdl-image1.2-dev \
libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev libportmidi-dev \
libavformat-dev libswscale-dev libjpeg-dev libfreetype6-dev \
evtest tslib libts-bin

The latest sdl libraries caused all sorts of issues with the touchscreen on Debian jessie/stretch. It works but the x/y values from the touchscreen were very intermittent.

Downgrading to sdl 1.2.15-5 fixed the issue. (More info here)

#enable wheezy package sources
echo "deb http://archive.raspbian.org/raspbian wheezy main
" > /etc/apt/sources.list.d/wheezy.list
#set stable as default package source (currently jessie)
echo "APT::Default-release \"stable\";
" > /etc/apt/apt.conf.d/10defaultRelease
#set the priority for libsdl from wheezy higher then the jessie package
echo "Package: libsdl1.2debian
Pin: release n=jessie
Pin-Priority: -10
Package: libsdl1.2debian
Pin: release n=wheezy
Pin-Priority: 900
" > /etc/apt/preferences.d/libsdl
#install
apt-get update
apt-get -y --force-yes install libsdl1.2debian/wheezy

Once the library has been downgraded then it’s time to calibrate the touchscreen:
sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 TSLIB_CALIBFILE=/etc/pointercal ts_calibrate

Follow the onscreen instructions to calibrate the TFT Screen.

Install pygame library required for python:
sudo pip install pygame

I then used the following code as an example to build a python driven menu for the Pi:
https://github.com/garthvh/pitftmenu

Temperature sensors using WeMos

After trying for a few months to get mysensors working on a Arduino mini pro with a NRF24L01+ I eventually gave up as the radio was too unstable. Works fine one day and next it loses communication. I tried all the tips and tricks to get these devices stable but had no luck. I now have a drawer full of them gathering dust.

There are loads of posts on various forums with various issues on the NRF24L01+

Next I tried a WeMOS D1 Mini Pro  which has a built in ESP8266 wifi module. This works great. I’ve now got 6 temperature sensors running and have they have been stable for 2 months so far.

WeMOS

The WeMOS is dirty cheap. You can find them all over eBay for $3-$4 with free shipping. They are stable, coding on them is really easy and there are plenty of examples of code on GitHub.

Description: The D1 mini is a mini wifi board based on ESP-8266EX.

Features:

  • 11 digital input/output pins, all pins have interrupt/pwm/I2C/one-wire supported(except D0)
  • 1 analog input(3.2V max input)
  • a Micro USB connection

The great thing is you can use the ArduinoIDE to program the WeMOS which makes it really simple.

I had a DS18B20 temperature sensor connected and up and running in no time.

To log the data I’ve setup Domotitz on a spare Raspberry Pi and the WeMOS sens the temperate to Domoticz via HTTP calls.

Domoticz

See my code on Github for my water sensor which words on the same principle as the temperature sensors.

 

ESP8266 + DS18B20 LUA code completed

This LUA code on the ESP works like a bomb – really simple and really stable.

The temperature sensors are connected directly to the ESP’s GPIO0 pin. This eliminates the need for an Arduino as all the work is done by the ESP.

IMAG0477_zpstqsfwssw

https://github.com/StormTrooper/ESP8266-Temperature-Sensor

ESP8266 LUA

After having struggled for many days with the instability of the ESP (I almost got some code going which read the DS18B20 sensors and upload the reads via the wifi, but the ESP kept resetting or returning unpredictable results) I did some more reading up and found these clever guys are now using the microcontroller on the ESP to do lots more things.

nodemcu-style5-150px.png_150x150

With NodeMcu firmware you can connect the DS18B20 sensors directly to the ESP and run LUA code. No more need for the Arduino and no more AT commands!!!

Check out this guys blog for how to flash the firmware.

You can also download this great GUI (ESPlorer) for sending LUA code to the ESP

ESPlorer

A day later, no arduino, and I seem to have stable code uploading the results.

This is great! Time to order a few more of these modules!