Author Topic: Tiny Binary Clock  (Read 9818 times)

0 Members and 1 Guest are viewing this topic.

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 105
Tiny Binary Clock
« on: March 25, 2015, 11:09:11 pm »
Hi,

  Playing with some leftover ebony and maple veneer, I designed a thing that would be nice as a clock. It is 12.5 x 12.5 x 60mm. There is no much room for 8 segments, so it will be a binary clock. I will need to mill a cavity for the pcb inside the wood, so the pcb size is limited to 56x10.5mm.

  I spent hours and hours (and hours) trying to find a leds driver that would feet in the PCB, and failed. So in the end, I will use two Pic MCUs. One of them will have a crystal and keep track of time, the other one will only be used as a led driver (with 25mA internal clamping diodes on output pins).

  I will use two capacitive touch sensing buttons to set time : when you switch on the clock, you set each bit to either 0 of 1 using one or the other.

  There is no room for a standard ICSP connector, so I will just user 3 pads to receive pogo pins (in low level programming, only three pins are needed)

  It is the first time I make a PCB where I have to create most of the components in eagle myself, where I have to put so much things in such a small place. It's the first time also that the PCB is to hard for me to make home*, so I will have to use OSHPark or Dirty PCB.

  I make the board on Eagle and tryed to verify every connection, passed the DRU that DirtyPCB provides (I even changed the space from 5mil to 10 mil to be sure). There are still a few things that I'm not very confident with :

-Are my vias wide enough for Dirty PCB or any cheap pcb manufacturing ?
-The pics will draw 90mA (left one) and 130mA(right one). Are my GND and +5B tracks wide enough ?
-I chose this vertical micro usb connector on mouser. I made the device in eagle myself. Is my device correct ? Will it be compatible with other vertical usb connectors ? Is this connector a good choice for something that will be open source (short and long term availability, ...) ?
-I selected the tsx-3225 crystal. In addition the the same questions as for the USB connector, does this crystal require a serie resistor ? (the pic16f1508 datasheet say that some will need one.) Is it a Serie (not parallel) crystal ? I could not find the information in the datasheet.
-Do you see any of the errors I probably made ? :)

  Eagle files in the zip !

Thank you,
John.

* : 8 mil spacing, except for the micro USB B connector which required 5 mil, 0.65 pitches SSOP mcus and 0603 leds, which probably require a solder mask
« Last Edit: March 25, 2015, 11:28:53 pm by Jaunedeau »
 

Offline senso

  • Frequent Contributor
  • **
  • Posts: 953
  • Country: pt
    • My AVR tutorials
Re: Tiny Binary Clock
« Reply #1 on: March 25, 2015, 11:36:48 pm »
Grab the DRC and JOB files from SeeedStudio, or OSHPark, they are all in the same limits, OSHPark might be a bit better regarding to minimum via size, after having the files, run the DRC with the respective rules file, and then generate the gerbers using the JOB file so it is all generated according to their specifications.
 

Offline linux-works

  • Super Contributor
  • ***
  • Posts: 2069
  • Country: us
    • netstuff
Re: Tiny Binary Clock
« Reply #2 on: March 26, 2015, 01:09:58 am »
suggestion: use gps (they are $15 on ebay) and avoid having the user set time.

at most, let them enter an hour correction (for DST stuff).

you talk to the gps at 9600 TTL.   its quite simple to get nmea sentences and get time (and date) from it.

(I'm also doing a clock project and I've included gps.  I'm so glad I did, its really a nice way to go, to avoid having to set time, but also knowing that the time is always accurate!)

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 105
Re: Tiny Binary Clock
« Reply #3 on: March 26, 2015, 07:16:21 am »
Well, the PCB is 8.5x60mm, I could barely fit the crystal on it. Forget about gps...
 

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 105
Re: Tiny Binary Clock
« Reply #4 on: March 27, 2015, 01:42:52 pm »
Since both OSH Park and DirtyPCB have a minimum track width and space of 5mil, I completely remade the PCB with 8 mil tracks W/S.

Also, different track size calculators told me that for 1oz copper and 8mil tracks, 35°C ambient temperature, and 130mA current, the temperature rise would be only 0.1°C. So I decided that I could accept to have "only" 45mil width GND and +5V planes. This allowed to place the "0" and "1" button hole more freely.

Finally, I cleaned the top left part by moving the crystal 5 millimetres away from the mcu.

Now my main question is about this TSX-3225 crystal : Is it the proper type (I remember something about serie / parallel crystals, but...) ? Does is need a serial resistor ? (I could not find the needed voltage in the datasheet)

Do you see anything I could have made wrong ?

Thank you,
John.
 

Offline linux-works

  • Super Contributor
  • ***
  • Posts: 2069
  • Country: us
    • netstuff
Re: Tiny Binary Clock
« Reply #5 on: March 27, 2015, 01:55:48 pm »
Well, the PCB is 8.5x60mm, I could barely fit the crystal on it. Forget about gps...

one vendor I saw on ebay sells a gps module as a remote item.  its connected over a 3 or 4 wire cable and the unit at the end of the wire IS the gps module.  so, it does not have to be onboard. if you can give it gnd, 5v, tx and rx, you're all set. in some ways its better not to be onboard; so that its an option but does not take up board space.

you should at least prototype it before you decide; once you have used it and have it working, you may find that you like it quite a lot.

anyway, I would not make a modern clock that did not have some  kind of auto-set ability (even if its just a serial port that you connect to a linux board to get NTP time from it).

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 105
Re: Tiny Binary Clock
« Reply #6 on: March 27, 2015, 05:48:09 pm »
mmm, i guess that for the ICSP to work, even if I don't use the power supply from the programmer, I need to connect GND ?
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3468
  • Country: gb
Re: Tiny Binary Clock
« Reply #7 on: March 27, 2015, 09:31:48 pm »

  I spent hours and hours (and hours) trying to find a leds driver that would feet in the PCB, and failed. So in the end, I will use two Pic MCUs. One of them will have a crystal and keep track of time, the other one will only be used as a led driver (with 25mA internal clamping diodes on output pins).

Are you talking about the ESD diodes within the PIC? These do not limit the output current from the pins, they are there only to prevent high voltages from electrostatic discharge from damaging the PIC.
 

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 105
Re: Tiny Binary Clock
« Reply #8 on: March 28, 2015, 06:35:22 am »
>Are you talking about the ESD diodes within the PIC?

Well, i was pretty sure Pics hade current limiting diodes on "25mA pins", but since you asked this question I checked and they dont :(

So I think i'll need to try to add all those resistors, or fit a 5v->3v3 voltage reductor between the usb connector and the circuit :(
 

Offline eneuro

  • Super Contributor
  • ***
  • Posts: 1562
  • Country: 00
Re: Tiny Binary Clock
« Reply #9 on: March 28, 2015, 10:25:13 pm »
Well, the PCB is 8.5x60mm, I could barely fit the crystal on it.
My SO8  AVR ATTiny85 based watch will be 1in2 25mm x 25mm, but probably two PCBs with 12 leds for hours/minutes classic  display.
Was also looking for a way to set each of those 12 output leds (usually 2 of them for  hour, minute with 1s pulses ) and... probably two those tricky SO16 74HC595  8 bit shift registers will do the job while it is possible to cascade them so using only 3 MPU pins I will be able control 12 leds and 4 additional output pins  8)

Detailed 74HC595 intoro is there Can you move over? The 74HC595 8 bit shift register

This sample AVR code from link above for AVR is only afew lines of code to controll many cascaded 74HC595
Code: [Select]
///
/// Can you move over? The 74HC595 8 bit shift register
/// http://bildr.org/2011/02/74hc595/
///

#include <avr/io.h>
#include <util/delay.h>


#define number_of_74hc595s 1 //How many of the shift registers are there daisey chained?


int main(){
        DDRB = 0xFF;
        PORTB = 0x00;
        char counter = 0;

        while(1){
                counter++;                              // Counter used for displaying a number in binary via the shift register
                shift(PB1, PB2, PB3, counter);          // PB1 = SERCLK  PB2 = RCLK  PB3 = SER
                _delay_ms(500);
                shift(PB1, PB2, PB3, 0x00);             // Set all pins to off
                _delay_ms(500);
        }
        return 0;
}


void shift(int SRCLK_Pin, int RCLK_Pin, int SER_Pin, unsigned long data){
        PORTB &= ~(1 << RCLK_Pin);                              // Set the register-clock pin low

        for (int i = 0; i < (8 * number_of_74hc595s); i++){     // Now we are entering the loop to shift out 8+ bits

                PORTB &= ~(1 << SRCLK_Pin);                     // Set the serial-clock pin low

                PORTB |= (((data&(0x01<<i))>>i) << SER_Pin );   // Go through each bit of data and output it

                PORTB |= (1 << SRCLK_Pin);                      // Set the serial-clock pin high

                PORTB &= ~(((data&(0x01<<i))>>i) << SER_Pin );  // Set the datapin low again
        }

        PORTB |= (1 << RCLK_Pin);                               // Set the register-clock pin high to update the output of the shift-register
}
However, probably this shift C function above needs to be tweak'ed to slow down filling 74HC595 register, while in oryginal version it runs at AVR MPU clock speed and it is not so bad, but PCB design might require slower data transfers rates since I used to switch ATTiny85 to 8MHz internal clock.
But OK, in watch we are interested in lower power consumption so AVR will run on lower speed, so probably no  :-/O needed to run this code above.
Need to find low power consumption I2C RTC and it is time design PCB.

I need new watch to test powering it using different energy harversting methods  >:D
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 105
Re: Tiny Binary Clock
« Reply #10 on: April 03, 2015, 12:31:39 pm »
Ok, some progress on this project :

-After I checked another 20-30 microchip datasheets, I don't know where I found this information about pic that could limit current sink/source to 25mA.
-I tryed to add 22 resistors on the pcb, but there were not enough space
-I tryed make a matrix multiplexing, using less resistors, a smaller mcu, and some transistors, but was not pleased with the result
-I tryed to have TI led drivers, and that almost fit if I used the larger possible PCB and a QFN pic. But the PCB was then more than 50mm wide and was twice the price at dirtypcb.com
-In the end, may have found a solution that uses two 12 leds TI drivers (I need 22 leds) on a 8x50mm board, and a pic, the crystal and usb connector on a second smaller board.

Microchip sells a QFN16 pic which can do USB without any crystal. Since I already wanted to use an USB connector for power supply, I decided that the binclock will also be usable as a bargraph to display anything from a computer (or that you'll be able to set the hour from a computer).

I found a 32.768kHz crystal on mouser which is small that the one I wanted to use. It is 12.5pF, and using information I found on the internet I guess the proper value for the capacitors should be 16pF

I also added some capacitors as close as I could from the led drivers and mcu. Should I use 10pF ones ?

 

Offline matseng

  • Frequent Contributor
  • **
  • Posts: 563
  • Country: se
    • My Github
Re: Tiny Binary Clock
« Reply #11 on: April 03, 2015, 03:14:07 pm »

-I tryed to add 22 resistors on the pcb, but there were not enough space

Did you try to fit some resistor arrays? A chip with 8 individual resistors is only 0.150" x 0.063" (3.80mm x 1.60mm)
 

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 105
Re: Tiny Binary Clock
« Reply #12 on: April 03, 2015, 03:28:55 pm »
Well, that would save some place compared to 0306 resistor, but on the other hand all my tracks would have to go to the resistor array. I will give it a try anyway, thank you for the hint :)
 

Offline BlueBill

  • Regular Contributor
  • *
  • Posts: 169
  • Country: ca
Re: Tiny Binary Clock
« Reply #13 on: April 03, 2015, 04:17:12 pm »
Could you post the schematic in PDF format. I don't use Eagle.
 

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 105
Re: Tiny Binary Clock
« Reply #14 on: April 03, 2015, 04:43:16 pm »
yes :)
 

Offline BlueBill

  • Regular Contributor
  • *
  • Posts: 169
  • Country: ca
Re: Tiny Binary Clock
« Reply #15 on: April 03, 2015, 11:06:20 pm »
My 2c
No current limiting on the LEDs is just bad design. The PIC can source sink 25 mA but that's not meant to be used as a current limiter.
No 0.1uF decoupling caps. You need one per digital IC across the power pins.
No pull-up on MCLR (but that's okay if you disable external MCLR)
How do you set the clock?
You need GND too on your programming connector.

Take a look at Charlieplexing those LEDs, you could put all 22 LEDs on 6 I/O pins with 6 100ohm resistors. Or split it up into 3 charlieplexed channels for hours, minutes, seconds.

Charlieplexing works best if you're only lighting a few LEDs at a time.
Something like this.
http://www.instructables.com/id/Controlling-20-Leds-from-5-Arduino-pins-using-Cha/
« Last Edit: April 03, 2015, 11:08:55 pm by BlueBill »
 

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 105
Re: Tiny Binary Clock
« Reply #16 on: April 04, 2015, 08:03:42 am »
BlueBill,

  Thank you for you feedback. I sent the wrong version of the schematic, and some on the problem are already corrected on the new one, but I indeed forgot the pull-up resistor on MCLR !

  To set the time, I will have two 1mm wires connected to RC2 and RC3 that will be used as capacitive touch sensors. When you start the clock, you will touch 18 times either of the wire to enter a zero or a one. I tried this on a breadboard and it seems to work.

  Also the last version has of the pcb has an USB capacble PIC, so if you choose to run the clock from a computer, you'll be able to set the time via a com port or an hid. Maybe I can also make some specific driver that automatically does the job.

John.
 

Offline BlueBill

  • Regular Contributor
  • *
  • Posts: 169
  • Country: ca
Re: Tiny Binary Clock
« Reply #17 on: April 04, 2015, 12:50:13 pm »
How do the LEDs represent the time?
 

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 105
Re: Tiny Binary Clock
« Reply #18 on: April 04, 2015, 01:00:24 pm »
It is a binary clock. Three groups of six leds can each code a number between 0 and 63. Two groups of two vertically aligned led separate the numbers for better readability.

".. .:.  . .:. . . " stands for "13:37:42"
 

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 105
Re: Tiny Binary Clock
« Reply #19 on: April 08, 2015, 03:25:02 pm »
Before I order PCB, I will try one last time to fit multiplexed leds with resistor array on a single pcb.

I need some transistor that:
-don't take much space,
-can accept 8*25mA (200mA)
-do not require a transistor on the gate to be driven by a 5V mcu
-has a low drain to source on resistance

  If found the 2N7002W, and I think its is ok (but I'm a software developer, last time I used a transistor I was in high school more than twenty year ago :) ).
  Datasheet says "Drain?to?Source On Resistance when GS = 4.5 V and ID = 200 mA : 2.5Ohm max", IIUC, this means :
-with 5V from MCU at Gate, RGS will be less than 2.5Ohm, so dissipated power will be less than 2.5*0.2*0.2 = 0.1W which should be fine
-with 1 led UGS would be 2.5*25 = 62.5mV, with all leds on that would be 8x2.5x25 = 500mV. With a 5v PS and 3.5V led, there would be a about 20-25% difference in intensity depending on the quantity of on leds. This is acceptable (can be corrected by software), but lower RGS would be better

  Gate to source max voltage is 10V, that's ok (I have a 5V USB psu)

  Is this transistor ok or did I miss something ? Is there any better alternative ? Can I use it by directly connecting gate to MCU, or do I need to have a pull-up, pull-down, or in serie resistor ?

thanks you,
John.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf