News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

How to interface to AY-3-8912 Port with other logic

Started by fkey, 13:46, 01 December 21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fkey

Hello all,


Does anybody know how to interface the PSG (AY-3-8912) I/O Ports with any other logic gates ?
I mean, I can see from the schematics that a 74LS145 is interfaced with the PSG to control the keyboard/keys.
This is an OpenCollector output chip which (to me) means that there is no problem to interface it to the PSG I/O Port (input or output).


If I'm not mistaken (and being wrong happens a lot when I speak about a domain that I don't master), if the PSG I/O Port is set as an input (Keyboard matrix read), we can tie the output of a classical gate, e.g. 74HC00, to it without problem.
But what if the PSG I/O Port is set as an output ? Could it burn my 74HC00, or even worse my PSG ?


I haven't been able to find this information in the AY-3-8912 datasheet (I was looking for something like "Open Collector", "Totem Pole", etc ..), so maybe I missed it.


I figured out that the safer in that case is probably to stick an open collector/drain buffer in-between the 74HC00 and the PSG to mimic what is done between the 74LS145 and the PSG and avoid any damage, but is there a better approach ?
Thanks.

ralferoo

Quote from: fkey on 13:46, 01 December 21Could it burn my 74HC00, or even worse my PSG
You'll probably destroy whatever is most expensive! And not necessarily either of those chips, although they are the most likely to suffer.

But any other chip on the board could see problems when it's ground is suddenly higher potential than its inputs. And of course, you could also destroy your PSU. And if all of those survive, you could burn up the tracks on the PCB.

If you want to mitigate the problem a bit, you could stick a 100R resistor on each data line between the chips, but this will slow the transition times down, and still won't particularly help if left with both chips driving for a long time, as eventually the resistors will very hot. But 100R is a reasonable compromise that's relatively low current, so you might be able to last a while. This is definitely in hacky territory though. It's common practice nowadays to do this in some places to protect against accidental short circuits, but you shouldn't design the circuit using this to make it work.

However... A MASSIVE word of caution. (Someone else will have to correct me here, it's been too long and I might have this next bit wrong)... I think it's whenever you change direction on the PSG port, it results the output value to 0. Or it might be whenever you select a different port, the direction is reset, but that would be too dangerous, so I think it's the first one. But, e.g. this is the reason why my tape demo can't play music AND allow keyboard/joystick input at the same time... Because as soon as you switch between them, the tape motor switches off. Which I think, must mean it's the output that gets set to 0.

fkey

Hi ralferoo,


Thanks a lot for your response.
Indeed, I would like to be as cautious as possible since I'm kind of learning on this area and I don't want to destroy anything.
The cpc 464 schematics [1] seems to suggest that 74LS145(OC) is connected straight to the AY-3-8912 when keys are pressed without any additional components.


That works well when the PSG Port is set an input, but I wonder what may happen if one sets the PSG I/O Port (PIN 7-14) as output and begins to change their values while keyboard keys are pressed ?
Is there a risk that something could break in that configuration ? (I would have thought that CPC engineers thought about  that, but who knows ?)


[1] https://www.cpcwiki.eu/imgs/6/6d/Schaltplan_cpc_464.jpg

TotO

You will next require to program the PPI and the AY to access your add-on... Why not using the parallel port instead?
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

fkey

Hi Toto,


I would like to build a gamepad adapter for pads that are not cpc compatible.
This adapter needs some logic (hence the gates I was mentionning) in order to operate correctly.
That's the reason why I would like to hook this to the joystick port.


I don't really want to use the PSG port as an output in that context, I'm just trying to consider side effects that may occur if this happens (who knows what cpc coders are capable of  :D [size=78%])[/size]
To be honest, I'm also using this "project" as an excuse to train myself in basic electronic.

TotO

OK. I unterstand better, now. ;)

You know, there is no vcc and no gnd on the controller port, so you will require an external psu for your interface.
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Bryce

The joystick pins are never set to be outputs in any normal situation and no game or demo I know of does this, so there is very little chance of damaging your device. As far as setting the pins is concerned, this has to done by shorting the pins to COM not to ground, so you can't use standard logic to pull pins low. On my AMX Mouse interface I did this by setting the inputs on a 74LS240 buffer and connecting COM to output enable. This way the joystick pins are only pulled low during the low pulse on the COM pin. You can see the circuit here:

https://www.cpcwiki.eu/index.php/File:PS2Mouse_Sch.PNG

Most of this circuit could be used as the basis for a joystick adapter.

Bryce.

fkey

Hi Bryce,


Thanks for your schematics and information.
To my knowlege, only "amcharge" might have set the PSG I/O port as an output to control the download of softs from the french minitel network [1]


Still (for the sake of education) speaking about the keyboard now, am I right to say that  a relatively high current might flow from a PSG I/O pin to a 74LS145 OC output pin in the following situation ?
- PSG set as output (unlikely, but possible)
- Key pressed (circuit closed)
- 74LS145 output line grounded (OC transistor saturated - which happens when a keyboard line is selected for read)


[1] https://www.cpc-power.com/index.php?page=detail&num=3970

Bryce

The AY Datasheet unfortunately doesn't mention what current the pins can supply or whether there is currrent limitation on the pins. If the Telecharger software is written properly, it should turn off the 74LS145 scanning while sending data, otherwise an accidental keypress would cause exactly what you are describing. As the 74LS145 is controlled by the 8255, setting the BCD inputs to 1111 essentially closes the path to ground for all 145 outputs.


Bryce.

fkey

Thanks for the confirmation, that's my understanding as well.
I think I'll go for the Tri-state buffer output as you suggest for my "project" as it looks safe to just "disconnect" the adapter whenever it's not requested to respond.

GUNHED

Back the day there was a modem for the CPC which was connected to the joystick port. So the joystick port was used as input and as output. However, few of them were sold.
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

TotO

Quote from: GUNHED on 00:47, 07 December 21
Back the day there was a modem for the CPC which was connected to the joystick port. So the joystick port was used as input and as output. However, few of them were sold.
Sure, because the CPC joystick port is directly wired on the AY GPIO. On Amstrad Plus, it can't works because the diodes. (may be serial data using the fire lines)
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

fkey

Quote from: GUNHED on 00:47, 07 December 21Back the day there was a modem for the CPC which was connected to the joystick port. So the joystick port was used as input and as output. However, few of them were sold.
If I remember well, my father built a modem for the cpc, probably from electronic magazine schematics back in those days.
I don't remember if it was connected to the joystick port though, but it was home-made

Quote from: TotO on 13:14, 07 December 21On Amstrad Plus, it can't works because the diodes.
Interesting ! I didn't realize that diodes were present there. Funny enough there is no diodes for the fire1 and fire2, would anybody know why ?
Having a second look at the schematics, it seems that those diodes are actually in the "correct direction" to allow current to flow from the AY port to the joystick port, so I don't see why that could cause an issue when the AY is configured as output. Maybe just a small voltage drop when the AY signal is high ...
When the AY port is configured as input, open-drain logic would probably be sufficient to mimic what is done by the joystick/keyboard

TotO

Yes, you can read but don't write to the joystick port on Amstrad Plus, because the diodes. And probably the key clash is more problematic with combined directions hold than just pressing fire.
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

GUNHED

In case you would like to have Fire 3 (called Spare) then you just need to solder in one more diode by yourself.
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

fkey

Thanks GUNHED for this information, I didn't know that FIRE3 was not connected on the PLUS.


Toto, I must admit that those diodes confuse me, especially when the AY port is configured to read from the joystick and the COM port is set to low (grounded).
In this situation, when a direction is pressed, then the switch basically ground the cathode of the diode through the COM pin.


If this is correct, that means a (small) current flows from the AY input PIN pull-up resistor through the diode and the COM to the ground
Which means that a small voltage appears on the diode (say 0.6V for example).


But, the AY-3-8912 datasheet says that the maximal voltage for a low level input is 0.6V ...


To me, the addition of those diodes bring very little room for deviation in the low signal detection by the AY ...
Very strange, but I might be missing something obvious there.

Bryce

What datasheet do you have for the AY. The versions I have don't mention the input voltages for I/O.

Bryce.


Bryce

Thanks, that's the version I have, but mine was missing the last pages! :)
That's interesting, because the diodes used on the plus are 1SS132 and they could easily drop more than 0.6V forward bias if the current rises.

Bryce.

Powered by SMFPacks Menu Editor Mod