Go Down

Topic: Nixie tube speedometer code. (Read 1 time) previous topic - next topic

BrockLee

Jun 10, 2010, 06:17 am Last Edit: Jun 10, 2010, 08:09 am by BrockLee Reason: 1
So I'm building a Nixie tube speedometer for my motorcycle. Arduino polls a variable reluctance sensor, does some math and writes to 2 Nixie tubes.
I have the Nixie driver and power supply circuits built and have control of the digits. Here is some test code that just counts up to 99.

Code: [Select]
int dataPin = 11;
int clockPin = 12;
int latchPin = 8;
byte dataArray[100];
byte nixie;


void setup() {
 pinMode(dataPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 pinMode(latchPin, OUTPUT);
 
 dataArray[0] = 0;
 dataArray[1] = 4;
 dataArray[2] = 2;
 dataArray[3] = 6;
 dataArray[4] = 1;
 dataArray[5] = 5;
 dataArray[6] = 3;
 dataArray[7] = 7;
 dataArray[8] = 128;
 dataArray[9] = 132;
 dataArray[10] = 64;
 dataArray[11] = 68;
 dataArray[12] = 66;
 dataArray[13] = 70;
 dataArray[14] = 65;
 dataArray[15] = 69;
 dataArray[16] = 67;
 dataArray[17] = 71;
 dataArray[18] = 192;
 dataArray[19] = 196;
 dataArray[20] = 32;
 dataArray[21] = 36;
 dataArray[22] = 34;
 dataArray[23] = 38;
 dataArray[24] = 33;
 dataArray[25] = 37;
 dataArray[26] = 35;
 dataArray[27] = 39;
 dataArray[28] = 160;
 dataArray[29] = 164;
 dataArray[30] = 96;
 dataArray[31] = 100;
 dataArray[32] = 98;
 dataArray[33] = 102;
 dataArray[34] = 97;
 dataArray[35] = 101;
 dataArray[36] = 99;
 dataArray[37] = 103;
 dataArray[38] = 224;
 dataArray[39] = 228;
 dataArray[40] = 16;
 dataArray[41] = 20;
 dataArray[42] = 18;
 dataArray[43] = 22;
 dataArray[44] = 17;
 dataArray[45] = 21;
 dataArray[46] = 19;
 dataArray[47] = 23;
 dataArray[48] = 144;
 dataArray[49] = 148;
 dataArray[50] = 80;
 dataArray[51] = 84;
 dataArray[52] = 82;
 dataArray[53] = 86;
 dataArray[54] = 81;
 dataArray[55] = 85;
 dataArray[56] = 83;
 dataArray[57] = 87;
 dataArray[58] = 208;
 dataArray[59] = 212;
 dataArray[60] = 48;
 dataArray[61] = 52;
 dataArray[62] = 50;
 dataArray[63] = 54;
 dataArray[64] = 49;
 dataArray[65] = 53;
 dataArray[66] = 51;
 dataArray[67] = 55;
 dataArray[68] = 176;
 dataArray[69] = 180;
 dataArray[70] = 112;
 dataArray[71] = 116;
 dataArray[72] = 114;
 dataArray[73] = 118;
 dataArray[74] = 113;
 dataArray[75] = 117;
 dataArray[76] = 115;
 dataArray[77] = 119;
 dataArray[78] = 240;
 dataArray[79] = 244;
 dataArray[80] = 8;
 dataArray[81] = 12;
 dataArray[82] = 10;
 dataArray[83] = 14;
 dataArray[84] = 9;
 dataArray[85] = 13;
 dataArray[86] = 11;
 dataArray[87] = 15;
 dataArray[88] = 136;
 dataArray[89] = 140;
 dataArray[90] = 72;
 dataArray[91] = 76;
 dataArray[92] = 74;
 dataArray[93] = 78;
 dataArray[94] = 73;
 dataArray[95] = 77;
 dataArray[96] = 75;
 dataArray[97] = 79;
 dataArray[98] = 200;
 dataArray[99] = 204;
}

void loop() {
 for (int d = 0; d < 100; d++) {
   nixie = dataArray[d];
 digitalWrite(latchPin, LOW);
 shiftOut(dataPin, clockPin, LSBFIRST, nixie);
 digitalWrite(latchPin, HIGH);
 delay(100);
 }
}


This works fine.

I also built an Lm1815n-based circuit to convert the analog VR sensor output to an Arduino-friendly gated digital signal. This also works fine (tested it with state change detection on serial monitor).

My question is; how do I scale the VR output pulses to the Nixie digits?

At 1mph the VR sensor will output 7.6 pulses per second (not worried about the decimal, doesn't have to be very accurate yet) and at 100mph it will output 762 pulses per second.

I imagine that it would be somewhat similar to say, scaling a pot for use with a servo but this method doesn't take time into account.

I should add that I'm not addressing the Nixie digits directly. I'm using an 8 bit SIPO shift register that shifts out to 2 nte74141 Nixie decoders.

Anybody know how to do this?
Thanks in advance.

BrockLee

#1
Jun 10, 2010, 07:48 am Last Edit: Jun 10, 2010, 07:51 am by BrockLee Reason: 1
The seemingly random #s are sort of irrelevant to my question. I'm using an 8 bit SIPO shift register and some nte74141 Nixie driver ic's to address each digit of the Nixies. It's a consequence of how everything is wired and the way the nte74141's decode the parallel data coming from the shift register. For example, if I shiftout a B01000000, The Nixies display a 10 instead of a 64. Sorry, should have been more clear about that.

As far as the code to read the VR sensor, I don't have any yet b/c, well I don't know where to start.

Somehow I need to ++ and -- the Nixie digits (dataArray[0] through dataArray[99]) in concert with changes in frequency of the VR pulses.

BrockLee

Hmm, didn't see any in the regular IDE examples (0017). I'll go check at the playground. Thanks.

Grumpy_Mike

If you haven't found it yet then Fscale is what you are after:-
http://www.arduino.cc/playground/Main/Fscale

AWOL

Can I suggest:
Code: [Select]
const byte dataArray[100] = { 0,  4,  2,  6,  1,  5,  3,  7, 128, 132,
                      64, 68, 66, 70, 65, 69, 67, 71, 192, 196,
// etc.
?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

BrockLee

Ah ha! I knew there was a better way to do that. Thanks!

Go Up