Introduction: Alternately Occluding Dichoptic Modifier of Stereoscopic Transmission 32 [STM32F103C8T6+STMAV340 VGA Superimposer]

About: I like designing useful devices. Also, I’m a vegan.

For some time I’ve been working on a successor to to the original AODMoST. New device uses faster and better 32-bit microcontroller and faster analog video switch. It allows to AODMoST 32 to work with higher resolutions and implement new functionalities. Device can now also be powered by USB’s 5V voltage.

Biggest new feature is implementation of simple patterned image mask for one eye and inverse patterned mask for the other one, similar to the one presented in this article: Dichoptic movie viewing treats childhood amblyopia. There are also more customization options for the shape, position and constant randomization of those parameters.

I should point out that I haven’t implemented all the ideas I had, and the firmware can be further developed. But I anticipate that due to socioeconomic issues I won’t be able to work on this project in the foreseeable future, so I am publishing it as it is. Firmware can now work with 3D content in Top – Bottom and Side by Side formats and was tested with Nvidia GPU equipped PC and Xbox 360.

2020-11-26 UPDATE: I finally managed to create MODE 3: FREE FLOATING OBJECTS. It is

included in version 1.00 of firmware. This new software features also few small adjustments, for example now all modes have separate Shape, Mask and Randomization settings which are saved when device is powered down. I am going to keep older files (from version 0.50 of firmware, when there is no version info in the filename, it means that this is this old firmware) in case 1.00 version is somehow faulty.

You can download source code, schematic, PCB, user manual, etc. for this project here:

aodmost_32_all_files_1.00.zip, mirror, SHA256: 995be9788ef92e089bb315575eba334afa45484a7193908273173f11346c882b

aodmost_32_all_files.zip, mirror, SHA256: f75f7d1db8237718cf2fe0a9de7672a320ffe77ec55d3420a17cd82f33f32f75

Supplies

Parts and materials:

  • STM32F103C8T6 microcontroller (LQFP-48)
  • 74AC00 quad NAND gate (SOIC-14, 3.9mm narrow)
  • STMAV340 analog video switch (TSSOP-16)
  • LM1117-3.3 voltage regulator (TO-263)
  • 3x BC817 transistor (SOT-23)
  • 3x white 3mm LED
  • 2x diffused yellow 3mm LED
  • diffused red 3mm LED
  • 2x diffused blue 3mm LED
  • diffused green 3mm LED
  • 8 MHz crystal (HC49-4H)
  • micro USB type B female connector (note that there are many types of them, and some might not be compatible with the holes in the PCB design, you can skip USB altogether, as USB is used only as 5V power supply)
  • 2x D-SUB 15 pin right angle female VGA connector (note that there are many types, and you need longer version with pins that will mach holes in the PCB)
  • 2 pin 2.54mm straight male pin header
  • 3 pin 2.54mm straight male pin header
  • 11x 6x6mm tactile switch buttons SMD/SMT
  • 2x 10 uF 16V Case A 1206 tantalum capacitor
  • 10x 100 nF 0805 capacitor
  • 2x 15 pF 1206 capacitor
  • 3x 1k ohm trimpot 6mm
  • 3x 10k 1206 resistor
  • 4x 4k7 1206 resistor
  • 3x 2k7 1206 resistor
  • 2x 1k 1206 resistor
  • 3x 470 ohm 1206 resistor
  • 3x 75 ohm 1206 resistor
  • 3x 10 ohm 1206 resistor
  • double sided copper clad board (79.375x96.901mm at least)
  • few pieces of copper wire (especially something with small diameter like 0.07mm might come in handy if are going to repair broken track next to leads of LQFP microcontroller)

Tools:

  • diagonal cutter
  • pliers
  • flat-bladed screwdriver
  • tweezers
  • utility knife
  • file
  • center punch
  • hammer
  • small needle
  • 1000 grit dry/wet sandpaper
  • paper towels
  • saw or other tool that can cut PCB
  • 4x 0.8mm drill bit
  • 1mm drill bit
  • 3mm drill bit
  • drill pres or rotary tool
  • sodium persulfate
  • plastic container and plastic tool that can be used to take PCB out of etching solution
  • brown packing tape
  • insulating tape
  • multimeter
  • soldering station
  • conical fine-point soldering tip
  • chisel soldering tip
  • solder
  • soldering flux (I used RMA class, flux gel intended for SMT assembly and repairs, that came in 1.4 cm^3 syringe)
  • desoldering wire
  • laser printer
  • glossy paper
  • clothes iron
  • cream cleaner
  • acetone
  • rubbing alcohol
  • permanent maker
  • ST-LINK/V2 (or clone of it) + cables that can connect it to AODMoST 32 + software that can make use of the programmer

Step 1: Disclaimer

Usage of such a device may cause epileptic seizures or other adverse effects in small portion of device’s users. Construction of such a device requires use of moderately dangerous tools and may cause harm or damage to property. You build and use described device at your own risk.

Step 2: Making PCB Using Toner Transfer Method

You need to print mirror image of F.Cu (front side) and normal image of B.Cu (back side) on glossy paper using laser printer (without any toner saving settings on). External dimensions of printed images should be 79.375x96.901mm (or as close as you can get).
Cut PCB to the size of printed image, you can add few mm to each side of PCB if you like. I personally like to do it by making a deep row along the whole length of a laminate with a utility knife (you need to cut along the whole length a few times), then repeating the process from the other side. When the rows are deep enough, whole laminate breaks in half easily. You need to perform the process of breaking laminate two times, because you need to have right length and width of the resulting piece. Smaller pieces of laminate can be broken of with the use of pliers (make sure not to scratch copper too much, use protective layer of paper for example between pliers and the PCB). Now you should smooth the edges of the resulting board piece with the file.

Next, you will need to clean copper layers using wetted fine sandpaper, then remove particles left by sandpaper with cream cleaner (you can also use washing up liquid or soap). Then clean it with rubbing alcohol. After that you should be very careful not to touch copper with your fingers.

Now its time to cut sheet with mirror image of F.Cu to a more manageable size (leave few cm around the external rectangle) and to put it on top of the clothes iron (toner up). You can hold iron between you thighs, but be very careful that a soleplate is constantly up and does not touch anything. Then, place PCB on top of glossy paper (cleaned side faces toner) and turn iron on (use full power). After short while paper should stick to PCB. You can use piece of cloth or a towel to push the board against the paper and move paper sticking to PCB a little. Wait at least few minutes, until paper will change color to yellow. Unfortunately, you need to determine right time to stop transfer process experimentally, so in case image on the copper has very bad quality, you will need to clean toner with acetone, sand and wash board again and start the whole process from the beginning.

When you think toner transfer is completed, put PCB with paper to water (you can add cream cleaner or washing up liquid) for 20 minutes. Next, rub paper from PCB. If there are places where toner didn’t stick to copper, use permanent marker to replace the toner.

Now you need to mark the centers of four empty spaces in the corners of PCB with a punch. Later those centers will be drilled, and the resulting holes used to align both sides of PCB.

Next, you need to cover back side of laminate with brown packing tape. Mix fresh water with sodium persulfate and put PCB in the etching solution. Try to keep solution at 40°C. You may put plastic container on top of radiator or other heat source. From time to time mix solution in the container. Wait for uncovered copper to completely dissolve. When it is done remove PCB from the solution and rinse it in water. Peel packing tape. Remove toner with acetone (nail polish remover should contain fair amount of it). At this point you may start removing any short circuits with utility knife.

Now, drill four aligning holes using 0.8mm drill. Then, drill corresponding holes through the paper with the image of B.Cu using the same 0.8mm drill. When this is done, sand and clean back of PCB. Then put the board on top of flat surface (cleaned copper on top), cover it with glossy paper holding image of B.Cu (toner down) and put four 0.8mm drills into the holes (round part down), to keep paper and the laminate aligned. Now you should gently touch the paper with the tip of hot clothes iron for a short while, so that paper and the PCB stick to each other. Then, remove drills, place iron between your thighs and place paper with the laminate on top of the iron and repeat the procedure of transferring toner. Later soak paper in water in order to remove it and replace any missing toner with permanent marker.

Now you need to cover front side of PCB with packing tape, as well as back around already drilled holes. Then etch back side the same way as you did front side, peel tape, remove the toner, and start hunting for short circuits.

You also need to drill rest of the holes in the PCB. There are four 3mm holes for the VGA connectors mounting. 1 mm holes are used for the rest of the VGA holes, trimpots, pin headers and vias next to micro USB (if you are not going to use USB, you can solder other 5V power connector/cables here). All other holes can be made using 0.8mm drill.

Step 3: Soldering Electronic Components

You may start by covering all copper with solder (use chisel tip and perform the operation on surface already covered in flux). If after this operation excessive amount of solder is present at some points, remove it with desoldering wire. If any tracks were dissolved in etching solution, replace them with thin wires.

Then you may start soldering other components, although I recommencement that you will wait with high and bulky stuff around the place for MCU until the end. Use decent amount of flux when making electrical connections.

MCU in LQFP-48 package is the hardest thing to solder. Start by aligning it, soldering just one lead near vertex of the package, and then another lead on the opposite side, in order to secure MCU in its position. Next, cover rows of leads in flux and gently solder them to the copper tracks with chisel tip. Make sure that you do not bend leads backwards, if you do, you may try to slide needle below rows of leads and to push the pins out. Or if you are really afraid of it, place the needle there even before you start soldering. Control that no short circuits are made and electrical connections are conducting, simple multimeter with continuity tester should be adequate (it could possibly destroy integrated circuit, but mine survived testing). If you made any short circuit, place desoldering wire on top of it and start heating. If copper tracks on PCB were damaged, use very thin wire to replace it. It is possible to solder wire directly to the leads of LQFP with conical fine-point tip. I did it few times, mostly because I damaged tracks when desoldering MCU that was beyond any hope after first attempt to solder it (it can be done by prying pins with needle). I sincerely hope that you will get it right the first time.

Other ICs are similar and should be soldered in the same manner, but they have smaller amount of bigger leads, so they shouldn’t pose much challenge. LM1117 has large tab that should be soldered to the copper, but it is hard to heat it adequately with regular soldering iron, so if you make it stick to the PCB and cover the sides with some amount of solder, it should be enough.

Some THT components need to be soldered from both sides of the board. In case of trimpots and LEDs, it is pretty straight forward. When soldering pin headers, slide plastic higher up than it should be before this operation, then solder all the pins from the both sides, and then slide plastic back to the original position. When soldering quartz crystal, at first position it higher up than necessary, solder the leads from both sides, and then while heating them from bellow, push crystal lower. Note that I also wrapped crystal case in wire and then soldered wire to the ground (the large copper fill to the left and bellow the crystal). Before soldering parts of VGA connector that go into 3 mm holes, I soldered some wires to the copper on both sides to make sure that both layers of copper are connected, and only then I soldered shielding leads. Vias can be made by placing larger wire inside the hole (for example unused length of THT component lead), soldering it from both sides of PCB, and then cutting unnecessary part.

When soldering USB connector you may use conical fine-point tip for the small leads.

When you think you soldered everything you should check once again that there are no short circuits or bad connections.

Step 4: Programming STM32 Microcontroller

To develop AODMoST 32 firmware I used System Workbench for STM32 (Linux Version), which uses OpenOCD to program microcontroler. You can find detailed instructions on how to import this project into SW4STM32 inside sw4stm32_configuration_1.00.pdf file.

Alternatively you can use ST-LINK Utility (STSW-LINK004). I tested Windows version and it worked well with aodmost_32_1.00.bin

I used cheap clone of ST-LINK/V2 as my programmer, which isn’t ideal, but it worked. To program MCU I needed to power AODMoST 32 from USB port and connect 3 jumper cables with 2.54mm female connectors to the programmer on one side and SW-DP port of AODMoST 32 on the other. You need to connect GND, SWCLK and SWDIO. When programming, make sure that software is set to perform software system reset.

aodmost_32_1.00.bin and aodmost_32_1.00.elf files needed to program MCU are inside aodmost_32_all_files_1.00.zip archive.

Flash memory of MCU should be empty before programming, otherwise some old data left in the last 4 kB of it could interfere with saving and loading of settings.

Step 5: Use of AODMoST 32

Now you can connect your graphics card or video game console to the VGA IN, connect your 3D display to VGA OUT and 5V power supply into micro USB. When AODMoST 32 is powered, it waits for the video signal (and detection of sync pulses polarization). It is signalized by red NO SIGNAL LED being lit up. Also blue LEDs should be constantly turned on. If they are blinking, it means that something is wrong with 8MHz HSE crystal. During this time you may push buttons, to check if they are connected properly. If at least one button is being pressed, yellow LEDs are on. When two or more buttons are being pressed, white LEDs are lit as well. When video signal is detected, start-up sequence commences. It consist of every second LED in a row being lit up (0b10101010) for 300ms, then four other LEDs are turned on for 300ms (0b01010101). Its done, so that you may check that LEDs are connected properly to the MCU.

Device has 4 working modes of operation. By default it starts in MODE 0: VIDEO PASS-THROUGH. There is also MODE 1: TOP – BOTTOM, MODE 2: SIDE BY SIDE and MODE 3: FREE FLOATING OBJECTS. There are 6 pages of settings. Those with numbers 0 and 3 contain settings of frequency/period, occlusion rate, objects being on/off and such. Pages 1 and 4 contain position settings while pages 2 and 5 contain size settings. By pressing MODE + PAGE buttons you restore default settings in all modes. There are also options for changing object shapes, introducing mask pattern and randomizing some of the settings. You can read more about configuring AODMoST 32 in manual_1.00.pdf

One possible source of 3D content in Top – Bottom or Side By Side format are computer games. If you use GeForce video card, many games from this list can be modified to output in compatible format. Basically, you need to use 3DMigoto based mods/fixes (DX11), that allow you to output SBS/TB 3D to any display after uncommenting “run = CustomShader3DVision2SBS” in “d3dx.ini” mod/fix configuration file. To have a good picture quality, you also have to disable 3D Vision Discover tint in NVIDIA drivers. You need to change “StereoAnaglyphType” to “0” in “HKLM\SOFTWARE\WOW6432Node\NVIDIA Corporation\Global\Stereo3D\”. You can read more about this here.

In new versions of Nvidia drivers, you have to lock the registry key after 3D is set up, in order to be able to remove the tint. To open Registry Editor, press WIN+R, then type "regedit" and press ENTER. Locking a key will require you to right click on it, select Permissions, Advanced, Disable inheritance, confirming disabling of inheritance, going back to Permissions window, and finally unticking Allow boxes in the Full Control row (ticking some Deny boxes may possibly be required) for all users and groups, and confirming it with a click on OK button. Note that there might be a need to change values of "LeftAnaglyphFilter" "RightAnaglyphFilter" as well. If you want to make any changes, you need to unlock registry key by enabling inheritance or restoring Allow/Deny boxes to their original state boxes. If you are having problems with enabling 3D Vision in the first place, because setup wizard in NVIDIA Control Panel is crashing, you need to change “StereoVisionConfirmed” to “1” in “HKLM\SOFTWARE\WOW6432Node\NVIDIA Corporation\Global\Stereo3D\”. This will enable 3D Vision in Discover mode. Unfortunately, Nvidia stopped supporting 3D Vision, so newest driver version that can be used is 425.31, but if you really want to use newer version you may try this.

There are other ways to get 3D games. You can try SuperDepth3D, a ReShade post-process shader. GZ3Doom (ViveDoom) natively supports 3D and can be played without any special software. Windows versions of Rise of the Tomb Raider and Shadow of the Tomb Raider have native support for Side by Side 3D.

Alternatively you may also use Xbox 360, which supports VGA output and has a few games that support 3D in Top – Botom or Side by Side. Here you can find a list of Xbox 360 games that support 3D (although there are some mistakes in this list, for example a copy of Halo: Combat Evolved Anniversary that I tested does not support Top-Bottom, neither SBS).

Of course you can also find movies in Top – Bottom or Side By Side format and play them on wide variety of hardware.

In the gallery you can find following games:

  • James Cameron's Avatar: The Game, SBS, Xbox 360
  • Gears of War 3, SBS, Xbox 360
  • The Witcher 3: Wild Hunt, TB, PC
  • Rise of the Tomb Raider, SBS (device is set to MODE 3: FREE FLOATING OBJECTS), PC

Step 6: Design Overview

VGA signal has 3 component colors: Red, Green and Blue. Each of them is send through separate wire, with intensity of component color coded into voltage level that can vary between 0V and 0.7V . AODMoST 32 draws objects (overlay) by replacing color signal generated by video card with voltage level provided by transistors Q1-Q3 in emitter follower configuration, that convert impedance of voltage on a 2k7 resistor – 1k trimpot voltage divider. Switching of signals is done by STMAV340 analog multiplexer/demultiplexer.

Timing of this switching is kept by advanced-control timer (TIM1) of MCU, which uses all four of its Compare Registers to drive the outputs. State of those outputs is then processed by 3 fast NAND gates. It work like this: HSync pulse reset timers Counter. Compare 1 Register controls when to start drawing first object in a line, Compare 2 Register when to stop it. Compare 3 Register controls when to start drawing second object in a line, Compare 4 Register when to stop it. When third object is needed, Compare Registers 1 and 2 are used again. NAND gates are connected in such a way that they send signal to the multiplexer that replaces original video, when pair of Compare channels tells it that object drawing has started, but is not finished yet.

Horizontal and vertical synchronization pulses vary in voltage level between 0V and 5V and wires that carry them are directly connected to STM32F103C8T6 5V tolerant interrupt pins configured as high impedance inputs.

Device consumes approximately 75 mA.