-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audio input suggestion #46
Comments
This may be of interest : Might be fun to be able to load from a real audio source 🙂. The software side will be tricky. There are moments when the z80 is paused to read the keyboard etc. It catches up afterwards but any audio input will need to be kept in sync.... I think it will require the CPU speed moderation to be rewritten and based on the depth of an audio queue. |
I'm not 100% sure but I think Vcc in their design is 5v... So we need to adjust R42 & R41 so that the gate bias is correct for 3.3v. Also, the author says his audio signal goes from -2.3 to +2.6 which seems high to me, I would expect more like -1.1 to +1.1v. The threshold voltage on the pico is about 1.8 volts, rather than 3.7 for the 74hc gate. |
Hmm, also this circuit has no gain, which we may want a little of if I am right about the voltage range on the input pin... May need to give this a little thought. If you can take some measurements of actual voltage ranges into a 1k load that would really help. E.g a pc audio jack, a phone, an old tape player. |
...Maybe the higher voltage is to able to drive headphones? |
On the pico... "Normally the voltage threshold is about 1.8V, but it isn't guaranteed; it can be anywhere between the maximum input low and minimum input high, that is, between about 0.8 and 2.0V." |
Could just try it with 39k for R42. Please correct my junior school maths if I have got it wrong. Centre voltage... Add in the BE voltage... So... And pick one that is easy to buy... |
Been on the road all day and will be the same for the next two days... we had a planned family trip. As soon as I'll be home, I can take some measurements with actual components and different audio signals. |
I hope you have a nice time with your family. |
Thanks for those measurements. It looks like the voltage swing is not really big enough 🙁. It's a shame the adc doesn't work, it would be ideal for this. Maybe we need an amplifier (rather than an emitter-follower) or a Schmitt trigger? Don't want it to get too complicated but I've seen some 2 transistor designs for a Schmitt trigger. |
At first glance, an amplifier may be too much (on the other hand it's late and I might not have all the marbles in place right now). |
Well, if the 0.8 to 2.0 volts thing is correct, at least 1.2v.I |
I've done some more reading and found the rp2040 inputs have their own hysteresis... I probably need to find out more about that. |
I found an example with hysteresis experimentation on the raspberry pi forums. |
Been reading this... |
As I should have expected, when using the 10K, with the PC headphone source (it was the only test I did), the AC voltage is the only difference encountered:
Also the same AC voltage seems to be present at the output line (same as before witch I failed to mention above)... so this is definitely not the way to go. |
They are easy to make with an op amp. I've ordered some that will run at 3v to have a play with. We can compare notes then 🙂. I'll post the circuit when I get a mo. |
...but it does turn out the op-amps I have ordered are going to take a long time to get to me! |
Hi, sorry for the slow reply, 'real-life' has been distracting me! The 1st circuit looks like a non-inverting comparator, without hysteresis. I like the way the bias is arranged; the single (rather than dual) voltage divider means you don't have worry about tolerance on the resistor values. The 2nd circuit looks like a high gain inverting amp... but I'm not sure what R30, R70, D9 & D10 are up to! Do you know what VMED gets connected to? |
I know what you mean about 'real life'. I've been pinned to the bed for the last two days due to a nasty cold... better now. |
Thanks for finding those... I will get back to this at some point! |
I've added a little test program which reads GP11 at 44Khz and sends 1s and 0s to the USB uart. Not as good as a dual-channel scope but it's something!
|
See https://github.com/fruit-bat/pico-zxspectrum/pull/54/files There is even a small chance this may work! It samples GP11 once a microsecond using the PIO and feeds it into the emulator. I'ts going to take a bit of work to fix all of the targets so only ZxSpectrumBreadboardHdmi4PinAudio is working at the moment. |
Been a bit busy digging the net for anything Spectrum for a while now (I lost at least four hours tonight just to find this in the end). Also I've been checking some wav dumps of some tapes since I'll surely need them to test the audio input. I will have to put together another Pico and test it with the breadboard since it's easier in the long run (I ordered a while back one piece of Wren's module and a micro sd card module). |
Hope your headache is better. Stick to 3.3v on the opamp. I think 5v will damage the pico. |
I've just loaded Frogger from a WAV file 🙂 |
Back with news: I tested wav files with both the LM358N and the LM224N using this schematic and this components:
I took in consideration this with the LM224N:
All wavs loaded fine with a little less or a little more volume level from the phone/pc. Now for DC voltages: LM224N | LM385N
Also, in the process, I found that the audio phone splitter, when hold in hand and no connection to the phone, generates a lot of noise. The 2m shielded audio cable (witch connects to the audio splitter) does no such thing when I hold it in my hand and isn't connected to any signal source. Maybe I should have made my own splitter after all. And unrelated, as a last thing I did, I changed the input resistor to the amplifier from 56kΩ to 100kΩ since the wife was complaining about the 'noise' :)) . She did not grow up with this 'noise'. |
Thanks, your resistor ladder values work much better for me too :-) I will try the other values as well but got a bit side tracked (can you believe it). I've been playing with trying to mix the L&R and been experimenting with decoupling both the signal and shield. Using the bias voltage as the shield voltage gives me better noise rejection and I pick up very little noise from picking up my If I plug my phone into a charger the amp becomes swamped with noise. This may be the same problem you were having if you were sending audio from your p.c. and powering the pico from it; possibly the decoupling capacitor will sort it... but probably not! I'm not sure what to do about it... I think I need a lot of coffee. Don't feel you have to do anything with the following (unless you want to). It's just what I have been experimenting with: |
On no! Hope you can get it to work. It will be quite an achievement to read a real tape. Also, Walkmans are still cool. |
I couldn't help myself and tried again to fix the walkman and replaced the electrolytic capacitors. |
Nice to see at least a few loaded first 🎉🙂 |
From messing about, having some resistance between the amp and the pico really helps stability. Doesn't seem to need much 10 to 100 ohms seems enough. |
Hello! In the end, the above tape player has too many issues, but the main issue has to do with it's motor. When I first started it, the motor started rumbling with noise from spinning. I oiled it, cleaned it, changed capacitors but in the end I gave up on it... it just doesn't work as it should. This had some problems a while back (2-3 years ago). It wasn't starting and all it did was blinking the power status led. I had it laying around doing nothing since then and today I opened it up and fiddled with some gears in the CD sections. The tape part was intact. In the end this one started to work. I added an 100 ohm resistor between the output of the op-amp and off I went with the demo tape from the old HC-91: With volume level 25 of 30, I loaded the first 6 parts and with volume level 20 of 30 I loaded the last part: Maybe I overdid it but I loaded all the programs on the tape. |
Amazing! I'm pretty sure that can be called successful... and thanks for posting all the pictures :-) I've been doing some messing around but not had time to write it up nicely... I have a nice working transformer coupled input stage. It has the advantage of no direct d.c. coupling and is wonderfully low noise (as the transformer acts as a filter). I'm not sure how practical it is as transformers are more expensive than a capacitor! I just wondered if it would work as the transformer will be reacting to the slope of the input rather than its amplitude. Also, and this is a bit embarrassing, I've found out why the input goes crazy when my phone is connected to a charger... it's because the audio output of the phone goes crazy!! So yes, I should have checked that first before assuming I had some complicated weird ground loop problem (grr). |
Show some pictures of the transformer... I do believe I bought some audio transformers a while back for another project involving a theremin... 5 pcs Audio Transformers 600:600 Ohm from one seller and another 2 pcs from another seller... |
I tried with the 600:600 audio transformer. With this schematic, the only static I hear is when I'm near the plug at about 1cm. By the way I just loaded another cassette on both sides with this schematic. Did you get the 4.7uF capacitors? |
Yes, and I get a bit more signal through them than the 1uf capacitors. |
When I get a mo, I will add you design to the 'readme' so others can have a play, as it is the best so far. Thanks for your tireless help and testing. |
In my opinion, you can add it to the readme and also you should add a note near the schematic: If someone is willing to improve it then we're willing to test it. If other people can improve it, then thats for the best for all of us. By the way, it's your design and I just tweaked it a little... I always understand and learn things by experimenting on stuff. I found browsing online that we could have better results if the input capacitor is as close as possible to the circuit... just a thought of what we could try until somebody can improve it. Now, if things are done with the design (until someone comes along and improves it)... how hard would it be to add tzx support? I'm thinking of the SpeedLock-ed apps that have pulses and stuff. I should add another issue for that... right? |
I've added a new issue for TZX support here #58 |
I've put up the diagram on the readme of the version that you have tested the most. I probably need to tidy it up at some point but its there now :-) ...because I clearly obsessive... I've done a version with the 600:600 audio transformer. Works rather nicely for me, including the degraded wav files, although they need more volume than PlayZX. I resorted to asymmetry rather than hysteresis to keep it quiet with no signal present... and it is absolutely silent, even with a dangling lead. |
As soon as I can, I'll test the last schematic. For now I've been sorting out through the tapes I got last week... Some of them are either really badly recorded or really badly degraded. |
Do you know what the yellow transformers are, winding/impedance wise? |
Thanks, I'll get a couple of the yellows so I can compare... and at some point I will build up the circuit that I believe you had some success with. It would be nice if there was a circuit that worked the same for both of us! |
I'll have to buy some yellow ones too (again) since I'll be using the two I got for this project and the red ones don't seem so reliable anymore. Meanwhile, I made a promise to sort some roms from some sites, while I wait for the next batch of tapes (witch I'll dump and check against the TOSEC for ZX Spectrum). I'm mostly searching for roms made in my country but whatever I can find and hasn't been dumped, it's a plus for everyone. After I'm done I'll be sending them upstream. |
Yes, I will also see if I can source some BAT54S diodes. You probably know this already, but the pins on transformers can take some cleaning; don't know why but they always seem to have gunk on them. |
I've seen tape glue on resistor pins but on transformers it would be a first. |
Since I figure that the ultimate goal is to recreate all functionality of the original ZX Spectrum, I am thinking that by using some modified hardware (or some new one even) from this microphone library, this goal can be achieved.
By adding a 100uF for isolation purposes as the guidelines for the analog module say maybe we can reach the goal.
I may be able (and willing) to test some hardware... I'm no audiophile but I got the tools to make what I usually need so that the analog "Line In" function can be available for the old cassette players out there... maybe even a save to ".tap" directly to the SD Card at the end... for comparison purposes since I still remember how error prone was this process in the old days.
I can try some different ways with the hardware part (will research more this part so we don't fry the pico) but since all this work is your baby, only you know if the analog part of the library can be adjusted to work with all the different layouts and if one input pin is available.
The text was updated successfully, but these errors were encountered: