As promised in my previous post, here’s more information on the JY-MCU 3208 Lattice Clock board. If you’re missing anything, or would like me to clarify or check something, please do feel free to leave a comment 🙂
The schematic can be hard to find. Most people seem to link to a host at ljy99731.13.dns222.net, however each and every time I’ve tried those links they come back with a weird chinese error. If anyone knows how to visit that host, or where it has moved to, please let me know. In the mean time, I’ve taken the liberty of setting up a mirror for this specific one, which can be found here: jy-mcu_3208_schematic. Seeing as most of the comments are chinese, and it can be a bit difficult to understand, I’ll try to explain what I understood so far.
All blue boxes appear to be optional components. The top-most box is the Real-time clock schematic, of which you can pick one (left is using two RX8025 chips, right is using the Maxim DS1302). The box right next to the ATMega8 is a mystery to me, if you know what it’s for, do let me know. The rest from top to bottom is a 18B20 digital thermometer chip circuit, an LED or light-sensing circuit, a speaker circuit, a USB connectivity circuit, and an IR receiving circuit.
The bottom four ICs are basically the LED-matrices. Notice how there are 8 pins not-connected on each, I believe those belong to the green LEDs that I’ve heard are in there too. Left IC is the HT1632C, basically the chip that drives the LED arrays. In the middle is the ATMega8. On the schematic it states it’s a Mega8, however my board came with an ATMega8L. The differences aren’t that big, but the ATMega8L isn’t rated for anything above 8MHz, and is rated for a lower voltage.
I was unable to find a datasheet for the board itself, and I don’t think there is any. However, here’s a list of datasheets I could find for the components (both optional and included chips):
- Atmel ATmega8L (main MCU) information datasheet
- Holtek HT1632C (LED-array driver) information datasheet
- Maxim DS1302 (RTC chip) information datasheet
- Epson RX-8025 (RTC chip)
- LD-1588BS (LED-array)
Adding USB Connectivity
For USB connectivity, you basically need a USB jack, zener diodes to drop the voltage on the USB data-lines, resistors on the data-lines, a pull-up resistor for the D- line, and the ATmega8 clocked at at least 12MHz.
The JY-MCU schematic for the board states 1.5 KOhm for the pull-up resistor, 180 Ohm for the data-line resistors, and 3.3v zener diodes. However, the V-USB hardware considerations (Solution B) seem to indicate 1.5 KOhm for the pull-up, 68 Ohm for the data-lines, and 3.6v zener diodes. I opted to go with the V-USB design, although I believe the JY-MCU design might work too.
Apart from the USB components there’s also the task of clocking the ATmega8 at something that V-USB or another USB library can handle. It appears the ATmega8 I got is perfectly capable of reaching 12MHz by calibrating the internal oscillator (you can use the existing 32768Hz crystal as a reference), however I was unable to get it stable whilst driving the LED-array (Voltage seems to fluctuate too much). In the end I figured it’d be easier to just replace the crystal and stick in two capacitors.
As for footprints:
- the resistors (both pull-up and data-lines) seem to be 0805. I, however, misordered 0603, which seemed to fit too (although a bit trickier)
- the USB jack appears to be the following Mini-USB connector footprint. Be sure to order a jack with a similar footprint.
- The zener diodes are SOD-323 footprints
- The crystal should be in a cylinder footprint (any other through hole would probably work too)
- the crystal capacitors should be 0805 too, but again 0603 might work too.
My final parts list (some linked to farnell, where I ordered them) was as follows:
- Mini-USB Jack, I ordered this one
- Pull-up resistor: 0805 1.5 KOhm 1% 125mW (any brand will work)
- 2 Data-line resistors (2x!): 0805 68 Ohm or 180 Ohm (see above) 1% 125mW
- Zener diodes: SOD-323 3.6V or 3.3V, 300mW or lower. I ordered these ones.
- Crystal: 12MHz, Cylinder. ATmega8 datasheet recommends 12 to 22pF capacitance. I ordered this one.
- Crystal capacitors: 0805, match these to your crystal.
As for placement, with the board upside down (LEDs down) and the text upright, the USB jack will be at the far left. just right of the jack are the resistors. two data-line resistors in the middle, zeners above and below those (cathode, in my case the gray stripe, towards the USB-jack), then the 1.5K pull-up just above the zener diode. The crystal is located just below the ATmega8 (replace the one that is already there), and the capacitors are just right of it’s pins.
Finally, for the code I recommend V-USB. And don’t forget to set the fuses correctly!
Adding a DS1302 RTC chip
To add the DS1302 RTC chip, you need the DS1302 chip itself, a decoupling capacitor, three 10 KOhm resistors on the data lines, a 32768 crystal, and if you want it to remember the time during a power-loss, a battery and possibly a battery holder.
The schematic indicates a CR927 battery or battery holder, but I was unable to get that anywhere. Instead, I ordered a few batteries with pins that I could bend into the contacts. The DS1302 allows for rechargable batteries, but seeing as I had no experience with those, opted to use a normal one instead. This is the one I settled with which fits perfectly if you mask off the sides with a bit of electrical tape and twist the contacts a bit.
The decoupling capacitor is marked as 104 on the schematic, which refers to a value of 100nF or 0.1uF (See this chart for more info), so use that or anything higher in a 0805 package.
The footprints are generally the same as what I just described in the USB section. The DS1302 chip is the normal SOIC version
The parts list will look like this:
- Chip itself, I used the DS1302Z+ one which was rated at up to 70C celsius and was a tad cheaper than the other options. Be sure to pick the SOIC version!
- Decoupling capacitor: 0805 100nF or 0.1uF.
- Crystal, 32.768Khz (or 32768Hz) in cylinder package. (Although you could also re-use the one that was attached to the ATmega8 if you’re a cheapskate)
- 3 Data-line resistors (3x!): 0805 10 KOhm 125mW, any brand will work
- Battery, CR927 or find a 3v one that’ll fit, and check that it’ll last you long enough (the DS1302 will use about 300nA from it)
- Optionally a battery holder (CR927)
If you hold the board LEDs down, printed text upright, the big white circle is the battery or battery holder. + and – are clearly marked. Right of the battery is the DS1302 chip, with it’s decoupling capacitor to the bottom-right, and the crystal on the right. The three data-line resistors are on the far-right end of the board, just above the 8th and 9th pin (from the left) of the bottom pins of the right-most LED-array.
As for coding, I’d recommend just reading the datasheet.
Adding other components
I myself have only added the DS1302 and USB-connectivity, however as stated before, there are more possibilities with this board. When finding out what components you need to add in some of the optional parts, here are a few hints:
- All resistors seem to be of the 0805 type. Personally I’ve also had luck with 0603 components, but they’re a bit tricky to solder on properly.
- All (zener-)diodes seem to be using the SOD-323 package.
- Both crystals seem to be using the “cylinder” package. (At least that’s what they called it at Farnell)
- If you’re not sure where a component should be placed, get out your multimeter and measure the traces.
Apart from the parts that were added by the board designer, some people have also added other components:
- Rick S. added an LM34 temperature IC instead of the DS18B20, described at http://rs-micro.com/?p=185.
- Rick S. swapped out the ATmega8L for an ATmega328P-AU, described at http://rs-micro.com/?p=171.
- github’s damien-hackadl has a crazily complicated scriptable scroller.
- DX.com’s DrJones has source for a simple clock.
- rs-micro.com’s Rick S. has source for a more advanced clock and temperature display (video). (Link at the bottom, note that this code will not fit the stock ATmega8)
- DX.com’s athlon256 has a nice clock and temperature display (video).
If, like me, you at some point set the fuses wrong. e.g. set it to a crystal while it has none, or set it to use an oscillator when you meant a crystal, use this guide: Recovering from a “locked out” AVR. It helped me get the board responding again by using my Arduino as a clock generator. It didn’t actually seem to run, but with the Arduino wired up and generating pulses it did start responding the the programmer again, allowing me to fix the fuse 🙂
9-7-2012: odokemono on reddit.com alerted me to the fact that the “104” for the capacitor on the DS1302 circuit is a code instead of a value. the 104 capacitor code refers to a value of 100 nanofahrad or 0.1 microfahrad. The value I chose (1pF) was about 10000 times too small. Article was updated to reflect this.