Connect with us

Building a cassette interface for z80 SBC, from schematic

Discussion in 'General Electronics Discussion' started by Joe Lyman, Dec 19, 2017.

Scroll to continue with content
  1. Joe Lyman

    Joe Lyman

    22
    0
    Dec 19, 2017
    I'm attempting to build a cassette interface for a simple z80 SBC based on a schematic I found online. The z80 is built and working properly, and the cassette interface is built but not quite working properly. Because the creators of these designs are busy, I figured I'd jump into an online community to see if I could get any hints on what to try next in my quest to add simple mass storage to my SBC.

    Before I start in, I should note that I'm not entirely "new" to electronics, but I am very inexperienced. I am a ham radio operator, an avid unix user, and a lover of computers and technology; but I've never really gotten into electronics until recently. Electronics as a hobby started, for me, with the idea of building a z80 computer. I love many things that are represented in such an activity. Take whatever I say with a grain of salt; I'm still learning.

    The circuit is simple enough, and the author has described it's functionality in their post linked above. It takes serial data, at TTL levels, and converts it into sound. Then it takes that sound- or a recording of that sound- and converts it back into serial data at TTL levels. My build of that circuit does turn serial data into sound (via a USB->TTL cable that I use for other projects,) but when taking those same sounds in, produces no output (kind of; read on.)

    I own a simple, cheap oscilloscope of sorts, the DS0138. I've used (learning as I went) to look at all of the parts of this build, as it is attempting to function. I used it to dial in the POTs in this design, so that the Schmitt trigger would operate as intended. I checked the triggers on the 555 timers, to make sure that they were working.

    What I found- and again, I don't really know exactly what it means- was that the 555 timer in the "audio in" side was constantly triggered (active low) on pin 2, producing constant high output on pin 3. This is intended, as the rx line of the TTL serial side is meant to be held high when idling. But nothing I could do would bring it low. So, I followed the signal with the scope, out of pin 7 on the LM358. That seemed to be producing a square wave, which dropped low with input. Then when it passed through the 100k resistor, the wave seemed to be (at least with my equipment and knowledge of how to use it) erased.

    (To test things further, I took a 19.2khz clock generator circuit that I made, the one that gives me 300 baud on my z80 SBC, and looked at that square wave on the scope. Then I added resistors to shrink that wave. I can only assume that this was intended in the circuit above, though I don't understand the circuit quite enough to know why.)

    Here is where things got a little more hopeful and interesting for me. When I built this design, I didn't have a 100k resistor. So, I combined 3 in series: a 75k resistor, a 22k resistor, and a 10k POT, in that order, with the POT closest to pin 7 of the LM358. With the scope, I looked at the signal as it went through those three resistors. Then, when I placed the probe between the 75k resistor and the 22k resistor and pressed some keys on the keyboard, I began to get some output.

    (With further testing, I noted that the output is accurate only with the o,u,m,w, and k keys. At least, mostly with those. It's not 100% accurate- meaning specifically that they don't come through with each keypress, but an "o" always comes through as an "o" for example. I suspect that the fact that these particular letters work has to do with the waveforms they produce, but I don't really know.)

    After some reading, I tested two things: first, I adjusted the POT in that series, and measured between ~95k and 104k. Those adjustments had no effect on the circuit; it still would only work with the probe in that particular spot. Second, I tried placing some very small capacitors between that spot and ground. This yielded some sort of characters coming though sometimes, but not reliably, and not the right characters.

    Unfortunately, that is as far as I've gotten in my troubleshooting efforts. At this point, I don't know what to test or try next, based on the information I've found. I'm hopeful that people here might have some clues as to what I could look at to move forward. Many thanks in advance for any tips!
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    10,218
    2,201
    Nov 17, 2011
    It is not necessary to have 100 kΩ. The important fact is that R2, R9, R10 and R11 have the same values. 4*75 kΩ would be equally viable.

    Sounds suspiciously like a bad solder joint. Using a single resistor (see above) minimizes this risk.
    I do not understand the connection with the pressing of keys. Where does that come into play? The interface is meant to be fed from a tape recorder? Did you connect the output to the input (local loopback) and test via a terminal program? A more detailed description of your test setup could help.

    The signal conditioning circuit is U1B. Adjust the pot RV2 such that U1B produces a clean square wave signal at the output (pin 7).
    Next check the collector of Q1. You should see the same square wave inverted at this node.
    Next check the THR oin on IC3. Without a tone present the voltage at this pin should be ~5 V. With a tone present the voltage should be ~ 0 V. You should not see the 4 kHz signal at this node. If you do, check the connection to C8.
     
    Joe Lyman likes this.
  3. Joe Lyman

    Joe Lyman

    22
    0
    Dec 19, 2017
    Test Setup: The circuit was originally designed to connect to an FTDI USB->TTL cable, which is what I'm using to test. This is connected at J1 on the circuit. On the computer I'm using minicom set at 300 baud 8n1, where I'm typing in characters manually. Instead of recording audio at J2 and playing it back through J3, I'm doing a loopback as you suspected by connecting J2 pin 1 directly to J3 pin 1.

    I tested as you directed with the following results:

    U1B pin 7 does produce a square wave (see image U1B_pin7.jpg), and collector pin 1 of Q1 does seem to have this wave inverted and reduced (see image Q1_pin1.jpg). The THR of IC3, pin 6, is steady at about 3.5v with no input at J3 (loopback disconnected), but with input at J3 it has a sawtooth wave that appears to show the capactior at C8 charging and discharging (see image Q1_pin1.jpg), which I read about a little here. I think since it's connected to that capacitor directly, it makes sense that I'm seeing that, but I'm not entirely certain.

    I don't think the sawtooth signal I'm seeing counts as seeing the 4khz signal, but to be safe I did check the connection between IC3 pin 6 and one leg of the C8 capacitor, and it seemed fine (continuity.) I also checked the other leg of C8 was well connected to ground.

    It sounds like I can attempt to re-build on breadboard even before I get more parts, by replacing the 100k at R1 with another value since I'm out of 100k resistors. I'm also out of 10k resistors at this time (also on order), but it sounds like if R2,R9,R10 and R11 match, then I'm OK, so I'll try the breadboard version with 4x of the 8.2k resistors that I have on-hand.

    Thank you for your help and insights, it's nice to have someone look at this that can actually understand it. If you can think of any other tests I can attempt, please let me know. My scope is simple, and doesn't give me the option to send captures to my computer, so the phone-camera images are poor. It's possible I also don't know how to setup the scope for the most accurate/readable output. In any case, it is super helpful to me to see something at least; let me know if the images are useful or if there is something I could do better there as well.

    U1B_pin7.jpg
    U1B_pin7.jpg

    Q1_pin1.jpg
    Q1_pin1.jpg

    IC3_pin6.jpg
    IC3_pin6.jpg
     
  4. Harald Kapp

    Harald Kapp Moderator Moderator

    10,218
    2,201
    Nov 17, 2011
    O.K:, but what irks me is the 2.33 V high level at the collector of Q1. I'd expect a much higher voltage, near 5 V. What happens when you disconnect this node from IC3, pin 2? Does the voltage at the collector go higher? If not, check R8 and its connections.

    This is correct and looks fine. The voltage on IC3, pin 6 may rise a bit too fast. You may try to increase the value of C8 to e.g. 22 nF (or 2*10 nF in parallel). Or use a higher value for R7, e.g. 47 kΩ. The operation of this circuit is described e.g. here.
    As mentioned above, this signal is to be expected, but it seems to rise too fast.

    These images are fine for the purpose.
     
    Joe Lyman likes this.
  5. Joe Lyman

    Joe Lyman

    22
    0
    Dec 19, 2017
    I re-built half of this on breadboard (the half I'm having issues with), with a few changes to the resistors out of necessity. The same issue persists.

    When I disconnect IC3 pin 2, nothing changes at the collector of Q1. R8 seemed fine, but I had swapped out a 10k POT since I didn't have a 10k resistor. I moved one lead to the wiper and adjusted the resistance, which allowed me to get the voltage up to 5V at the collector with the nice square wave.

    The above also lets me get some characters through, as I was getting with the probe attached, but with no probe present. Seems like a step in the right direction.

    I attempted different things with R7 and C8, various values. They did affect the "picture" of the capacitor discharging, but they didn't seem to help the circuit along in any way that I understood.

    I'm going to rebuild the rest of the circuit on breadboard, but didn't have time today. I'm not sure it's right to just test the one half, as the problem might also lie in the other part that generates the signal.
     
  6. Bluejets

    Bluejets

    4,151
    879
    Oct 5, 2014
    Don"t know if of any help but there is a large collection of detail on these old computers in the link below.
    We originally started when the kids were about 6 year old (mmm 40 years ago...wow) with the DSE VZ200 which is listed along with others.
    Cheers ...Jorgo

    http://www.vz200.org/bushy/
     
  7. Harald Kapp

    Harald Kapp Moderator Moderator

    10,218
    2,201
    Nov 17, 2011
    It doesn't look so. The signal generation seemingly works o.k. as you can see the 4 kHz signal.

    What is the resistance resulting from this adjustment?
    Looking again at post #3, image 'U1B_pin7.jpg' it seems that the output of the opamp U1B doesn't go all the way down to 0 V. Instead the scope trace shows Vmin = 1.04 V. This is too high and will not turn off Q1 (Vbe <0.6 V is required to turn off Q1). The LM358's datasheet states in chapter 6.5 that the max.low output voltage should be <= 20 mV. This is inconsistent with your measurement. What is the output voltage of U1B with R10 short-circuited? It should be only a few millivolts.
    Do you have a bypass capacitor across teh power supply terminals 4-8 of U1? If not, crosstalk between the two amplifiers could happen. Place a 100 nF ceramic capacitor as close as possible and with wiring as short as possible across pins 4-8 of U1 to stabilize the power supply for U1 and to minimize the risk of crosstalk.


    Btw.: What kind of 555 do you use? The bipolar one or the CMOS one? This may have an influence (I'm not sure).
     
    Joe Lyman likes this.
  8. Joe Lyman

    Joe Lyman

    22
    0
    Dec 19, 2017
    Thanks Jorgo, that looks like an interesting collection!
     
  9. Joe Lyman

    Joe Lyman

    22
    0
    Dec 19, 2017
    It appears to be quite low, about 1.6k to get the voltage up to 5v.

    The wave there is oscillating between ~1v min and ~4.5v max. When I short R10, I get a steady (no wave) 1v. When I short R11, I get a steady 4.5v. I haven't looked at the datasheet for the LM358 yet, I guess I need to do that next.

    I just put on on, but I'm still using the breadboard (for the audio in half) + prototype board (for audio out half) so I'm not sure if it matters as much? That said, with this setup there are two LM358's in play... is that acceptable, or are U1B and U1A related in any way that requires them to be on the same IC?
     
  10. Joe Lyman

    Joe Lyman

    22
    0
    Dec 19, 2017
    I forgot to reply to this: I'm using NE555P's from TI.
     
  11. Bluejets

    Bluejets

    4,151
    879
    Oct 5, 2014
    For the VZ200 at least, there are complete schematics including cassette interface for saving and retrieving programs. Cheers
     
    Joe Lyman likes this.
  12. Joe Lyman

    Joe Lyman

    22
    0
    Dec 19, 2017
    Very cool! I believe I located the schematic you mentioned in the file labeled "Diagrams - for the VZ300 Technical Manual." It's neat to see a schematic for a simple z80 computer with the cassette interface! Grant Searle's design doesn't have one- for simplicity sake and the reality of most modern users I'm guessing- and he also has the code for it stripped out of his ROM basic I believe.

    I'll have to spend some time looking at this (these schematics aren't readily understood without great effort for me) and see if there is any way I can apply it to my setup. Thank you!
     
  13. Joe Lyman

    Joe Lyman

    22
    0
    Dec 19, 2017
    I just noticed something that might make a difference. My DS0138 scope, connected simply to my power supply's vcc/ground, shows between 0.64v-0.88v for vmax with the power supply turned off and between 0.24v-0.32v vmin. When I turn on my power supply, I'm showing vmin of 5.23v and vmax between 5.63v-5.72v.

    I tried two different power supplies, both 5v regulated, one with a POT to adjust the voltage output. They both showed about the same readings with the scope. With a simple voltmeter, I'm showing exactly 5v on both power supplies.

    This might be normal, but I thought I'd mention it. I might be using the scope wrong in some way, it may be mis-calibrated, or it might just be cheap junk.
     
  14. Harald Kapp

    Harald Kapp Moderator Moderator

    10,218
    2,201
    Nov 17, 2011
    Sounds wrong. You should get a reading near 0 V. What happens when you disconnect R1 to reduce the load?
     
  15. Joe Lyman

    Joe Lyman

    22
    0
    Dec 19, 2017
    I found this on the scope manufacturer's website:
    Also, found how to "zero" that average level out. Apparently it's a relative reading, but I think it will be more accurate, having set it to zero when there were zero volts present. Still not perfect, but it's better now.

    I feel like this circuit "almost works." Of course, my feelings have little to do with the reality of the situation. I'm going to put this on hold until I get more parts, so I can introduce fewer of my own variables into the mix through combined resistors and other substitutions.

    If there are other ideas/designs that would accomplish the same goal (i.e. converting a digital serial signal @ 300 baud into audio, then back to digital again), I would absolutely love to see them. Thank you for all of your held and insights so far, I'm learning a lot, and I appreciate it!
     
  16. Joe Lyman

    Joe Lyman

    22
    0
    Dec 19, 2017
    I couldn't stop messing with this, as it's the only electronics project I have going right now... in my fiddling, I did notice a few things, which I figured I would share.

    First, I found through testing that R5 and R6 are determine the frequency of the tone at J1 pin 1. That is perhaps not a surprise to anyone but myself, and it's not really interesting. I rebuilt the tone generator on breadboard, just to play with it. With a tone of 5.8khz I was getting the same results as with the 4khz tone; that is, I was able to get a few characters to pass through. I changed R5 and R6 to get ~4khz, though the two resistors didn't match... I'm not sure if this is critical or not, or if the frequency generated by IC2 needs to be anything in particular, or if 4khz is just a reasonable goal. I'm curious also, if I change the frequency at IC2, do I have to change anything at IC3?

    Second, I noticed that by adjusting the POT at RV2, I could get the wave at U1B pin 7 (the schmitt trigger I think) to change to a constant high which would drop low when keys were pressed at the terminal (again, in my test setup those keypresses from the computer are turned into the tone at J2, looped back to J3.) To me, this seemed like the final goal: to have a stead idle high which would drop low when characters came through. So out of curiosity I connected the USB->TTL RX, which is normally connected at J1 pin 2, directly to pin 7 of U1B. To my surprise, I got the same performance that I've been getting out of the entire circuit around IC3, which is a number of characters coming through properly some of the time, but only certain characters (o,u,l,k,m,w; generally speaking.)

    This leads me to wonder: what is the purpose of the circuit around IC3, if the schmitt trigger is already doing the job at least as well as my current build attempts of the circuit around IC3? Is there more to the job than what the output of the schmitt trigger is giving?

    Ultimately this means that I don't quite understand the function of the circuit around IC3. In some online reading on 555 monostable circuits, I noted that the timing of the circuit is controlled by (in my schematic's case) R7 and C8. Does this timing help keep things moving at the correct baud rate? Does it condition the output in some other important way? Does the timing at IC3 have anything to do with the timing/tone of IC2?

    Of course, I'm asking all this assuming that people with more experience understand the circuit just by looking at it, not having authored it or built it. I might be off on that; to me a lot of this is wizardry at some level still. But slowly, it is starting to make sense.
     
  17. Joe Lyman

    Joe Lyman

    22
    0
    Dec 19, 2017
    (previous post deleted, mis-tested.) I just re-verified, with the J1 pin 2 connected to U1B pin 7, but this time with the R1 resistor removed, effectively bypassing the circuit around IC3, I get some characters coming through clean. When I tested before, I didn't remove R1, so I wasn't sure if that was affecting it.
     
  18. Harald Kapp

    Harald Kapp Moderator Moderator

    10,218
    2,201
    Nov 17, 2011
    Thes perform different tasks:
    1. The Schmitt-Trigger restores the analog signal to clean digital signal (square wave).
    2. The Monostable generates a steady high signal when triggered by the 4 kHz input signal, otherwise a low signal (at least that's what it is intended to do but obviously seems to be flawed here). Instead of a packet of square waves the Rx output get a steady signal.
    upload_2017-12-22_9-36-17.png
    Use your scope to check this behavior. If the monostable is correctly (re-)triggered, you should see the above relation between input and output.
    To make this test easier, you may connect Tx directly to 5 V or gnd instead the computer. If you do so, be sure the connection to the computer or the USB-to-serial cable respectively is removed, otherwise connecting Tx to a voltage source may damage the interface.

    What happens if you connect Tx and Rx directly, without this interface? Does the loopback work correctly then?
     
  19. Joe Lyman

    Joe Lyman

    22
    0
    Dec 19, 2017
    This is a good troubleshooting item that I hadn't thought of. It does work fine, at both 115.2k and 300 baud, when I simply touch TX and RX together and type (I tested 115.2k because minicom starts at that speed, but 300 baud is what I'm using otherwise.)

    I first tried with a ~10k resistor at R8. with that setup, I see a smaller (~2v) wave form at IC3 pin 2 (input) which I can see move when typing. At pin 3 of IC3 (output) I see a constant high (~4.5v), even if I disconnect the signal at J3.

    Next I tested with a 2.2k resistor at R8, which had worked previously to get the levels up (to ~4.3v) at the Q1 pin 1 collector. With that in place, the wave at IC3 pin 2 (input) is ~4.3v, and IC3 pin 3 (output) is high (~4.5v) except when I type, where I can see it drop clear down to 0v neatly. Also, when I remove the signal at J3 in this configuration, IC3 pin 3 (output) drops to 0v.

    I believe, if I understand properly, that means with the 2.2k resistor I'm seeing the waveforms as you expect them.
     
  20. Joe Lyman

    Joe Lyman

    22
    0
    Dec 19, 2017
    There is another interesting correlation here, which I'll share in case it helps. It might well be that it doesn't matter at all, so feel free to tell me that if you think it's the case.

    With that 2.2k resistor at R8, I can sometimes effectively loop back the following characters: ouwk_[]{}

    I say sometimes, but what I mean is that if I hold down one of those keys, I will always get the correct letter through, just not with every keypress. Any other key will not return the correct character.

    Yesterday, while I was testing, I removed the circuit around IC3 entirely from the breadboard, and connected J1 pin 2 directly to U1B pin 7. With the RV2 adjusted right on the edge before the wave went through, pin 7 was held high and dropped low with keypresses, and I was able to type, every single keypress, those same letters: ouwk_[]{} It was a little odd, but it worked perfectly, with every keypress, no matter how fast or slow I typed.

    I tested every key on my keyboard (but not the letters shifted uppercase.) I found that several other keys, when typed, returned those working characters: ouwk_[]{}

    Here are those characters, along with their binary representations:

    "o" was also produced by !#ag'c/
    01101111 00100001 00100011 01100001 01100111 00100111 01100011 00101111

    "k" ... )+i
    01101011 00101001 00101011 01101001

    "m" ... -%e
    01101101 00101101 00100101 01100101

    "u" ... 5
    01110101 00110101

    "w" ... 137qs
    01110111 00110001 00110011 00110111 01110001 01110011

    "{" ... 9y;
    01111011 00111001 01111001 00111011

    "}" ... =
    01111101 00111101

    [
    01011011

    ]
    01011101
    _
    01011111
    To be clear, when I typed "o" I got an "o" back through the circuit. When I typed a "!" I got an "o" back. When I typed a "i" I got a "k" back, and so forth based on the above.

    It's interesting to me that the only characters that work are those that start with 0 and end with 1. And all of the convoluted characters also started with 0 and ended with 1. If you look at an ascii chart with binary representation, you'll see that characters who's binary didn't start with 0 and end with 1 did not work at all, even in error.

    As I said, this is just an interesting correlation, but perhaps it means more to others than it does to me. I do find it odd that I get the same results, but less consistently, when I have the circuit around IC3 built out with R8 at a lower resistance. It makes me wonder if something might be wrong in another part of the circuit, prior to IC3.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-