#define LATCH 10#define CLOCK 13#define DATA 11#define PWM 9
void setup(){ pinMode(LATCH, OUTPUT); // Latch is pin 10, FALLING edge copies shift register to latches pinMode(CLOCK, OUTPUT); // Clock is pin 13, FALLING edge clocks in a bit from DATA pinMode(DATA, OUTPUT); // Data is pin 11 pinMode(PWM, OUTPUT); // PWM (Blank) is pin 9
digitalWrite(LATCH, HIGH); digitalWrite(CLOCK, HIGH); digitalWrite(DATA, HIGH); digitalWrite(PWM, HIGH);
delay(10); BlankDisplay(); LightDisplay();}
void BlankDisplay(){ // Disconnect shift register from data latches: digitalWrite(LATCH, LOW);
// Set the data to LOW digitalWrite (DATA, LOW); // Clock in the LOW 128 times for (uint8_t i = 0; i < 128; i++) { digitalWrite(CLOCK, LOW); // Clock in one data bit digitalWrite(CLOCK, HIGH); digitalWrite(LATCH, HIGH); // Bring the latch high to copy the shift registers to output latches
}}
void LightDisplay(){ // Disconnect shift register from data latches: digitalWrite(LATCH, LOW);
// Set the data to LOW digitalWrite (DATA, HIGH); // Clock in the LOW 128 times for (uint8_t i = 0; i < 128; i++) { digitalWrite(CLOCK, LOW); // Clock in one data bit digitalWrite(CLOCK, HIGH); digitalWrite(LATCH, HIGH); // Bring the latch high to copy the shift registers to output latches
delay(20); // Slow this step down by 20ms so we can see each output turning on
}}
void loop() {//nothing}
#define PIN_LE 10 //Shift Register Latch Enable#define PIN_CLK 13 //Shift Register Clock#define PIN_DATA 11 //Shift Register Data#define PIN_BL 9 //Shift Register Blank (0=display off 1=display on)
// lookup tables for the high and low value of mins/sec to determine// which number needs to be displayed on each of the minutes and seconds tubes// e.g. if the clock is to diplay 26 minutes then it // will look up the values at the 26th position and display a 2 on the high mins tube and a 6 on the low mins tubeconst byte minsec_high[]= {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,11};const byte minsec_low[] = {0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,11};
// shift register positions// --------------------------HV5530 #1--------------------------// Controls 9 Dots (One cathode each), Plus/Minus tube (2 cathodes), One 10 digit tube (10 cathodes)
// Dots are first// Dot 1 2 3 4 5 6 7 8 9int dots[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
//HV5530 #1 Pin 10 (HVOUT20) is not used
// Plus/minus tube + -int plusminus[] = {11, 12};
// Rightmost numeric tube (Tube 1)// Digit 0 1 2 3 4 5 6 7 8 9// NL840 Pin # 13 5 7 10 6 2 8 1 3 9 int tube1[] = {16, 17, 19, 22, 18, 14, 20, 13, 15, 21}; //Pins 35-44 (HVOUT1 - HVOUT10) are not used
// --------------------------HV5530 #2,3,4--------------------------//HV5530#2,3,4 each control three (3) numeric tubes each (10 cathodes each, 30 cathodes total)//Connections are similarly numbered between each set of tubes and HV chip for chips 2,3,4//Pins 21 and 22 (HVOUT31 and HVOUT32) are not used
// Next 3 tubes from right to left (Tubes 2,3,4)// Digit 0 1 2 3 4 5 6 7 8 9// NL840 Pin # 13 5 7 10 6 2 8 1 3 9 int tube2[] = {16, 17, 19, 22, 18, 14, 20, 13, 15, 21}; int tube3[] = {4, 5, 7, 10, 6, 2, 8, 1, 3, 9}; int tube4[] = {41, 40, 38, 35, 39, 43, 37, 44, 42, 36};
// Digit 0 1 2 3 4 5 6 7 8 9// NL840 Pin # 13 5 7 10 6 2 8 1 3 9 int tube5[] = {16, 17, 19, 22, 18, 14, 20, 13, 15, 21}; int tube6[] = {4, 5, 7, 10, 6, 2, 8, 1, 3, 9}; int tube7[] = {41, 40, 38, 35, 39, 43, 37, 44, 42, 36};
// Digit 0 1 2 3 4 5 6 7 8 9// NL840 Pin # 13 5 7 10 6 2 8 1 3 9 int tube8[] = {16, 17, 19, 22, 18, 14, 20, 13, 15, 21}; int tube9[] = {4, 5, 7, 10, 6, 2, 8, 1, 3, 9}; int tube10[] = {41, 40, 38, 35, 39, 43, 37, 44, 42, 36};
void setup() {
pinMode(PIN_LE, OUTPUT); pinMode(PIN_BL, OUTPUT); pinMode(PIN_DATA,OUTPUT); pinMode(PIN_CLK, OUTPUT);
digitalWrite(PIN_BL, LOW);
Serial.begin(115200);
}
unsigned long previousSRMillis = 0; // keeping track last time shift register values were clocked in
void loop() {
delay(100);digitalWrite(PIN_BL, HIGH);
unsigned long currentMillis = millis(); if (currentMillis - previousSRMillis >= 1000) { // clocking in 1 times a second previousSRMillis = currentMillis;
boolean srBuffer[128] = {0};
// time_t now;// struct tm * timeinfo;// time(&now);// timeinfo = localtime(&now);
int seconds1 = 1; int seconds2 = 2; int seconds3 = 3; int seconds4 = 4; int seconds5 = 5; int seconds6 = 6; int seconds7 = 7; int seconds8 = 8; int seconds9 = 9; int seconds10 = 10;
// doing the lookups for what number to display then // looking up which shift register position // for each tube // "10" from the lookup table indicates to blank the tube since it is out of range. srBuffer[dots[minsec_low[1]] - 1] = 1; srBuffer[plusminus[minsec_low[1]] - 1] = 1; srBuffer[tube1[minsec_low[seconds1]] - 1] = 1; srBuffer[tube2[minsec_low[seconds2]] - 1] = 1; srBuffer[tube3[minsec_low[seconds3]] - 1] = 1; srBuffer[tube4[minsec_low[seconds4]] - 1] = 1; srBuffer[tube5[minsec_low[seconds5]] - 1] = 1; srBuffer[tube6[minsec_low[seconds6]] - 1] = 1; srBuffer[tube7[minsec_low[seconds7]] - 1] = 1; srBuffer[tube8[minsec_low[seconds8]] - 1] = 1; srBuffer[tube9[minsec_low[seconds9]] - 1] = 1; srBuffer[tube10[minsec_low[seconds10]] - 1] = 1;
//// srBuffer[10 - 1] = 1; // tube 2 decimal point// srBuffer[52 - 1] = 1; // tube 5 decimal point
digitalWrite(PIN_LE, LOW);
for(int i = 127;i >= 0;i--){ digitalWrite(PIN_DATA,srBuffer[i]); digitalWrite(PIN_CLK,HIGH); delayMicroseconds(5); digitalWrite(PIN_CLK,LOW); delayMicroseconds(5);
}
digitalWrite(PIN_LE, HIGH); }
}
#define PIN_LE 10 //Shift Register Latch Enable#define PIN_CLK 13 //Shift Register Clock#define PIN_DATA 11 //Shift Register Data#define PIN_BL 9 //Shift Register Blank (0=display off 1=display on)
// shift register positions// --------------------------HV5530 #1--------------------------// Controls 9 Dots (One cathode each), Plus/Minus tube (2 cathodes), One 10 digit tube (10 cathodes)
// Dots are first// Dot 1 2 3 4 5 6 7 8 9
int dots[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
//HV5530 #1 Pin 10 (HVOUT20) is not used
//Bit 9 not usedint blank1[] = {9};
// Plus/minus tube + -
int plusminus[] = {10, 11};
// Rightmost numeric tube (Tube 1)// Digit 0 1 2 3 4 5 6 7 8 9// NL840 Pin # 13 5 7 10 6 2 8 1 3 9
int tube1[] = {15, 16, 18, 21, 17, 13, 19, 12, 14, 20};
//Pins 35-44 (HVOUT1 - HVOUT10) are not used
int blank2[] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
// --------------------------HV5530 #2,3,4--------------------------//HV5530#2,3,4 each control three (3) numeric tubes each (10 cathodes each, 30 cathodes total)//Connections are similarly numbered between each set of tubes and HV chip for chips 2,3,4//Pins 21 and 22 (HVOUT31 and HVOUT32) are not used
// Next 3 tubes from right to left (Tubes 2,3,4)// Digit 0 1 2 3 4 5 6 7 8 9// NL840 Pin # 13 5 7 10 6 2 8 1 3 9
int tube2[] = {35, 36, 38, 41, 37, 33, 39, 32, 34, 40};int tube3[] = {45, 46, 48, 51, 47, 43, 49, 42, 44, 50}; int blank3[] = {52 , 53};int tube4[] = {57, 58, 60, 63, 59, 55, 61, 54, 56, 62};
// Digit 0 1 2 3 4 5 6 7 8 9// NL840 Pin # 13 5 7 10 6 2 8 1 3 9
int tube5[] = {67, 68, 70, 73, 69, 65, 71, 64, 66, 72};int tube6[] = {77, 78, 80, 83, 79, 75, 81, 74, 76, 82};int blank4[] = {84 , 85};int tube7[] = {89, 90, 92, 95, 91, 87, 93, 86, 88, 94};
// Digit 0 1 2 3 4 5 6 7 8 9// NL840 Pin # 13 5 7 10 6 2 8 1 3 9
int tube8[] = {99,100,102,105,101,97,103,96,98,104};int tube9[] = {109,110,112,115,111,107,113,106,108,114}; int blank5[] = {116 , 117};int tube10[] = {121,122,124,127,123,119,125,118,120,126};
void setup() { pinMode(PIN_LE, OUTPUT); pinMode(PIN_BL, OUTPUT); pinMode(PIN_DATA,OUTPUT); pinMode(PIN_CLK, OUTPUT);
digitalWrite(PIN_BL, HIGH); BlankDisplay();
}
unsigned long previousSRMillis = 0; // keeping track last time shift register values were clocked in
void loop() {
boolean srBuffer[128] = {0};
unsigned long currentMillis = millis();
if (currentMillis - previousSRMillis >= 250) { // clocking in 4 times a second
previousSRMillis = currentMillis;
boolean srBuffer[128] = {0};
// doing the lookups for what number to display then // looking up which shift register position // for each tube // "10" from the lookup table indicates to blank the tube since it is out of range.
srBuffer[dots[1]] = 1; //light up dot 1 srBuffer[blank1[1]] = 0; //unused output on HV5530 #1 (pin 10) srBuffer[plusminus[1]] = 1; //light up plus srBuffer[tube1[1]] = 1; //light up number 1 on tube 1 srBuffer[blank2[1,2,3,4,5,6,7,8,9,10]] = 0; //unused outputs on HV5530 #1 (pins 35-44) srBuffer[tube2[2]] = 1; //light up number 2 on tube 2 srBuffer[tube3[1]] = 1; //light up number 1 on tube 3 srBuffer[blank3[1,2]] = 0; //unused outputs on HV5530 #2 (pins 21-22) srBuffer[tube4[2]] = 1; //light up number 2 on tube 4 srBuffer[tube5[1]] = 1; //light up number 1 on tube 5 srBuffer[tube6[2]] = 1; //light up number 2 on tube 6 srBuffer[blank4[1,2]] = 0; //unused outputs on HV5530 #3 (pins 21-22) srBuffer[tube7[1]] = 1; //light up number 1 on tube 7 srBuffer[tube8[2]] = 1; //light up number 2 on tube 8 srBuffer[tube9[1]] = 1; //light up number 1 on tube 9 srBuffer[blank5[1,2]] = 0; //unused outputs on HV5530 #4 (pins 21-22) srBuffer[tube10[2]] = 1; //light up number 2 on tube 10
digitalWrite(PIN_LE, LOW);
for(int i = 0; i < 128; i++){
digitalWrite(PIN_DATA,srBuffer[i]); digitalWrite(PIN_CLK,HIGH); delayMicroseconds(5); digitalWrite(PIN_CLK,LOW); delayMicroseconds(5); }
digitalWrite(PIN_LE, HIGH); }
}
void BlankDisplay(){ // Disconnect shift register from data latches:
digitalWrite(PIN_LE, LOW);
// Set the data to LOW
digitalWrite (PIN_DATA, LOW);
// Clock in the LOW 128 times for (uint8_t i = 0; i < 128; i++) {
digitalWrite(PIN_CLK, LOW); // Clock in one data bit digitalWrite(PIN_CLK, HIGH); }}
void digitalWrite(uint8_t pin, uint8_t val) { uint8_t timer = digitalPinToTimer(pin); uint8_t bit = digitalPinToBitMask(pin); uint8_t port = digitalPinToPort(pin); volatile uint8_t *out; if (port == NOT_A_PIN) return; // If the pin that support PWM output, we need to turn it off // before doing a digital write. if (timer != NOT_ON_TIMER) turnOffPWM(timer); out = portOutputRegister(port); uint8_t oldSREG = SREG; cli(); if (val == LOW) { *out &= ~bit; } else { *out |= bit; } SREG = oldSREG; }
#define DATA PD5 //define Dataline #define CLK PD7 //define clockline
#define OE 6 //define latch pin
#define thePort PORTD //define Hardware port where Shift-Registers are connected
void setOutputs(unsigned long val_one, unsigned long val_two) { //Function to shift out 2 x 32bit fast enough to prevent flicker!
// ------------WARNING!--------------------
// This functions operates directly on ports, not via digitalWrite()
// because digitalWrite() would be to slow, and display would flicker
// if different pins are used, you maybe hav to change the variable "thePort"
// to the matching I/O port letter of the controller!
digitalWrite(OE, LOW); //Disable Outputs to prevent flicker
//Send first 32-bit variable value
for (int i = 0; i < 32; i++) {
thePort &= ~_BV(DATA); //Data LOW
if ( bitRead(val_one, i) == 1) {
thePort |= _BV(DATA); //Data HIGH
}
thePort |= _BV(CLK); //CLK HIGH
thePort &= ~_BV(CLK); //CLK LOW
}
//Send second 32-bit variable value
for (int i = 0; i < 32; i++) {
thePort &= ~_BV(DATA); //Data LOW
if ( bitRead(val_two, i) == 1) {
thePort |= _BV(DATA); //Data HIGH
}
thePort |= _BV(CLK); //CLK HIGH
thePort &= ~_BV(CLK); //CLK LOW
}
digitalWrite(OE, HIGH); //Enable Outputs }
;--- shift out display buffer
;--
shift_out: _init_z _disp_buff ; point to primary buffer
ldi ii,DISP_BUFF_SIZE ; how many bytes to clock out
shift_out_lpt: ldi temp2,8 ; bit counter, 8 bits in a byte
ld temp,z+ ; get the byte of data
shift_out_lp: cbi DOUT_PORT,DOUT ; assume zero bit
rol temp ; move data bit to carry
brcc pc + 2
sbi DOUT_PORT,DOUT
cbi clk_port,CLK
sbi clk_port,CLK ; blip clock line
dec temp2 ; done yet?
brne shift_out_lp
dec ii
brne shift_out_lpt
// _LATCH_DATA
sbi latch_port,latch
cbi latch_port,latch
ret
--
You received this message because you are subscribed to the Google Groups "neonixie-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neonixie-l+...@googlegroups.com.
To post to this group, send email to neoni...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/neonixie-l/7a03013b-823e-4e95-a8d3-792dac750c1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Bill