Electron Cassette I/O

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
User avatar
davidb
Posts: 1883
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Electron Cassette I/O

Postby davidb » Thu Apr 27, 2017 8:47 pm

As readers of the Electron ULA Documentation Updates thread will know, I've been experimenting with the cassette port to see what kinds of things it might be useful for, especially for unexpanded Electrons, but also for those machines that don't really need to use it for storage any more - maybe the user has a disk drive or memory card interface.

One of the uses for the port is as an input device, like a mouse or graphics tablet. This shows something more like the latter than the former: Touch screen input on the Acorn Electron via the cassette port. The opposite of this would be to use the Electron as an input device for a touch screen phone, sending key strokes on the Electron's keyboard to the device.

I haven't yet tried mixing input and output, but I imagine it might be possible to use the cassette port as a kind of serial port, turning the Electron into a simple terminal. :)
Attachments
DSCF7936-Electron-Android-touchscreen.jpg

User avatar
davidb
Posts: 1883
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Electron Cassette I/O

Postby davidb » Thu Apr 27, 2017 10:29 pm

I've uploaded the relevant code to this repository. I can attach the Android application to this thread if people want it, though it won't be any use on its own until I make it automatically deliver the custom cassette handling code to the Electron when it runs. :)

User avatar
myelin
Posts: 182
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Electron Cassette I/O

Postby myelin » Thu Apr 27, 2017 10:54 pm

Clever! I finally have the ability to program cartridges outside the Electron, but the cassette port is still the most convenient way to get stuff into the machine's memory. I love the direction you're going in here, trying to turn the cassette port into a simple serial port!
SW/EE from New Zealand, now in San Francisco: http://myelin.nz/
Having fun making hardware projects for the Electron!
So far: 32k flash cart, USB cart interface, 3-cart expansion, Elk PiTubeDirect. Later: Dual ported ram cart.

User avatar
davidb
Posts: 1883
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Electron Cassette I/O

Postby davidb » Thu Apr 27, 2017 11:21 pm

Thanks! I think what you've done with the cartridge programmer is very useful. It's something we wanted to do at some point because it would make programming "large" Flash ROMs convenient. The Mega Games Cartridge could also benefit from being programmed in this way.

Although I have a Plus 1, I'm interested in peripheral-less Electrons because I imagine that most people who acquire Electrons (for their collections, for example) will never manage to get hold of a useful add-on like that, and those machines will languish unused on shelves because getting software onto them is a pain (unless you get something like GoSDC). Ironically, most of those people will have spent lots of money on fancy smartphones and tablets that could provide the connectivity and some expansion capabilities, but they may not realise it.

User avatar
myelin
Posts: 182
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: Electron Cassette I/O

Postby myelin » Fri Apr 28, 2017 12:07 am

Hah, yes, once I've got it tested out on my own flash cartridges, I'm going to give the programmer a go against the MGC and see if I can get it nicely programming that.

As for the cassette port, I wonder if there's any possibility for increasing the throughput. Looks like the cassette signal goes straight into the ULA, and I can't see any mention in the EAUG of much in the way of controls for the shift register clock. I wonder if there's anything interesting in the OS ROM, maybe in the code that switches between 300 and 1200 bps...
SW/EE from New Zealand, now in San Francisco: http://myelin.nz/
Having fun making hardware projects for the Electron!
So far: 32k flash cart, USB cart interface, 3-cart expansion, Elk PiTubeDirect. Later: Dual ported ram cart.

User avatar
1024MAK
Posts: 6733
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Electron Cassette I/O

Postby 1024MAK » Fri Apr 28, 2017 9:23 am

As there is a separate thread about the USB Electron Cartridge Interface, please be sensible in staying on topic. You can always include a link between topics / posts.

@David - nice idea =D>. I look forward to seeing what else can be achieved with the cassette port :D.

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
davidb
Posts: 1883
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Electron Cassette I/O

Postby davidb » Fri Apr 28, 2017 9:58 am

I've no problem with having a wandering discussion here, especially as I was the one doing most of the wandering. ;)

I don't think the Electron supports 300 baud in the same way as the BBC Micro, though I wouldn't rule out any surprises there. :)

Looking at the OS disassembly, the counter at FE06 gets written with values from &821-&823 that the extended EAUG refers to as an "interval multiplier", plus &292 (system clock) and other bytes from the ROM itself. Perhaps something could be done to the counter to "speed up" operation of the shift register, but surely everything is limited by the hardware's ability to detect 1200 Hz and 2400 Hz tones? If the cassette input circuitry basically translates analog signals into digital input for the shift register then I imagine the frequency response of that circuitry is the limiting factor. Can someone explain the circuit to us non-hardware people in fairly simple terms? :)

User avatar
1024MAK
Posts: 6733
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Electron Cassette I/O

Postby 1024MAK » Fri Apr 28, 2017 10:43 am

All component references are for the issue 4 schematic that I'm looking at. It's not a very good copy, so if anyone knows of a better copy, or differences for the other Elk PCB versions, please point me in the correct direction ;-)

For the Elk output to cassette, there is a simple filter (R23, R28 and C15), followed by a op-amp (IC13) used as a unity voltage gain (current) buffer, followed by a coupling capacitor (C19).
Ignoring R28, the values of R23 and C15 (100k and 2.2nF) will roll off frequencies of 723Hz and above. As the frequency is increased beyond 723Hz, the output voltage level will drop.
Further, C19 at 220nF will block DC and low frequencies. The cut-off frequency very much depending on the impedance of whatever is connected to the output. If this is the equivalent of a 4.7k resistor, the frequency cut-off is about 153Hz, so not really a problem for AC audio signals.

For slow DC output applications, use the cassette motor control ;-). DIN pins 6 and 7 are a "voltage free" relay contact. The relay is only suitable for switching low voltage, low current loads. But you can always use it to feed either an electronic circuit, or a heaver duty relay (use a diode across the coils of the relay to clamp the back EMF or the high voltage will damage the cassette relay contacts).

The cassette input to the Elk, is a bit more complex. I'll be back in a little while...

Mark
Last edited by 1024MAK on Fri Apr 28, 2017 1:46 pm, edited 2 times in total.
Reason: Edited to correct some values after looking at the clearer schematic posted by Dave in the post below.
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
1024MAK
Posts: 6733
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Electron Cassette I/O

Postby 1024MAK » Fri Apr 28, 2017 10:57 am

The cassette input to the Elk.

First we have resistor R64 (10k) and diodes D6 and D7, then C26 (1.5nF). The resistor and diodes limit any input voltage (after the resistor) to +5V and -5V. The R64 and C26 act as a low pass filter with a roll off of 10kHz, so this limits the high frequencies.

Then there is a series coupling capacitor, C22 (820pF). This blocks DC and low frequency signals.

Then it gets father more complex..

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
hoglet
Posts: 6480
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Electron Cassette I/O

Postby hoglet » Fri Apr 28, 2017 12:49 pm

1024MAK wrote:All component references are for the issue 4 schematic that I'm looking at. It's not a very good copy, so if anyone knows of a better copy, or differences for the other Elk PCB versions, please point me in the correct direction ;-)

Is this one any better?
electron.gif

User avatar
1024MAK
Posts: 6733
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Electron Cassette I/O

Postby 1024MAK » Fri Apr 28, 2017 1:32 pm

Yes! :D

Thanks Dave =D>

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
BigEd
Posts: 1442
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: Electron Cassette I/O

Postby BigEd » Fri Apr 28, 2017 1:37 pm

(what's that pin labelled CAS RC doing? Is that an input or an output?? Is it some kind of external time reference???)

User avatar
1024MAK
Posts: 6733
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Electron Cassette I/O

Postby 1024MAK » Fri Apr 28, 2017 2:01 pm

BigEd wrote:(what's that pin labelled CAS RC doing? Is that an input or an output?? Is it some kind of external time reference???)

Some time delay reference by the look of it. Definitely an input. May or may not also be an output. If pin 64 (CAS MO) can drive low, when this pin is low, it will discharge C8. When the motor is engaged, approx. 0.056 seconds later the resistor will have recharged C8. The input on pin 47 will likely have passed the switch on threshold before then (depending on the pins input current).

Or if pin 47 is both an input and an output, it may be part of a timer. With the diode connecting to pin 64 being an inhibitor...

What it is used for though is hard to say...

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
MartinB
Posts: 4548
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity

Re: Electron Cassette I/O

Postby MartinB » Fri Apr 28, 2017 2:05 pm

Presumably the RC means Resistor/Capacitor and the two components set some time constant for a cassette frequency reference. Maybe for baud rate or tone frequency....?

Oops - Mark posted just before me!

User avatar
1024MAK
Posts: 6733
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Electron Cassette I/O

Postby 1024MAK » Fri Apr 28, 2017 2:13 pm

The time constant appears to be too long (too slow) to be any thing to do with baud rate or tone frequency.

Could be a tone detected / lack of tone timer though.

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
davidb
Posts: 1883
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Electron Cassette I/O

Postby davidb » Fri Apr 28, 2017 2:24 pm

Some further meanderings:

I saw a video on YouTube that explored the tolerance of the cassette interface and OS routines for reading standard encoded cassettes. Playing a recording in at about 1.16 times normal speed worked, but higher speeds were unreliable.

Thinking about the high tone detect interrupt, the requirement of "20 cycles of 2400 Hz" (10 high bits being invalid data) stated in the EAUG is the amount of latency we have to deal with if we wanted to bypass the shift register completely and just use this interrupt as a way of signalling data. However, I considered that we could use pure high tones of various durations to detect and interpret Morse code! :)

User avatar
davidb
Posts: 1883
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Electron Cassette I/O

Postby davidb » Fri Apr 28, 2017 3:08 pm

I modified my screen data reader (original video) to set different values for FE06 instead of the recommended 0 value. As mentioned in the updated EAUG, bit 7 doesn't seem to influence things. For the other bits, values up to and including 7 will work, but corruption does occasionally occur, though this appears to be only a single bit every now and again.

I'm interested to know just how FE06 is used in cassette input mode; if it is used to construct the starting value or limit of a counter. I wonder if it is related to its use for generating sounds, or whether that belongs to an entirely separate subsystem. :-k

User avatar
davidb
Posts: 1883
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Electron Cassette I/O

Postby davidb » Sat Apr 29, 2017 11:06 pm

Those brave enough and equipped with an Android device can download/sideload the application attached to this message to try out the touch demo.

Warning: Ensure that an audio cable is connected before running the application and shut down the application before disconnecting it. The application generates streams of loud noise. Ensure that your device is only emitting sounds via the audio cable - my phone disables the speaker when the headphone port is in use, and it shows a headphones symbol at the top of the display when this occurs.

Once installed, proceed with the following steps:

  1. Connect the phone to the Electron using an audio cable with a 7-pin DIN connector on one end that plugs into the Electron's cassette port and a suitable connector for your Android phone on the other.
  2. Turn the Electron on.
  3. At the BASIC prompt enter

    Code: Select all

    *TAPE
    if necessary, then

    Code: Select all

    *RUN
  4. Run the Electron Touch application on the device. This should show a blank green window. Tap it once. The Electron should load and run a small piece of software. A small blue circle should appear on the device.
  5. You should now be able to tap and swipe on the device to draw on the Electron's screen.

Good luck!
Attachments
ElectronTouch.apk.zip
ElectronTouch.apk file with a .zip suffix to satisfy the forum software. ;-)
(31.44 KiB) Downloaded 5 times

User avatar
1024MAK
Posts: 6733
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Electron Cassette I/O

Postby 1024MAK » Sat Apr 29, 2017 11:30 pm

I've been simulating the Electron cassette circuits in LTSpice.

Electron cassette output circuit

Band pass of about 200Hz to 6kHz if using AC signal input.
If using a digital signal, results at spot frequencies are:-
Freq,+mV,-mV
100Hz,411,422
200Hz,368,398
400Hz,291,348
600Hz,,,287mV p-p
800Hz,237,300
1kHz,224,290
2kHz,200,267
4kHz,185,254
6kHz,182,246
8kHz,176,229
10kHz,167,209
12kHz,156,189
I'll convert all these into peak to peak values on Sunday...

Frequency range of tape decks varies. But a typical low cost stereo deck has a bandwidth of about 35-12000Hz.

Input circuit
Band pass of about 200Hz to 13kHz for a 600mV AC signal. However, this ignores the input threshold of the ULA input pin.

If the ULA input pin threshold is 550mV dc...
Simulation ran with the following steps: (all AC peak-peak) 100mV, 200mV, 300mV, 400mV, 600mV, 700mV, 800mV, 900mV, 1V, 1.5V and 2V. All input signals were AC Sine waves.

FREQ,min AC input V (peak-peak)
100Hz,did not pass the 0.55V threshold even at 2V input.
200Hz,did not pass the 0.55V threshold even at 2V input.
400Hz,1.5
600Hz,0.6
800Hz,0.4
1kHz,0.3
2kHz,0.2
4kHz,0.2
6kHz,0.3
8kHz,0.5
10kHz,0.6
12kHz,1
14kHz,1.5

More info on Sunday...

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
davidb
Posts: 1883
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Electron Cassette I/O

Postby davidb » Sat Apr 29, 2017 11:43 pm

Thanks, Mark, that looks very promising. :)


Return to “hardware”

Who is online

Users browsing this forum: Bing [Bot], simoni and 15 guests