SyncFix64 v1.1

Following the first prototype of the LM1881 based SyncFix64 I made a few minor changes, improving the schematics and layout. Then I was ready to order the first batch of properly manufactured PCBs. The boards took a little over two weeks for production and shipping.

This was also my first try at ordering a v-cut PCB panel and I’m quite satisfied with the result considering the resulting low price per unit. I assembled one of the boards tonight and the device is working properly. So I assume the whole batch should be fine.

The project files for the updated version 1.1 of the SyncFix64 are available on Github and here is the list of required components:

C1,C2,C3 0805 100n
Q1,Q2 SOT-23 BSS138
R1 0805 100r
R2 0805 680k
R3 0805 10k
U1 SOIC-8 LM1881
U2 SOT-223-3 AMS1117-50
C4,C5 1206 22µF

Update: There are German assembly instructions available for download now.

 

 

Fixing WifiModem64 Version 1.0

As hinted at earlier, I made a couple of mistakes when designing version 1.0 of the WifiModem64 and they will be fixed in version 1.1.

Still, with some minor manual modifications, those first boards are still usable. In short, RTS must be connected to WeMos D7 instead of D8 for the ESP8266 to boot reliably and the WS2812 LED must be connected to WeMos D5 instead of D0 if you intend to use it.

These are the step-by-step instructions to get WifiModem64 V1.0 on line:

1. Re-route RTS

Take a sharp knife, small screw driver or some other suitable tool and carefully cut the old trace to WeMos D8, which is marked (1) in the image below. Use a multimeter to make sure there is no more connection between R6 and WeMos D8. Solder an insulated piece of jumper wire between R6 and WeMos D7.

2. Re-route RGB LED

Take your tool of choice from step 1 and carefully cut the old trace to WeMos D0, which is marked (2) in the image above. Use a multimeter to make sure there is no more connection between DATA_IN of the WS2812 and WeMos D0. Solder an insulated piece of jumper wire between DATA_IN and WeMos D5.

3. Power Safety

Either fit components D1 and F1 on the top side of the PCB (diode and fuse), or close solder bridge JP1 on the bottom side.

4. Power Source

Fit either a 3 pin male header to JP6 and use a jumper to select between internal and external power supply or use a matching toggle switch instead.

5. Level Shifter

Depending on whether you believe that the ESP8266 needs level shifters on the data lines (I actually don’t), either fit the components R1-R8 and Q1-Q4 to the bottom side of the PCB, or close the solder bridges JP2-JP5.

6. WeMos Headers

Solder 8 pin female headers to the top side of the PCB to hold the WeMos module(s).

7. User Port Connector

Bend the copper leads of a user port connector slightly inwards, slide the PCB in between and solder all 24 leads to their respective pads on the PCB.

8. Optional Components

Depending on whether you intend to use them, fit any of the optional components:

  • baud rate reset switch SW1
  • C64 reset switch SW2
  • micro USB connector J2 for external power
  • LED1 and C1 for the RGB status LED
  • WeMos OLED display on U2

Please note that firmware support for the RGB LED and the OLED display is still being developed!

9. Flash Firmware

Make sure the WeMos D1 mini is NOT connected to your C64 before flashing the firmware. Then there are two options. If you’d like to compile the firmware yourself:

  1. Install the Arduino IDE
  2. Install Arduino Core for ESP8266
  3. Fetch the WifiModem64 project
  4. Open, compile, and upload WifiModem64.ino

If you’d rather flash my pre-compiled binary:

  1. Download and extract the archive
  2. Follow the instructions to upload to the ESP8266

10. Initial Setup

Follow Alwyz’s instructions for the initial setup of the modem if you want to use it at 9600 baud.

Components

To save you from the need to open the actual schematics when soldering components to the board, here is the relevant part of the BOM:

D1 B5819WS (0805)
J1 C64 User Port Connector
U2 WeMos_D1_mini_OLED_Shield
R1,R2,R3,R4,R5,R6,R7,R8 10k (0805)
U1 WeMos_mini
LED1 WS2812B
C1 100n
F1 0.5A (1206)
J2 USB_B
Q1,Q2,Q3,Q4 BSS138

SyncFix64 Prototype

After the encouraging results of my first attempt to fix the composite signal from a C64, so that the cheap TFT monitor could display it, I shared the idea on Forum64 to double-check and get some feedback. Consensus seems to be that the circuit at least won’t hurt the video source. Since, in addition to that, it seems to be working for me, I decided to design a board for it in KiCAD.

The goal was to make it so small that it would fit inside the display’s case alongside the display controller, so I went for all surface mount components. To get immediate results, I created a single sided layout and etched the board myself using the toner transfer method.

Soldering the components to the finished board proved a little challenging, cramped as it was, without a solder mask layer. But it turned out fine and it fits inside the case easily. The display had two separate input lines to begin with, so now I’ve got one fixed for my old C64 and a second “regular” one to choose from.

Update: The KiCAD project including schematics and a preliminary board layout is available on Github now.

 

 

Cheap Displays for Old Hardware

A couple of months ago I dug out my old Commodore hardware again and started tinkering with it – the goal being to finally try out a bunch of mods, hacks, and builds that I missed back in the day. To start with, I bought a cheap TFT display for around 13€ to connect to the C64 and C128.

It was meant to sit on my work bench to e.g. quickly test a naked C64 board. It wouldn’t matter if the video quality wasn’t great. But after I made the necessary adapter cable and hooked everything up, I was a little disappointed to find out that the display wouldn’t show anything other than a black screen interrupted by an occasional flicker. I verified that the display itself was working by connecting it to a Raspberry Pi and I double-checked the cable I had made.

Doing a little research, I learned that the video signal produced by the C64 is actually not that great and that problems with modern displays are quite common. I got curious and used my (also very cheap) Hantek 6022 oscilloscope to take a look. The first thing that caught my eye was that the Commodore signal looked rather weak when compared to that from a RasPi.

C64 Composite Video

C64 Composite Video

Raspberry Pi Composite Video

Raspberry Pi Composite Video

So I thought if I amplified the signal, maybe I would get the TFT to display it. I did a little search on how to do this and stumbled across Raphaël Assénat’s page where he describes a problem very similar to mine. The interesting part is that his first impulse too, was to amplify the signal. But later he found out that the signal strength didn’t seem to matter much, it was the unorthodox v-sync sequence produced by the Commodore that confused his display. So he added a LM1881 sync stripper and an AVR micro controller to replace that sequence. Unfortunately, that contraption is very sparsely documented.

C64 Composite and VSync

CH1: C64 Composite, CH2: LM1881 VSync Out

Since he mentions that just “removing” the sync sequence already resulted in a somewhat stable display and that amplification might not be necessary after all, I figured I might just try to get away without the AVR and the amplifier and  I came up with this reduced circuit:

To my great delight and surprise, this yielded instant results! I hadn’t really hoped that this simple improvised circuit would be enough to make my display cooperate.

Of course, there are a few issues and to-dos left:

  1. Ask a few people who actually know this stuff for their opinion and for some advice on the actual components and their values.
  2. Make sure this does not damage the video source in any way.
  3. Revise the circuit accordingly.
  4. Make a nice board with proper wiring and real connectors.

Do you have any thoughts or advice on this? I would love to hear in the comments!

 

The Modular WifiModem64

I’ve been playing with the ESP8266 since late 2014 and it was love on first sight: so many possible uses for such a small device at such a low price tag. And very early on I thought: wouldn’t it be great to build a WiFi “modem” from this? That shouldn’t be too hard. But I didn’t find the time to pursue the idea then. When I remembered again this summer, I was not surprised but still excited to find that others had had the same idea and hadn’t been as lazy as me.

Alwyz’s instructions on how to build such a device couldn’t be easier! I followed them and it worked like a charm. For the next months, my setup then looked like variations of this:

I wanted something tidier that would still be inexpensive and stay true to the easy-to-assemble spirit of the original version. So I decided to go with the WeMos D1 Mini variant of the ESP8266 modules. It is easily available and for a price as low as $2.60. It is supported by the Arduino IDE, allowing to flash the firmware with no equipment other than a PC and a micro USB cable. This is the board I’ve come up with:

The minimal setup is quite easy:

  1. Solder the User Port connector and the female pin headers.
  2. Close a hand full of solder bridges.
  3. Program the WeMos module and plug it in.

The board offers a bunch of optional extras that aren’t strictly required but may be freely combined to upgrade the device:

  • An OLED display can be plugged into the second WeMos slot.
  • A WS2812B RGB LED can be fitted and used as an extended status indicator.
  • There are pads for a diode and fuse to protect the C64.
  • Alternatively, external power can be supplied through an optional USB connector.
  • Additional components may be fitted for level shifting between 5V and 3.3V. (Personally I don’t think they are needed and the ESP8266 can cope with the 5V. But this way the board is “one size fits all”.)
  • There are pads for a reset switch and a second one to interact with the modem.
  • Potentially, other shields like the LED Matrix could be added instead of the OLED.

Somewhat unfortunately, I made a last minute change to the board layout before I ordered, hoping to make it more compatible with other WeMos shields. I missed the fact that with this wiring a pull-down resistor is required for the ESP to boot. I patched the resistor to the bottom side of my first build but still the ESP needs a second try from time to time. So I might reconsider this in a future revision.

KiCAD and Arduino sources will follow when I find the time to do some cleaning up.

SD2IEC Revisited

When I discovered the MMC2IEC / SD2IEC project by chance back in 2009, it made me dig up again my soldering iron and electronic components after many years of disuse. I built myself one of those devices on a prototyping board and had a lot of fun doing so. It was the first time that I got involved with micro controllers and I learned a lot in the process.

Now, many years and projects later, I was looking for an excuse to try out KiCAD and to learn how to design my own boards using it. I had already ordered a small PCB I found on the net as a proof-of-concept to see if the Gerber files I produce would result in working boards. When they turned out just as expected I was eager to create something myself. This was the perfect opportunity to revisit the subject and make myself a brand new SD2IEC.

I wanted the design to be based on Shadowolf’s latest version but also make my own additions and changes:

  • The board should be able to tap into the cassette port of the C64 for power supply.
  • It should be board for external use with proper connectors just like my first build.
  • All components should be cheap to buy from Chinese suppliers.

So, this is the first prototype of what I came up with. I call it the “SD2IEC pluggable”:

On one side, it plugs into the cassette port, but all lines are traced across the board to the other side. This should allow the use of a datasette without unplugging the device. I haven’t tried it yet because I currently don’t have a datasette available. IEC and SD connectors are facing left as is the USB connector serving as an optional external power source. It is currently mini rather than micro USB because that was what I had in stock.

There are pin headers for the ISP, for connecting alternate LEDs, for I2C devices (like displays) and for optional buttons or switches. Also optionally, additional components can be fitted that should hopefully allow turning this board into a TAPuino using the right firmware. But I did not yet have time to try this either.

I just assembled the first board, flashed the latest SD2IEC firmware, and it seems to be working great! There are a few issues in version 0.9 that I’m planning to resolve in the next revision:

  • Pin 5 of the USB connector needs to be connected to GND, too.
  • Change footprint of D3 to accommodate MELF packages.
  • Maybe replace the mini USB connector with a micro USB one.
  • Add a reset button.

The KiCAD project files are available on Github in case you’d like to make your own pluggable SD2IEC. If you do, I would love to hear about it in the comments!

 

 

 

Wireless Sensor Network, Part 2

Still trying to save my batteries

By now it is time for at least an intermediate update on this project. In the meantime I have indeed revised the sensor boards by adding a switching transistor controlled through one of the remaining digital pins on the ATmega. The firmware was modified, and it will now power down the attached sensors before entering sleep mode. Disappointingly, this resulted in a battery lifetime extended by no more than roughly 10%.

On a mostly unrelated note, the voltage graph now looks “stepped” when compared to the previous one. This seemed to be a direct result of switching from maniacbug’s original driver for the RF24 module to the one newly optimized by tmrh20. I’ve got absolutely no clue why this would affect the voltage measurement against the bandgap reference, but there it was. If you can shed some light on this, please leave me a comment.

The next thing I tried, somewhat desperately, was to reduce the number of data samples by increasing the sleep time from 1 minute to 5 minutes. This had no discernible effect on battery life-time. But at least it leads to the conclusion that I need to further investigate power consumption during sleep mode.

So, just assuming that it was the sensors that were draining the batteries in sleep mode turned out to be a bad idea. Now I really need to replace my crappy 7€ multimeter with something a little more precise that will allow me to actually measure which part of the circuit is drawing which amount of current.

Wireless Sensor Network, Part 1

With all components finally having arrived from China, I built the first couple of wireless sensors a few months ago. They are using the cheap nRF24L01 transceiver modules for data transmission based on the RF24Network network layer. I’m using a Raspberry Pi with the transceiver module directly connected to its GPIO pins as the root node. The sensor nodes are controlled by an ATmega328 microcrontroller flashed with the Arduino firmware for convenience.

Each sensor node currently features a DHT11 humidity sensor, a DS18B20 digital thermometer, a BMP180 barometric pressures sensor and it’s powered by three AA cells. The controller spends most of its time in power-saving sleep mode, waking up to send a data packet about every minute. Each packet contains the readings from the three sensors as well as the battery voltage as determined against the bandgap reference.

The setup is far from final. For one, I’m still not sure how to store the data. Currently, it is just logged into a text file with an occasional and experimental import into OpenTSDB. I haven’t really come to trust OpenTSDB since I haven’t found a suitable and convincing way to backup the HBase data, yet.  Also, I might still replace the Raspberry Pi root node with an Arduino based MQTT relay.

First though, the power consumption of the sensor nodes needs improving. When I started out I was hoping for each node to run for close to a year on a single set of batteries. As you can see in the graph above, with the current design a set of three NiMH batteries with low self discharge lasts for no more than 6 weeks. What comes to mind in order to improve this, is to switch off the sensors and the transceiver in between samples. That is probably what I’ll try next. Please let me know if you’ve got any other ideas!

 

 

Seeeduino Stalker: Writing to the SD Card

After I managed to upload the first sketches to the Seeeduino Stalker last week, I was eager to try the special features offered by this special kind of Arduino platform. I decided to try writing to an SD card first and followed the example included in the Stalker’s documentation. Which turned out to not work at all.

A couple of hours later and looking for errors in all the wrong places, I finally managed to find out how to use the FileLogger library:

  1. The SD card needs to be FAT16 formatted.
  2. The file that the the Arduino is writing to must exist, the library does not create files.
  3. The file must not be empty, it must contain at least one byte of data.

If these conditions are met, the following tiny sketch will work just fine and append data to the file:

#include "FileLogger.h"

void setup(void)
{
 byte buffer[] = "Hello World!";
 FileLogger::append("data.txt", buffer, 12);
}

void loop(void) {}

Update 10/8/12: Please note that this example will work with version 1.0 of the Stalker, only. For newer versions of the board you should try sadfatlib.