Showing posts with label Datasette. Show all posts
Showing posts with label Datasette. Show all posts

Sunday, 19 June 2022

Powering Commodore Datasette Drives

After last weeks post covering the modification of a Commodore datasette drive to create cassette masters, literally no one asked for more details on how the datasette drive was powered. So I thought that was a perfect excuse to go into considerably more detail on the subject.


The datasette was first introduced to go with the Commodore PET in 1977, and remained in use right through into the early 1990s. The original PET was almost entirely 5V. All the logic, ROM and RAM was 5V only. These were the days before the 4116 DRAM chips which need -5V and +12V as well. 

The exception to the 5V only statement is the datasette drive. It has a 5V supply for the internal logic, but there is a separate power connection for the motor, which should be supplied with 6V.

The arrangement is different from most cassette mechanisms. Normally there would be a permanent 6V supply for the motor, and a mechanical switch on the drive itself to turn the motor on or off, sometimes in series with a relay controlled switch on the computer end. The Commodore datasette relies on the host to use the sense line to detect when a key is pressed on the mechanism to turn the motor on or off. 

You will see some situations where these are driven from 5V, for example the old parallel port X1531 type transfer cables. These run the motor slowly, 5/6 of normal speed. This makes the tape move more slowly, so the data is written closer together on the tape. When played back at normal speed, it will actually be 20% fast. This is just about within the tolerance of the loading routine, so can speed up loading a bit, but it's not guaranteed, and wouldn't be recommended these days.

PET 2001

The PET's power supply was 9V DC unregulated, with several 7805 5V regulators, so 9V was available, and that was used to generate 6V for the motor.

There is quite a lot going on there. If you ignore the resistors and 2N3904 on the left, what you have is a 7.2V zener diode fed via a 1.5KΩ resistor, which gives a regulated 7.2V reference. The 10nF capacitor smooths the reference voltage, which is then buffered by the two transistors in a darlington arrangement. The output is a regulated supply of 7.2V, minus the two base voltage drops, 0.6V each, giving a 6V supply. 

Bringing back the 2N3904, when the Control signal is low, the 2N3904 is off, and does nothing, and the output voltage remains at 6V. When the control signal is high, the transistor is turned on and pulls the 7.2V reference voltage down, and in turn, the output transistors are turned off and there is no output.

That gives a simple switched 6V output. Control is high, motor is off. Control is low, motor is on.

VIC20 / C64 / C128 / TED

Over the years, that circuit was revised a few times, and I found quite a bit of variation from model to model and machine to machine. Different drive transistors, different zeners etc. The voltage is always "around 6V", but it varies from a little over 5V to almost 7V on some of the machines I have tested.

The final version in the TED machines like the C16 and plus/4 was much simplified.

This used a 7406 gate to replace the 2N3904 transistor, but still doing the same job of pulling down the reference voltage when the drive is not in use. Gone is the second buffer transistor, so more current is drawn from the zener reference, which had it's resistor value dropped to 470Ω. That does mean that when the motor is off, the 470Ω resistor is across the supply rails and wasting 20mA all the time.

Mini PET

When I designed the original Mini PET, I used the design from the TED machines shown above.


The two datasette drive circuits were drawing 40mA in total, with the rest of the board drawing less than 100mA, but it was nice and simple and a product of the last generation of Commodore optimisation. 

Mini PET 40/80

When it came to the Mini PET 40/80, there was an additional challenge to deal with, soft power on/off. I could have stuck with the same circuit, but the 40mA draw would have been present when the rest of the unit was switched off, not ideal. I could have added a separate transistor, probably a MOSFET, to switch the 9V rail before this circuit, but I was trying to simplify things.

I had used some new surface mount 6V regulators with on/off controls in the multi port duplicators I had made for TFW8b. Each drive had it's own switched and regulated supply, which worked quite nicely. I was able to use the sense input directly to switch them on or off, so no additional logic was required, not even a pullup resistor.


I would have like to use those, but they were only available in surface mount, or the sort of 5 pin TO220 packages that might be a problem for some kit builders as the leads are a bit close together. 


After looking around for quite a while for alternatives, I finally settled on the Micrel MIC2951. (Micrel is now owned by Microchip, but I haven't seen any Microchip branded as yet.)

This little 8 pin chips work in two modes. In the first mode, they are fixed 5V, 150mA regulators, with a shutdown input so they can be turned on or off via the soft power on controls.


The Mini PET uses less than 100mA, so 150mA should be fine. I used a second 5V regulator to supply the datasette port, more than enough for a datasette drive logic and powering an SD2PET.

The second mode allows the voltage to be set via a resistor divider (like an LM317 if you remember those). The shutdown signal is the same logic as the datasette control, low is on, high is off. A 74LS07 gate is used to pull the signal low when the motor should be on, the rest of the time, the 10KΩ resistor pulls it high and keeps the output turned off.


The value is set using the following equation, Vref is an internal 1.235V reference, and R2 is using the recommended value of 100KΩ. The nearest standard resistor value to give the output voltage we need is 390KΩ.

That gives an output voltage of around 6.05V. The value depends on the resistors which have a 5% tolerance (absolute worst case 5.59V-6.56V). The exact value is not important, as long as the voltage is within range and is constant during playback. Speed was expect to vary over the life of the drive due to belt stretching, so is accounted for in software (by timing the header tone at the start). The output is current limited to 150mA, to avoid motor burnout when rewinding or fast forward is left pressed and the end of the tape is reached.

That left the power section of the Mini PET 40/80 as four identical MIC2951 chips, and a pile of passive components.

Mini PET 40/80D

When it came to the Mini PET 40/80D, I was able to go for one of the surface mount 6V regulators with enable pins, so no need for the resistors, these were pre-set for 6V. The 5V regulator next to them is a plain fixed voltage always on type, as there was no need for soft power on with the 40/80D.

The on/off pin was now the inverse logic, so I needed to use 74LS06 dates to drive those, but it at least there were no zeners or set resistors.



Advertisements

The Mini PET 40/80D is still available from TFW8b (whilst stocks last)

https://www.thefuturewas8bit.com/shop/tynemouth-products/minipet4080d.html



This post is an combination of several posts from my Patreon. If you want advance previews of posts like this and behind the scenes progress on new projects, you can follow along and support me on Patreon (which now includes access to my new Discord server)

https://www.patreon.com/tynemouthsoftware


Sunday, 12 June 2022

Creating Commodore Tapes - Adventures in Modern Recording

Publishing software on cassette in 2022 presents some unusual challenges. I am not sure how they did it back in the day, but it turns out traditional audio cassette duplication isn't really suitable.

When we were starting out with the Future Was 8 bit 499 range, we looked at various options, the most obvious seemed to be create a master tape and duplicate it. 


Creating master tapes from WAV files turned out to be a bit patchy, not a reliable result, and not a great candidate for a master to be duplicated further (and likely get worse). The master tapes created by saving the file from a real computer were always fine, those were written using good old Commodore Datasette drives.


I looked into a few different mechanisms to drive a datasette from a tap file. I tried adapting the arduino based board which can load files into a C64, which sort of worked, but I wasn't happy with the results, I wrote a program which ran on a PET, this was fine with plain files, but couldn't cope with fast loaders. Finally, I turned to an old piece of DOS software, ptap, which seemed to be the best option. This needed a 'proper' parallel port, i.e not a USB one, one using low level hardware wired direct to the pins.


It also need 'proper' DOS, not just a DOS shell in Windows, both for unrestricted access to the parallel printer port, and also for timing so it wasn't interrupted by system tasks and other programs. The easiest way to get that and a proper parallel port was to use an old laptop running DOS or Windows. 


Here I resurrected an old Toshiba Satellite 210CT (remember when laptops were grey?). The original hard drive was noisy and not in the best of health, so I started afresh with a 1GB compact flash card in an adapter to fit directly into the 44 pin connector for the old 2.5" IDE hard drive.


The external (proprietary) floppy drive wasn't working, but I managed to find an old bootable Windows 98 SE CD.


It was a long time since I had seen that screen, but was soon greeted with the good old logo.


And finally the welcome screen. Windows 98SE is my favourite choice for older machines, as it is pretty solid and functional, and since this laptop was "designed for Windows 95", by the time Windows 98SE came along, all the required drivers for the previous era of machines were included with the OS, so I didn't need to find any drivers for anything, it just worked.


I took out the CF card and used a USB CF card reader to copy over the ptap files and initial tape files. That is OK once, but I didn't want to have to keep taking the CF card in an out to copy new tape images on. This laptop is pre USB, and although Windows 98SE does support USB it is frustratingly difficult to get a USB storage driver to work. The floppy was out of commission anyway, but that would have been a faff to write to write files with a USB floppy then copy them back with the Toshiba external floppy. 


In the end, I went for a nice simple option of using RS232 serial file transfer. Windows 98 came with Hyper Terminal, which supports Zmodem file transfer.


At the modern PC end, Tera Term can send and receive a number of formats including Zmodem, so I pointed them at each other and pressed go.


It's not very fast or efficient, but in most cases I am transferring one or two tape images of a few hundred KB each, so it's no problem and saves messing around with anything else. 


Out of interest, I did take the above screenshot on the laptop and sent it back, it was a 1.4 MB BMP file which took about 4 minutes to transfer. 

With all the files transferred, time to fire up ptap.


Very nice. I am told the coloured flashing bars showing data only work on the oldest of video cards. Thank you Toshiba.

So that is the master tape generated, and it loads perfectly on all the machines I tried it on. You always get the best result using hardware designed for the purpose. The datasette is pretty much direct drive of the tape head. From the digital signal on the parallel port (or from a Commodore computer), all there is are a few 74LS14 inverters to buffer the signal and drive the write head. No audio filtering or automatic level controls to mess up the signal.


The trouble was, the audio duplicators are full of audio filters and automatic level controls etc. After various duplicators were tried and rejected, we gave up on the two stage approach of creating a master tape and then duplicating it. What we now do is create lots and lots and lots of master tapes. To enable this, I have built various buffering boards to feed multiple datasette drives from the one parallel port output.


I think there is a whole blog post to be written on powering and driving datasette drives, so expect that to follow shortly. 

That version added individual 6V regulator for each datasette's motor power. The latest also adds a second 5V regulator as it turns out TFW8b was running the boards from 12V instead of 9V as designed, so the single 5V regulator was getting a bit warm. (Each drive uses 25-50mA on the 5V rail and 100-200mA on the 6V motor.)

All TFW8b then needs is a small army of datasette drives, which luckily, they have.


And in no time at all* you have a box of perfectly duplicated master tapes.


* actually it takes an awful lot of time

Making a stand alone unit

I've built a few rigs for this, most of which have gone down to TFW8b to be used for mass tape duplication. The one I had left was quick lash up based on an old Mini PET PCB, built to quickly test a change to one of the VIC20 fast loaders.


That was a bit unwieldy, so to test out the 3D Monster Maze and Tut-Tut masters, I thought I would do a better job.

I decided the neatest solution would be to integrate the controller into a datasette case, and keep it all neat and tidy.

For that I need a datasette, and for a change, rather than the usual 1530 / C2N datasette designed for VIC20s and Commodore 64s, I went for a 1531 datasette, the dark themed version for the TED series of machines.


Here are four suitable candidates out of the 'broken' box. These were all a bit ropey and non-functional. 


This one had a squashed plug and a broken tape counter.


This one had a fantastic inline splice. I decided to start with that, and opened it up and rewrapped all the connections. One of the other drives had come with a cassette in, so I borrowed that and tried it out.


And it started loading....


It didn't finish though, it got to the end of the tape and failed. But that was good enough for me, perfectly normal for a tired datasette. The same reason why most of these drives fail. Loose belts and dirty heads. 


In many cases, you can get away with just using a head cleaner cassette - https://www.thefuturewas8bit.com/tapeclean.html

In this case, I could see the drive was a bit manky, so I stripped down the drive, cleaned the heads and fitted a new belt.


Belts for these drives are easily available, of course I get mine from TFW8b.com - https://www.thefuturewas8bit.com/shop/commodore/commodore-spares/c2nbelt.html 

I find the easiest way is to unscrew and lift up the PCB, and then there is just this plate to deal with. I under the screw on the top and loosen the screw on the side and rotate it up so the belt can slip out the slot in the side.


Whilst you have it open, also run some IPA over the play and record heads. and clean up all this beastly mud and oomska.


Do not touch the azimuth adjustment on the head. The only time I ever have to adjust the azimuth screw is when someone has previously fiddled with it and adjusted it away from correct alignment. It is almost always perfect as it is. Just forget about it, clean the heads and replace the belt and it will fix 99% of drives.

And there you go, first time I tried after that, Space Sweep loaded. A very colourful and action packed game it would appear, might have found it out more I had a C16 joystick to hand, but I didn't, so back to the drives.

I went through the other drives, and all were found to be functional. One the motor wasn't moving, but a quick turn by hand and it started and is still running fine. A new belt and a clean head and it loaded.


I like to label up the ones that have had new belts and a bit of a clean up.


But I also kept one as is, without cleaning the heads or replacing the belt. It worked well enough to load a tape. I keep these for testing master tapes on 'representative hardware', i.e. ones that haven't been cleaned up to serviced, just like the ones the people at home might be using.

I was left with the one with the mangled plug, I wasn't able to save it, one of the pins had broken off, so I cut it off and borrowed the end of the cable from the drive where it was twisted on.


This is not the approved way of testing things. Don't do this!


Again it worked well enough and actually loaded, so I was left with a drive that had a damaged plug on the end of it's lead that I had cut off. It also had a broken tape counter, and I was able to take one from a damaged 1530 drive.


Now onto the conversion process. The datasette drives need two power supplies. The first is a fixed 5V used for the logic and the opamp. I plan to power the drive from a 9V DC supply (the same used on the Minstrels, Mini PETs etc.). 

The datasettes use about 25mA on the 5V rail, rising to 50mA when recording, so I went for a simple TO92 regulator rated for 250mA. I wired that up with all the parts soldered directly to each other, and used heatshrink to separate the wires. Not exactly the neatest solution, but you haven't seen what I did for the motor yet, so appreciate this whilst you can.


The next one is a bit complicated. It should be a 6V supply, but only active when one of the keys are pressed. Some similar cassette mechanisms (e.g. the ZX Spectrum +2) have a leaf switch which is activated when a key is pressed, and that switches the negative connection to the motor.


You can see here on the right the Commodore drives also have a leaf switch, but these are only used as a logic input, so I wasn't sure if they were rated for the motor current. I expect they are, but I wanted to play it safe. Also, the switch is used as an input to the computer to tell a button is pressed. This is pulled up to 5V, and grounded when a key is pressed. I have used this input to control the shutdown pin of a regulator before, but the ones I was using have an active low output, so would be off when the button was pressed, so I had to use an inverter.


I didn't want to have to add an IC or a transistor to act as an inverter, so I went for the other 6V regulator circuit I had been using on the Mini PET.

This uses the 8 pin DIP package regulator, set to 6V using the two feedback resistors. I implemented that as very much a 'point of load' regulator. Soldered, as it was, directly to the top of the motor. These are rated for 250mA, and I have found they generally run cold even when the motor is running, and draws about 100mA. (my original plan had been to bolt 7805 and 7806 regulators to the metalwork somewhere, but it turned out neither were necessary).


All I needed to do then was to tap onto the 'sense' wire which is connected to the switch. I also added a pullup resistor to 5V, rather than relying on that happening somewhere inside the laptop.


I retained the original seven core screened cable, and attached two of the now unused wires to a short piece cut off the end of a 2.1mm DC jack extension lead. The rest of the wires attached to the 25 way D connector for the parallel port.


With the cover installed, it looked quite neat.


Less so inside the unit.


But it was starting to look tidier once it want back into the case.


Before I closed it up, I wanted to check it was all working, so I tried a few tapes and the motor spun when it was required to, and was able to fast forward and rewind.


Once I was happy the mechanism wasn't going to chew tapes, I tried a 3KHz test tape. I captured the digital output from the back of the drive.


It averaged 3.001KHz, that's probably a fluke, but it shows it's around the right speed, 2.98-3.02KHz is more than close enough.

Time to introduce it to the Windows 98 laptop. On reflection, I should have cut the cable shorter, but it's too late now.


Time to write a tape, so I grabbed a brand new C20 cassette - https://www.thefuturewas8bit.com/shop/media/c20.html 


I booted the laptop to DOS and ran PTAP.

When instructed, I pressed play and record and the LED came on. 


That all seemed to work, so over to the Mini PET to try and load it.


3D Monster Maze loaded first time, and I found the exit first time I played it, so that must be a good sign.


You may ask why I was loading from tape 2?

Where do you think I stole the MIC2951 regulator from? The lead time on those is currently a rolling six months, so I'd better get used to it (or swap it with the one from tape 2 which is more sensible).


It wasn't released when I started these posts, but the reason I was running the tapes was testing out my PET version of Tut-Tut.


Hey, I took a picture of a CRT and it wasn't totally awful!

That's running nicely on all the hardware I tested. This is the point where I specifically try to use tatty unmodified datasettes to try out the worst case someone might have at home when they try to load a tape.


Bonus!

When I was writing up these posts for Patreon, it occurred to me that I quite liked that laptop, and I should maybe see if I can find a similar model on ebay to fix some of the issues. 

And here it is, £30 of broken 90s laptop (half of which was shipping).

This was a 210CS, a lower model with a worse screen (the 210CDT has a nice TFT panel). It is also the CS not the CDS, so comes with a floppy drive, rather than a CD ROM and an external floppy drive in an external enclosure (the type where you can swap the floppy into the laptop, but you can't then use the CD externally).


The laptop has some video card issues, lines on the screen. I tried an external VGA monitor, and could switch between them using the FN keys, but the VGA output was no better. I'm not too bothered about that, I'm just putting that aside as a source of spares for the future. What I am interested in is the bits I can transfer to the other laptop.


I was hoping the floppy drive and battery would be in better condition than mine. As a bonus, I got a broken hard drive and a Sportster 28.8 modem. It's no wonder IBM got out of the hard drive game, if you have to put warnings like this on your drives, you are doing something wrong. People are going to pick it up, rattle it and say "oh yeah", and quite possible damage their drives in the process. 


The star of the show however is something I didn't expect, and never thought I would find. The exact proprietary 16MB memory upgrade module.


That's right, my Windows 98 laptop now has 32 whole megabytes of RAM!

The hard drive was not detected, and was making the usual clicking sounds you get from IBM drives like this and the 'deathstar' 3.5" versions. No real loss there, I'm happy using the CF card, and I have piles of old hard drives.

The floppy drive did the same as the previous one unfortunately. The ominous sound of a motor spinning freely, indicative of it no longer attached to anything. I had been hesitant to take the previous drive apart, as there looked to be lots of plastic clips that could easily snap, but I thought I would have a look at this new drive and see if it could be repaired.


And indeed, as unlikely as it may seem, this is an early enough 3.5" drive that it uses a belt driven spindle. And the belt is old and stretched and hanging loose, but at least not turned to black goo as they sometimes do.


I tried to replace it, but I didn't have a suitable belt. It needs to be flat profile, and the only one I had that would fit was square profile, so it rubs. It does spin and tries to seek, but all I get from Windows is "Device is not ready"


I'll keep looking for a suitable belt (found one on a US site, but shipping is complicated these days). I suspect if I were to look for another drive it would likely be in the same state, and it's a proprietary undocumented flat flex with combined power and data, so no easy path to a replacement. It would be useful to have a floppy drive available, so I will keep looking. 


No immediate plans for the PCMCIA Faxmodem. I thought it would be useless without the lead, but it turns out it has a neat pop out RJ11 connector. It's still pretty much useless these days unless anyone is running their own dial up server.


The battery is better than the one I had, this one charges and runs for several hours, so I'll keep using that one. But the clear winner is the memory module, it was worth it for that alone.



Advertisements

The TFW8b produced cassettes are available here:

3D Monster Maze - https://www.thefuturewas8bit.com/cas022.html 

Tut-Tut - https://www.thefuturewas8bit.com/cas024.html 

All the rest of the tapes and cartridges - https://www.thefuturewas8bit.com/shop/games.html

Digital downloaded are available form my itch page: https://tynemouth.itch.io/ 


This post is an combination of several posts from my Patreon. If you want advance previews of posts like this and behind the scenes progress on new projects, you can follow along and support me on Patreon:

https://www.patreon.com/tynemouthsoftware