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


Saturday, February 20, 2021

Repair : Burning "Chucky's" DiagROM

After fixing 8 or so C64's I'd gotten a little board with 8 bit repair. So on a whim I bought a very broken Amiga 2000 and Oh my . . . now I'm neck deep in it.

To assist my efforts I'm having to source chips, but the availability of just bits from broken machines is really limited at the moment and I really am not keen to cannibalize working Amigas for this.  So I thought, let's see what "Chucky's" DiagROM does, I've got some spare EEPROMS.

Steps in detail

I've previously backed up and burnt Amiga EEPROM's in previous projects using my GQ-4x4 with the 16 bit ROM adapter. This time let's do it in detail.

DiagROM

    You can get the DiagROM from  Chucky's website here : https://www.diagrom.com/
 
1) Plug your burner in and start the software (don't put any chips or adapters in it just yet).
 

2) Go to "Device" and select "AT27C400".
 
The Software tells you that you will need a) the Adapter and b) to put the chip into the bottom of the 40 pin socket.


 

3)  Go to "File" and then "Open" and open the file "16.bit" from the zip file you downloaded from the website.

4) You can leave all of the settings default and just click on "Write" to burn the image to the chip.  I will also perform a verify as well once complete.
 
 
5) Complete, now you have a DiagROM of your very own.
 
 
The next step from here is to get a serial console going.  So I'll need to get a USB to Serial cable, Null modem cable and a 9pin serial to ( whatever the big d-sub socket is ) converter.
 

Wednesday, February 3, 2021

Z80-MBC2 and the uTerm

One of the funnest projects that I've built has been the Z80-MBC2 and the uTerm projects by Fabio Defabis; what's more he just keeps churning out the Open Source goodness.

You can read more able the projects with the numerous links below:

https://www.facebook.com/groups/Z80MBC2

https://hackaday.io/project/159973-z80-mbc2-a-4-ics-homebrew-z80-computer

https://hackaday.io/project/165325-uterm

https://github.com/SuperFabius 

I'm really happy with my z80 CP/M board and after a REALLY long time I've finished my uTerm.


Why so long to finish the uTerm . . . well I am glad you asked!

 

After completing the uTerm it was time to program the STM chip and oh boy it went super pear shaped.  I looked for doco on how to do it and I just missed everything.  I plugged it in the wrong way connected power and POP . . . it was dead.  What follows is a HOW not to blow up your uTerm blog entry.

Read the Hackaday page : https://hackaday.io/project/165325-uterm/details

Scroll down to : HOW TO FLASH THE STM32 WITH THE ST-LINK V2

Read my Blog so you don't make mistakes!

  1.  The FIRST thing you should solder to the board is the STM chip
  2. The SECOND thing you should do it to solder on the 4 pin header for J6

        NOW STOP!!  It is time to program it.

You'll likely notice that there isn't much room around the chip once you put all of the through hole components in.  If you fully populate it, it's going to be a pain to get the broken chip out and put a new one in.  The second reason is that the STM chips have been really hard to get hold of.  I had to wait 3 months just to get mine on back order. 

  • The next thing to do is to PLUG the programmer into the board correctly. Make sure you have NOT plugged it into your computer.  Leave it disconnected until it is connected to the board like so.
  • The order of the pins of J6 on the uTerm board is as follows :

                PIN 1 : VCC 3.3v - ** make sure it is 3.3v ** 

                PIN 2 : SWDIO

                PIN 3 : SWCLK

                PIN 4 : GROUND 

  •  Check you programmer as pinouts are all different.  Mine has the pinout printed on the side.


  • With 4.6 version of the STM32 ST-LINK Utility you will need the following settings.

And you are done, now I have a green blinky cursor.

The complete uTerm.





Sunday, December 13, 2020

Repair : Fixing an Amiga tank mouse

I recently bought an Amiga mouse on Ebay.  Unfortunately the little sucker wouldn't work in the horizontal axis.  After a little searching I found this very useful youtube video.  I plugged the mouse into my scope and saw right away that one of the photo transistors wasn't working properly. So I decided to just replace them.

So off to RS Compnents I went to get some OSRAM LPT 80 A Radial Side Lookers.

Taking the black body off was a pain in the bottom.  I DO NOT recommend trying to lever the locking parts apart.  Just try to lever the whole part up.  I broke mine and had to glue them up.



You need to put the parts together and slide them in, just really gently. The slide the wheel in really gently as well.

If you do happen to break any of the plastic there isn't much that will stick to it.  I tried Tamiya model cement and super glue with no joy.  The only thing that did work was E6000 and it worked amazingly.
I did let mine cure for 3 days before re-assembly.

Now I have another working Amiga 600 tank mouse.