Wednesday, July 28, 2021

MiSTer FPGA : User Serial Connector to C64 IEC - part 2


This is part 2 of my journey, building my own custom board for C64 peripherals for MiSTer.
If you haven't read part 1, you can do so here Part 1

Today my boards from PCBWay arrived, so straight to the workbench to put it together.

The board I had made actually has two functions the IEC bus and a keyboard interface for a C128 keyboard that I use for my MiSTer.

The new board makes a pretty big difference, here are my previous prototypes that I had hanging off my MiSTer.

What I used to have
My original custom IEC bus for my custom C64 core
 

The new IEC Bus for the official core
 

A C128 Keyboard to USB interface
 

What I have now!

IEC on the Left - C128 Keyboard interface on the Right

Giving it a test run before unplugging my MiSTer

The MiSTer stack and my new board looking neat

From the back with the IO port

All plugged in and working

Make your own?

I know my requirements are pretty niche, but if you want one you can get one 
from PCBWay
 
You'll also need these parts:
 

 

Programming the Arduino

I found a great piece of Arduino code for C64 keyboard on the Internet.  
I've hacked it to suit my needs and to drive a C128 Keyboards extra keys.
 
You can get my hacked version of the code from Git Hub.
 
A special note: 
  Once you upload the code it is really hard to re-program the Micro with the keyboard code again.
  Simply upload the blink example code first ( that comes with the Arduino IDE ) THEN reload the 
  keyboard code.
 
 
PCB and Schematics 
 
I have released the board schematics and design here.

 

 




Monday, July 19, 2021

MiSTer FPGA : User Serial Connector to C64 IEC - part 1

I have been using my own custom hacked code and hardware on the MiSTer C64 core for a few years now, but finally it's in the official core.  This is awesome for two reasons, 1) I don't have to keep recompiling my cores and 2) it uses less pins and also has reset.

Initially I was confused about how the in/out pins worked and I also got lost in a mess of wires.  Eventually, I bit the bullet and rebuilt it from scratch and it worked.


You'll note that the uIEC is powered from my USB hub.  The DE10-nano doesn't have enough juice to run it.

I even put together a board for my IEC bus and my USB Arduino Interface for my C128 keyboard. They should sit together nicely under the MiSTer. I hope it works :-) . . . ( see Part 2 )


Here is a dump of all of my notes . . .

Caveat

Be very aware that this plug contains both 5v and 3.3v and that you are connecting a 3.3v system to a 5v system.

a) Wiring this up incorrectly may destroy your MiSTer!

b) You must also use a logic level converter

c) Verify everything I have written and linked to, I am not responsible for any mistakes below.


USB Cables

Please note that the pins of the USB 3 cable ends do differ on plug in some places (not all are straight through).


C64 Core Document

You should refer to the C64 core documentation : https://github.com/MiSTer-devel/C64_MiSTer#user_io-pins


USB 3 Type A Receptacle on the I/O board and DE10-nano pins

I have previously wired my own IEC bus directly from the DE10-nano. However, please note that the official MiSTer I/O board has 100 Ohm resistors between the pins and the USB Connector. The Newer I/O boards (5.6 and up) also have 10K Ohm weak pull ups.

However the IEC bus works fine without the pull ups ( I have a 5.5 board ).


Study the schematic for the pin out on the I/O Board : https://github.com/MiSTer-devel/Hardware_MiSTer/blob/master/releases/iobrd_5.5.pdf

or this one with the pull ups : https://github.com/MiSTer-devel/Hardware_MiSTer/blob/master/releases/iobrd_5.6.pdf

Verify the pin numbering of the USB 3 Type A Receptacle on the I/O board : https://au.mouser.com/datasheet/2/837/USB1075-1948891.pdf

Verify the pin translation of the USB 3 Type a Receptacle on the I/O board : https://pinout.net/pinout-scheme/507/USB%203.0%20SuperSpeed

Make the necessary adjustments / translations for your cable!!


The pins for the USB connector ON THE I/O board are :

1) 5 V

2) RS232 Tx

3) RS232 Rx

4) GND

5) ATN

6) DATA

7) RESET

8) CLK

9) 3.3v


Logic Level Conversion

I used this Logic Level converter : [url]https://www.sparkfun.com/products/12009[/url]

Please read the data sheet for usage.

L side is MiSter side

H side is IEC side


LV1 ATN => HV1 ATN

LV2 DATA = HV2 DATA

LV connect to 3.3v

GND connect to GND to GND ( I powered the Logic Level Converter entirely from the MiSTer so it has a common Ground, if you don't then you'll need to separate the grounds to each power source, Read The Manual ).

HV connect to 5v

LV3 RESET to HV3 RESET

LV4 CLK to HV4 CLK


IEC receptacle

I used this part for the IEC receptacle on my PCB design : SDS-60J : https://au.mouser.com/datasheet/2/670/sds_j-1778983.pdf


1) SRQ ( unused )

2) GND

3) ATN

4) CLK

5) DATA

6) RESET

 

Please see Part 2 for Schematics and Design!

https://8bitshardway.blogspot.com/2021/07/mister-fpga-user-serial-connector-to_2.html 


Tuesday, June 22, 2021

Atmel ATF1504AS(L) CPLD Development Board - Part 9 - DIP 14 and 16

After replicating the function of a 74HC00 in part 8, I became a little obsessed with creating a programmable CPLD that would fit a DIP format.  So after a little bit of playing about in DipTrace I came up with this.

I created two versions, a 14 pin version and a 16 pin version.  Both use the ATF1504AS(L) but in a TQFP package.  I also used 0603 SMD parts for the Capacitors and the Resistors, which although they are tiny, aren't too bad to solder on by hand. Just make sure you use Flux.

Because the PLCC and TQFP have different pinouts I first needed to find the correct MAX product to write for.  I am using the ATF1504ASL-25AU44-T which translates to this part from the conversion guide.

So I'll copy the existing project and set the part to EPM7064STC44-5.

 
I will also need to change the pins to match the new layout
 
 


Now I upload it as a 1504ASL ** NOTE the "L"

I had to make special jig to program the CPLD as used 1mm pitch not 1.25mm.

Here is the comparison between the 74HC00 and the CPLD.


 Here it is working just fine in my Z80MBC.





Friday, June 4, 2021

Building the : Cart64out by Sven Petersen ( kits available )

I've been looking at cart breakouts for quite a while now, but I've not had the skills or equipment to warrant one, that is, until now.  I recently bought and started using a Digital logic probe from Kingst and it it is a wonderful piece of kit.

So with my Kinst probe in conjunction with Sven's cart I am now looking at two more projects:

    1) Cart repair : I have two carts that I need to repair, both of which seem to be fine, but just don't work.

    2) Cart design : I'd like to try my hand at building a cart with a CPLD or FPGA.

Anyhow this build was pretty simple but I think It's going to be really handy.  The parts themselves are readily available apart from the cart edge connector, luckily the vendor was pretty good and I got a personalized deal for 30 units.  This is fine as I'll use them for board repairs and I may sell a few.

This is a bit of a niche project, I have quite a few spare boards and parts.

If you're in Australia and would like one please get in contact with me.  If you're outside of Australia, it's probably not worth while due to postage costs. 

The cost is $30 (AUD) for a full unassembled kit which includes:

  • 1 x PCB
  • 1 x edge connector
  • 1 x 40 pin connector
  • 1 x 18 pin header ( you can remove the 5v and GND pins if you wish like I have )
  • 1 x momentary switch
  • 1 x resistor network
  • 2 x standoffs
  • 2 x screws
  • 7 x jumpers
  • Standard Tracked parcel post to anywhere in Australia

I'm probably losing money on this I'm too scared to do the sums and find out, but it would be cool to see them other peoples hands.


Thursday, May 13, 2021

Repair : Commodore 128 blackscreen repair - part 2

This is a continuation of the Commodore 128 blackscreen repair.

Ohh Ohhhhh . . . We're half way there . . . 

Just before I started recapping the C128 I suddenly had a thought. I had only run the C64 diagnostics, was that really enough? 

It turns out that the C128 mode of a C128 does not check it's memory on startup and the C64 dead test cartridge only tests the 64K of RAM in the LOW Bank and ignores the HIGH Bank.

However do not fear there is also a C128 dead test cart available.  I went to the World of Jani and downloaded an image from the collection he has amassed in this awesome blog post : Diagnostic Carts and Manuals.

Making a C128 diagnostic cart

I downloaded a cart from from the World of Jani on to a 8K EPROM 27C64 and tried it with one of the many VersaZif64 carts that I had made quite a while ago.

No matter what I tried I could not get it to work.  I read Jani's blog on making C128 carts and decided that even though the ROM image was only 4K, a 16K cart was probably required for it to work.

So I tried using the 785260 image on a 16K EPROM 27C128 and it worked first go.  For the VersaZif64 cart you need to set the all DIPs to OFF and then turn the selector to 16K

Where's the rest of the RAM?

Running the C128 Diagnostic Cart it brought up the unseen memory issues lurking in the background.
** You can ignore the other errors, I do not have a test harness installed. **
 

I tried putting RAM dips over the existing dips and it didn't change.  Then I replaced both U46 and U47 and it still did not change.  That's really weird.  I thought maybe the Diag Cart is wrong so I downloaded memtest64 from this article.  However it also told me there was a memory issue.  Interestingly when I loaded it, it would sometimes just start the machine code monitor and on one occasion the  Diagnostic Cart also started the Machine Code monitor when it was running.

This is one of the symptoms of the C128 Kernel ROM being bad ( the low one I think ).  I pulled both the High and Low Kernel ROM's, tested them and they were both completely fine.

My next thought was that one of more of the logic chips had failed.  There are a lot of chips so I thought I'd probe around with my Oscilloscope to try to find the culprit, rather than just trying pot luck replacing the chips one by one.
 
However in the end it was just bad RAM and I replaced the entire high ram bank and it fixed the issue.

Recapping

I find it a chore looking at the motherboards to get a parts list for recapping.  Luckily there's always someone whose compiled a list already ( and may even sell you kits ).

I used the parts list from here https://console5.com/wiki/Commodore_128 but I sourced the caps myself as I wanted to do quite a few machines.

The caps in the machine overall looked in pretty good condition, until I popped open the shielding on the video chips.  One of the caps had a nasty burn mark on it.

 


Wednesday, April 14, 2021

The risk of buying chips online

 So far I’ve been pretty lucky buying chips from the internet but recently ( 2021 ). I have had two bad purchases on AliExpress.

The first purchase was 2 x 6510 CPU’s. This was a pretty easy dispute as one of the chips was broken in half and the other was dead.  This dispute was very quickly and easily resolved. 

On the second dispute I got scammed by a very schrewed and dishonest trader.  So I am going to document my lessons learned here for dealing with fake chip disputes on AliExpress. 

So here goes . .

When opening a dispute with AliExpress you need to document your dispute fully. 

1) take photos of the product front and back

2) take photos of the packaging front and back including all packing material

3) take SHORT videos of you testing the item as clearly as you can showing the item not working. 

4) write your issue in detail in full

5) when logging the issue only do "full refund no return"

6) do not engage the vendor if they try to get you to return the item.   Let AliExpress deal with them. 

I learnt a very hard lesson from this vendor and lost a lot of money. So in full disclosure I’m going to put it here.

I do not recommend buying from Liheng at Aliexpress.  Please note that they have a number of shop fronts such as Liheng1 and Liheng2 . . etc etc.  I suspect this is so they can cycle through thier stores to clean out negative feedback.


Saturday, March 27, 2021

Atmel ATF1504AS(L) CPLD Development Board - Part 8 - Replacing Logic 74HC00

Time to experiment with replacing Logic chips.  This time I am going to replace a 74HC00 on a Z80-MBC2 board.

It's important to review not only the data sheet for the 74HC00, but also the Z80-MBC2 to ensure that it is appropriate.  For this experiment everything is running at 5Volts so it is safe to proceed.

You don't need a Z80-MBC you can just connect A and B to the VCC and GND lines in combinations and the Y lines to some LEDs.

However I wanted to see if it would work in a REAL system.

You can go to Hack a Day to learn more about the Z80-MBC.

 

74HC00 Datasheet

Let's first review the Datasheet, specifically we need to know how the 74HC00 operates and the pin out.  In this case it is very easy, there are four NAND gates in the DIP.
 
It should be strongly noted that we are implementing LOGIC only with the CPLD.  Some Logic chips have built in electrical characteristics that can not be replicated by the CPLD

 

Replicating the 74HC00 in Verilog

Now it's time to replicate the 74HC00 in Verilog.
As you can see on the image above there are Four NAND gates.
 
To save time having to type out each gate individually you can create an array of pins, the following declares 4 pins ( 0,1,2 and 3 ).
 
     input [3:0]  pinA
 
which is much better than this
 
    input pinA0    
    input pinA1
    input pinA3    
    input pinA4
 
Each gate has Two Inputs ( A and B ) and One Output ( Y ).
The Two inputs A and B are AND'ed togther and then the result is NOT'ed ( reversed ).
 
    Y = NOT ( A AND B )
 
In Verilog this is as follows where x is the pin number in the array.
 
    assign y[x] = ! ( a[x] & b[x] ) 
 


Let use also allocate the pins in a logical way in the Pin Planner.


Hooking it all up

Finally let's hook it up to the Z80-MBC2.  It is a bit tight for space so take your time with the wires.  I am using the Z80 to power the CPLD via pins 7 GND and 14 VCC.

Without the 74HC00 installed the computer stops at the line" IOS: Z80 is running from now".

It lives, the user prompt is ready and waiting for action.







Thursday, March 25, 2021

Atmel ATF1504AS(L) CPLD Development Board - Part 7 - Using a Clock ( clk )

Buttons and LEDs are fine but it really doesn't come close to interfacing with real hardware.  So now to take the human element out of the equation and time to use a clock.

For this experiment I am using a 1 Mhz crystal oscillator.  It doesn't sound very fast but the untrained human eye can only really see somewhere less than 100Hz (see various debates on this on the internet).

This isn't a step by step, but I've given you big hints on how to avoid the big issues.

Happy learning!

The BOM

For this experiment I will be using the following items:

  • 1 x CPLD Dev board
  • 1 x LED array ( as seen previously, or you can just use 1 LED and a resistor )
  • 2 x 4017 decade counters
  • 1 x 1 Mhz crystal oscillator, any 5 volt, 1Mhz  4pin crystal oscillator will do.
  • 1 x 01.uF capacitor
  • Lots of Jumper wires
  • LA2016 Logic Analyzer ( or any logic analyzer that can handle 5v )  (optional bonus content)


 

Failing and learning ( get a Logic Analyzer )

The one thing I learnt early on when constructing this experiment was that I simply could not get the clock division down to a low enough level to see the result.  What I really needed was a Logic Analyzer so I could actually see what was going on.  I went over and over the code trying to work out what was wrong with it and . . . there was nothing wrong.  I just didn't have the right instruments to tell me I was ok.

If you are going to continue your journey with CPLD's and FPGA's you are going to need one.  Go buy it now or you will just be frustrated.

Failing and learning part 2 (tie down all of the control input pins on the 4017)

 
The second issue I had was just failing to ground the reset and clock enable pins on the 4017.  Don't let control inputs float.  Either connect them to ground or to power.  I only realized at the end that I had not tied the reset pin to ground.  So frustrating.

 

Failing and learning part 3 (assign ALL pins on the CPLD)


I got mighty confused with the clocking because of the way the compiler works.  If you don't assign all of the outputs the compiler will assign random outputs on the internal buses that are not assigned to unassigned pins.  If you don't want to see output then assign them all to 0.

 

Example code

 
I originally wrote the code in Verilog, but as I didn't have a Logic Analyzer I failed and looked around for some example code.  Eventually I found Bil Herds example program on Hackaday and modified it for my own use.
 
The source is just a plain rip-off of Bil's project with a few modifications with the help of old school wisdom from my cousin.


Here are the pin assignments.

 

Why are you using 4017 decade counters?

 
This is pretty simple really.  When I first started this project I made some really rookie errors and couldn't get the clock less than about 122Hz with a little advice I managed to get it to work properly and no longer need them.
 
However, it is fun to used them and we get to learn a little more about how to interface with the CPLD.


Wiring up the board and Logic Analyzer output

 
Looking at the Analyzer you can see a number of signals.
  1. This signal is the clock itself at 1MHz.
  2. This is the output of the first CPLD counter at 3.90KHz
  3. This is the output of the second CPLD counter at 49.90Hz
  4. This is the output of the third CPLD counter at around 0.06Hz +/- a bit

 

Plugging the second CPLD output into the 4017's makes the LED flash a around once every 3 seconds.

And here is the finished product.

 


Saturday, February 27, 2021

Repair : Commodore 128 blackscreen repair - part 1

Quite a while ago I bought what I thought would be an easily fixable Commodore 128.  On the pictures it booted into 128 mode and c64 mode just had the blue screen with no text.

When the computer eventually arrived the green screen started with no text, that's odd and the C64 screen was not working at all.  Then after a few restarts nothing worked. Ugh oh!.

Let's open her up!

 
I've bought and fixed two 128's so far and previously I've used the rocking method on a soft surface with mixed results.  This time I tried a spudger and it work miraculously.  
 
Insert the flat end just above the joystick port and slowly move it to the high point.
As you get close to the highest point lift the spudger up, this pulls the bottom of the case out and pushes the top in.  Intern this releases the catch.
 
Once complete do the same on the other side.  


Maintenance on the Character and Kernel Roms

On opening the case, the first blatantly obvious issue was that the character ROM had fallen out.  It was a custom ROM in an adapter so that a larger 8K ROM would fit in the 4K ROM socket.  Reseating the ROM did not fix the issue either.

The second thing I noticed was that the Character and Kernel ROMs didn't have any tape over the windows.  So I covered them immediately and popped them out to verify the ROM contents.  Surprisingly both ROMs where 100% fine.  So I put them back in.

What is going on with the PLA?

I left the machine for a few days and when I started it again 128 mode was working again, but this time it only lasted for one reboot then disappeared.  This really confused me.  I removed the SID and still nothing.  I was about to pull both of the CIA's when I noticed the PLA had one of those round pin sockets.  I am really dubious about them so I tried booting again with my finger pushing down on Chip and it booted back into the familiar 128 boot screen.

I tried this a number of times and it was really really inconsistent. In the end the best method I found was to try to twist the whole socket.  Even bending out the pins to make better contact with the socket failed to help. At this point I knew the socket had to come out so I ordered a proper socket and waited for it to arrive.

Previous repair damage, what *%# happened to this board?

While waiting I decided to remove the old socket.  I used the desoldering gun and some solder wick clean up most of the pins. The socket itself proved to be difficult to remove, so I ended up carefully cutting it up the removing it piece by piece.  The disaster struck, part of a via and the connecting trace slightly lifted. However the the damage was minimal.  On inspecting the board I also noticed that one of the other vias was damaged as well, this one I definitely was not responsible for, it just was not there. 

Then I had a really good look at the board and noticed the damage on the Ram sockets where someone had applied way too much heat and burnt the board and then soldered in the sockets really badly.

This machine was a mess and it was pretty obvious a lot of repair work had been done on the board prior to me receiving it.

The damaged vias I decided where probably the primary source of the issue of the socket.  So I decided that was the first item on my list to fix,  I would deal with the rest later.

Replacing the vias

I've never replaced vias or riveted a PCB before so I took a fairly pragmatic approach.  I worked out the current diameter of the vias by inserting micro drill bits into the holes and then double checking the diameter with digital calipers.  The diameter worked out to be 0.8mm.  I then sourced some vias from EBay, specifically this item here.


As the internal diameter was correct I needed to drill out the holes very carefully using a hand drill to 1.2mm.

 After inserting the rivet I placed tape over it so it wouldn't fall out and them placed a standoff under the via to stop it pushing out.

Ensuring the rivet is sitting on the standoff by pushing it down a little, hopefully you'll meet the resistance that the standoff offers.

Using a circular motion slowly flatten the rivet down. then use the other end to ensure it is flat to the edge.


Once you are happy and the rivet is tight, you will need to solder the track back to the rivet and then more importantly check the continuity of the new via and track!

A working C128, well just the 128 part!

Soldering in the socket and inserting the PLA back in gave me rock solid C128 mode.


The final stretch, fix C64 mode

The final part of this repair wasn't straight forward either. I was using the C64 dead test cartridge and using the old put the new RAM chip over the top of the old RAM chip technique. I just couldn't get it work 100%.  On closer inspection every single one of the already replaced and socked RAM chips had terrible soldering. There were huge blobs and non-existant solder on every single socket. The first job was to resolder every single leg.  After that I was very quickly able to complete identifying and replacing two RAM chips.



So really there wasn't very much wrong?

In the end there really wasn't much to do.  However it does pay to inspect your unknown dead boards for bad repairs before you start the repair work.  I'm pretty happy how this turned out.

The final step for this will be to recap the electrolytic capacitors and I might look at a video memory upgrade using modern parts, but that is a whole other project.

But hang on wait . . . I've only check the C64 mode . . . does the C128 mode actually work properly?

See part 2