News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_MacDeath

[GX4000/Plus] Analog joystick port

Started by MacDeath, 12:41, 01 February 10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nocash

PS. something else: All the time I read people in the forum writing about cpc+ schematics, I am wondering where the hell you got the schematics from???

So far, I've found only the pdf service manuals on cpcwiki, download them, and immediately deleted them after having a near death experience. Even on a fast 1ghz computer, the adobe software draw the cpc+ service manual in slow-motion, looked slower than Locomotive BASIC graphics too me. Plus it's zoom function is blurry, can't do simple things like 50%, 100% or 200% zoom, and it can't scroll with left/right cursor keys, and so on.

Would be great if it'd be possible to get the schematics as GIFs or so.

nocash

Last post for now. Here's a summary of the known (and unknown) info:

The analog inputs are read from memory mapped ASIC registers:
  6808h  ADC0  Analogue Joystick 1, X-Axis (00h=Left= [maybe 0 ohm???], 3Fh=Right= [maybe 1xx Kohm???])
  6809h  ADC1  Analogue Joystick 1, Y-Axis (00h=Up=   [maybe 0 ohm???], 3Fh=Down = [maybe 1xx Kohm???])
  680Ah  ADC2  --unknown: MIGHT be Analogue Joystick 2, X-Axis (or Y-Axis, or whatever) ??
  680Bh  ADC3  --unknown: MIGHT be Analogue Joystick 2, Y-Axis (or X-Axis, or whatever) ??
  680Ch  ADC4  --unknown: MIGHT be unused (maybe wired to GND or VCC) ??
  680Dh  ADC5  --unknown: MIGHT be unused (maybe wired to GND or VCC) ??
  680Eh  ADC6  --unknown: MIGHT be unused (maybe wired to GND or VCC) ??
  680Fh  ADC7  --unknown: MIGHT be unused (maybe wired to GND or VCC) ??
To read that registers: Unlock the ASIC, and then map its register to memory at 4000h..7FFFh.

MacDeath

Good news every ones.

BDC-Iron told me at cpcrulez that he had a full working analogic joystick.


So I am awaiting for him to give me more informations concerning the model, and perhaps the way it is wired.

nocash

> using the ASIC outputs ADC0 - ADC6 (Pins 4 - 9) to vary the voltage

Uh, did you mean 7 outputs (ADC0..6), or 6 outputs (4...9)?

If it's only 6 outputs, then it should be quite obvious how it works on the computer side. Just a 6bit D/A converter, whose increasing (or maybe decreasing) output is compared with the voltage on the analog input, making it a standard 6bit A/D converter. Nothing special then (and no self-adjust feature or so). Having schematics would be helpful though. Are you really using the pdf ones??

Bryce

That's a typo, I meant ADC0 - ADC5 ie: 6 outputs which are Pins 4 - 9 of the ASIC. Yes, it is just a 6 bit ADC, where the bits are being set and then compared to the voltage coming from the Joystick, but this isn't the normal way it would have been done at the time. Normally an ADC component such as the ZN448 would have been used, rather than creating an ADC out of discrete components, this would have been simpler and cheaper, so there must have been a reason to do it the way they did. The only reason I can imagine is that the ASIC could calibrate itself. By that I mean that if a Joystick during calibration didn't ever return the value 3Fh even in the furthest position, that the ASIC then adjusted the values so that 3Fh was still the value being returned at this position, so that software would be oblivious to the hardware offset. Or can you think of another reason why they chose discrete components?

Bryce.

Btw, no I am not using the PDF files, I have a set of schematics in PNG format. Are there any Schematics in the Wiki? I couldn't find them.

nocash

> Or can you think of another reason why they chose discrete components?
Plenty reasons for doing that...
ADC chips were something like dreams from outer-space, expensive.
I think Resistor ladder and comparator were a cheaper solution.
Plus, the ASIC can handle the "FOR i=0 to 3Fh" part to feed the circuit.

And plenty details that indicate that it is actually done like that...
If there were self-calibration amstrad would have proudly mentioned it.
For self-calibration the hardware would need a calibration point, but there is none.
(except, it could "guess" that the joystick is connected, and is in the center position at power-up).
For calibration, the D/A output would need more than 6bit. Like 10bit (0..3FFh) output, and "scale" whichever calibrated range to the 6bit (0..3Fh) input range.

And last, everybody reported that PC joysticks don't work. The "pot common" is same (pin1) on PC and CPC, so, if the CPC could auto-detect different pots (like 100K or 300K or else) then the X/Y inputs should work fine.

----

NB. the interesting thing about testing PC joysticks with the CPC would be: Did anybody do some before/after test? Like connecting the stick to PC, and see if special electronics like autofire do still work, or if the CPC has blown them up?

Don't know if there's a resistor in the CPC joystick ports 5V line. If not, the 5V (aka -5V as how the PC joystick sees them) should cause some smoke, bad smelling, loud bang, or cause the stick to catch fire :-)

MacDeath

#31
using a PC analog joy on a CPC was reported as a weapon of mass destruction , this explain why the Plus range wasn't allowed to be exported to rogue states.

Iran and North Corea are actually testing a "GX4000 and a PC Analog joy" explosive head to use on their ballistic missiles.

This explains why GX4000 are so expensives on the internationnal market.

But they were screwed by local retro computers mafias as they were supplied with Amstrad Plus compatible Analog joys, explaining their failure to overtake the world, and explaining also why we cannot find any.

Bryce

Due to the latest developments, I'm writing this E-Mail from my Atomic Bunker at an undisclosed location somewhere in the Alps. Apologies for the delayed reply, my firewall is made of 3 metres of concrete...

Nocash, I assume from your posts that you have never worked in the electronics industry. But I'll ignore that fact for just a moment. At the time the CPC was being built, I was working as a freelance hardware developer in the 8-Bit scene (although not directly for Amstrad), the ZN448 family were by no means exotic back in the eighties, in fact the chip had been around quite a while and was already being produced by several alternative manufacturers making it even cheaper. It was the ADC chip of choice and was used in much cheaper units such as the Music Machine among others. The ZN448 didn't need a "For i=0 to 3Fh", it did everything for you, and balancing it's price against a dual comparator (where only half is being used anyway) plus a pile of resistors (taking into account the time and expense of placing each part and the PCB real estate required), the 448 would win every time on both price and simplicity. This still doesn't explain why Amstrad chose the other route.

To calibrate it would obviously need to be calibrated by the user, I didn't mean it would do it all by itself, rather it would have been calibrated by moving the joystick left/right/ up/down, pressing fire at the furthest position, much like you had to on old PC joysticks. This would allow the ASIC to define the highest and lowest analogue value without the need for 8 / 10 Bits and return 0 to 3Fh to reflect the position correctly. Even if the CPC had this function, I doubt they would have advertised it at a time when most people didn't really understand how a computer works anyway.

Bryce.

nocash

#33
No, I haven't worked in industry. I am sure the industry, like the NASA or so, had access to such superior chips. As far as I remember an 8bit D/A chip did cost around 10 german marks, is that the price you had in mind when saying it was cheaper than resistors? Asides if the ZN448 were so incredible cheap, why didn't anybody use it... PC gamecards would have been much faster if they had some A/D in them. I know that A/D chips do the For i=0 to 3Fh automatically (or whatever that gives equivalent results) that's why they were so expensive. Good reason for Amstrad to use something else. Dunno how expensive comparators were compared with A/Ds, nor how expensive it is to install resistors, but it seems that you don't know/remember that, too?

For the calibration. You suggest amstrad wanted the developers do that by software, but refused to tell them about it because they'd be scared? And if the software senses a range of 2..4 on the inputs, then there would be a secret undocumented hardware feature that commands the hardware to "scale" that values (2,3,4) to different values (0, 20h, 3Fh)? Sorry, that's really nonsense. The resolution wouldn't be any better, three values are only three values. Anyways, let's assume the designer was crazy: Designed a totally useless super-complicated calibration circuit for making the cpc+ compatible with all existing joysticks, no matter which pots are in them - and then blew the compatibilty by reversing the supply voltages?

MacDeath

The fact tennis cup doesn't really calibrate may come from the fact it does not use an analogue really.

From what I tested, the 2 working direction were like on digital joys.
you go to a direction, the sprite advance into that direction, you stop, he stop, he doens't go back to the middle.

But as 2 directions didn't worked, this may also explain it.

As I said, BDC-Iron told us at CPCrulez that he had a working analog joy on Amstrad+.

Yet he has no time for this at the moment.
So we'll have to wait a bit.


Yet Knowing an actually working model may be a great step for us.

OCT

Quote from: nocash on 21:47, 07 February 10Anyways, let's assume the designer was crazy: Designed a totally useless super-complicated calibration circuit for making the cpc+ compatible with all existing joysticks, no matter which pots are in them - and then blew the compatibilty by reversing the supply voltages?
It would not be an entirely uncommon feat for Amstrad to use standard connectors for already at least de facto standardized hardware with pinout varied only so slightly as to break compatibility with everything else.

They had done it before, on/to the original CPCs' digital joystick ports. ;)
As a matter of fact mine worked marvelously (and do so to the present day) with of-the-shelf C64 etc. gear (including auto-fire and all) the moment I contrived a little contraption supplying the +5V to the joystick and running the returning lines through opto-couplers; self-made back in the day before we met CNY17 and friends, from 5 green LEDs on the joystick side of things, and 5 photo transistors on the CPC side, stuffed into cuts of drinking straw. Seriously.

Bryce

That sounds like a really cool Joystick mod, any pictures available?

Nocash, a ZN448 in the eighties was approx the price of an LA6393. As far as prices for component placement is concerned, that depends on the machines they used and what country they were in. But generally, the more components and pins you have, the more expensive and time consuming it becomes. As far as "street" prices are concerned, yes, the ZN448 may have been difficult to source back then and probably cost around 10DM (if you bought it from Conrad), but in industrial terms, the part would have cost a few pfennigs in the quantities Amstrad could have ordered. I certainly hadn't a problem getting them, and neither would Amstrad, as I mentioned earlier, the ZN448 was used in cheaper peripherals like the Music Machine which would have had a much tighter budget and a lower profit margin.

Bryce.

nocash

Bryce, okay, maybe the price doesn't differ too much, or maybe an ADC would have even been cheaper. Still the solution used by Amstrad is quite straight (I've seen much more overcomplicated circuits from other companies, you know, that circuits where you ask: Why did they use that hundreds of useless components, and who paid that?).

Music Machine is something else. First it needs high-speed A/D for audio (not the joysticks 200 Hz sample rate), and low-budget or low-quantity often means that the company uses more expensive parts (if they produce only 100 units, with 10 cent wasted each, that isn't dramatic too them).

---

Btw. here's a schematic how joysticks look like, it's very simple:
http://www.allpinouts.org/index.php/File:Conn_game-f1.gif
that's for PCs. For CPCs it should be same, except that pin1 is GND instead 5V, and except that buttons may connect only to pin4 (not pin5).

Again, the only open question at the joystick side is how many ohm the potentiometer should have.

At the computer side, at the moment ADC2-ADC7 are still unknown, aren't they? Two of them should be for joystick2, but which? Doesn't somebody of you have an adobe-compatible super-computer, and could extract that info from the cpc+ service manual?

For people without super-comps: Does somebody know if there are tools to extract the scanned pics from pdf files, and save them as gifs? I think that'd be a nice option to using the pdf files.

Knowing a working joystick would be interesting. It'd be mainly for curiosity, still it'd be nice to have a photo or so, saying "this works" :-)

Bryce

Can't get my super-computer to boot since I installed Windows 7 on it, but I can answer those two questions anyway.

The variable resistor in the Joystick should be a 100K Linear part.
ADC2 is connected to Joystick 2 X-Axis and ADC3 is connected to Joystick 2 Y-Axis. ADC4 + 6 are hardwired to the 5V rail, so would always return 3Fh. ADC5 + 7 are hardwired to 0V, so they would always return 00h.

Bryce.

Edit: I have all schematics as PNG or Jpg, should I upload them somewhere?

arnoldemu

#39
The following from the arnold 5 specification:
"An additional 15-way female D-type connector will provide four analogue input channels and access to the four existing "fire" buttons. This is pin compatible with the games control port on the PC200 (PC-8) computer. "

"The ASIC includes the logic for an octal A/D converter, in conjunction with an external R-2R network, comparator and analogue multiplexer. Eight analogue input channels are thus available on the PCB, of which only four have connectors. This allows support for four paddles or two joysticks, with capacity for twice this many without redesigning the ASIC. The A/D is 6 bits wide, to give sufficient resolution after calibrating joysticks. It appears to the software as a bank of eight, 6 bit, read-only registers from 6808h to 680Fh, known as ADC0-7. They are updated approximately 200 times per second. The A/D inputs have an input range of 0V (data = 00) to 2.5V (data = 3Fh), and an input impedance of 180k to Vcc. "

Ok, so find some analogue joysticks compatible with the PC200.

Also it says "after calibration". Does this imply manual calibration through code? I think so.
It also says that not all inputs are used, and gives more info about what we should expect?

http://www.nvg.ntnu.no/sinclair/computers/peripherals/spj1.htm

http://www.silicium.org/forum/viewtopic.php?f=32&t=13355&start=0
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Bryce

#40
I just checked the higher resolution schematics, and the resistors are actually 180K to the 5V rail not 100K (the other schematics were barely readable) so the pots would have to be 180K too and not 100K as I mentioned earlier. This would then give the required 0 to 2.5V input range.

Bryce.

nocash

> ADC2 is connected to Joystick 2 X-Axis and ADC3 is connected to ...
Great, thanks! Just how one would expected it, but good to have it confirmed. I've read about the ADC4=3Fh somewhere else, too. But it wasn't explained what it's been causing it (ie. that it's wired to 5V).

>> and an input impedance of 180k to Vcc.
> the pots would have to be 180K too
Okay, then it's clearly 180K linear ones. Even being not so good on analog electronics, I had suspected the impedance things could have some important meaning :-)

> it says "after calibration". Does this imply manual calibration through code?
Could mean anything. It's different as the calibration on PCs.

On PCs, the pot is measured with a software counter. If the software uses a 32bit counter it could theoretically work with an infinite range of pot types, like from 10 kilo-ohm pots up to 100 giga-ohms. In the latter case, it may take some seconds to read the joystick, but it would be possible.

The CPC+ seems to be intended to be used with 180K pots ONLY. So software calibration would be needed only for some fine-adjustments. Guess it would also work with smaller pots, like 18K, spanning only a range of 0..6 on the ADC input (instead of 0..3Fh with 180K). But I guess that wasn't the intended way; the Tennis game doesn't handle that case.

Calibration could also mean hardware: I have a Quickshot DS-113 (bought it around 1990, it's PCB is dated (C) 1987). As mentioned above, it has "mechanical" calibration for X and Y axis. Maybe amstrad was meaning that. The photos at http://www.silicium.org/forum/viewtopic.php?f=32&t=13355&start=0 do also show some "mechanical" stuff at the bottom side - that might be calibration... or it might be a mechanism to disabled the springs that move the stick back to its center position (?)

nocash

#42
> I have all schematics as PNG or Jpg, should I upload them somewhere?
Would be cool! Best, here: Under "literature" is a schematics page,
http://cpcwiki.eu/index.php/Schematics

Oh, and just had a look at Tennis Cup 2. The options say "player 2 = analog", but actually, the option affects player 1, not player 2.

Ie. Player 1 can use DigitalStick1 or AnalogStick1. Player 2 always uses DigitalStick2. Done like so to avoid the Fire-button problem.

Bryce

Hi, I've uploaded the (readable) schematics to the page mentioned above...

Gryzor (or any other administrator) for some strange reason the Wiki refuses to display CPC_Plus_Asic_Schematic.jpg even after saving it with several different programs and compressions, so I had to convert it to GIF for the wiki. CPC_Plus_Asic_Schematic.jpg and CPC_Plus_Asic_Schematic1.jpg (a second fruitless attempt) may be deleted.

Bryce.

OCT

Quote from: nocash on 23:59, 07 February 10
Doesn't somebody of you have an adobe-compatible super-computer, and could extract that info from the cpc+ service manual?
What makes them supercomputers is called Linux ;) and (even on my old 486) something like pdfimages -j Adobe.pdf PDFimage extracts them quite nicely as JPEGs.

Bryce

My super-computer runs SuSE 11.2  :)

But my computer of choice runs Locomotive Basic 1.1  ;)

Bryce.

nocash

Many thanks for the CPC plus schematics! Viewing them as gif/jpgs is 1000 times faster, and more comfortable anyways.

Couldn't leave my fingers of the files, and made an edited version, re-arranged them a little to eliminate the blank space. Resolution is only half as good, but still okay. Uploaded them to the schematics page, too. Maybe they are useful for somebody.

nocash

Had a closer look at the schematics...

There's no resistor at all in the 5V line. So it injects the whole "negative" 5 volts, 2.4 Amperes to connected PC joysticks, yipieh. That proves the mass-destruction theory. Also explains the random crashes reported by redbox, probably the 5V collapsed to 3V or so. Guess if you open the joystick you will find some coal black melted components in it that exposed a critical dose of chemicals to the neighborhood. If you observe an increased mutation rate, or rapidly growing population of radioactive spiders under your bed - you know where it comes from.

The Digital Joystick Port is interesting, too. According to the schematics, Fire3 is not connected. And, the Y-cable-style diodes are implemented only in the direction lines, not in the fire button lines. That's funny, the CPC+ was shipped with 2-button gamepad, but actually, it seems to be incompatible with 2-player 2-button games :-) Is that a known problem?

Back to the analogue potentiometers. It'd be still nice if somebody could test them with a real CPC+. The 180K ohm should give 2.5V on the joystick input. But, if the CPC+ really outputs exact 2.5V to the comparator isn't 100% sure. It'd depend on the voltages on the ADC0..ADC5 pins, they are probably TTL-style, but TTL doesn't always mean exactly 5.00V. So possibly the pots could needed to be whatever... something like 150K through 220K.

MacDeath

#48
So I must have been lucky that no one of the 3 joys I tested exploded in my face and blown up my lair and the entine Valence area...


QuoteThat's funny, the CPC+ was shipped with 2-button gamepad, but actually, it seems to be incompatible with 2-player 2-button games :-) Is that a known problem?
Yep, it seems known as some CPCers told me that in CPCrulez.

"What were they thinking about ?"

Bryce

#49
Morning Nocash,
          I've just realised that your understanding of electronics is quite basic and normally I'd reply with the standard "Buy a book on the subject" sentence, but I can see you are genuinely interested, so here's a quick lesson on some basics.... Maybe helpful for others too? First of all some facts:

1) There's no "negative" 5V rail in the CPC, just a 5V and a 0V. (or did you mean negative as in unwanted?)

2) Putting a resitor in line with  the 5V line would limit the current, but the voltage would depend on the internal resistance of the Joystick (which varies from 0 to 180K). You can't reduce the voltage with a single resistor unless you have a stable and known current in the load.

Now some theory: Potential dividers. These are used to produce a defined voltage using the centre point between two resistors, one to the 5V rail and one to the 0V rail, here's how it works: (See attached picture)

If the variable resistor is at it's highest resitance (180K) then the ratio is 50/50, ie: The voltage is divided exactly in half and the voltage measured at V is exactly 2.5V. As the variable resitor is lowered, the ratio varies.  The voltage can be calculated like so:
(Vsupply(5V) / Rfixed(180K) + Rvariable) * Rvariable = Vout.

If the resistor was at the centre position (ie: 90K) then that would result in (5/180+90)*90= 1.66V
This is how the Joystick position is being read in the CPC+.

If things are blowing in a non-compatible joystick, then only the Auto-fire circuit, the variable resistors and fire buttons could easily survive anything a CPC could throw at it, the CPC would die first (unfortunately).

Hope that was of help to someone.

Bryce.

Powered by SMFPacks Menu Editor Mod