Pages: [1]   Go Down
Author Topic: 12 volt 7 segment 6 digit clock  (Read 1649 times)
0 Members and 1 Guest are viewing this topic.
Ontario
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i am in the process of making a 6 digit clock and have found some examples but none of the ones i found are 12 volt. i have made my own 7 segment displays out of foam core board and rgb led strip. it is not fully wired yet so it can be common anode or cathode but the strip is common anode. i would like it to change color depending on time of day but for now i would be happy if it is only one color. i have a ds1307 rtc, arduino uno.  i am open to any ideas.
Logged

Dan

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1189
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can use TPIC6B595 shift reg / latches to sink 50 volt loads up to 150 Ma per segment, see below and replace relays with your LED strips.
Just use Shift out to send your required pattern every second and latch it.

You can also use the pin 10s to dim the display by PWM.  You can daisy chain as many ( well almost ) of these chips as you like.

You could have different colour LEDs connected to the same latched pins, and switch the supply ( via a transistor )  to each colour , if you did it fast enough you could change colour through the rainbow throughout the day :-)

« Last Edit: November 13, 2012, 01:15:21 am by Boffin1 » Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23835
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Also look at TPIC6A595, TPIC6B595, TPIC6C595, TPIC6D595, and TPIC6595 for other current amounts.

I prefer SPI.transfer() to send the data out, much quicker.
Don't forget 100nF caps across VCC & GND.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1189
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess I had better add the 100nF to that old drawing !   :-)
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

0
Offline Offline
Shannon Member
****
Karma: 162
Posts: 10496
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess I had better add the 100nF to that old drawing !   :-)

100nF isn't enough for large currents being switched - for substantial LED installations something more like 100uF per amp of LED load will be better.
Logged

[ I won't respond to messages, use the forum please ]

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1189
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

we are talking about the VCC decoupling at each chips pins,  the LED supply should of course have big electrolytics.
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Ontario
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i would like to multiplex them to cut back on components needed. i found this guy
http://www.instructables.com/id/Make-A-Digital-Clock-From-Scratch/
and i like his clock but any ideas on how to make it work with 12 volt leds.
Logged

Dan

Chile
Offline Offline
Sr. Member
****
Karma: 0
Posts: 260
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've used ULN2003 to work with 12V led strips. It's a darlington array that will sink current from the strips, activated with an Arduino's signal.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23835
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Use the TPIC6x595 to sink all the cathodes in parallel.
Add P-channel MOSFETs to turn current on/off to the anodes of the digit being driven.
You will need another device in front of the p-channels, another TPICxxxx would work.
Resistor pulls the MOSFET gate high (12V) to turn it off, shift register output pulls the gate low to turn the P-channel on and enable a digit.
So you save on shift registers, but you add "high side" drivers instead, and you cut back brightness to 1/6 of what it could be.

This would be a good mosfet
http://www.digikey.com/product-detail/en/NTD2955-1G/NTD2955-1GOS-ND/1484753  64 cents - plus pullup resistor
while a 100mA/IO pin shift register is less, just 56 cents
https://avnetexpress.avnet.com/store/em/EMController/Counter-Shift-Register/STMicroelectronics/STPIC6D595B1R/_/R-5750380/A-5750380/An-0?action=part&catalogId=500201&langId=-1&storeId=500201&listIndex=-1&page=1&rank=0

All kinds of tradeoffs are possible.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Ontario
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i just looked through my parts bin and found some tlc5940's i didnt realized i had. would these work good for this. also i have no experience with any rtc's so coding is gonna be a challenge as i was hoping to use the code i found on the one guys project.
Logged

Dan

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23835
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure, power it from 5V and sink from LED anodes at 12V.
Datasheet at www.ti.com
There's an RTC I2C library if you can't figure out how to code it from the datasheet or find examples here in the forum - I know I had posted a  nice sketch to set the time and read it back via the serial port.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Ontario
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok so i got all the segments wired up and i am waiting for my rtc to come in the mail. but i am trying to work on part of the code. the half that controls the leds. i am haveing some troubles. i am using a subroutine to do this. the first time i call up the routine it works fine but if i call it again with a different number it does not clear the old one. i have tried putting the Tlc.clear(); line in meny places but they all cause flicker or the display to show nothing. can any one help.

Part 1

Code:
#include "Tlc5940.h"
int hhh, mmm, sss;
void setup()
{
  /* Call Tlc.init() to setup the tlc.
     You can optionally pass an initial PWM value (0 - 4095) for all channels.*/
  Tlc.init();
  Tlc.clear();
  Tlc.update();
}

void loop(){

time(01,37,55);
delay(500);

time(12,29,38);
delay(500);
  
}

void time(int hh,int mm, int ss){

  uint8_t fh,lh,fm,lm,fs,ls;
  fh = hh/10;
  lh = hh-fh*10;
  fm = mm/10;
  lm = mm-fm*10;
  fs = ss/10;
  ls = ss-fs*10;
  
  
  switch (fh){
  
    case 0:
    Tlc.set(0+0, 4095);
    Tlc.set(1+0, 4095);
    Tlc.set(2+0, 4095);
    Tlc.set(3+0, 4095);
    Tlc.set(4+0, 4095);
    Tlc.set(5+0, 4095);
    Tlc.update();
    break;
    
    case 1:
    Tlc.set(1+0, 4095);
    Tlc.set(2+0, 4095);
    Tlc.update();
    break;
    
    case 2:
    Tlc.set(0+0, 4095);
    Tlc.set(1+0, 4095);
    Tlc.set(3+0, 4095);
    Tlc.set(4+0, 4095);
    Tlc.set(6+0, 4095);
    Tlc.update();
    
    break;
    
    case 3:
    Tlc.set(0+0, 4095);
    Tlc.set(1+0, 4095);
    Tlc.set(2+0, 4095);
    Tlc.set(3+0, 4095);
    Tlc.set(6+0, 4095);
    Tlc.update();
    break;
    
    case 4:
    Tlc.set(1+0, 4095);
    Tlc.set(2+0, 4095);
    Tlc.set(5+0, 4095);
    Tlc.set(6+0, 4095);
    Tlc.update();
    break;
    
    case 5:
    Tlc.set(0+0, 4095);
    Tlc.set(2+0, 4095);
    Tlc.set(3+0, 4095);
    Tlc.set(5+0, 4095);
    Tlc.set(6+0, 4095);
    Tlc.update();
    break;
    
    case 6:
    Tlc.set(0+0, 4095);
    Tlc.set(2+0, 4095);
    Tlc.set(3+0, 4095);
    Tlc.set(4+0, 4095);
    Tlc.set(5+0, 4095);
    Tlc.set(6+0, 4095);
    Tlc.update();
    break;
    
    case 7:
    Tlc.set(0+0, 4095);
    Tlc.set(1+0, 4095);
    Tlc.set(2+0, 4095);
    Tlc.update();
    break;
    
    case 8:
    Tlc.set(0+0, 4095);
    Tlc.set(1+0, 4095);
    Tlc.set(2+0, 4095);
    Tlc.set(3+0, 4095);
    Tlc.set(4+0, 4095);
    Tlc.set(5+0, 4095);
    Tlc.set(6+0, 4095);
    Tlc.update();
    break;
    
    case 9:
    Tlc.set(0+0, 4095);
    Tlc.set(1+0, 4095);
    Tlc.set(2+0, 4095);
    Tlc.set(3+0, 4095);
    Tlc.set(5+0, 4095);
    Tlc.set(6+0, 4095);
    Tlc.update();
    
    break;
  default:
  Tlc.clear();
  Tlc.update();
  }
  
  switch (lh){
    
    case 1:
    Tlc.set(1+7, 4095);
    Tlc.set(2+7, 4095);
    Tlc.update();
    break;
    
    case 2:
    Tlc.set(0+7, 4095);
    Tlc.set(1+7, 4095);
    Tlc.set(3+7, 4095);
    Tlc.set(4+7, 4095);
    Tlc.set(6+7, 4095);
    Tlc.update();
    break;
    
    case 3:
    Tlc.set(0+7, 4095);
    Tlc.set(1+7, 4095);
    Tlc.set(2+7, 4095);
    Tlc.set(3+7, 4095);
    Tlc.set(6+7, 4095);
    Tlc.update();
    break;
    
    case 4:
    Tlc.set(1+7, 4095);
    Tlc.set(2+7, 4095);
    Tlc.set(5+7, 4095);
    Tlc.set(6+7, 4095);
    Tlc.update();
    break;
    
    case 5:
    Tlc.set(0+7, 4095);
    Tlc.set(2+7, 4095);
    Tlc.set(3+7, 4095);
    Tlc.set(5+7, 4095);
    Tlc.set(6+7, 4095);
    Tlc.update();
    break;
    
    case 6:
    Tlc.set(0+7, 4095);
    Tlc.set(2+7, 4095);
    Tlc.set(3+7, 4095);
    Tlc.set(4+7, 4095);
    Tlc.set(5+7, 4095);
    Tlc.set(6+7, 4095);
    Tlc.update();
    break;
    
    case 7:
    Tlc.set(0+7, 4095);
    Tlc.set(1+7, 4095);
    Tlc.set(2+7, 4095);
    Tlc.update();
    break;
    
    case 8:
    Tlc.set(0+7, 4095);
    Tlc.set(1+7, 4095);
    Tlc.set(2+7, 4095);
    Tlc.set(3+7, 4095);
    Tlc.set(4+7, 4095);
    Tlc.set(5+7, 4095);
    Tlc.set(6+7, 4095);
    Tlc.update();
    break;
    
    case 9:
    Tlc.set(0+7, 4095);
    Tlc.set(1+7, 4095);
    Tlc.set(2+7, 4095);
    Tlc.set(3+7, 4095);
    Tlc.set(5+7, 4095);
    Tlc.set(6+7, 4095);
    Tlc.update();
    break;
  
  }
 
Logged

Dan

Ontario
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Part 2

Code:
switch (fm){
    
    case 1:
    Tlc.set(1+16, 4095);
    Tlc.set(2+16, 4095);
    Tlc.update();
    break;
    
    case 2:
    Tlc.set(0+16, 4095);
    Tlc.set(1+16, 4095);
    Tlc.set(3+16, 4095);
    Tlc.set(4+16, 4095);
    Tlc.set(6+16, 4095);
    Tlc.update();
    break;
    
    case 3:
    Tlc.set(0+16, 4095);
    Tlc.set(1+16, 4095);
    Tlc.set(2+16, 4095);
    Tlc.set(3+16, 4095);
    Tlc.set(6+16, 4095);
    Tlc.update();
    break;
    
    case 4:
    Tlc.set(1+16, 4095);
    Tlc.set(2+16, 4095);
    Tlc.set(5+16, 4095);
    Tlc.set(6+16, 4095);
    Tlc.update();
    break;
    
    case 5:
    Tlc.set(0+16, 4095);
    Tlc.set(2+16, 4095);
    Tlc.set(3+16, 4095);
    Tlc.set(5+16, 4095);
    Tlc.set(6+16, 4095);
    Tlc.update();
    break;
    
    case 6:
    Tlc.set(0+16, 4095);
    Tlc.set(2+16, 4095);
    Tlc.set(3+16, 4095);
    Tlc.set(4+16, 4095);
    Tlc.set(5+16, 4095);
    Tlc.set(6+16, 4095);
    Tlc.update();
    break;
    
    case 7:
    Tlc.set(0+16, 4095);
    Tlc.set(1+16, 4095);
    Tlc.set(2+16, 4095);
    Tlc.update();
    break;
    
    case 8:
    Tlc.set(0+16, 4095);
    Tlc.set(1+16, 4095);
    Tlc.set(2+16, 4095);
    Tlc.set(3+16, 4095);
    Tlc.set(4+16, 4095);
    Tlc.set(5+16, 4095);
    Tlc.set(6+16, 4095);
    Tlc.update();
    break;
    
    case 9:
    Tlc.set(0+16, 4095);
    Tlc.set(1+16, 4095);
    Tlc.set(2+16, 4095);
    Tlc.set(3+16, 4095);
    Tlc.set(5+16, 4095);
    Tlc.set(6+16, 4095);
    Tlc.update();
    break;
  
  }

  switch (lm){
    
    case 1:
    Tlc.set(1+23, 4095);
    Tlc.set(2+23, 4095);
    Tlc.update();
    break;
    
    case 2:
    Tlc.set(0+23, 4095);
    Tlc.set(1+23, 4095);
    Tlc.set(3+23, 4095);
    Tlc.set(4+23, 4095);
    Tlc.set(6+23, 4095);
    Tlc.update();
    break;
    
    case 3:
    Tlc.set(0+23, 4095);
    Tlc.set(1+23, 4095);
    Tlc.set(2+23, 4095);
    Tlc.set(3+23, 4095);
    Tlc.set(6+23, 4095);
    Tlc.update();
    break;
    
    case 4:
    Tlc.set(1+23, 4095);
    Tlc.set(2+23, 4095);
    Tlc.set(5+23, 4095);
    Tlc.set(6+23, 4095);
    Tlc.update();
    break;
    
    case 5:
    Tlc.set(0+23, 4095);
    Tlc.set(2+23, 4095);
    Tlc.set(3+23, 4095);
    Tlc.set(5+23, 4095);
    Tlc.set(6+23, 4095);
    Tlc.update();
    break;
    
    case 6:
    Tlc.set(0+23, 4095);
    Tlc.set(2+23, 4095);
    Tlc.set(3+23, 4095);
    Tlc.set(4+23, 4095);
    Tlc.set(5+23, 4095);
    Tlc.set(6+23, 4095);
    Tlc.update();
    break;
    
    case 7:
    Tlc.set(0+23, 4095);
    Tlc.set(1+23, 4095);
    Tlc.set(2+23, 4095);
    Tlc.update();
    break;
    
    case 8:
    Tlc.set(0+23, 4095);
    Tlc.set(1+23, 4095);
    Tlc.set(2+23, 4095);
    Tlc.set(3+23, 4095);
    Tlc.set(4+23, 4095);
    Tlc.set(5+23, 4095);
    Tlc.set(6+23, 4095);
    Tlc.update();
    break;
    
    case 9:
    Tlc.set(0+23, 4095);
    Tlc.set(1+23, 4095);
    Tlc.set(2+23, 4095);
    Tlc.set(3+23, 4095);
    Tlc.set(5+23, 4095);
    Tlc.set(6+23, 4095);
    Tlc.update();
    break;
  
  }
  
  
  switch (fs){
    
    case 1:
    Tlc.set(1+32, 4095);
    Tlc.set(2+32, 4095);
    Tlc.update();
    break;
    
    case 2:
    Tlc.set(0+32, 4095);
    Tlc.set(1+32, 4095);
    Tlc.set(3+32, 4095);
    Tlc.set(4+32, 4095);
    Tlc.set(6+32, 4095);
    Tlc.update();
    break;
    
    case 3:
    Tlc.set(0+32, 4095);
    Tlc.set(1+32, 4095);
    Tlc.set(2+32, 4095);
    Tlc.set(3+32, 4095);
    Tlc.set(6+32, 4095);
    Tlc.update();
    break;
    
    case 4:
    Tlc.set(1+32, 4095);
    Tlc.set(2+32, 4095);
    Tlc.set(5+32, 4095);
    Tlc.set(6+32, 4095);
    Tlc.update();
    break;
    
    case 5:
    Tlc.set(0+32, 4095);
    Tlc.set(2+32, 4095);
    Tlc.set(3+32, 4095);
    Tlc.set(5+32, 4095);
    Tlc.set(6+32, 4095);
    Tlc.update();
    break;
    
    case 6:
    Tlc.set(0+32, 4095);
    Tlc.set(2+32, 4095);
    Tlc.set(3+32, 4095);
    Tlc.set(4+32, 4095);
    Tlc.set(5+32, 4095);
    Tlc.set(6+32, 4095);
    Tlc.update();
    break;
    
    case 7:
    Tlc.set(0+32, 4095);
    Tlc.set(1+32, 4095);
    Tlc.set(2+32, 4095);
    Tlc.update();
    break;
    
    case 8:
    Tlc.set(0+32, 4095);
    Tlc.set(1+32, 4095);
    Tlc.set(2+32, 4095);
    Tlc.set(3+32, 4095);
    Tlc.set(4+32, 4095);
    Tlc.set(5+32, 4095);
    Tlc.set(6+32, 4095);
    Tlc.update();
    break;
    
    case 9:
    Tlc.set(0+32, 4095);
    Tlc.set(1+32, 4095);
    Tlc.set(2+32, 4095);
    Tlc.set(3+32, 4095);
    Tlc.set(5+32, 4095);
    Tlc.set(6+32, 4095);
    Tlc.update();
    break;
  
  }
  switch (ls){
    
    case 1:
    Tlc.set(1+39, 4095);
    Tlc.set(2+39, 4095);
    Tlc.update();
    break;
    
    case 2:
    Tlc.set(0+39, 4095);
    Tlc.set(1+39, 4095);
    Tlc.set(3+39, 4095);
    Tlc.set(4+39, 4095);
    Tlc.set(6+39, 4095);
    Tlc.update();
    break;
    
    case 3:
    Tlc.set(0+39, 4095);
    Tlc.set(1+39, 4095);
    Tlc.set(2+39, 4095);
    Tlc.set(3+39, 4095);
    Tlc.set(6+39, 4095);
    Tlc.update();
    break;
    
    case 4:
    Tlc.set(1+39, 4095);
    Tlc.set(2+39, 4095);
    Tlc.set(5+39, 4095);
    Tlc.set(6+39, 4095);
    Tlc.update();
    break;
    
    case 5:
    Tlc.set(0+39, 4095);
    Tlc.set(2+39, 4095);
    Tlc.set(3+39, 4095);
    Tlc.set(5+39, 4095);
    Tlc.set(6+39, 4095);
    Tlc.update();
    break;
    
    case 6:
    Tlc.set(0+39, 4095);
    Tlc.set(2+39, 4095);
    Tlc.set(3+39, 4095);
    Tlc.set(4+39, 4095);
    Tlc.set(5+39, 4095);
    Tlc.set(6+39, 4095);
    Tlc.update();
    break;
    
    case 7:
    Tlc.set(0+39, 4095);
    Tlc.set(1+39, 4095);
    Tlc.set(2+39, 4095);
    Tlc.update();
    break;
    
    case 8:
    Tlc.set(0+39, 4095);
    Tlc.set(1+39, 4095);
    Tlc.set(2+39, 4095);
    Tlc.set(3+39, 4095);
    Tlc.set(4+39, 4095);
    Tlc.set(5+39, 4095);
    Tlc.set(6+39, 4095);
    Tlc.update();
    break;
    
    case 9:
    Tlc.set(0+39, 4095);
    Tlc.set(1+39, 4095);
    Tlc.set(2+39, 4095);
    Tlc.set(3+39, 4095);
    Tlc.set(5+39, 4095);
    Tlc.set(6+39, 4095);
    Tlc.update();
    
    break;
  
  }
  
}
Logged

Dan

Ontario
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i have figured it out i put Tlc.clear(); before the first switch and Tlc.update(); after the last one instead of updating in every switch
Logged

Dan

Pages: [1]   Go Up
Jump to: