Modern Homebrew "Cassette" Data Communication

For discussing the 65xx hardware itself or electronics projects.
sburrow
Posts: 833
Joined: 09 Oct 2021
Location: Texas

Re: Modern Homebrew "Cassette" Data Communication

Post by sburrow »

AndersNielsen wrote:
I’m building something similar based on the 6522 datasheet T1 example and Don Lancaster’s “Bit Boffer” (Google it). The important thing here is that you need sine waves because they record better.
For a 6502 the TX can be done with a 74hc373 and some passives.(Cheap DAC) Rx needs an opamp and some passives for sine > TTL demodulation.
I think I’ll make a video on this… sometime in the next 6 months
I'm returning to this topic, because I'm still interested, and I have a question that is still lingering.

I completely understand using the '373 with some resistors and stuff to make a DAC. And as Garth pointed out below, you could also use the VIA 6522 to do this.

But the phrase "Rx needs an opamp and some passives" is not enough for me! Need more details on how to receive :)

My first idea is this type of connection:

Audio Source -> OpAmp -> Diode -> 6522/6551 -> 6502

The OpAmp amplifies the smaller voltage into 5V, and the diode would cut off negative voltages leaving 0V to 5V. Yes?

Consider the cassette interface for the Apple 1:

https://www.applefritter.com/files/imag ... c-6889.gif

I was seeing that the OpAmp they use is an LM311. The rest are just logic components and some ROM. Again, I'm not worried about sending audio OUT from the circuit, I'm worried about receiving audio IN to the circuit. I don't want to lose signal, and I don't want to fry chips. Thoughts?

Last question, since I'm here (and so are you!), could I get away with a setup like this without needing 12V? It seems to me that using an OpAmp to step up a voltage requires a voltage even higher than that to begin with. BUT, what if I were to supply with 5V and only care to output 3.3V from the OpAmp? I'd use an 74HCT' chip to pick up the signal and send it off to it's 74HC' friends. I'm not scared with 12V, but it is inconvenient for my particular projects.

Thank you all!

Chad
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Modern Homebrew "Cassette" Data Communication

Post by BigEd »

Good persistence points there! I think going back to simple and cheap early systems is going to be the closest match to your needs - I don't have analogue design skills, so my best shot is to look at other schematics out there. Here's one Eric Schlaepfer made which seems to fit the bill:
http://tubetime.us/index.php/2017/09/05 ... interface/

Their op amp is supplied by 0 and 5V, which is handy because you'll already have those, and also handy because it means the output of the op amp is certainly going to be between those two levels.
sburrow
Posts: 833
Joined: 09 Oct 2021
Location: Texas

Re: Modern Homebrew "Cassette" Data Communication

Post by sburrow »

BigEd wrote:
Good persistence points there! I think going back to simple and cheap early systems is going to be the closest match to your needs - I don't have analogue design skills, so my best shot is to look at other schematics out there. Here's one Eric Schlaepfer made which seems to fit the bill:
http://tubetime.us/index.php/2017/09/05 ... interface/

Their op amp is supplied by 0 and 5V, which is handy because you'll already have those, and also handy because it means the output of the op amp is certainly going to be between those two levels.
Wow Ed, that is RIGHT ON! Very neat, good find, thank you for that!

I went to the datasheet for the CA3140:

https://www.electroschematics.com/wp-co ... A-3140.pdf

and found this:

"Figure 4 shows some typical configurations. Note that a series resistor, RL, is used in both cases to limit the drive available to the driven device. Moreover, it is recommended that a series diode and shunt diode be used at the thyristor input to prevent large negative transient surges that can appear at the gate of thyristors, from damaging the integrated circuit."

Thyristors?! Anyways, it is saying that a diode could be used as well. Also, from the circuit you gave me, that 22K resistor seems like a lot. I would probably replace it with a pot, or at least experiment with a breadboard and the 'scope first. Also, the datasheet says a 6.2V zener would be a nice addition for TTL usage. Interesting.

Ok cool, this is a great start. Thank you again Ed, great help. It seems I'm diving into analog circuits now!

Chad
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Modern Homebrew "Cassette" Data Communication

Post by BigEd »

Experimenting with component values, on a circuit which works, is a good way to learn!

But sizing components by random exploration on a circuit which doesn't work, that's another thing...
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Modern Homebrew "Cassette" Data Communication

Post by BigEd »

I think their Zener is there because they want to allow a great range of supply voltages - so, not needed, I think.
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Modern Homebrew "Cassette" Data Communication

Post by BigEd »

Likewise, the extra components illustrated for switching mains power with a thyristor - that's kind of interesting, and useful for some purposes, but not the territory we're in.
User avatar
AndersNielsen
Posts: 185
Joined: 26 Dec 2021
Contact:

Re: Modern Homebrew "Cassette" Data Communication

Post by AndersNielsen »

BigEd wrote:
Good persistence points there! I think going back to simple and cheap early systems is going to be the closest match to your needs - I don't have analogue design skills, so my best shot is to look at other schematics out there. Here's one Eric Schlaepfer made which seems to fit the bill:
http://tubetime.us/index.php/2017/09/05 ... interface/

Their op amp is supplied by 0 and 5V, which is handy because you'll already have those, and also handy because it means the output of the op amp is certainly going to be between those two levels.
Yes, something like that is what I meant. I haven't had the time to test but that's basically what I would do - I think I have an actual comparator in my arsenal though.

I got the idea from Don Lancaster's design, which seems to have been the basis for the Kansas City Standard, if you ask Wikipedia.
https://www.tinaja.com/glib/bitboff.pdf
Using a 6502 you can throw away most of his rx circuit though. I plan to use a VIA's PB6 to count negative pulses, after the comparator/opamp.
User avatar
Sheep64
In Memoriam
Posts: 311
Joined: 11 Aug 2020
Location: A magnetic field

Re: Modern Homebrew "Cassette" Data Communication

Post by Sheep64 »

I highly recommend reading through the KIM-1 manual in full because it describes a large number of digital techniques which remain relevant. This includes connecting 5V 6502 to 12V UART, connecting to 1V audio cassette storage, address decode using open collector equivalents to 74x138 and a combined matrix for key switches and seven segment LEDs. There is also a natty technique for automatically detecting serial line speed and I am disappointed that it is not commonly used. Of particular note, circuit diagrams and source code are provided.

The audio cassette storage uses a very simplistic scheme where every bit is stored as a fixed duration of low tone and high tone. The hardware decoder detects two fixed tones and reduces this to one bit input for the most likely case. This is sampled in software at fixed intervals. I understand this pre-dates the Kansas City Tape Standard (and I am amused that the most conformant implementations could be found furthest from Kansas City). This remains relevant because a similar scheme (without audio modulation) is used for digital LEDs.

It is also relevant because various schemes exist to pass source code, cipher keys or URLs via audio. Unfortunately, this is a privacy issue because ultra-sonic tones are embedded within television adverts and "smart" phones, running arbitrary code, and with audio input privilege, are able to log exposure to adverts. When people "consent" to allowing privilege to audio input, they are typically unaware that the maximum audio frequency may exceed 100kHz or that it is primarily used to fuel unnecessary consumerism.

Anyhow, I have an idea for a simplistic, self-clocking scheme which is more efficient than the Kansas City Tape Standard and possibly more tolerant to error. The downside is that it requires more hardware because it uses five tones. Four tones are used to encode two bits of data and the remaining tone is used to convey "same again". Therefore, 00 00 00 00 is transmitted as tone 0, tone 4, tone 0, tone 4. The receiver has five (or more) tone detectors and decode may use a jump table. This has similarities to some of the more advanced line following robots, which have five or more light sensors. Indeed, it maybe worthwhile to experiment with line following robots before introducing the additional problems of audio harmonics and over-sampling.
User avatar
Dr Jefyll
Posts: 3526
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: Modern Homebrew "Cassette" Data Communication

Post by Dr Jefyll »

Sheep64 wrote:
I highly recommend reading through the KIM-1 manual in full
All three manuals supplied with the KIM-1 are excellent. :!: Links to searchable and raw-scan PDF's are in this post (as well as an amusing story about how Chuck Peddle had to be coerced to complete the manuls). :roll: :P

-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
User avatar
AndersNielsen
Posts: 185
Joined: 26 Dec 2021
Contact:

Re: Modern Homebrew "Cassette" Data Communication

Post by AndersNielsen »

Sheep64 wrote:
The audio cassette storage uses a very simplistic scheme where every bit is stored as a fixed duration of low tone and high tone. The hardware decoder detects two fixed tones and reduces this to one bit input for the most likely case. This is sampled in software at fixed intervals. I understand this pre-dates the Kansas City Tape Standard (and I am amused that the most conformant implementations could be found furthest from Kansas City). This remains relevant because a similar scheme (without audio modulation) is used for digital LEDs.
Well, one could argue the KIM-1 is almost KCS-compliant. What exactly was the KIM1 modulation? The manual doesn’t seem clear, but Chuck had quite a few months to study KCS implementations before the KIM1 was released, so I’m not sure what you mean by “pre-dates”? KCS was defined in ‘75 based on.. I think a suggestion Don had from his TVT addons in Byte.
KCS was 1 start low, 8 data, two high stop - 300 baud 1200/2400hz = 4 cycles @ 1200hz or 8 cycles @ 2400.
I’m not sure if I can get away with 1c/1c = 1800 baud avg.

Everyone should read the 6500 family manuals if they want to have fun with 6502’s :)
User avatar
Dr Jefyll
Posts: 3526
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: Modern Homebrew "Cassette" Data Communication

Post by Dr Jefyll »

AndersNielsen wrote:
What exactly was the KIM1 modulation?
From Appendix E of the KIM-1 User Manual:
  • Each transmitted bit begins with a 3700 hertz tone and ends with
    a 2400 hertz tone. "Ones" have the high to low frequency transition
    at one-third of the bit period. "Zeros" have the transition at two-
    thirds of the period.
-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
User avatar
AndersNielsen
Posts: 185
Joined: 26 Dec 2021
Contact:

Re: Modern Homebrew "Cassette" Data Communication

Post by AndersNielsen »

Dr Jefyll wrote:
AndersNielsen wrote:
What exactly was the KIM1 modulation?
From Appendix E of the KIM-1 User Manual:
  • Each transmitted bit begins with a 3700 hertz tone and ends with
    a 2400 hertz tone. "Ones" have the high to low frequency transition
    at one-third of the bit period. "Zeros" have the transition at two-
    thirds of the period.
-- Jeff
Thanks!

Aha! That reminds me of ws2811-style encoding (each bit starting high, ending low, varying cycle for 0/1). I guess that’s what sheep64 meant.
sburrow
Posts: 833
Joined: 09 Oct 2021
Location: Texas

Re: Modern Homebrew "Cassette" Data Communication

Post by sburrow »

BigEd wrote:
Good persistence points there! I think going back to simple and cheap early systems is going to be the closest match to your needs - I don't have analogue design skills, so my best shot is to look at other schematics out there. Here's one Eric Schlaepfer made which seems to fit the bill:
http://tubetime.us/index.php/2017/09/05 ... interface/

Their op amp is supplied by 0 and 5V, which is handy because you'll already have those, and also handy because it means the output of the op amp is certainly going to be between those two levels.
That schematic works!

I just got parts in today, tested them. After a couple breadboarding goofs I got it to work. The OpAmp feeds into a 74HCT00 and outputs a beautiful inverted signal. I also tested it with an 74LS' chip and that works great too. The only thing I changed was the 22K resistor into a 50K audio-style pot. And yes, 22K is about right.

I connected it to my line-out from the desktop, and ran this command on my Linux box:

play -n synth square 1200 gain 2

"play" is a derivative of "sox" by the way.

I altered the volume and about 25% worked for me, I got a clean signal. Using both the volume control and the pot is good because I can adjust BOTH to make it just right. Too little resistance and I get fluctuations. Too high resistance and I get no signal at all.

Soon I will make a little bash script to 'play' alternating high/low signal. I also want to test different volume levels and pot levels, and test this in a headphone jack and on my wife's laptop. I think I might record something and see if this also runs off of my phone, that'd be cool. And lastly I'm going to connect the breadboard to my VIA and see if I can read signals in to the 6502! That will be fun :)

If this all works, I will try the reverse direction, making a little resistor DAC from the VIA out to my desktop, and see if I can record it, and then play it back without signal/data loss.

Neat! Thank you again Ed, this was really a cool side-project. I will be integrating something like this into my next board for sure :)

Chad
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Modern Homebrew "Cassette" Data Communication

Post by BigEd »

Great to hear it! Look forward to further adventurings...
User avatar
drogon
Posts: 1671
Joined: 14 Feb 2018
Location: Scotland
Contact:

Re: Modern Homebrew "Cassette" Data Communication

Post by drogon »

AndersNielsen wrote:
Dr Jefyll wrote:
AndersNielsen wrote:
What exactly was the KIM1 modulation?
From Appendix E of the KIM-1 User Manual:
  • Each transmitted bit begins with a 3700 hertz tone and ends with
    a 2400 hertz tone. "Ones" have the high to low frequency transition
    at one-third of the bit period. "Zeros" have the transition at two-
    thirds of the period.
-- Jeff
Thanks!

Aha! That reminds me of ws2811-style encoding (each bit starting high, ending low, varying cycle for 0/1). I guess that’s what sheep64 meant.
Manchester Code is also worth a look at if it's new you folks here:

https://en.wikipedia.org/wiki/Manchester_code

It was used on early computer tape system - not cassette but bigger units...

-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
Post Reply