News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

How tape is supposed to work ?

Started by Lone, 14:54, 19 September 14

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Lone

Hello there,


As some of you may know, I'm in the process of writing a new emulator. After solving most problems about the disk, I decided that it was not enough pain, so I began to add tape support.


And, guess what, I have some trouble understanding how the whole thing works in details.


As I didn't wanted to write this part multiple time (as I did for the FDC), I directly aimed to support WAV file, to fit to the maximum to the reality.


Some works later (lots of reading also), this part works a bit. And that's the trouble : "a bit" is not enough...


The specific problem I have seems to rely on the way data are transformed from a wave signal to "1" and "0" in the CAS.IN bit of port B of the PPI.


I first assume that all datas above the average are "1", and all below are "0". Works, but not always.
The, I think that, it's maybe linked to the rising and falling edge... Results are not really bad, but not as good as previous one.




So, does any of you have any clue about this ? Maybe some of you, electronic guru, can measure (with your magical devices) what's on the tape head, and what's the result ?


Thanks in advance


Thomas


ralferoo

Quote from: Lone on 14:54, 19 September 14
As I didn't wanted to write this part multiple time (as I did for the FDC), I directly aimed to support WAV file, to fit to the maximum to the reality.
Supporting CDT files would be far more useful (and probably easier for you too), but OK... :)

Quote
The specific problem I have seems to rely on the way data are transformed from a wave signal to "1" and "0" in the CAS.IN bit of port B of the PPI.
I first assume that all datas above the average are "1", and all below are "0". Works, but not always.
Yes, this is roughly what the hardware does, but it's less binary than that...

If you look at http://www.cpcwiki.eu/imgs/b/b1/CPC_Disc_Cassette_Schematic.gif you'll see the tape schematic in the bottom right. The connector is labelled J302, you'll see pin 4 goes to the +ve input (pin 7) of the op-amp labelled IC902 (the big triangle). There's some feedback via the resistor from output (pin 8 ) to the -ve input (pin 6) which will tend to amplify the voltage. It'll also make the output "sticky", so once the voltage has crossed the threshold it'll take a bigger voltage difference before it swings back the other way. So for instance, if you have a voltage that's oscillating around +-0.1v the output pin won't be changing but if the peak-to-peak voltage is oscillating at around +-0.5v it will be oscillating as expected.

There's another slight thing to be aware of... the capacitor C919 is acting as a DC-bias. That is, it tends to let AC voltage through but not DC. In this way, if you had a signal oscillating between 1v and 2v at the input, at the other side of C919 you'd see +-0.5v going into the op-amp (superimposed on the voltage from the divider which will be about 1.6v and used so that the result from the op-amp can be used to drive TTL logic by driving it higher or lower from this mid-range voltage.

So, for your implementation, probably the key thing is to maintain a running average of the last however many input samples and then check for a new sample that's above or below a certain threshold from that and when you detect that drive the output low or high depending on the direction.

Of course, if you use CDT files, you don't have to deal with any of this analogue nonsense! The data inside the CDT file represents the 0 or 1 that the emulator wants to see... :)

Quote
The, I think that, it's maybe linked to the rising and falling edge... Results are not really bad, but not as good as previous one.
If this works, it'll be through luck. It certainly does reflect what actually happens!

Lone

Thanks for the clue !
I will certainly add CDT support one day or another, but I'll also try to implement what's you explained so nicely.


Lone

Well...


So I added this new algorithm. Basically, as this :
- Keep average level of last xxx values (call it AV - from -1 to 1 ).
- Set a threshold value (0.05 for 5%, for example)
- For each new sample, if the level is below AV - Threashold, set 0. If level is above AV + threshold, set 1. Otherwise, return last level.


I give a try, and already manage to start far more tape than before ( well... Tape are long to load, so i just use 3 or 4 tapes at the moment).
I think with some little adjustement, it should be ok. And fit the reality, which is not that bad.




So I just have to thank you for your time, knowledge, and ideas !






Gryzor

Any more details about the emulator? :)

Powered by SMFPacks Menu Editor Mod