Author Topic: How to interface to AY-3-8912 Port with other logic  (Read 661 times)

0 Members and 1 Guest are viewing this topic.

Offline fkey

  • CPC464
  • **
  • Posts: 8
  • Country: fr
    • Awards
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.
like
0
No reactions

Offline ralferoo

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.035
  • Country: gb
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #1 on: 22:25, 01 December 21 »
Could 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.
like
0
No reactions

Offline fkey

  • CPC464
  • **
  • Posts: 8
  • Country: fr
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #2 on: 12:30, 02 December 21 »
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
like
0
No reactions

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 4.090
  • Country: fr
    • ?area=showdonations;u=4
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #3 on: 13:47, 02 December 21 »
You will next require to program the PPI and the AY to access your add-on... Why not using the parallel port instead?
like
0
No reactions
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline fkey

  • CPC464
  • **
  • Posts: 8
  • Country: fr
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #4 on: 18:47, 02 December 21 »
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.
« Last Edit: 18:51, 02 December 21 by fkey »
like
0
No reactions

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 4.090
  • Country: fr
    • ?area=showdonations;u=4
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #5 on: 20:39, 02 December 21 »
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.
like
0
No reactions
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline Bryce

  • The Hardware Guy.
  • Supporter
  • 6128 Plus
  • *
  • Posts: 12.538
  • Country: wf
  • It's not broken, it just hasn't been fixed yet.
    • index.php?action=treasury
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #6 on: 10:19, 03 December 21 »
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.
like
0
No reactions

Offline fkey

  • CPC464
  • **
  • Posts: 8
  • Country: fr
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #7 on: 12:22, 03 December 21 »
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
like
1
Members reacted like:
ComSoft6128,

Offline Bryce

  • The Hardware Guy.
  • Supporter
  • 6128 Plus
  • *
  • Posts: 12.538
  • Country: wf
  • It's not broken, it just hasn't been fixed yet.
    • index.php?action=treasury
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #8 on: 12:44, 03 December 21 »
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.
like
0
No reactions

Offline fkey

  • CPC464
  • **
  • Posts: 8
  • Country: fr
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #9 on: 10:12, 06 December 21 »
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.
like
0
No reactions

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 3.004
  • Country: de
  • Reincarnation of TFM
    • FutureOS - Revolution and Revelation for CPC6128 and 6128plus
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #10 on: 01: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.
like
0
No reactions
http://futureos.de --> Get the revolutionary FutureOS (Update: 2022.01.11)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 4.090
  • Country: fr
    • ?area=showdonations;u=4
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #11 on: 14:14, 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)
like
0
No reactions
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline fkey

  • CPC464
  • **
  • Posts: 8
  • Country: fr
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #12 on: 18:04, 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.
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

On 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
« Last Edit: 19:34, 07 December 21 by fkey »
like
0
No reactions

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 4.090
  • Country: fr
    • ?area=showdonations;u=4
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #13 on: 23:44, 07 December 21 »
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.
like
0
No reactions
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 3.004
  • Country: de
  • Reincarnation of TFM
    • FutureOS - Revolution and Revelation for CPC6128 and 6128plus
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #14 on: 01:00, 08 December 21 »
In case you would like to have Fire 3 (called Spare) then you just need to solder in one more diode by yourself.
like
0
No reactions
http://futureos.de --> Get the revolutionary FutureOS (Update: 2022.01.11)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

Offline fkey

  • CPC464
  • **
  • Posts: 8
  • Country: fr
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #15 on: 12:54, 08 December 21 »
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.
« Last Edit: 13:19, 08 December 21 by fkey »
like
0
No reactions

Offline Bryce

  • The Hardware Guy.
  • Supporter
  • 6128 Plus
  • *
  • Posts: 12.538
  • Country: wf
  • It's not broken, it just hasn't been fixed yet.
    • index.php?action=treasury
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #16 on: 16:13, 08 December 21 »
What datasheet do you have for the AY. The versions I have don't mention the input voltages for I/O.

Bryce.
like
0
No reactions

Offline fkey

  • CPC464
  • **
  • Posts: 8
  • Country: fr
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #17 on: 16:16, 08 December 21 »

Hi Bryce, Page 6 of this document: http://www.ym2149.com/ay8910.pdf
like
1
Members reacted like:
Bryce,

Offline Bryce

  • The Hardware Guy.
  • Supporter
  • 6128 Plus
  • *
  • Posts: 12.538
  • Country: wf
  • It's not broken, it just hasn't been fixed yet.
    • index.php?action=treasury
    • Awards
Re: How to interface to AY-3-8912 Port with other logic
« Reply #18 on: 16:26, 08 December 21 »
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.
like
0
No reactions