Show Posts
Pages: [1]
1  Projects / ArduiNIX / Re: IN-17 Bulb CrossFade Code Example. on: August 25, 2011, 10:01:40 pm
Thanks for the help, I see the issue now. Everything is working except for upperseconds is not fading for whatever reason.

Code:
// SN74141 : Truth Table
//D C B A #
//L,L,L,L 0
//L,L,L,H 1
//L,L,H,L 2
//L,L,H,H 3
//L,H,L,L 4
//L,H,L,H 5
//L,H,H,L 6
//L,H,H,H 7
//H,L,L,L 8
//H,L,L,H 9

int ledPin_0_a = 2;                
int ledPin_0_b = 3;
int ledPin_0_c = 4;
int ledPin_0_d = 5;

int ledPin_1_a = 6;                
int ledPin_1_b = 7;
int ledPin_1_c = 8;
int ledPin_1_d = 9;

int ledPin_a_1 = 10;
int ledPin_a_2 = 11;
int ledPin_a_3 = 12;
int ledPin_a_4 = 13;

void setup()
{
  pinMode(ledPin_0_a, OUTPUT);      
  pinMode(ledPin_0_b, OUTPUT);      
  pinMode(ledPin_0_c, OUTPUT);      
  pinMode(ledPin_0_d, OUTPUT);    
  
  pinMode(ledPin_1_a, OUTPUT);      
  pinMode(ledPin_1_b, OUTPUT);      
  pinMode(ledPin_1_c, OUTPUT);      
  pinMode(ledPin_1_d, OUTPUT);      
  
  pinMode(ledPin_a_1, OUTPUT);      
  pinMode(ledPin_a_2, OUTPUT);      
  pinMode(ledPin_a_3, OUTPUT);    
 
  // NOTE:
  // Grounding on virtual pins 14 and 15 (analog pins 0 and 1) will set the Hour and Mins.
  pinMode( 14, INPUT ); // set the vertual pin 14 (pin 0 on the analog inputs )
  digitalWrite(14, HIGH); // set pin 14 as a pull up resistor.

  pinMode( 15, INPUT ); // set the vertual pin 15 (pin 1 on the analog inputs )
  digitalWrite(15, HIGH); // set pin 15 as a pull up resistor.
 
}

void SetSN74141Chips( int num2, int num1 )
{
  int a,b,c,d;
  
  // set defaults.
  a=0;b=0;c=0;d=0; // will display a zero.
  
  // Load the a,b,c,d.. to send to the SN74141 IC (1)
  switch( num1 )
  {
    case 0: a=0;b=0;c=0;d=0;break;
    case 1: a=1;b=0;c=0;d=0;break;
    case 2: a=0;b=1;c=0;d=0;break;
    case 3: a=1;b=1;c=0;d=0;break;
    case 4: a=0;b=0;c=1;d=0;break;
    case 5: a=1;b=0;c=1;d=0;break;
    case 6: a=0;b=1;c=1;d=0;break;
    case 7: a=1;b=1;c=1;d=0;break;
    case 8: a=0;b=0;c=0;d=1;break;
    case 9: a=1;b=0;c=0;d=1;break;
    default: a=1;b=1;c=1;d=1;
    break;
  }  
  
  // Write to output pins.
  digitalWrite(ledPin_0_d, d);
  digitalWrite(ledPin_0_c, c);
  digitalWrite(ledPin_0_b, b);
  digitalWrite(ledPin_0_a, a);

  // Load the a,b,c,d.. to send to the SN74141 IC (2)
  switch( num2 )
  {
    case 0: a=0;b=0;c=0;d=0;break;
    case 1: a=1;b=0;c=0;d=0;break;
    case 2: a=0;b=1;c=0;d=0;break;
    case 3: a=1;b=1;c=0;d=0;break;
    case 4: a=0;b=0;c=1;d=0;break;
    case 5: a=1;b=0;c=1;d=0;break;
    case 6: a=0;b=1;c=1;d=0;break;
    case 7: a=1;b=1;c=1;d=0;break;
    case 8: a=0;b=0;c=0;d=1;break;
    case 9: a=1;b=0;c=0;d=1;break;
    default: a=1;b=1;c=1;d=1;
    break;
  }
  
  // Write to output pins
  digitalWrite(ledPin_1_d, d);
  digitalWrite(ledPin_1_c, c);
  digitalWrite(ledPin_1_b, b);
  digitalWrite(ledPin_1_a, a);
}

float fadeIn = 8.0f;
float fadeOut = 8.0f;
float fadeMax = 8.0f;
float fadeStep = 0.4f;
int NumberArray[6]={0,0,0,0,0,0};
int currNumberArray[6]={0,0,0,0,0,0};
float NumberArrayFadeInValue[6]={0.0f,0.0f,0.0f,0.0f,0.0f,0.0f};
float NumberArrayFadeOutValue[6]={8.0f,8.0f,8.0f,8.0f,8.0f,8.0f};

void DisplayFadeNumberString()
{
 
  // Anode channel 1 - numerals 0,3
  SetSN74141Chips(currNumberArray[0],currNumberArray[3]);  
  digitalWrite(ledPin_a_1, HIGH);  
  delay(NumberArrayFadeOutValue[0]);
  SetSN74141Chips(NumberArray[0],NumberArray[3]);  
  delay(NumberArrayFadeInValue[0]);
  digitalWrite(ledPin_a_1, LOW);
  
  // Anode channel 2 - numerals 1,4
  SetSN74141Chips(currNumberArray[1],currNumberArray[4]);  
  digitalWrite(ledPin_a_2, HIGH);  
  delay(NumberArrayFadeOutValue[1]);
  SetSN74141Chips(NumberArray[1],NumberArray[4]);  
  delay(NumberArrayFadeInValue[1]);
  digitalWrite(ledPin_a_2, LOW);
  
   // Anode channel 3 - numerals 2,5
  SetSN74141Chips(currNumberArray[2],currNumberArray[5]);  
  digitalWrite(ledPin_a_3, HIGH);  
  delay(NumberArrayFadeOutValue[2]);
  SetSN74141Chips(NumberArray[2],NumberArray[5]);  
  delay(NumberArrayFadeInValue[2]);
  digitalWrite(ledPin_a_3, LOW);
  
  // Loop thru and update all the arrays, and fades.
  for( int i = 0 ; i < 6 ; i ++ )
  {
    if( NumberArray[i] != currNumberArray[i] )
    {
      NumberArrayFadeInValue[i] += fadeStep;
      NumberArrayFadeOutValue[i] -= fadeStep;
  
      if( NumberArrayFadeInValue[i] >= fadeMax )
      {
        NumberArrayFadeInValue[i] = 0.0f;
        NumberArrayFadeOutValue[i] = fadeMax;
        currNumberArray[i] = NumberArray[i];
      }
    }
  }  
}

// Defines
long MINS = 60;         // 60 Seconds in a Min.
long HOURS = 60 * MINS; // 60 Mins in an hour.
long DAYS = 12 * HOURS; // 24 Hours in a day. > Note: change the 24 to a 12 for non millitary time.

long runTime = 0;       // Time from when we started.

// default time sets. clock will start at 12:34:00.  This is so we can count the correct order of tubes.
long clockHourSet = 12;
long clockMinSet  = 34;

int HourButtonPressed = false;
int MinButtonPressed = false;

////////////////////////////////////////////////////////////////////////
//
//
////////////////////////////////////////////////////////////////////////
void loop()    
{
  // Get milliseconds.
  runTime = millis();
  
  int hourInput = digitalRead(14);  
  int minInput  = digitalRead(15);

  if( hourInput == 0 )
    HourButtonPressed = true;
  if( minInput == 0 )
    MinButtonPressed = true;
  
  if( HourButtonPressed == true && hourInput == 1 )
  {
    clockHourSet++;
    HourButtonPressed = false;
  }
  
  if( MinButtonPressed == true && minInput == 1 )
  {
    clockMinSet++;
    MinButtonPressed = false;
  }

  // Get time in seconds.
  long time = (runTime) / 1000; //////////change this value to speed up or slow down the clock
  
  // Set time based on offset..
  // long hbump = 60*60*clockHourSet;
  long hbump = 60*60*clockHourSet;
  long mbump = 60*clockMinSet;
  time += mbump + hbump;

  // Convert time to days,hours,mins,seconds
  long days  = time / DAYS;    time -= days  * DAYS;
  long hours = time / HOURS;   time -= hours * HOURS;
  long minutes  = time / MINS;    time -= minutes  * MINS;
  long seconds  = time;

  // Get the high and low order values for hours,min,seconds.
  int lowerHours = hours % 10;
  int upperHours = hours - lowerHours;
  int lowerMins = minutes % 10;
  int upperMins = minutes - lowerMins;
  int lowerSeconds = seconds % 10;
  int upperSeconds = seconds - lowerSeconds;
  if( upperSeconds >= 10 )   upperSeconds = upperSeconds / 10;
  if( upperMins >= 10 )      upperMins = upperMins / 10;
  if( upperHours >= 10 )     upperHours = upperHours / 10;
  
  if( upperHours == 0 && lowerHours == 0 )
  {
    upperHours = 1;
    lowerHours = 2;
  }

  // Fill in the Number array used to display on the tubes.
  
  NumberArray[5] = upperHours;
  NumberArray[1] = lowerHours;
  NumberArray[3] = upperMins;
  NumberArray[2] = lowerMins;
  NumberArray[4] = upperSeconds;  
  NumberArray[0] = lowerSeconds;

  // Display.
  DisplayFadeNumberString();
}

The only other thing I changed was if the clock is displaying 0 0 for the hours, I want it to say 12.

Code:
 if( upperHours == 0 && lowerHours == 0 )
  {
    upperHours = 1;
    lowerHours = 2;
  }

This seems to work fine.

Images: http://imgur.com/a/c79QS
Video: http://www.youtube.com/watch?v=lG1PW85CdcQ
2  Projects / ArduiNIX / Re: IN-17 Bulb CrossFade Code Example. on: August 24, 2011, 08:29:03 pm
Been trying to adapt this into a six bulb setup. Here's what I have thus far (not working yet)

Code:
// fading transitions sketch for 4-tube board with default connections.
// based on 6-tube sketch by Emblazed
// 4-tube-itized by Dave Blevins 16 June 2011
// this shows minutes and seconds only

// SN74141 : Truth Table

//D C B A #
//L,L,L,L 0
//L,L,L,H 1
//L,L,H,L 2
//L,L,H,H 3
//L,H,L,L 4
//L,H,L,H 5
//L,H,H,L 6
//L,H,H,H 7
//H,L,L,L 8
//H,L,L,H 9

int ledPin_0_a = 2;               
int ledPin_0_b = 3;
int ledPin_0_c = 4;
int ledPin_0_d = 5;

int ledPin_1_a = 6;               
int ledPin_1_b = 7;
int ledPin_1_c = 8;
int ledPin_1_d = 9;

int ledPin_a_1 = 10;
int ledPin_a_2 = 11;
int ledPin_a_3 = 12;

void setup()
{
  pinMode(ledPin_0_a, OUTPUT);     
  pinMode(ledPin_0_b, OUTPUT);     
  pinMode(ledPin_0_c, OUTPUT);     
  pinMode(ledPin_0_d, OUTPUT);   
 
  pinMode(ledPin_1_a, OUTPUT);     
  pinMode(ledPin_1_b, OUTPUT);     
  pinMode(ledPin_1_c, OUTPUT);     
  pinMode(ledPin_1_d, OUTPUT);     
 
  pinMode(ledPin_a_1, OUTPUT);     
  pinMode(ledPin_a_2, OUTPUT);     
  pinMode(ledPin_a_3, OUTPUT);     
 
  // NOTE:
  // Grounding on virtual pins 14 and 15 (analog pins 0 and 1) will set the Hour and Mins.

  pinMode( 14, INPUT ); // set the vertual pin 14 (pin 0 on the analog inputs )
  digitalWrite(14, HIGH); // set pin 14 as a pull up resistor.

  pinMode( 15, INPUT ); // set the vertual pin 15 (pin 1 on the analog inputs )
  digitalWrite(15, HIGH); // set pin 15 as a pull up resistor.
 
}

void SetSN74141Chips( int num2, int num1 )

{
  int a,b,c,d;
 
  // set defaults.
  a=0;b=0;c=0;d=0; // will display a zero.
 
  // Load the a,b,c,d.. to send to the SN74141 IC (1)
  switch( num1 )
  {
    case 0: a=0;b=0;c=0;d=0;break;
    case 1: a=1;b=0;c=0;d=0;break;
    case 2: a=0;b=1;c=0;d=0;break;
    case 3: a=1;b=1;c=0;d=0;break;
    case 4: a=0;b=0;c=1;d=0;break;
    case 5: a=1;b=0;c=1;d=0;break;
    case 6: a=0;b=1;c=1;d=0;break;
    case 7: a=1;b=1;c=1;d=0;break;
    case 8: a=0;b=0;c=0;d=1;break;
    case 9: a=1;b=0;c=0;d=1;break;
    default: a=1;b=1;c=1;d=1;

    break;
  } 
 
  // Write to output pins.
  digitalWrite(ledPin_0_d, d);
  digitalWrite(ledPin_0_c, c);
  digitalWrite(ledPin_0_b, b);
  digitalWrite(ledPin_0_a, a);

  // Load the a,b,c,d.. to send to the SN74141 IC (2)
  switch( num2 )
  {
    case 0: a=0;b=0;c=0;d=0;break;
    case 1: a=1;b=0;c=0;d=0;break;
    case 2: a=0;b=1;c=0;d=0;break;
    case 3: a=1;b=1;c=0;d=0;break;
    case 4: a=0;b=0;c=1;d=0;break;
    case 5: a=1;b=0;c=1;d=0;break;
    case 6: a=0;b=1;c=1;d=0;break;
    case 7: a=1;b=1;c=1;d=0;break;
    case 8: a=0;b=0;c=0;d=1;break;
    case 9: a=1;b=0;c=0;d=1;break;
    default: a=1;b=1;c=1;d=1;

    break;
  }
 
  // Write to output pins
  digitalWrite(ledPin_1_d, d);
  digitalWrite(ledPin_1_c, c);
  digitalWrite(ledPin_1_b, b);
  digitalWrite(ledPin_1_a, a);
}

////////////////////////////////////////////////////////////////////////
//
// DisplayFadeNumberString

// Use: passing an array that is 4 elements long will display numbers
//      on a 4 nixie bulb setup.
//
////////////////////////////////////////////////////////////////////////
float fadeIn = 0.0;
float fadeOut = 8.0;
float fadeMax = 8.0;
float fadeStep = 0.3;  // tweak this to adjust speed of fade. Smaller number = slower fade
int NumberArray[4]={0,0,0,0};
int currNumberArray[6]={0,0,0,0,0,0};
float NumberArrayFadeInValue[6]={fadeIn,fadeIn,fadeIn,fadeIn,fadeIn,fadeIn};
float NumberArrayFadeOutValue[6]={fadeOut,fadeOut,fadeOut,fadeOut,fadeOut,fadeOut,};

void DisplayFadeNumberString()
{
  // Nixie setup..
 
  // NOTE: If any of the bulbs need to blend then it will
  // be in time with the seconds bulbs. because any change only happens
  // on a one second interval.
 
  // 1 (0,3)
  SetSN74141Chips(currNumberArray[0],currNumberArray[3]);   
  digitalWrite(ledPin_a_1, HIGH);   
  delay(NumberArrayFadeOutValue[0]);
  SetSN74141Chips(NumberArray[0],NumberArray[3]);   
  delay(NumberArrayFadeInValue[0]);
  digitalWrite(ledPin_a_1, LOW);
 
  // 2 (1,2)
  SetSN74141Chips(currNumberArray[1],currNumberArray[2]);   
  digitalWrite(ledPin_a_2, HIGH);   
  delay(NumberArrayFadeOutValue[1]);
  SetSN74141Chips(NumberArray[1],NumberArray[2]);   
  delay(NumberArrayFadeInValue[1]);
  digitalWrite(ledPin_a_2, LOW);

  // 3 (4,5)
  SetSN74141Chips(currNumberArray[4],currNumberArray[5]);   
  digitalWrite(ledPin_a_3, HIGH);   
  delay(NumberArrayFadeOutValue[1]);
  SetSN74141Chips(NumberArray[4],NumberArray[5]);   
  delay(NumberArrayFadeInValue[1]);
  digitalWrite(ledPin_a_3, LOW);
 
 
  // Loop thru and update all the arrays, and fades.
  for( int i = 0 ; i < 6 ; i ++ )
  {
    if( NumberArray[i] != currNumberArray[i] )
    {
      NumberArrayFadeInValue[i] += fadeStep;
      NumberArrayFadeOutValue[i] -= fadeStep;
 
      if( NumberArrayFadeInValue[i] >= fadeMax )
      {
        NumberArrayFadeInValue[i] = 0.0f;
        NumberArrayFadeOutValue[i] = fadeMax;
        currNumberArray[i] = NumberArray[i];

      }
    }
  } 
}

// Defines
long MINS = 60;         // 60 Seconds in a Min.
long HOURS = 60 * MINS; // 60 Mins in an hour.
long DAYS = 24 * HOURS; // 24 Hours in a day. > Note: change the 24 to a 12 for non millitary time.


long runTime = 0;       // Time from when we started.

// default time sets. clock will start at 12:59:00
long clockHourSet = 12;
long clockMinSet  = 59;


int HourButtonPressed = false;
int MinButtonPressed = false;

////////////////////////////////////////////////////////////////////////
//
//
////////////////////////////////////////////////////////////////////////
void loop()     
{
  // Get milliseconds.
  runTime = millis();
 
  int hourInput = digitalRead(14); 
  int minInput  = digitalRead(15);

  if( hourInput == 0 )
    HourButtonPressed = true;
  if( minInput == 0 )
    MinButtonPressed = true;
 
  if( HourButtonPressed == true && hourInput == 1 )
  {
    clockHourSet++;
    HourButtonPressed = false;
  }
 
  if( MinButtonPressed == true && minInput == 1 )
  {
    clockMinSet++;
    MinButtonPressed = false;
  }

  // Get time in seconds.
  long time = (runTime) / 1000;
 
  // Set time based on offset..
  // long hbump = 60*60*clockHourSet;
  long hbump = 60*60*clockHourSet;
  long mbump = 60*clockMinSet;
  time += mbump + hbump;

  // Convert time to days,hours,mins,seconds
  long days  = time / DAYS;    time -= days  * DAYS;
  long hours = time / HOURS;   time -= hours * HOURS;
  long minutes  = time / MINS;    time -= minutes  * MINS;
  long seconds  = time;

  // Get the high and low order values for hours,min,seconds.
  int lowerHours = hours % 10;
  int upperHours = hours - lowerHours;
  int lowerMins = minutes % 10;
  int upperMins = minutes - lowerMins;
  int lowerSeconds = seconds % 10;
  int upperSeconds = seconds - lowerSeconds;
  if( upperSeconds >= 10 )   upperSeconds = upperSeconds / 10;
  if( upperMins >= 10 )      upperMins = upperMins / 10;
  if( upperHours >= 10 )     upperHours = upperHours / 10;

  // Fill in the Number array used to display on the tubes.
  NumberArray[3] = upperMins;
  NumberArray[2] = lowerMins;
  NumberArray[1] = upperSeconds;
  NumberArray[0] = lowerSeconds;

  // Display.
  DisplayFadeNumberString();
}

Any help would be appreciated.
3  Projects / ArduiNIX / Re: Sample 6 Bulb Hookup Diagram on: April 22, 2010, 10:21:44 pm
This is the layout I used for my clock. I had to change this in the code:

Code:
  int NumberArray[6]={0,0,0,0,0,0};
  NumberArray[2] = upperHours;
  NumberArray[4] = lowerHours;
  NumberArray[0] = upperMins;
  NumberArray[5] = lowerMins;
  NumberArray[1] = upperSeconds;
  NumberArray[3] = lowerSeconds;
4  Projects / ArduiNIX / Re: IN-17 Bulb CrossFade Code Example. on: March 31, 2010, 09:47:35 pm
Been trying to get this to work with no luck. Using the code straight from here only lights up 2 bulbs and they flicker a lot.

I tried adding the code you changed to the old code and it pretty much does the same thing, not sure - I'm not a coder Smiley

In the original code I had, I needed to change two things to get my digits to work correctly:

Code:
// SN74141 (1)
int ledPin_0_a = 2;                
int ledPin_0_b = 3;
int ledPin_0_c = 4;
int ledPin_0_d = 5;
// SN74141 (2)
int ledPin_1_a = 6;                
int ledPin_1_b = 7;
int ledPin_1_c = 8;
int ledPin_1_d = 9;

// anod pins
int ledPin_a_1 = 10;
int ledPin_a_2 = 11;
int ledPin_a_3 = 12;


and


Code:
 int NumberArray[6]={0,0,0,0,0,0};
  NumberArray[2] = upperHours;
  NumberArray[4] = lowerHours;
  NumberArray[0] = upperMins;
  NumberArray[5] = lowerMins;
  NumberArray[1] = upperSeconds;
  NumberArray[3] = lowerSeconds;
5  Projects / ArduiNIX / Re: Starting my build soon - few questions on: March 11, 2010, 01:03:26 pm
Thought I would post an update.

Here is my enclosure: pretty much finished.






I went out to my local radioshack and bought a bunch of switches/toggles for the alarm section. I'm not very good with coding, or the arduino, but I think I can get most of it working. Just a couple gray areas I have no idea how to get going.

Emblazed, would you be willing to help me out on here, or via email? I can post what I have figured out thus far.
6  Projects / ArduiNIX / Re: Suggestions for Ribbon Cables and Connectors on: March 08, 2010, 08:58:55 am
I ordered a set of those dupont connectors, they work great for a few connections but they don't do very well fitting 20 or so connections side by side on the cathode pins. You could probably make it work by shaving a little of the sides of them, but it still might be tight.

I ended up using a very heavily modified IDE cable for my clock.
7  Projects / ArduiNIX / Re: Troubleshooting on: March 07, 2010, 07:55:11 am
Yeah, good idea. I tested continuity between pins 2 and 5 and what do you know, the meter lit up. What a headache Smiley
8  Projects / ArduiNIX / Troubleshooting on: March 05, 2010, 10:23:34 pm
I'm not sure if I have a bad tube or something is messed up in the wiring or one of the chips. I have one tube that will always display the digit 2 and 5 at the same time no matter what socket it's in. If I plug it into another socket, other tubes will start doing the same thing. If that tube is left out, all the other ones work great.

I thought about using it for the first digit for the hours so it would only display 0 and 1, but doing that, it makes some of the other tubes display 2 and 5 at the same time. I guess I don't really understand how this could happen even if the tube was bad, how it would "short" out other tubes.

Thought maybe someone else has run into this before?
9  Projects / ArduiNIX / Re: Starting my build soon - few questions on: February 10, 2010, 07:21:16 pm
Some more updates

Three down, three more to go.


So many wires!


my "workstation"
10  Projects / ArduiNIX / Re: Starting my build soon - few questions on: February 09, 2010, 11:30:09 pm
Here is what I have so far:

Laying out all the parts:




Beginning to solder the board up:


Almost done:


Yay!



Now that I know it works, time to wire all 6 up and start designing some sort of enclosure for it.

Not the greatest work in the world, but this is my first time soldering a board up like this. Not shown is the transistor I put on backward and had a hell of a time getting back off! Smiley
11  Projects / ArduiNIX / Starting my build soon - few questions on: February 05, 2010, 07:02:18 pm
I just ordered all the parts needed to make my nixie clock, pretty excited. I'm still very much in the learning stage (with electronics and the arduino) but this should be a pretty fun build.

There are two things I would like to add to my build and if possible, maybe someone could help me out with this.

The first thing I want to add is crossfade between the tubes (I will be using six of the SZ-8s) as seen here:
http://www.youtube.com/watch?v=Xo2KDvvWuFY

The second would be a tad more difficult. I haven't put the kit together yet but I am hoping there are enough ports left open to add an alarm clock function. One button to view/set the alarm. Two buttons to change hour/min. One switch to turn the whole function on and off, possibly a snooze function as well. To those who know about this than I do: is this feasible? I think it would add a ton of 'actual' functionality to it other than being a pretty $150 clock.

Edit: The more I think about it, a dimmer would be pretty nice too for bedroom use, not sure if that's possible though.
Pages: [1]