Subscribe via RSS
21Nov/220

Resurrecting a Dead PowerMac G4

Saw this on FB Marketplace... didn't know what I was thinking. Seller listed it as a "display piece" and, upon opening it, I worked out why. Weird cables disconnected, RAM missing, power supply set to 115v in Australia?

Switching it to 240v and attempting a power up saw nothing. I realised the ribbon to the front panel was disconnected internally? Connecting it didn't help though. OK, time to pop the supply open and.. oh look? It's just a blown fuse... replace... test... OH LOOK, IT'S A BLOWN MAINS BREAKER.

(Something has now occurred to me after posting this blog entry: The sticker above the 'closed off' power plug says 100-120v MAX... with no 240v rating? Even though the power supply had a 115-240v switch, was this supply actually only ever going to work on 110v? It's a little weird!)

Either way, screw it, this power supply is filthy... time to hack off the power cable and inject some ATX goodness.

Replacing a G4 Power Supply

First step? Choose a donor. I have some ATX to AT adapters which I could re-wire, but I would have to cut and heatshrink wires, so, I might as well just use a real donor ATX power supply. The next question is if the donor ATX supply in the junk box is even race-fit. If I install it and, knowing an Apple, too much power is consumed.. it might fail in minutes/hours/days. Should I go buy a new one? Actually, does the unit even fit?

The answer is simple.. it didn't... so-much-so that I even forgot to take a photo. The shot above is from Google images and explains a newer power supply where the main power socket is centered and has a mains-switch underneath. This, when compared to the image above of the actual power supply from the G4, is obviously quite different. The original had two plugs (one covered), with the the power-on plug much lower-than-center when compared to newer power supplies.

Could I shift the guts of the newer one into the Apple supply? Or put this PS into my PIII-550 and use that older PS in here? I could... but that's a lot of unscrewing... oh what the heck... Maybe I should jerry-rig this ATX supply into this power cable.. I could just tin and insert the wires? Just to see if the motherboard even wants to show life.

Of course, the gauge of the wires prevents one from cleanly jamming them in the end of the ATX plug. What to do? Tin them all and trim them with snips... then tediously jam them in and grab two diodes to make the trickle supply.

To do the actual wiring, here's the mapping:

ATX Supply Gigabit Pinout
3.3v 12 24 GND
12v 11 23 5v GND 11 22 28v TRKL
12v 10 22 5v 12v 10 21 5v
+5v TRKL 9 21 5v NC 9 20 5v
POK 8 20 -5v 3.3v 8 19 GND
GND 7 19 GND GND 7 18 GND
5v 6 18 GND 5v 6 17 GND
GND 5 17 GND GND 5 16 GND
5v 4 16 P-ON 5v 4 15 P-ON
GND 3 15 GND GND 3 14 GND
3.3v 2 16 -12v 3.3v 2 15 -12v
3.3v 1 14 3.3v 3.3v 1 12 3.3v

Above, you can see that more than the lower half of pins can be straight-wired through. The top just needs a bit of juggling. Firstly, glue the plugs from the ATX supply together, then cut all four wires (11,12,23,24) from the ATX header, leaving zero mm length on 12 and 24, but 5cm on 11 and 23. Run the ground to pin 11 and pin 19 on the Mac side. Then cut pin 9 from ATX clean level with the plug and run it into a diode and then into pin 22 on the Mac side. Run the 12v from pin 11 on the ATX side through another diode and join to the Mac side of the previously-soldered diode. This makes the trickle voltage as per ATXG4's doings. Finally connect the 3.3v from pin 12 on the ATX side to pin 8 on the Mac side.

Finally, it's all plugged together... how does the Mac respond!?

WE HAVE LIFE! A hideous single beep, but... LIFE! The single beep means we have no RAM? Sure we do... but it seems to hate PC100 modules. After slapping in a PC133 DIMM....

It worked! But nothing would boot.. until I flexed the IDE cable to the CD-ROM?

Right, that damage was hiding up behind the CD-ROM/ZIP chassis area.. fun. It's also ultra-DMA, which I can't reproduce, so I'll just create a new IDE cable as I did for the last G4. Wait, that G4 was faster... and I ended up putting it on the gutter during hard-rubbish for another scavenger to collect. Why did I buy this one!? Oh well.

Hacky cable created and...

Yessss... it works! In the end, I had two options: truncate an existing ATX plug and graft on the old cable or just re-wire a 24-pin plug to fit... with overhang. I did the latter. As mentioned above, glue the 4-pin extra plug ONTO the base 20-pin plug. That way you (like I did!) won't cut wires that you need. When the 22-pins don't line up, it's easy to mistake the wiring!

Old and new... but we're only going to use the new. The old can be donated to a museum (or to the next G4 I stupidly pick up after disposing of this one.)

Route the grounds and volts and stuffs as per above... you'll have wires left over, but that's OK. Don't forget to wire up the fan plug!

And then remember that there'll be two pins hanging over the edge... easily removed if you can be assed...

No need... JUST PLAY!

WHEEEEE.....

Filed under: Apple No Comments
20Oct/222

NEC PC-9801VX – SCSI Devices

So, I've gotten my PC-9801VX to power-on, boot a floppy disk and then initialise the 486 upgrade... the next step was to get a HDD attached. Luckily, the unit already came with both SASI and SCSI cards, so I just had to choose one and connect things. SCSI was chosen, as I don't even know what SASI is and, perfectly by chance, I'd purchased an external 4.3gb SCSI HDD with the matching HD50 plugs!

Upon searching the usual boxes'o'junk for a cable, I attempted to plug the unit in and, to my surprise, the connector on the SCSI card wasn't actually HD50.

Turns out it's a mini-centronics HPCN50! You can learn all about SCSI connectors over here. It seems this connector type is very popular amongst PC98s. With this new information, I went scouring the web for an adapter. I found one from my usual favourite seller in NSW (RetroShopBox on eBay) and then also another full SCSI cable (HPCN50 to HD50) from the UK... but that was to take a lot longer to arrive.

I adjusted the HDD to SCSI ID 0 and, with everything connected, booted the IPL disk and then MS-DOS 6.20 Disk #1. The installation was painless, thanks to the Gotek, and before long the machine rebooted and failed miserably. This was due to MS-DOS 6.20 trying to start without the 486 Accelerator initialised and so I rebooted and installed that via the Installation disk. Before long, the machine had rebooted into DOSSHELL!

Removable Media

I grabbed my nearest Magneto-Optical drive and chained it onto the SCSI bus. It happened to be set to ID 6 and I just left it as-is and attempted to boot. Before long it threw the following error:

No system files!

To add insult to injury, it just continued to emit a high pitched squeal. Seems it thinks/knows this is a removable drive and expects removable media to be bootable. The disk in there certainly wasn't... I didn't even know what was on it.

Just for fun, I slapped in the IPL disk, installed DOS, installed the accelerator and then voila!, the disk started booting.. But the fun didn't last long. It failed with an error initialising MSDOS.SYS? How does that even fail?

No matter of mucking around got me further... Until I switched the MO's SCSI ID from 6 to 1. I had no idea why, but on ID 1, the MO booted to a command prompt! Unfortunately, once booted, I couldn't get to the internal HDD. The MO was mounted as drive A: and the floppies were mounted straight afterwards. No HDDs to be seen.

I had initially expected this unit to show up as a second HDD, so was a little perplexed as to how to make it act as one. A few emails back and forth from Adachi-san saw me realise that I either had to configure the drive into HDD mode, or force the SCSI controller to treat it like a HDD.

The SCSI controller is a TEXA HA55-BSW and, whilst booting, there's an initialisation screen that shows the devices found on IDs. During this process, there's no hint that it's able to be configured. After a little bit of googling, it turns out it can be configured, but only if you hold down the T and S keys at the same time whilst it's initialising.

Inside the configuration menu, you'll find drive options in the second choice. From here you can tick through the IDs and set the parameters accordingly.

I happened to find that the drive type could be set to MO Small Image and, well, this worked! I now got to the SCSI boot menu instead of just booting directly from the MO.

From here I booted into DOS on the main HDD at SCSI ID 0, but I still could only see that HDD (and other partitions on that SCSI drive), and no other SCSI devices. After a few more emails, it turns out there's a requirement with PC98 SCSI IDs: they need to be consecutive! That explained the issue above with MSDOS.SYS, but not this new one. Adachi-san also passed me a formatter that could format 230mb MOs up to 218mb and I went for it. Actually, it was obvious that the format was wrong as this is how the MO showed in the SCSI boot menu:

Similar to USB keys of nowadays with multiple partitions, this MO has been partitioned+formatted in "removable mode" and therefore shows up corruptly in HD mode. I re-partitioned and re-formatted the drive in the current HD mode with (RMUTL (Now MOUTL) from Adachi-san, received 218mb free and drive C appeared! Yesssss...... We can now copy from MO to HDD.

Thanks to my MO USB drive on my main machine, I could start expanding HDI files onto MOs and tinker...

CD-ROMs

I thought I might have needed the latest CD Drivers from archive.org, but DOS 6.20 just installed NECCDB.SYS and MSCDEX.EXE and my SCSI CD drive was mounted! I could even list the contents of the CD in the drive! Looking more-closely, it's actually an NEC CD-3010A which is somehow covered by the driver installed. Note that upon installation, DOS copies the driver it wants to use to the DOS folder as NECCD.SYS. Just match the sizes to determine which one it's actually using.

The Final SCSI Stack

Somehow I had enough cables, with the correct SCSI connectors, to join all of these together and terminate them!

It all works perfectly and I'm actually really impressed with the tech-level of multiple-booting and boot-menu of my PC-9801VX.

Filed under: Retro 2 Comments
14Oct/229

NEC PC-9801VX – PK-X486 CPU Upgrade

So, this PC-9801VX came with the weird sticker on the front indicating that it was powered by a 486 CPU.

It was a pretty random claim seeing as that the base system is built from a 286. How could you possibly upgrade an 8-bit CPU to 32-bit?

A quick inspection (see the over here) saw that the 486 was contained on a daughter board which used a PLCC-socket adapter to hijack the 286 socket!

The upgrade happens to be an IO-DATA PK-X486/87SLS (IOD2Y284), consisting of a Texas Instruments TX486SLC 25mhz CPU coupled with a Cyrix FastMath CX-83387 33mhz 387 Math Coprocessor.

As that this CPU actually replaces the existing 286, it's always been active and operating the system but, regardless of this fact, the system still reports as a 286!

Trying to install DOS 6.20 very quickly throws a "You cannot install DOS 6.20 on a machine with a 286 Processor."

So, a little googling later and it turns out there's a TSR which needs to be loaded. That link indicates the TSR is named PK486.COM, but no amount of googling resulted in such a file. Instead, PK486D.COM showed better results, like this Interrupt Extender for this CPU Upgrade, but that software still didn't include the TSR!

Finally, a little more googling brought up this Japanese forum post indicating that there was an old oldsoft/98.htm page at the IODATA website that had derelique drivers. Of course, this page no longer existed, so web.archive.org to the rescue! Finally, there it is, down the bottom of the page.

Unfortunately, the files are just upgrades and want the original setup disk to hack some bytes. So, next up I started clicking random links on the iodata library site and found this page. It's full of random Win95 stuff, but one file seemed to be valid for a newer upgrade card than I had.

The COM files looked great... so I just renamed and executed... and the CPUCHK.COM even threw out the following result...

But, alas, both TSRs just reported an incorrect CPU when trying to run. Of course, what are the chances they'd even work.

UPDATE:: Adachi-san of Adachi Giken has come to the rescue! You can skip this part.


IF ANYONE HAS ONE OF THESE UPGRADE KITS, CAN THEY PLEASE MAKE AN IMAGE OF THE DISKS FOR THE INTERNET?... there's many sites with people asking for the software and I'd love to try it out! The box looks like this... and the disks seem to come in both 5.25 and 3.5" variants.

The disks are labelled "共通サポートソフト".

Excuse the image quality... they were flogged from a yahoo auction. But here's a better close-up...

I'll have to keep watching the auctions as those Power Up Kit /PK-X486Sシリーズ disks above went for $10.


The disks!

So, the kit comes with two disks: an IPL and an Installation disk.

Downloads
IPL Disk Image Installation Disk Image

The IPL (or Initial Program Loader) is used to boot the machine into a state where the seconday CPU is active. This is good to use prior to installation of something that needs a 386+ (i.e. DOS 6.20), so boot this disk to the following prompt:

And then swap disks. Once done, hit enter and you'll get to continue as if you booted the second disk you inserted, but on a 486! Of course, after installation, rebooting the machine will set the 286 active again and that's where the Installation disk comes in. Let the machine restart after installing DOS 6.20 and watch it crash and burn. Once it does that, insert the Installation disk and restart the machine...

That screen above scrolls onto the screen in 90s goodness... and then you get the main menu. The options are to Backup something, read the README, install the software or configure cache. Choose the third option, and then your SCSI disk.

From here, choose the partition/installation and go for it!

You'll then be told that everything is complete and that it's time to restart your machine.

With this done, your machine is now a 486! Congrats. Message me if you need the disk images.

Filed under: Retro 9 Comments
30Apr/220

PowerComputing PowerCenter 180 – Power Supply

Turned this machine on for the first time since packing it away after getting Linux running on it and it tripped the main circuit breaker in my apartment! I'm still resetting clocks.

20220429 155013

I opened up the power supply, and didn't really like what I saw. The main large caps were bulging and there was a burnt-out resistor in between them. Instead of attempting a repair, I compared the ATX plug on the dead power supply with another ATX supply I had on hand and.... would you believe it... they matched? Same plug type/size/wiring. Probably not a smart idea to just plug it in and test, but it worked perfectly! Thank you PowerComputing for choosing off-the-shelf parts instead of proprietary power supplies!

So the answer is: You can use a standard ATX Power Supply in the PowerComputing PowerCenter 180. It lives!

Filed under: Apple No Comments
29Apr/220

Z Scale Layout – Rokuhan Flexi-Track

My crazy layout design needed some flexi-track for some curves, so I purchased a box in one of the batches. Opening it up, it became very apparent that it's nothing like any other flexi-track I've ever worked with!

20220423 121244

In the box, you get two rails with ballasted sleepers and a joiner fixed at one end. There's then 3 sets of 2-sleeper foundations that need to be removed from the frame. These are then slid onto one of the rails and, once you've added enough sleepers and created your desired length, the opposite rail is slid in very carefully.

20220423 121450

20220423 122029

Note above there's still a burr on the sleeper. Get rid of these with a sharp knife, otherwise the sleepers wont sit flush once the whole track is together...

20220423 122239

Keep going, sliding on the sleepers, then feed in the other side.

20220423 121331

20220423 122938

Note that I actually used all of the sleepers and the length of the track came to 35cm! Not 33cm as mentioned on the box? Once you've worked out your desired length and fed in all of the sleepers, you'll then need to cut the excess rail on either side. I thought I'd be getting out the dremel, but it turns out a sharp set of snips worked fine!

20220429 091511

20220429 091610

There was a bit of a point to the rail, so I filed it down with my pocketknife.

20220429 093417

A trial connection to a piece of straight track worked very well! There's a tiny gap up the top as the flexi-track wasn't bent to the expected curve... I couldn't hold it in position and take a photo at the same time.

20220429 105023

Back on the layout, the curve slotted in perfectly! I was initially worried about this style of flexi-track, but it turned out to be very easy to use!

Filed under: MRR No Comments
28Apr/220

Z Scale Layout – Akia 485-Series Traction Tyres

Just for a lesson in complete-failure, I attempted the fitting of traction tyres to an Akia 485-series EMU powered-car. The train couldn't get up gradients and so I thought I'd see how it went with traction tyres from Rokuhan.

20220418 150833

Rokuhan provides both 4mm and 5mm tyres, and I purchased a bunch of both sizes as I know I'll need them in the future. The power car in question is a standard 485-series passenger car and the shell comes off once minimal force is applied to separate both walls from the chassis. From here, you then need to remove the top circuit board by inserting a flat-head screwdriver in the 4 holes in the chassis, two on each side.

20220418 152052

Once that's off, remove the two weights.

20220418 151901

It gets a little tricky from here. The bogies are attached via drive-shafts with lateral pins. The chassis is a single unit, so you actually have to spread the frame to get the bogies out. Make sure to allow space for the drive-shafts when doing this, otherwise you might snap them.

20220418 151803

With the bogies out, you can grab a flat-head screwdriver and press down on the clips next to the power pick-ups. Pushing down on these will push the under-frame of the bogie onto the table. Once it's separated enough, you can flip the bogie over and lever the frame off.

20220418 151746

With this finally off, you have full access to the wheelsets and you can install traction tyres.

20220418 151555

Unfortunately, these wheelsets don't have the grooves for tyres and the trains run erratically once installed.
So don't do it! The end.

Filed under: Retro No Comments
26Apr/220

Z Scale Layout – Reviving A Marklin 8852 Krokodil

This poor thing came to me from Yahoo Auctions Japan in the first bundle'o'stuff. I threw it on the rails and it just sat there, dead as a doornail. Actually, I lie, I saw the headlights flicker once. Fortunately I paid only half the current going rate to versions showing on eBay now. Of course, that may be because this is an older variant.

20220410 205215

20220410 205224

20220410 205236

20220410 205404 20220410 205723 20220410 210139

The train was then thrown on the test track and still chose not to respond...

20220410 205326

I had a quick squiz of the manual above and realised that the unit had a switch to select between catenary and rails...

20220410 205416

But this also proved fruitless. The train was therefore stored back in its box for another day when I had the courage to try and service it. Around a week ago, that day arrived and I dismantled the loco.

Open-Train Surgery

The plastic shells come off with ease. Remove the main shell first, followed by both bogie shells.

20220410 205756

20220410 210006

The bogies are secured to the chassis by their axles, which are actually kept in place by the main shell. The axles hold a gear in between the bogies and main chassis which transfer the power from the worm gears.

20220422 110702

A quick look at the motor saw that it was in need of love. I carefully extracted it and un-sprung the brushes. They looked OK, but the contacts on the armature were tarnished. Cleaning these and reassembling the brushes saw the engine come to life, but still very erratically.

20220410 215926

20220410 215936 20220410 221107 20220410 221403

At one point the motor jammed when I wasn't looking and melted the contact off a brush. I attempted to solder it back on, but I couldn't get a precise location and the motor kept stalling and melting the solder I applied!

So. I started searching for brushes and found some on eBay... Which are still crossing an ocean from Italy somewhere. The joys of European models! I then stumbled across a page indicating that these older models had an optional 5-pole motor upgrade! Of course, the motor I needed was absolutely sold out and unavailable.

A lot of emails and searching later, I did the unthinkable: I actually clicked on the second and then third pages of Google search results! I then doubled down and opened a pdf result... To only find success! Nathan's Trains in QLD had five of the motors I needed in stock! And also brushes for the old motor. I bought both and they arrived in no time. I'd personally like to thank Noel at Nathan's Trains for stocking these vintage parts and providing great service.

20220421 201431

The new motor went in very quickly and easily, but the bogies were still jamming pretty badly. In fact, one wouldn't even complete a full revolution with the axle in, regardless if it was mounted to the chassis or not! At this point, after resoldering a few wires which had broken from twisting the components around, I went all-in and disconnected the bogies from the chassis to do a full service and alignment.

20220410 212647

Just like the actual Lego Krok that I built (see the end of this post), these wheelsets need the driving rods at 90-degrees to operate and I had a feeling they were both out. The electrical pick-ups were also showing over the top of the drivers and not behind them, where they should have been. Trying to work on these with the chassis strung on by the wiring was proving impossible. With the bogies separated, it was very easy to then roll them on the bench top, align, roll, align, test and repeat until the were totally in-binding.

20220421 214942 20220421 220332 20220421 215205

Note that there's really only one way to re-assemble these bogies. The driving wheels are permanently connected to the driving rods and the rods have a secondary 'fake' rod that makes orientation easy. If you scroll up to the pic of the side-on Krok with just the chassis shell, you can see that the bogie on the right has the drivers installed upside down. The 'extra' rod is hanging so low it hits the rails on each revolution!

I reckon I re-assembled both bogies around 10 times each. There's around 7 gears per unit and they're VERY fiddly. The electrical pickups are sprung behind the drivers and actually push them down when you're trying to force them in. Trying to align it all takes great patience! There was even a chunk of (what looked like) solder in one of the bogies that was causing the gears to jam... no wonder.

In the end, patience, grease and minute adjustments saw both bogies re-assembled and rolling smoothly on the table. The new motor was mounted in the chassis and the only real point you need to know is to push the motor ALL the way down into the chassis. It's easy to let it sit a 1-2mm too high... and if this happens, it'll fail to make proper contact with the bogies.

Finally, the wiring... It's slightly complex with the overhead caternary switch, but I re-soldered it all, failing to note how the directional headlights were wired... so... instead...

LED Headlights

It now has a 5-pole motor... the least I can do is give it a beautiful headlight. I found that the unit was really only running well in one direction (after all my hard work), so I set about removing the incandescent grain-of-wheat bulb and replacing it with an LED. I found a 3mm white LED in my box'o'junk and slapped on a 780ohm resistor. I then cut the legs ridiculously short.

20220426 142653

The existing light housing and contacts were removed and one LED leg and the other resistor leg were soldered to the tabs on the wheel pickups. Once in the correct direction, the LED lit up when heading forward!

20220426 142935

A little bit of adjusting saw the shell fit back on!

Internal Model Clearances

I just need to point this out, as I had a lot of trouble at the end. It turns out that the solder blobs I put everywhere were actually millimetres too high and causing the shells to not actually clip onto the frames! Easily fixed, remove the solder. I just had never thought that the clearance would actually be that low.

20220410 211923

Above, a reference shot for your future soldering nightmare.

My Lego Krok

I eluded to this before.. and I really can't believe that I haven't featured it on here before. It's a Lego version of this locomotive and it arrived for my bday last year.

20220426 220857

What a tiny Z-Scale loco!

Filed under: MRR No Comments
12Apr/220

Z Scale Layout – Arduino Control and Track Plan Updates

Actual trackwork on the layout has stalled recently. I failed to order all of the components I needed to build my previous plan and so used a few other off-cuts to, at least, make a circuit I could run trains on. First testing of trains was done with a 9v battery and the results were sub-optimal. Whilst browsing Jaycar recently, I saw a motor-controller shield for Arduino with 4 outputs and decided that was the way to go. It even has two servo controllers... I wonder what I can animate?

20220407 174142

I also had an Arduino Uno Wifi, so decided, instead of building some physical box with switches and dials, I'd make a webpage to control the layout! I've programmed this Uno Wifi before, so go and check that post out for caveats when dealing with this unit. The main point being that you need to program the WIFI module independent from the Arduino itself, using the serial connection as the conduit to communicate between the units. This all then gets a little difficult as you may also want to use that Serial port for logging output.

The Web Server

Fortunately, there are hundreds of examples to run with when creating these mini-webservers. I used the example over here, adjusting the page to control two throttles. Whenever a user presses a button, it updates the internal throttle variable and then sends both throttle values out over the serial port.

#include <ESP8266WiFi.h>

const char* ssid     = "wifi accesspoint name";
const char* password = "wifi password";
WiFiServer server(80);
String header;
unsigned long currentTime = millis();
unsigned long previousTime = 0; 
const long timeoutTime = 2000;

void setup() {
  delay(3500);
  Serial.begin(115200);
  Serial.print("AP:");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    //Serial.print(".");
  }
  // Print local IP address and start web server
  //Serial.println("");
  //Serial.println("WiFi connected.");
  //Serial.println("IP address: ");
  //Serial.println(WiFi.localIP());
  Serial.println("OK");
  server.begin();
}

int t1 = 100, t2 = 100;
int lastT1, lastT2;
void loop(){
  WiFiClient client = server.available();   // Listen for incoming clients
  if (client) {                             // If a new client connects,
    //Serial.println("New Client.");          // print a message out in the serial port
    String currentLine = "";                // make a String to hold incoming data from the client
    currentTime = millis();
    previousTime = currentTime;
    while (client.connected() && currentTime - previousTime <= timeoutTime) {
      currentTime = millis();         
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        header += c;
        if (c == '\n') {                    // if the byte is a newline character
          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println("Connection: close");
            client.println();
            
            if (header.indexOf("GET /1/less") >= 0) {
              t1 -= 5;
            } else if (header.indexOf("GET /1/off") >= 0) {
              t1 = 100;
            } else if (header.indexOf("GET /1/more") >= 0) {
              t1 += 5;
            } else if (header.indexOf("GET /2/less") >= 0) {
              t2 -= 5;
            } else if (header.indexOf("GET /2/off") >= 0) {
              t2 = 100;
            } else if (header.indexOf("GET /2/more") >= 0) {
              t2 += 5;
            }

            if (t1 < 0) t1 = 0;
            if (t1 > 200) t1 = 200;
            if (t1 < 0 && t1 > -15) t1 = -15;
            if (t1 > 0 && t1 <  15) t1 =  15;
            if (t2 < 0) t2 = 0;
            if (t2 > 200) t2 = 200;
            if (t2 < 0 && t2 > -15) t1 = -15;
            if (t2 > 0 && t2 <  15) t1 =  15;

            if (lastT1 != t1 || lastT2 != t2) {
              Serial.print("THR:");
              Serial.print(t1);
              Serial.print(":");
              Serial.println(t2);
              lastT1 = t1;
              lastT2 = t2;
            }
            
            // Display the HTML web page
            client.println("<!DOCTYPE html><html>");
            client.print("<head><meta name=\"viewport\" ");
            client.println("content=\"width=device-width, initial-scale=1\">");
            client.println("<link rel=\"icon\" href=\"data:,\">");
            // CSS to style the on/off buttons 
            // Feel free to change the background-color and font-size attributes to fit your preferences
            client.print("<style>html { font-family: Helvetica; display: inline-block;");
            client.println("margin: 0px auto; text-align: center;}");
            client.print(".button { background-color: #195B6A; border: none;");
            client.println("color: white; padding: 16px 40px;");
            client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");
            client.println(".button2 {background-color: #77878A;}</style></head>");
            
            // Web Page Heading
            client.println("<body><h1>Train Controller</h1>");

            client.println("<h1>Throttle 1</h1>");
            client.print("<p>Requested Speed: ");
            client.print(t1 - 100);
            client.println("</p>");
            client.println("<p><a href=\"/1/less\"><button class=\"button button2\"><<</button></a> ");
            client.println("<a href=\"/1/off\"><button class=\"button button2\">Stop</button></a> ");
            client.println("<a href=\"/1/more\"><button class=\"button button2\">>></button></a></p>");

            client.println("<h1>Throttle 2</h1>");
            client.print("<p>Requested Speed: ");
            client.print(t2 - 100);
            client.println("</p>");
            client.println("<p><a href=\"/2/less\"><button class=\"button button2\"><<</button></a> ");
            client.println("<a href=\"/2/off\"><button class=\"button button2\">Stop</button></a> ");
            client.println("<a href=\"/2/more\"><button class=\"button button2\">>></button></a></p>");

            client.println("</body></html>");
            
            // The HTTP response ends with another blank line
            client.println();
            // Break out of the while loop
            break;
          } else { // if you got a newline, then clear currentLine
            currentLine = "";
          }
        } else if (c != '\r') {  // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }
      }
    }
    header = "";
    client.stop();
  }
}

Note that the ESP2866 throws out a stupid line of text when it switches on. It's at 74880 baud or somesuch and, if you're already listening on the arduino-side, you'll receive a random pile of junk. Due to this, I've added a 3 second delay to the start of both units.

Arduino Motor Control Code

So, we have the webserver sending the throttle over the serial port... let's now read it and control the motors as expected.

#include <AFMotor.h>

AF_DCMotor innerLoop(1, MOTOR12_64KHZ); 
AF_DCMotor outerLoop(2, MOTOR12_64KHZ); 

bool is_ready = false;

void setup() {
  //just to skip the bios text output from ESP8266
  delay(1000);
  Serial.begin(115200);
  Serial.println("Starting...");
  innerLoop.run(RELEASE);
  outerLoop.run(RELEASE);
}

void loop() {
  while(Serial.available() == 0) { }
  String in_str = Serial.readString();

  Serial.print(in_str);
  while(in_str.length() > 0) {
    if (in_str.startsWith("OK")) {
      Serial.println("OKAY!");
    } else if (in_str.startsWith("THR:")) {
      String this_str = in_str.substring(0, in_str.indexOf('\n'));
      in_str = in_str.substring(this_str.length());
      Serial.print("Dealing with: ");
      Serial.println(this_str);
      int next_colon = this_str.indexOf(':', 4);
      int tt1 = this_str.substring(4, next_colon).toInt();
      int tt2 = this_str.substring(next_colon + 1).toInt();
      //Serial.println(next_colon);
      int t1 = (tt1 - 100) * 2.5;
      int t2 = (tt2 - 100) * 2.5;
      Serial.print("Throttles: ");
      Serial.print(t1);
      Serial.print(", ");
      Serial.println(t2);

      if (t1 == 0) { 
        innerLoop.run(RELEASE);
      } else {
        innerLoop.run(t1 >= 0 ? FORWARD : BACKWARD);
        if (t1 < 0) t1 *= -1;
        innerLoop.setSpeed(t1);
      }
      if (t2 == 0) { 
        outerLoop.run(RELEASE);
      } else {
        outerLoop.run(t2 >= 0 ? FORWARD : BACKWARD);
        if (t2 < 0) t2 *= -1;
        outerLoop.setSpeed(t2);
      }
    }
    in_str = in_str.substring(1);
  }
}

The AFMotor library was fun to wrangle. You choose the polarity via the run call, passing either FORWARD or BACKWARD. Turns out though, if you pass a negative value into the speed, it'll reverse the direction automatically. I initially was setting both and wondering why my train wasn't reversing!

Layout Updates

With the hobbled-together track, I'd made the basic figure-of-eight dual-track loop and was nearly bored of it once the controller was working properly. Friends also then came over for dinner that evening and asked how more complicated I was going to make the track... slightly insulted, I went back to the drawing board. Instead of dual-track all the way round, let's reduce it to single with a few loops and a yard.

newestplan

The result is ridiculous, but nicely uses the track I'd accumulated... only needing a little bit more. No problems with that as I got to order more trains at the same time. That track is still in the mail, so instead here's a video of the current trains.

Excuse the audio. How nice is that Marklin Santa Fe F7A? Love it. The Akia 485-Series hated the incline straight away and no amount of throttle got it going. I also need to fix the throttle increments as you can see the trains only start moving after 4 presses. Work to do!

Filed under: MRR No Comments
16Mar/220

Z Scale Layout – Track Types

If you search any Japanese Hobby Store online, you'll find that Rokuhan dominate the market when it comes to Z Scale track. It seems that, back in the day, there were a few other manufacturers, but they aren't that popular anymore.

Whilst going crazy-shopping on Buyee lately, I bid on some random auctions of track, not really paying attention to brands and getting it all for cheap. Turns out it's cheap as they're literally piles of junk track from companies that no longer exist. The only real exception was a stash of Micro Trains track which seems to have come from America to Japan and now into my hands in Australia.

Rokuhan

As mentioned, currently the leader of the hobby in Japan and widely available. It's very much the Kato Unitrack of Z Scale. I've invested heavily in it and will use it as the core of the layout.

20220316 123124

You can get insulated joiners and power feed modules to segment your track as required.

Akia ZJ Gauge Track

This seems to be a real relic and was purchased in a bulk set of track from Yahoo Auctions.

20220316 123158

I don't think I'm even going to open the box. It looks as bad as the track that came with the Akia trains... and well, that makes sense.

RealZJ Real Track

Simple name, but quite nice track! The sleepers are further apart than Rokuhan and that makes it look more like cape-gauge.

20220316 123333

I happened to need a piece of this as I had failed to order the correct parts list for my intended layout.

20220316 123341

With the plastic clips removed, the track happily joined together. The Real Track is the bottom-left piece. As you can see, the sleeper difference is obvious, but could be disguised with enough scenery. I don't intend on keeping this piece in place though.

Micro Trains

This USA variant is immediately obvious. The ties are much thinner and the spacing is might tighter. It makes sense as it's trying to emulate standard gauge.

20220316 123542

Again, as that I'd failed to order enough of the track I needed, I swapped in the larger radius curves from this accidental purchase.

20220316 123316

The differences are immediately obvious and really only good for areas that can't be seen; inside a tunnel or somesuch. I'll fix this bit in the future with a proper order of the remaining required track.

Layout Update

It's looking good. Regardless of my mismatched track, the layout fits and is starting to come together!

20220316 123416

As usual, I've left next-to-zero space for scenery, so I've been mulling over the plan to see how I can fit more in. I'm really happy with the height available in the table. It could nearly fit three layers of trains!

Filed under: MRR No Comments
10Mar/220

Z Scale Layout – Gambling With Rolling Stock

After sourcing a lot of both track and rollingstock locally (Thanks Tony!), I realised I had to put in an order to Buyee to get the rest of the parts I wanted. I could've just gone to HobbySearch, but I also needed some parts for my PC-9801. Hence, an order was placed, expensive shipping was paid and a box'o'magic arrived! I'll discuss the contents later... today I'll just talk about two of the components that were included.

Takara Micro Gauge

In Japan, at some point, next to the register in (I actually don't know which) stores, there were trains + chewing gum offered for cheap prices. The contents of these items were meant for display, but supposedly some of them actually came motorised. Per box, you received at least got one item of rollingstock, one item of track and a piece of chewing gum! This is actually how the sets I've already received were 'built up'. The goal, just like the magazines that used to offer part-by-part components to build a greater model, was to collect enough boxes with the intention to complete a set of ... something!? So, without further ado, I bring up the first item into evidence.

20220310 161456

This is a shop-ready counter-ready box of Takara (Yes, the Takara Tomy brand) Micro-Gauge rolling stock + gum. It's unopened and ready to be explored. The theme is based on the EF-81 locomotive and associated sleeper trains... let's open it...

20220310 161512

20220310 161534

Awesome! Ten chances to win. I do love my Twilight Express, so let's see if I'm lucky!?

20220310 163552

The end result? Two locomotives and two night trains! One of the twilight carriages is duplicated, but that's OK.

20220310 164546

Note that each box comes with a postcard of the locomotives and some cute information on the back. Meanwhile, back to the locomotives... one of them was a little heavier?

20220310 163557 20220310 163629 20220310 163854

Oh nice, it's actually got an engine... but it's battery operated! The chassis just pulls apart... an AAA battery was inserted and, well, the train ran like shit on the plastic track. The locomotive's coupler was also around 3mm lower than the carriages, so I couldn't even get it to pull anything. No real loss as this box was an entire gamble and I'm just super stoked to have two night trains in the mix!

Akia ZJ Gauge

The other box was exactly the same shape/size/form. Instead of targeting EF81s, it instead provided a chance to complete a 485-series EMU set.

20220310 164710

So, this is the Akia ZJ Gauge series. It's actually the same as the rollingstock you see inside my coffee table, so I was happy to gamble with this box and see if I couldn't get another engine or, at least, make my consists a little longer.

20220310 164802

The box actually looked like it had been re-taped shut... I wonder if someone opened it and scanned for motorised cars? Are they heavier?

20220310 164904

Each box contained one car, one piece of track, a liquid sachet of candy and, for the cab cars, a replacement coupler.

20220310 164904

In the end, I ended up with one cab-car of each livery and a mix of intermediate cars. No motors! It's OK, I purchased motors individually on Yahoo Auctions and they came in the box'o'magic from Buyee as well. No loss here, lots of fun gambling!

Filed under: MRR No Comments