Wednesday, June 23, 2021

Assigning a HUION tablet to a single screen in a multi-screen Linux environment

Couldn't get the GNOME WACOM applet to actually pin my HUION tablet to a single screen so I did a little research, found out what commands to use and wrote a script to simplify it.  Has to be run at each boot.  I kept this as generic as possible but because of differences in the way that HUION constructs their device name strings it will probably have to be slightly modified to work.

This looks at active displays and connected tablets and gives you a simple menu to select from.  Defaults to whatever display you have designated as "primary".

#!/bin/bash


# Get list of active displays
DIS_LIST=($(xrandr | grep 'connected' | grep -v 'disconnected' | awk '{print $1}'))
unset DIS_PRI

#=======[SELECT DISPLAY]================


# Unset validation check 
unset gDISv

# Loop until validation check is passed
until [[ $gDISv == "yes" ]]; do

   echo ""
   echo "The following ${#DIS_LIST[@]} displays were detected"
   printf "%2s | %10s | %10s | %7s\n" "#" "Resolution" "Physical Size" "Priority"
   echo "-----------------------------------"
   for (( i=0; i<${#DIS_LIST[@]}; i++ )); do
      # Offset index to offer nicer options - this way the display numbering will
      #  not start at zero, AND theoretically it will match the XORG display
      #  numbering shown in GNOME
      let j=$i+1
   
      # read the xrandr line into a variable
      DLINE=$(xrandr | grep "${DIS_LIST[$i]} c")
   
      # Pull screen resolution and physical size to make it easier to identify which display is which
      THIS_RES=$(echo $DLINE | sed 's/primary//' | awk '{print $3}' | awk -F'+' '{print $1}')
      THIS_SIZ=$(echo $DLINE | sed 's/primary//' | awk '{print $(NF-2), $(NF-1), $NF}')
   
      # Mark which display is primary (using the offset index) so we can default
      #  to this choice
      if [[ -n $(echo $DLINE | grep -o 'primary') ]]; then
         DIS_PRI=$j
      fi
      
      printf "%2s | %10s | %10s | %7s\n" "$j" "$THIS_RES" "$THIS_SIZ" "$(echo $DLINE | grep -o 'primary')"
   done

   echo ""
   read -p "Select a display (1-${#DIS_LIST[@]})? [$DIS_PRI]:" gDIS
   # If no input was provided, set value to default
   if [[ -z $gDIS ]]; then let gDIS=$DIS_PRI; fi
   # Validate input
   if [[ $gDIS -gt 0 ]] && [[ $gDIS -lt ${#DIS_LIST[@]} ]]; then
      gDISv="yes"
      DIS_TGT=${DIS_LIST[${gDIS}-1]}
   else
      echo "[$gDIS] is not a valid selection."
      unset gDIS
      echo ""
      gDISv="no"
   fi
done


#=========[Find XINPUT IDs]============

ID_STYLUS=$(xinput | grep pointer | grep HUION | grep -i pen | awk '{print $(NF-3)}'| awk -F'=' '{print $2}')

#echo "XINPUT device ids: Stylus ($ID_STYLUS), Pad ($ID_PAD)"

#=========[Assign Tablet To Screen]=========
echo "Assigning the HUION stylus to display $gDIS: $DIS_TGT"
xinput map-to-output ${ID_STYLUS} ${DIS_TGT}



 


Tuesday, March 05, 2019

Casio TS-100 Repair Log


Story Time

Half a lifetime ago I was at school.  It was the 10th grade and I noticed something unusual about the digital watch the kid sitting next to me in shop class was wearing.  Below the display was an indentation with a round aluminum disc.  Being a total digital watch geek I had to ask him about it.  That's when I learned that the aluminum circle on the face was a temperature sensor.  It has been so long that I honestly cannot remember the particulars but I ended up trading something with him to get that watch.

At some point in my 20's the watch stopped working and I took it apart to try to fix it - what I thought I could accomplish is beyond me.  Predictably I wasn't successful in my attempts to get it working.  Rather than put it back together, I placed all of its pieces into an empty margarine tub and promptly lost track of it for nearly 20 years.

Fast-forward to last week when my wife was clearing out one of our many catchalls (you know when you've spent all day cleaning and you're down to that last pile of miscellaneous crap and you just want it to be over so you just dump it all into a box and stick it somewhere).  She left me a pile of stuff she thought I might want to keep and among it was the partial remains of my TS-100 - basically just the watch module and housing.  Evidently the margarine tub I had placed it in had shattered at some point and its contents were spilled everywhere.  By the time I recognized what I was seeing, my wife had already emptied the dregs at the bottom of the box into a trash bag.  Fortunately it had not been picked up yet so we dumped out and sifted through the contents of the bag to find what we could.  We managed to recover the back, three of the four screws, the battery clasp and the remains of the gasket and the band.    We did not find the last screw or the coil spring for the beep membrane.

Assessment


I can only speculate as to what kind of weathering the watch had been subjected to since I put it away, but the band had hardened and become brittle, the gasket was brittle and had broken in two.  This suggests some seriously extreme temperatures - might have been left in the garage over the course of several summers and winters.

I took a screw from another non-functional Casio watch to replace the one that was lost.  It's still possible to order new screws from Pac-Parts but they're $2.50 apiece.

I had no idea what functional condition the watch was in, so the first thing I needed to do was put in a new battery and see what happened.  CR1620 is not a very common size but fortunately Walgreens does carry them - well they carried one of them and I bought it.

The First Issue - Swollen Zebra Connectors

When I put the battery in the watch, the display showed numbers and appeared to work at first, but when my finger slipped and I had to re-insert the battery the display ended up all garbled.   It's never a good sign when putting the battery in the watch causes the light to come on - it means something is shorted somewhere.

The next step was to dismantle the watch module to see what might be going on.


TS-200 LCD Holder - something has caused the zebra connectors to swell and warp

I don't have a ton of experience with zebra connectors so it may not be terribly significant but I've never seen anything like this.  The zebra connectors which transmit electrical signals from the watch module to the LCD had somehow swollen in place causing them to warp.  I've read about these connectors shrinking with heat, but I don't know what could make them swell up like this.  Temperature, moisture?  It's hard to know.

When I removed them, I found the compression of being inside the slot when they swelled had caused them to expand unevenly and they ended up with a very pronounced curve.   The slot where the connectors are supposed to rest is 20mm wide, but the connectors had each swollen to over 25mm!

Because I knew that these connectors are prone to shrink with heat, I set my hot air workstation to 212 degrees Fahrenheit (its lowest setting) and gently heated the zebra connectors to see if they would shrink.  Not only did they shrink back to what appears to be their normal size, they also straightened out in the process.

In the image below, the top connector is what they both looked like when I first removed them from the watch, the bottom shows what the connector looked like after applying 212 degree heat to it for about 45 seconds. In hindsight I think placing them in boiling water would also bring them back down to size.

Top - a swollen and curved zebra connector as it was when first removed from the watch.  Bottom - a zebra connector heated with hot air and restored to almost normal size and shape.





















After heating both of the zebra connectors they reduced in size back down to about 21mm across which I think is probably their original size.  It's a bit of a tight fit getting them back in, but the curving was nowhere near as dramatic as when I first opened the watch, and unlikely to cause any shorts.


When I reassembled the watch and pressed the battery into it, it came to life, but again when I let go of the battery to try re-insert it with the clasp, the display was garbled.  I had to take a moment to pray about what to do next because it seemed like the watch might just straight up be damaged despite the fact that it would randomly seem to work and then not.

It might seem goofy to insert prayer into the middle of a repair log but it's been hard to argue with the results.  I had the thought that even though I had restored the zebra connectors to their original size and shape, I still hadn't cleaned them.  I disassembled the module again and took a Q-tip and alcohol to all of the pads on the module and to both of the zebra connectors, reassembled the whole thing, prayed again, and glory to God the thing worked perfectly when I re-inserted the battery.

I fastened the battery clasp, inserted the module into the casing and here's what I got:




So far so good.

Second Issue - Missing Coil Spring

Now the next item on the agenda was what to do about the missing "coil spring".  For reference the coil spring is a tiny spring that sticks out of the back of the watch module and makes contact with the piezoelectric pad on the watch back creating a circuit that allows the watch to make beep sounds.  The original coil spring had been lost when the parts were scattered.  I figured it had to be a pretty common part - pretty much every digital watch that beeps uses them, but after searching with Google and a phone call to Pac Parts (the official parts supplier for Casio) I could not seem to find these parts anywhere.  I went back to that donor watch that I pulled the missing screw from, but its spring was too shallow to work.

I'm sure that with a little more time and maybe calling around to watch shops I might be able to find a suitable replacement, but it's just a simple conductor - surely I had something on hand that would do the job.  Eventually I decided to just snip off a tiny length of solder - the metal is soft enough that it's easy to cut and will give a little when pressed.  Turned out to work perfectly - now I've got beeps.

The TS-100's missing coil spring replaced by a small strip of .22" diameter un-melted solder.

Third Issue - Inaccurate Temperature

To my recollection, the temperature sensor on this watch was always more of a novelty than an instrument of accuracy, but I do remember it it at least being somewhat close to reality once upon a time.  With everything back together I noticed the temperature reading was way off - registering about 10 degrees above the actual temperature in the room.  That kind of jarred my memory as being the main reason I took it apart in the first place, but I'm 20 years older now and hopefully a little wiser so I figured I might have better success this go around.

There's no setting you can access from the display that will allow you to offset the temperature displayed on the watch.  Calibration requires taking the back off and adjusting the potentiometer (pot) concealed underneath the sticker labeled "DO NOT TURN".





Turning the pot clockwise will increase the displayed temperature, counter-clockwise will decrease it.




Calibrating this watch to the correct temperature can be a tedious process.  Firstly you have to decide whether you want it to display the correct temperature when worn, or when left on display.  Despite the fact that the thermocoupler's primary source of heat is the aluminum pad on the front of the watch, body heat is enough to raise the temperature of the watch about 20 degrees.

Temperature Calibration Instructions

These are the steps I followed to calibrate the temperature to be as accurate as possible while wearing the watch.  (To calibrate it to be accurate when on display, I suspect all you really need to do is set the watch next to a reference thermometer and turn the pot until the displayed temperature matches the reference thermometer.)

Step 1: Remove the watch back and expose the potentiometer.

Step 2: Try to figure out the ratio of turn to temperature change on the watch display.  I recommend looking at the temperature displayed on the watch face then turning the pot 45 degrees and immediately re-checking the temperature.  What's tricky about this is that with the back exposed the air moving back and forth over the sensor as you turn it is also changing the actual temperature being measured. You'll probably need to check this a couple of times to make sure your results are consistent.  When I did this I found that every 5 degrees of turn was roughly 1 degree of Fahrenheit temperature change.  Your mileage may vary.

Step 3: Find a reliable digital thermometer to use as a reference.

Step 4: With the back securely screwed on, put the watch on your wrist and rest your wrist next to the reference thermometer.

Step 5: Wait until the temperature on the watch stops rising in reaction to your body heat.

Step 6: Continue to check the temperature on the watch every minute to ensure that it's still steady.

Step 7: Note the difference in temperature between the watch display and the reference thermometer.

Step 8: Remove the watch back and expose the potentiometer.

Step 9: Turn the potentiometer (clockwise to increase, counter to decrease) according to the temperature difference you recorded in step 7.  For example, if your temperature was 2 degrees Fahrenheit too high and you got the same 5:1 ratio as I did, you'd try to turn it about 10 degrees counter-clockwise.

Step 10: Replace the back and repeat steps 4 through 9 until you get to step 7 and find that the reference thermometer and the watch are showing the same temperature.


Finishing Touches

A New Band

The band for the TS-100 is an unusual size - 17mm wide at the hinge, but amazingly as of the time of this writing, the original genuine Casio resin band is still available to buy on Amazon - just search for TS-100 band.  Unfortunately the band does not come with the matching spring bars to attach the band to the case.  Since it's such an odd size, not may people sell them.  I ended up having to buy an assortment of over 100 spring bars just to get a pair of 17mm ones.

A New Gasket

And finally it would be the icing on the cake if I could somehow replace the gasket that provides water resistance.  Without a good way to measure the circumference of the gasket (the original was swollen too large to fit) I ended up ordering an assortment of gaskets from Esslinger & Co.  I'll update this post if I have any luck finding a gasket and somehow getting it into the weird shape required to seal up the back of this watch.

Friday, January 04, 2019

Sega CD Model 2 Repair Log (Revisited)


A while ago I wrote about firing up my Sega CD Model 2 and finding that it did not work.  Not only did it not work, but it was broken in more than one way.

To recap, first discs were making a terrible scraping noise and getting rings scratched into them.

I discovered that this was due to the shock dampers having cracked and collapsed.

Page 11 of the Service Manual courtesy of the Console5 Tech Wiki


The dampers deteriorated with time and use.

When the shock dampers fail like this, the CD drive sits too low and the discs will scrape the tray as it tries to spin the disc.

My first solution was to add some home-made washers to prop up the collapsed dampers.  While this did work, it had two major problems.  Firstly, with the CD drive rigged like this, the CD spindle was not properly level.  While the magnetic clamp holds the disc in place anyway, it seemed like being off balance like that might be putting extra wear on the spindle motor.

As far as I can tell, direct replacements for these "Rubber Dampers" are no longer made.  After at least a dozen hours of searching off and on I finally found a substitute part that seems to work pretty well.

Based on rough measurements of the original part this was the closest substitute I could find anywhere on the web.


At first glance they do appear quite different, but the inner diameter and the neck are pretty close.  There were a lot of other similar "damper balls" but most of them had too wide a neck or the wrong inner diameter.  Although the original part has a much wider outer diameter, the outer diameter doesn't really make much difference.  As far as support, the original part is hollow whereas the substitute I found is solid and actually a bit sturdier.

The original part is installed by slotting the damper into the CD drive assembly, then lowering the drive assembly onto the pikes.  The substitute part will ride too high if installed in the same way as the original.

One small issue with the substitute part is that the inner diameter is a single size, whereas the original damper has a larger opening on the bottom to match the two different diameters of the pike.  If you try to just drop the new dampers in like the originals, the CD drive will end up riding too high.  Fortunately the different dimensions of the new part mean that there's an alternative method of installation.


With the substitute, it's necessary to install the dampers onto the pikes first, then use downward twisting motion to stretch them over the lower portion of the shaft as shown here:



With all four dampers in place and pushed down, you can lower the CD drive onto the pikes, then push down.  The top ring of the new dampers are small enough that they should be able to push through with a little gentle encouragement from a pair of tweezers.



With the new dampers installed, you should be able to re-assemble the shell.

The red arrows show where there should be height differences.  The CD drive shield should sit about half-way between the disc well and the back edge of the tray.

With all six screws back in place, inspect the height of the CD drive shield.  It should be raised above the disc well.  There should also be a gap between the CD drive shield and the back of the disc well.

To make sure everything came out level and balanced, connect the Sega CD to a Genesis, power it on and put a disc in (you might want to test with something unimportant or easily replaceable first).  Wait until you hear the drive spin up, then open the lid while the disc is spinning.  If everything went well, the disc should continue spin levelly without any wobble.


The next issue I had to re-visit is the grinding noise during seek operations.  Sometimes this is a momentary buzz, others it's a constant noise that won't stop until you power the unit off.  This happens because the limit switch for the "home" position of the laser pickup is not correctly registering the end of travel.  You'll probably find half a dozen guides online of people describing gently bending the limit switch back toward the pickup.  While this did work for me, it wound up only being temporary - after a few hours it was right back to doing it again.  The problem is, I believe, that the drive likes to park the laser pickup in the home position which causes it to push against the limit switch for extended periods of time.  After a while the switch just bends into the shape of being pushed back.

The best solution I found was to wedge a tube of heat-shrink tubing behind the limit switch to provide a small amount of constant forward pressure.


With this fix in place the system has been working normally.  Time will tell if it continues to help.  A good game to test this with is Heart of the Alien - the drive always seeks to home when it goes to the continue/password entry screen.  

Sunday, September 16, 2018

3DO FZ-10 USB Host Controller Review

What is a 3DO FZ-10 USB Host Controller?


If you know what an "Everdrive" is, that's basically what this works out to being for the 3DO.  This type of device is most commonly referred to as an Optical Drive Emulator (ODE).  It installs into a 3DO game console in place of its CD drive which allows you to load games from a USB device.  The main advantages to this are that there are no moving parts to wear out, and more importantly you can have the entire library of 3DO games loaded onto the console at once.


Overview

Back in June of 2018, I wrote about a 3DO FZ-10 that I "rescued".  It had a broken latch, and literal dirt and dead bugs in its innards.  The CD drive spindle was seized, and the power and access lenses were missing.

My main motivation in purchasing an "as-is" 3DO FZ-10 was to install the 3DO FZ-10 USB Host Controller by MNEMO (http://3do-renovation.ru/USB_Host_for_FZ10.htm).

It was quite a fun journey, at times feeling like some kind of cloak-and-dagger mission fraught with uncertainty and intrigue.  Most of my adventures in modernized retro gaming have been mostly straightforward affairs or at least had shallow easy learning curves with a thriving responsive community ready to weigh in when things get troublesome.  This one device, however is shrouded in more obscurity than usual.



Ordering

Compared to buying something on Amazon, buying handmade "botique" retro gaming components like this can be astonishingly complicated.  Instead of browsing for something, deciding to buy it, popping it in your cart and checking out, these things are usually in short supply and made by people with a passion for the technology, but no aptitude for the business/e-commerce end of things.  I've pre-paid months and even years in advance, used informal email messages, forum posts and private messages on Facebook to place orders, brokered purchases through private and professional proxies in foreign countries and paid in at least four different currencies to what feels like the four corners of the earth - all of which is pretty normal.  This one, however took the cake.  For a while it felt like being in one of those cold war movies I watched as a kid, trying to get the mission-critical MacGuffin from the aloof Russian contact, including it's own cliffhanger where the protagonist loses his edge of control and has to give the Russian all of the diamonds and just hope he doesn't decide to disappear with them then the audience hangs in suspense wondering whether the hero has been left high and dry.  Well, okay, it wasn't quite that dramatic, but I did nearly gasp with relief when the thing finally showed up in my mailbox.

As I mentioned, this adventure started in June when I cleaned, repaired and modded an FZ-10.  As soon as I was done testing things and sure that the console was in good working order I went to the "how to buy" section of MNEMO's website (http://3do-renovation.ru/How_to_buy.htm).  The FZ-10 model was listed as "in-stock" and the "last update" time was less than a month old, so it seemed reasonable to expect they were actually available.

To place an order, you are asked to complete a really simple web form then click "Make Order".  Once you do that your order disappears into the ether.  No order number is provided, no confirmation email is sent to you.  There's no email address anywhere on the website, no way to reach out and ask about it.  You just wait.

After a couple of weeks with no response, I thought I might just need to re-submit the order, but there was a message on the website (which has since been removed) that said "I am swamped with orders, don't send your order a second time." 

I tried to be clever and use the Way Back Machine to see if a previous version of the website included an email address.  Sure enough I found a version that did.  I sent an email to "dr.mnemo@gmail.com" but never received a reply. (Although after installing the unit and sending a question about its operation, I did get a reply within a day, so YMMV).

On August 24th, A little over two months from when I first submitted my order, I received an email with the subject "3DO FZ-10":
hi
Sorry for delay.
USB FZ10 was out of stock.
Now available, and I can accept your order.
Send me payment 165 usd without fee
to account

Here is direct link https://www.paypal.com/myaccount/transfer/gift
notes not nessesary
I know your Paypal account and all data of your order.
The PayPal address in the request didn't seem to have anything to do with MNEMO at all, and I had no way to verify who I was communicating with.  (I have not included the email address in this article because MNEMO doesn't publish it anywhere and I'm trying to be respectful of his privacy).  It's fairly common practice to side-step PayPal fees by sending money as a "gift", but the downside of that is that you don't have any purchase protection whatsoever.  If the transaction comes across as a purchase of goods or services, there's a fee, but if something goes wrong, the recipient doesn't get to just walk off with your money. 

Trust is a beautiful thing, but it seemed foolish to go forward like that.  While the opportunity to purchase one of these adapters is tenuous at best and the last thing I wanted to do was to offend the one guy on the planet selling them, that was a little more risk than I was up for.

It had been so long since my original order was placed that my old PayPal email address was no longer valid.  I replied to the email I received and gave my new PayPal email address and explained that I could not send the money as a gift, but would be happy to cover the fees myself.  I got a response within a couple of hours:
At next week I will sent you Paypal Invoice
I forwarded the email from my old account to my current account and then replied - my thinking was that this would move the conversation away from my old account and eliminate any confusion.  That response was on a Friday.  Monday rolled around and I didn't hear anything.  On Wednesday, I sent an email response asking when I should expect the invoice.  I waited until Thursday for a reply, and when I didn't get one, I sent the message from my old account and received a response within a couple of hours.  The gist of the response was that the Invoice would be sent on 9/1.

True to his word the invoice was sent on 9/1, though now it included not only the PayPal fees, but an extra charge for shipping as well.  Instead of $165 it was $187.  Fair enough.  I made it formal, so he made it formal.

Right after I paid the invoice I sent an email to the same address asking to be notified when the adapter shipped and for an electronic copy of the installation instructions so I could get started.  I never heard another word.  The instructions are not published online as far as I was able to find.

The adapter arrived in my mailbox on 9/13, which is only about 8 business days from when I placed my order.


Installation

The adapter arrived with a wire harness for the IDE interface, a wire harness for power, an extra-thick ground wire, PCB spacers, a black-and-white instruction booklet and an un-sharpened pencil (which the instructions referred to as a "wand", lol).

All in all, it's a pretty great kit - the wires were already pre-cut to length.  Despite a little broken English, the installation instructions were clear enough.  The only criticism I have is that if you're going to go to the trouble of pre-cutting the wires, it might be helpful to provide some advice on how to orient them during installation.  There's a single picture toward the end of the instructions where you can see some of the data wires attached to give you an idea of the expected orientation.

To complete the installation, I used:
  • Hot Air rework station
  • Hair Dryer
  • Tweezers
  • Aluminum Foil
  • Kapton Tape
  • Liquid No-clean flux
  • Solder (I really prefer 62/36/2 silver-bearing)
  • De-soldering braid
  • Fiberglass pen
  • Automatic Wire Strippers
  • Digital Multi-Meter
Firstly you should read the instructions all the way through.  Not only to make sure you understand the procedure, but because some of the stuff is oddly out of order.

Disassembly is mostly self-explanatory - just unscrew and pull apart.  The one exception is the CD Drive which is attached by two plastic tension pegs.  The instructions illustrate inserting the pencil (a.k.a. "green wand") into the holes underneath the pegs and pushing up.  I recommend holding your hand over the top as you push the pegs out as they tend to pop out rather forcefully and can fly across the room.

The most difficult part is getting the drive controller IC off of the motherboard. 

To prep for the hot-air gun I used sheets of foil and Kapton tape to mask off the IC from the other components.  Basically I left the IC exposed, but the rest of the motherboard was covered in a foil shield, held flush to the motherboard by the tape to make sure that hot air did not pass under the foil to the rest of the board. This is especially important as there's a plastic socket just below the IC that will melt under the hot-air gun if not properly protected.

The next step was to take the hair dryer to the underside of the motherboard.  I don't have a dedicated warming oven.  The idea here is that you want to pre-heat the board to lower the temperature differential when you start applying the hot air.  It's supposed to reduce the likelihood of micro-fractures of the PCB from rapid heating and cooling.  I don't know if it actually makes a difference but it's an easy step to take.

Next, I covered all of the IC pins in no-clean flux, and applied some fresh solder to all of the pads.  Old solder has a tendency to resist being re-heated, so freshening it a bit helps it to conduct heat a little more readily.

From there it was a matter of patience, applying hot-air in a back-and-forth motion as uniformly as possible to the IC until the solder on all of the legs was hot enough to let go.  When it was ready I simply nudged it with a pair of tweezers and it slid right off.

With the IC off, I cleaned all of the pads with a little more flux and a de-soldering braid.

After reading through the instructions about 3 more times to get a feel for where everything would  go, I stripped separated and tinned all of the wires on the provided ribbon connector, then tried to loosely hold them in place with my fingers to get a feel for how it was all supposed to fit.

The ribbon wires are connected in three places - the gray wire goes to the reset switch, and the rest go to the pads of an unpopulated IC below the drive controller, then to drive controller pads.  I started with the gray wire, then the lower IC and then the upper.

A note on the installation diagrams: The instructions helpfully point out alternate connection points for lines that are very close together.  These points are usually little circles used for connecting between the PCB's layers, and they're not meant to be soldered-to.  The board is coated in a lacquer which will prevent solder from sticking to those points.  You'll need something to scrape through the lacquer.  In my case I used a fiberglass pen to gently rub off the coating.  With the coating worn away the pads are considerably brighter and will readily attach to hot solder.

After making sure all of the ribbon connections were soldered securely to the motherboard I used a DMM to test continuity to make sure there weren't any solder bridges between adjacent pins.

The instructions very properly encourage you to test everything BEFORE you fasten the controller board to the 3DO.  If you have any cold solder joints, or anything else is wrong it's a lot easier to check before you put it all back together.    In my case it worked perfectly on the first try.

The instructions tell you to remove the rubber shock absorbers from the CD drive unit, and re-use them along with the spacers to mount the host controller securely where the CD drive used to be but I went a slightly different way.  If you've ever tried to source those little rubber shock-absorbers you'd know just how impossible they are to replace.  Using them to mount the host controller will eventually ruin them because they'll be permanently compressed.  As unlikely as it is that I'll ever re-install the original optical drive, I'm also not going to ruin a perfectly good component.  Instead I had some replacement memory foam ear pads (this kind, if you're curious) laying around which worked perfectly in their place and didn't even require the included spacers.



Usage

Here's where things get obscure. The instructions for installing the unit were about 99% of the way there.  The instructions for using it, however, are missing a few key components. 

What IS Explained

The printed instructions provide a tiny bit of guidance.  
  • To Launch a Normal Game press "A"
  • To Launch an Unencrypted Game press "B" I'm not an expert on the subject, but I believe the 3DO required executables to be encrypted to prevent unlicensed software from being distributed for the system.
  • Use "RS" (right shoulder) to page down through the file list
  • Use "LS" (left shoulder) to page up through the file list
  • To copy the contents of the 3DO's NVRAM to a file on the USB drive press "Right+C"
  • To copy the contents of an NVRAM file on the USB drive to the 3DO's NVRAM press "Left+C"
  • To make the 3DO memory manager accessible, write a blank file to the USB drive.  Basically any file you try to launch with "A" which isn't a valid game disc image will make the 3DO think there's no disc in the drive and give you access to the storage manager.  So if you create a blank text file and name it "Launch Storage Manager", selecting it from the menu and hitting "A" will bring you to the "Insert Disc" prompt, from which you can hit "X" or "Stop" to open the Storage Manager.

What IS NOT Explained

  • Supported File Format For Games.  Games need to be in "ISO" format - that is to say "MODE1/2048".  It does not matter what the files are called - so you can save them to the USB drive without a file extension and get a cleaner look for your loader menu.  See "More on Disc Image Formats" below for more info on my experience.
  • How to Create an NVRAM file. In order to copy the contents of NVRAM to a file, you have to already have an NVRAM file on USB drive, and there's no option to just create a new one.  There IS a tiny tiny breadcrumb on the product page, though.  There's a note on the page: "For quick select of the game Image - extract that file to USB"  What "that file" actually contains is an example directory structure along with some example NVRAM files.  Now you could just copy those files, rename them to whatever you want and use them directly, but with a little trial and error, I figured out any file that's exactly 32k in size can be used.  You can create blank 32k files in Windows using "fsutil", or in Linux using "fallocate".  Examples below.
  • If/How Multi-Disc Games are Supported I reached out to MNEMO about this and his reply was "it works the same as with a CD".  Evidently all of the multi-disc games expect the console may be cycled between disc swaps.  The only one I've tested so far is D.  When the game asks for Disc 2, open and shut the CD lid, and the 3DO will load the USB loader, select and boot Disc 2 and it just works. I believe it writes a temporary file to NVRAM an deletes it upon load.  One of the example NVRAM backups in "that file" is labeled as "D disc 2".  I think if you write the NVRAM to a file when you're between discs you can capture this temporary file.
  • How to Navigate Directories.  This one isn't rocket surgery or anything, but unlike every other similar device I've ever used, there is no "back" button.  To descend a directory, highlight the directory using the D-pad and press "A".  To ascend back to the parent directory, use the D-pad to highlight the ".." at the top of the directory list and press "A".



More on Disc Image Formats

The CDRWin "bin/cue", and Clone CD "ccd/img/sub" formats are NOT supported by this device.  Nor are the more exotic DiscJuggler ".cdi", nor the Nero ".nrg".  If you have ripped your games in bin/cue or ccd/img/sub, you'll need to either re-rip the or convert them.  There are probably a dozen and a half ways to go about this, but I'll go over what I used and can confirm works.

ImgBurn (www.imgburn.com)
This is a free tool that runs on Windows and will rip original 3DO CDs in the correct format without any extra tuning or configuration.  Simply insert the disc, launch ImgBurn, select "Create Image File From Disc", select your drive and click disc-to-file icon.

Converting bin/cue to ISO
I had okay luck with bchunk, but I'm running a mixture of Windows and Linux in my environment and I used the Linux version.  Some files came across as 0bytes for some reason, but I was able to find alternative copies that worked just fine for those.

Converting ccd/img/sub to ISO
To do this conversion, I used Virtual Clonedrive (https://www.elby.ch/en/products/vcd.html).  It's free and made by the same company that invented the format.  I mounted the "ccd" image as a virtual disc, then used ImgBurn to rip it like any other CD.

What do I do with iso/cue?
If you run across any images that come as a .iso and a .cue pair, open the .cue file with a text editor and just confirm that the section with the .iso file notes "MODE1/2048".  If that's the case you can just discard the .cue file and use the .iso file as-is.

If all else fails and you can't lay hands on the original disc, you can always try burning the image to an actual CD-R then re-ripping it with ImgBurn.


Creating New NVRAM files

Just like with the game images, the name of the NVRAM file doesn't matter, so you can leave the extension off of the filename for a cleaner look to the menu.

Windows 7/8/10:
Assuming 
  • USB drive is "G"
  • Backups are in a directory called "NVRAM Backups"
  • You are running "CMD" as an administrator
fsutil file createnew "g:\NVRAM Backups\slot 01" 32768

This will create a file called "slot 01"

Linux:
Assuming


  • Your USB drive is mounted at /run/media/user/USB_DRIVE
  • Backups are in a directory called "NVRAM Backups"
  • You have write-permissions to the drive

fallocate -l 32768 "/run/media/user/USB_DRIVE/NVRAM Backups/slot 01"

This will create a file called "slot 01"

Monday, August 06, 2018

Thoughts on "Best Electronics"

Deal with Atari hardware long enough, and sooner or later you're going to come across "Best Electronics" (http://www.best-electronics-ca.com/).  While I haven't done a ton of research on the company, I gather that at one point they were a (or possibly THE) official Atari repair shop.  When Atari called it quits from the gaming biz, Best ended up with most, if not all, of the leftover stock of systems, games, accessories, repair parts and miscellany.

The first thing you're likely to notice is that browsing their website is like time-traveling to the early nineties.  Seriously, just fire it up and you'll see what I mean.  Monolithic old-school HTML pages complete with in-line gifs, center-justified spacing, funky font color transitions, and yes, a hit counter at the bottom of the page!  The whole thing is disorganized and difficult to wrap your brain around, but kind of fun if you aren't in a hurry to find useful information.

Some pricing is available on the webpage, but they reserve the complete price list for their printed catalog which they insist on selling for a profit.

Browse the web page long enough and you'll come across references to their "##+ year Atari tech".  If you're a fan of Top Gear, this is basically their version "The Stig".  A mysterious man (or woman!) identified only by reputation and credential.  And they are very rare to miss an opportunity to evoke the ##+ year Atari tech.

I've only dealt with them a handful of times over the years, and it is always something of a charming hassle.

They seem acutely aware of the need to protect their profit margins, as any business should, but it emerges in some annoying and disingenuous ways.  For example, they set minimum order amounts which change from time to time.  The justification for this is the cost to ship.  They absolutely will not budge from these minimums - even if you eliminate their excuse by offering to pay the extra shipping and processing costs.  Furthermore, their vaunted parts catalog cannot be counted toward the minimum order amount.

On top of the minimum order amount, they charge a healthy handling fee.

So I wanted to buy a sealed copy of the Tempest 2000 soundtrack.  This is a $5 item.  The minimum order amount at the time was $20.  When I offered to pay whatever extra they thought necessary to offset the cost of dealing with small orders, they resorted to what I have classically termed "the idiot's defense" - that is when faced with a rebuttal which logically defeats your given reason, you simply return to the beginning of the loop and start repeating the already-defeated premise of your argument.  This is not to say that they are under any obligation to allow me to circumvent their minimum order policy, but that I would appreciate it if they would be honest about the policy and just state up front that the minimum is there to make sure you buy more stuff, not to offset the cost of dealing with small orders.

But I digress.  So I wanted to buy something that costs $5, and at the time that was the only thing I wanted.  I attempted to quickly scour the website for something that would help me meet the minimum while I had them on the phone, but as I stated earlier, it's not what I would call organized.  I ended up hanging up with them and calling back to complete the order after finding that they sell the Jaguar cart connectors for $15.  I will probably never need one, but as I only have one Jaguar, replacement parts are somewhat appealing.  So now I had an order for $20.  Then, of course, they had to apply "Shipping" costs on top of that, which came to about $1 million space bucks.  Seriously, though it was about $8.  That was ALMOST cheaper than buying a new copy of the Tempest 2000 soundtrack from Ebay.

While I ended up spending more than I really wanted to, I got what I wanted and a little something extra so I called it a wash.  Not a great experience, but not a terrible one either.

So recently I got the urge to clean up and mod a Lynx II handheld (which is a story for another day).  One of the last parts I needed was a replacement lens piece for front of the system.  The one I had was in really good shape except for a rather prominent crack in the upper left corner.  It didn't cover any of the visible part of the screen, but my OCD just wouldn't let it go.  In searching around for where I might source a replacement, I came across several mentions that Best Electronics still sells replacements for $20.  The newest of those posts was from 2014.  I wasn't sure if they would still have any of the screen lenses in stock, so I sent them an email.

Email conversations with Best Electronics is something of a trip.  If you scroll down to the bottom of their home page, there's rather a lengthy diatribe about SPAM and the formatting of email inquiries.  That in itself is a little strange, but the fun really begins when the conversation starts.  Firstly, they seem to bounce the messages through multiple mailboxes - some in front of the SPAM filters, and some evidently behind.  I received a reply from a different email address and some explanation about Yahoo mail being blocked etc...  Since their filters reject any message beginning with "Re:" or "Fw:", they prepend the outgoing subject with "More" instead.

When you send them a message they attempt to fit it into a Q&A format.  Though a little weird, I found it to be very refreshing because it provides evidence that they actually read your message for comprehension.

For example, I sent something to the effect of:

Hello,

Do you have any replacement clear screen covers for Lynx II, and if so please quote me a price.

And they replied with something like:

Dear Customer Person,

Q: "Do you have any Lynx II screen covers"
A: "Yes we have those"

I'm paraphrasing of course, but you get the idea.  It took a couple more messages for me to actually get pricing from them, and to my dismay the price had lept up to $35 for the replacement screen.  But when you're the only source left, you can kinda get away with charging what you want.  That's almost as much as I paid for the Lynx II I was modding, but I eventually convinced myself it was worth it to get a perfect brand new screen cover.

When the part arrived I realized immediately that it was not the brand new part I thought it was, but a used part.  It was in pretty good condition, but for $35 it should have been flawless, and it wasn't.

When I reached out to them to ask if it could be replaced with an actual new one, they evoked the 34+ Year Atari tech (lol), and explained that the Stig had personally pulled that screen from a brand new defective Lynx II, and that all of the "new" parts were gone.  While it may have technically been "brand new defective", given the scratches on it, it was not "uncirculated".

They continued to respond in the Q&A format even when it ceased to make sense, and offered a refund.   Of course they were not going to pay for the shipping, so I would have been out something like $14 and still left with a cracked screen cover, so I decided to keep it, but I'll probably never deal with them again after that experience.

ViewEra V220D-B Monitor Repair Notes

A little over a year ago, my ViewEra V220D-B monitor started struggling to wake up out of power-save mode.  At first it would take a few seconds to come on, then it would take minutes and pretty soon it simply wouldn't come on at all.  This a classic case of spent capacitors.

According to my NewEgg order history I bought that monitor 11 years ago in 2007.  It doesn't even go up to 1080p.  Over the years it ended up front-ending secondary and tertiary computers that I barely used.  When it finally quit altogether, I stashed it in a corner and it stayed there for at least a year gathering dust.

It's customary when an old monitor goes out to use that event as an excuse to buy a new one with better features and chuck the old one in the bin.  Given that and the age of this thing I think the odds against someone stumbling across this post and finding it useful are astronomical.  But I've never been a fan of wastefulness, and if a perfectly serviceable bench monitor can be had for a couple of dollars worth of capacitors, they why not give it a shot?

Taking the thing apart was a bit of a chore.  There are three screws in back along the bottom - the middle one hidden in the center of a foil sticker.  However the back is actually held on by about two dozen tension clips that have to be carefully pried apart (I used one of those Lego pry-tools as a spudger to do it).

Once I got it apart, the problem was immediately obvious - four 1000uF 25v capacitors in the center of the power board were clearly swollen. (The capacitors in the yellow box in the image below are the replacements.)  The bottom side of the board was coated in yellow-brown syrupy electrolytic fluid that had leaked from the dead capacitors.  I happened to have a handful of capacitors with the right specs, so I cleaned the board, swapped out the bad capacitors and put everything back together. (The capacitors were attached to the board and the linear power regulators with gray epoxy - I'm not an electrical engineer, but I think doing that would transfer more heat from the regulators into the capacitors and cause them to fail prematurely - planned obsolecence?)

When I plugged the monitor in, I saw the familiar "Searching for Signal" box pop up for a few seconds, then, since I didn't have anything plugged in, it was followed by the "Power Saving..." box.  Up to that point I thought "Yay, it works again!". Then instead of going dark and powering down, the screen went completely white - lit up as brightly as it would go.  If I hit the "source" button, the screen would go mostly black, display the "Searching for Signal", then "Power Saving..." then back to a completely white screen.

With a video source plugged in, the monitor worked perfectly normally - it displayed a nice clear bright picture with no problems, but the minute I tried to power it off, or the PC went to sleep, or the DVI cable was unplugged - bright white screen.

My first clue as to what was wrong was that when the screen went white, it didn't just "snap to" white.  The whiteness would spread across the screen like a ripple - as though the blackness was "draining" out of it along the edges.  Since the LCD works by darkening the screen in front of a florescent backlight, it made sense that what I was seeing was the LCD turn transparent as the power drained from it - the LCD was properly shutting down, but the backlight was staying constantly lit.

I took the monitor back apart to re-check everything - make sure I hadn't dropped some solder somewhere, or created a bridge somewhere.  I de-soldered and checked a couple of other capacitors but everything checked out fine.  Then I decided to completely strip the thing back down to give it a thorough cleaning and that's when I found what I had done wrong.

The power board has a 5-conductor wire harness connecting it to the backlight ballast board. This is the red box in the image below.  On the backlight board, this 5-conductor harness connects a 5-conductor plug to a 5-conductor socket.  What I did not notice is that on the power board side, the 5-conductor harness connects a 5-conductor plug to a 6-conductor socket.  When I had first plugged it back in after replacing the capacitors, I simply lined the plug up with the bottom of the socket and pressed in. From that angle, it appeared to fully populate the socket, though in fact the top pin was unconnected.  When I noticed this, I switched the position of that plug so that the bottom pin was unconnected, and viola! the monitor works like it should - shutting off the backlight when appropriate.  Thankfully the plug and socket were designed in such a way that connecting it wrong didn't burn anything out.
In Red: the correct orientation of the backlight plug, with the plug aligned to the top of the socket so that the bottom pin is unconnected.  In Yellow: the location of the four capacitors which had gone bad.

Of all the lazy engineering, this one really took the cake.  It's not the first time I've seen a wire harness with fewer conductors than the socket, but normally the plug will still match the socket to prevent exactly this sort of thing - the unused pin just won't be connected to anything.

Monday, July 30, 2018

NES Dejitter

When choosing my "modern" TV, I did a lot of research and comparison and wound up with the very excellent KDL-70R550A which has so far supported everything I have thrown at it.  Every console via the OSSC just works, every scaling mode, every oddball resolution, every janky sync signal, everything.

A few weeks ago, I installed an NESRGB on an NES for a friend.  He was using an OSSC to scale it to his PC monitor and a Panasonic Plasma, but could never get better than 2x.  He wasn't terribly concerned as those were stopgaps until his "real" gaming TV arrived.  Unfortunately the TV he bought couldn't tolerate the NES's irregular sync signal.  Fiddling with OSSC settings made it possible to display in 5x mode, but it would randomly lose sync.


Some Background

Others have analyzed and explained it far better than I, but the gist of the problem my friend was having was because of a design flaw in the original NES/SNES video output.  CRT televisions were considerably more forgiving of this flaw than most modern displays.  

This thread at shmups goes into great detail:
https://shmups.system11.org/viewtopic.php?f=6&t=61285

The gist of it is that the NES and SNES have irregularities in the sync pulse that tells the display where to draw lines from the incoming video.  CRTs displayed video in real time, whereas modern displays want to see a whole frame completed before sending it to the screen.  

The Easy Road...

It is, perhaps, fortuitous that marqs of the shmups forum had just recently completed hardware development of a "dejitter" mod designed to straighten out the irregular sync signal.  The hardware design has been available in a DIY fashion for some time via github (https://github.com/marqs85/snes_dejitter) but after reading through the programming instructions, I had no desire to fuss with building the board myself. 

Fortunately BuckoA51 (of the shmups forum) decided to start selling pre-assembled and programmed dejitter boards via videogameperfection.com.  I ordered one and told my friend to ship the NES back to me.

...Sometimes Crumbles Beneath You

About two days after placing my order, someone found a problem in the NES installations which required a firmware fix.  Though to his credit marqs identified and fixed the problem almost immediately, my big plan to avoid going through some complicated steps to reprogram the dejitter board was now a complete failure.


Step 1: You're Basically On Your Own

Reprogramming the dejitter chip represented a challenge for a couple of reasons.  Firstly, the interface socket, appears to be completely custom.  Secondly, it can apparently only be accomplished with an application called "OpenOCD" which is about a 2/10 in user friendliness and a 1/10 in intuitive design.

The first thing you'll notice about the instructions for programming is that there is no "get this specific programmer, get this software, enter these commands" instruction.  Most of it seems to assume that you have some existing knowledge and capability with CPLD programming.  In fact when asked this question, the OpenOCD developers replied with a statement to the effect that they purposefully avoid telling people which programmer to buy because the software is supposed to be universal.

The Real Step 1: Getting OpenOCD to play with USB Blaster Clones

As I mentioned earlier, the socket on the dejitter board is, as far as I can tell, proprietary, however the signals are standard.  I needed to create an adapter to go from the USB jtag header to the 6-pin socket on the dejitter board.  Fortunately the pins are all labeled so all that was needed was to look up a reference to the USB Blaster pins and match them.

I'm not completely new to programming CPLDs, though my knowledge is about as deep as a single sheet of paper.  (The original forum thread, posted above, has an excellent write up by the user NoAffinity with instructions for performing updates to the CPLD via a Raspberry Pi, and after going a different route myself, I believe that may be a better way to go if you have a Pi laying around)

About 9 or 10 years ago, I bought a "USB Blaster" to perform software updates on my v1 Everdrive64.  At the time I had no idea it was a cheap clone and not a real "USB Blaster".  It always just worked for me.

My "clone" USB Blaster

After looking at "official" USB Blaster prices, yeah, there's no way mine isn't a cheap clone. I paid more than $10, but not $300.  Evidently, for about 99% of what you'd want to do with it, it functions just like the real thing, but when it comes to OpenOCD - the supposedly "universal" software, the clone fails one of the basic startup checks.


OpenOCD will error out when it can't get latency timing because that's not a feature with USB Blaster clones, I wound up messing with the OpenOCD source code to "patch" out the check.


The steps I detail below are specific to Fedora Linux, but if you're using a different distro, or Windows, the modification of the source file "ublast_access_ftdi.c" should still work, you'd just go about compiling and installing it differently.


Download and install the Source RPM for OpenOCD 0.10.0 for your distro.
This puts the source tarball at ~/rpmbuild/SOURCES/openocd-0.10.0.tar.bz2

Unpack it:
Code:
cd ~/rpmbuild/SOURCES/
tar -xf openocd-0.10.0.tar.bz2


With the source tarball extracted, edit the source file that controls the latency timer check:

Code:
vim ~/rpmbuild/SOURCES/openocd-0.10.0/src/jtag/drivers/usb_blaster/ublast_access_ftdi.c


Comment out lines 105-109 and save the file:

Code:
105 /* if (ftdi_get_latency_timer(ftdic, &latency_timer) < 0)
106       LOG_ERROR("unable to get latency timer");
107    else
108       LOG_DEBUG("current latency timer: %u", latency_timer);
109 */


Then while still in the directory "~/rpmbuild/SOURCES", rename the old tarball and replace it with the edited source:

Code:
mv openocd-0.10.0.tar.bz2 openocd-0.10.0.tar.bz2.old
tar -cf openocd-0.10.0.tar openocd-0.10.0
bzip2 openocd-0.10.0.tar


With that done build the RPM

Code:
cd ~/rpmbuild/SPECS
rpmbuild -bb openocd.spec


Of course this requires that you have "rpm-build" installed, and will probably bug you for a bunch of dependencies.

When successful rpmbuild should give you the location of the RPM

Code:
Wrote: /home/user/rpmbuild/RPMS/x86_64/openocd-0.10.0-2.fc26.x86_64.rpm
Wrote: /home/user/rpmbuild/RPMS/x86_64/openocd-debuginfo-0.10.0-2.fc26.x86_64.rpm


From there just install the newly-created RPM and it will no longer check for a latency timer on USB Blaster clones. 



Step 2: Voltage Matters


With OpenOCD no longer failing because of that latency timer check, I was able to move on to the next problem.  OpenOCD was happy to use the USB Blaster, but it couldn't see the CPLD on the dejitter board.

The USB Blaster does not provide voltage to the chip it's programming - the chip actually has to be energized by some other means for the programmer to update it.  The expectation is that you'll have it installed on the NES and the NES turned on when you try to update it.  In my case since the NES was still in the mail on it's way to me, I simply wired an external 5v power source to the chip. The dejitter chip was built with the expectation that the programmer one might use to update it will only tolerate 3.3 volts rather than the 5V that the NES is going to be pumping into the circuit.  For this it has a resistor (R4) on the voltage pin.  After a forum conversation with marqs, I decided to short this pin because my USB Blaster is rated for 5v.


After doing this I was able to actually see the CPLD correctly in the OpenOCD interface, however it would still fail to program.

Finally I switched to a higher-current 5V power supply. The one I was initially using was rated at 700mA - and it may not have even been that high. I switched to a 2400mA supply and the OpenOCD was able to program the chip on the first try.


Step 3: Write The Instructions



Since the dejitter board was primarily designed as a SNES/Super Famicom fix and just happened to work for the NES/Famicom, most of the original instructions did not describe how to install the chip in anything else.

The Wiki at https://www.retromodwiki.com/wiki/NES_dejitter_mod did not originally have instructions for the front-loading NES (NES-001) until I provided them.  I was able to figure it out thanks to the general guidance at the beginning of that page, and the NES-001 schematic available at the excellent console5.com wiki.

The basic idea is to take the original crystal oscillator used for video processing out of circuit, and replace it with the oscillator circuit on the dejitter board.  Then the video sync signal is intercepted and cleaned by the dejitter board.  Figuring out what to do was a matter of mapping the clock circuit out with a continuity tester and comparing that to the schematic.

To prep the NES-001 for the dejitter mod, you need to remove the X1 crystal oscillator, and the C44 and C45 capacitors.  To make sure the mod board will fit, you'll also want to bend the three capacitors circled in yellow flat against the board.

Next you'll want to solder a wire between the outer vias of C44 and C45.  This connects the PPU and CPU "CLK" pins together.  Later on you'll connect the clock on the dejitter board to the CLK pin on the PPU so this will give both components a timing reference.


I recommend attaching the dejitter mod to the NES RGB like this, as it will ensure that you have access to the update socket if needed, and it lines up with the valley between the CPU and the PPU socket.

The rest of the instructions for wiring the dejitter mod to the nesrgb are available at https://www.retromodwiki.com/wiki/NES_dejitter_mod.


After installing the dejitter mod, I've tested the NES on every TV in my house and it's rock solid.