"Bulletproof" Shift-out timing?

Hello

For my next project, based on a multi digit vaccum tube, i need a multiplex drive with Shift-Register (similar to 595 types). The timing is very important to the life of the tube. The Controller will be a Atmega168

The operation will be like this

  • shift out 4 bytes of data (4 registers)
  • wait 200uS
  • shift out 4 bytes of zeros
  • wait 50us

this has to be done 14 times, since the tube has 14 digits.

Now my question is, how can i implement this in my code, and be absolutely sure that nothing will change the timing? Sure, avoid using delay(), but what if some things take longer? Or libraries have functions that cause delay?

Is there something like a interrupt based on time?

Or would it be even a better choice, to attach a Attiny via I2C, which will recieve only the data and do the shifting, while the atmega168 does all the other stuff?

Pls post your current code - whatever you have already.
And: have your code placed within code tags “</>”

rpt007:
Pls post your current code - whatever you have already.
And: have your code placed within code tags “</>”

Sorry i have no code yet, it was a general question how i should start with it.

Yes, look up timer interrupt.

sgt_johnny:
multi digit vaccum tube

I assume you mean Nixies? Or a VFD?

Then timing might be imported but I can't see a reason it absolutely critical. And if you think it is, just show us the components and a diagram. Both ways, we can learn from each other :wink:

More parameters are needed in order to properly comment on this.
You have said that timing is important, but have not stated in what way.
What part of the timing is critical?
You offered nothing with respect to the timing of the shifting out of the bytes (data or zeros)
And no guidance as to the needed accuracy of the other two delays.
Must the delays be at least that long, no longer that that amount, or within some tolerance?

And then given you are talking about using something like a 595 shift register, there are other questions
like how/when is the shifted data presented on the output pins?

There are many ways to use a shift register. Some require using a latch signal after all the data is shifted in, some allow the shifting bits to flow through "live" as the shift operation is being done.
And sometimes the system may use or depend on using a clear signal to clear out the shift register after each operation. Some use external logic to clear the part, and some use an unused output bit to perform a clear.

How the shift register is used depends on the overall system design but it can affect the needed timing and s/w design.

For example, if there is a latch signal required, what is the needed timing of that with respect to the two delays specified?

So at least for me, I have many questions.

I don't know anything about tube types displays, but if this a ground up design, it might be very helpful to get some background information on the overall circuit needs to make sure we are not stepping down into a XY problem.
i.e. if we knew more about how they worked, it would clarify many things and potentially allow another alternative design that might be easier or simpler to implement.

--- bill

Hello!

Sorry for providing to few info! Here is more

The used IC's are HV513, Smart | Connected | Secure | Microchip Technology

CLK is Clock,
DIN is data
and LE is "transfer data to outputs"

So basically you shift out the data, and then set LE high to actually change the outputs.
The only special thing is, that the data has to be present before the clock goes high ,but that's not really a problem, the shift-out code is easy :slight_smile:

The tube is a special nixie tube, right. Time is critical, since the individual digits are driven by a specified current, which is calculated for the on time, if the digits would stay longer on which would result in over current. Over current does not destroy the tube, but degrades its life time.

Rated current is 5mA for an impulse duration of 150us.

The 50us "pause" time, is not really critical, its only to prevent visual ghosting. The "on" time of 150-200us is the critical one. Here

I have not written the code yet, but it will include a rotary encoder (which uses "timerOne" libary), Wire.library, and library from Adafruit to control WS2812 LED's. I don't know exactly what those libraries do, but i fear that some of them will use functions that create delays in execution of the code.

sgt_johnny:
but what if some things take longer? Or libraries have functions that cause delay?

You will need to test your code and not use libraries that cause problems.

Maybe you should actually create a blocking function to update the digits with interrupts off - that puts you in complete control of timing. Or maybe you could allow interrupts during the loner 200µs interval.

I assume there will be a much longer non-critical interval between successive updates of the display.

...R

Do you have SPI available? The HV513 looks compatible with SPI. With this, you can set the clock rate and mode ... timing will not be influenced by other code.

SPI HV513


CLK CLK
MOSI DIN
CS LE

What will happen to the tube when the Arduino is just starting up, and cannot execute any code for some time?

I'd think that you should use the BL (blanking) line of the HV513 to switch the output between data and all zeroes, at the required timing. Then your code must shift out the data only once, e.g. using SPI, the rest is done by the HV513.

The BL line can be driven by an external oscillator, or from a timer using e.g. Fast PWM mode. This may require some low level code, to initialize all related timer/counter registers. Try to understand how to program a timer for the required waveform, write and test according code, using e.g. a scope. This can be all done without an attached display. If the BL timing is okay, attach the tube and send it whatever data you like.

The entire project may become quite expensive, if you don't have the required electronic and programming skills :-]

DrDiettrich:
What will happen to the tube when the Arduino is just starting up, and cannot execute any code for some time?

The entire project may become quite expensive, if you don’t have the required electronic and programming skills :-]

The tube will not do anything, because the code has to activate the power supply. For the first display after boot-up, i would set all outputs to desired state, and then turn on the power for the tube…

And about costs… compared to the price of the tube, it can’t be that expensive :'D

By the way, here’s finally a image of the tube! "http://www2.pic-upload.de/img/30725625/Nixie_1.jpg

dlloyd:
Do you have SPI available? The HV513 looks compatible with SPI. With this, you can set the clock rate and mode … timing will not be influenced by other code.

SPI HV513


CLK CLK
MOSI DIN
CS LE

Thanks, that really could work

so… CLK ? Would that be SCK on a Uno bord?
and CS is SS? or do i get it wrong?

I never heard that Nixies will die on wrong timing. They work pretty well on DC. At least 50 years ago, when I used some in my first computer display.

And yes, CLK is SCK. LE may work with SS, or with a pulse after the transmission. See pg. 6 of the HV513 data sheet.

DrDiettrich:
I never heard that Nixies will die on wrong timing.

These is special, and if they stay longer on, the current will be higher which will decrease life. And it doesn't hurt to be a little over protective

Hi,
the OP image.

Do you have a link to the spec sheet and/or suggested driver circuit?

Thanks .. Tom.. :slight_smile:

According to the many digits and few pins I'd think that the display is multiplexed. This would make sense with the timing, 200µs to fire a digit, 50µs to extinct it. Then a timer can be used to provide the pulse train for LE and BL, and data transfer is done in the ISR. Do the SPI routines work in an ISR?

DrDiettrich:
According to the many digits and few pins I'd think that the display is multiplexed. This would make sense with the timing, 200µs to fire a digit, 50µs to extinct it. Then a timer can be used to provide the pulse train for LE and BL, and data transfer is done in the ISR. Do the SPI routines work in an ISR?

BL is not needed in my application. Only LE

I'm now playing around with SPI, maybe there is a way to change the clock that the data is present before the clock goes high.

sgt_johnny:
I'm now playing around with SPI, maybe there is a way to change the clock that the data is present before the clock goes high.

What you're describing is SPI mode 3. This is a good link that describes SPI timing.

SPI.setDataMode(SPI_MODE3);

Note: for SS, do not use pin 10 as it will be normally high and controlled by the SPI driver. Pick another unused pin and have it default low (normally low). Pulse it low-high-low after the SPI transfer to the shift register. This will transfer data from the shift register to the latch.

I made a few experiments today, and i think that SPI_MODE0 is the right one.

i send the following value 10010101 (0x95)

And got this result:

Yellow = CLK
Blue = DATA

The first state of data (a 1) is present before clock goes high.

Buenos días. Soy nueva en esto de programar en Arduino y no sé mucho.
Alguien me podría ayudar con un código para que un botón me prenda o apague la pantalla NOKIA 5110.
Muchas gracias.

Yes, SPI_MODE0 looks good. The only difference between mode 0 and mode 3 is the clock polarity. For both, the data will transmit on the high to low edge.

SPI_MODE3: Transmit bit first, then SDO valid.
SPI_MODE0: SDO valid, then transmit bit.

Both may work ... or you may loose a bit or the data might be shifted by one bit with one of the modes.