how shift registers work (HV5622) - Page 1
Forum section: electronics / beginners

author: VEGETA
author_rank: Super Contributor
timestamp: March 14, 2023, 09:59:26 am
content: HelloI am bad at digital electronics because I simply hate them. However, I want to make a nixie tube clock at some time later this year and I found most of them without multiplexing use shift registers like this one:https://www.microchip.com/en-us/product/HV5622I need to understand how does shift register works, like how can i set specific outputs via each shift register IC?i mean if it is 8-bit shift register, should i send 00001000 and i will get it on the output? and why such clock projects cascade them together?thanks

author: MarkS
author_rank: Unknown
timestamp: March 14, 2023, 12:28:01 pm
content: Not considering the POL and BL inputs on the chip you specified, you hold LE low, clock in the data, one bit per clock pulse, and then hold the LE line high to set the output latch, placing the shifted in data on the outputs. You cascade shift registers if you need more outputs than a single chip provides. This reduces microcontroller pins required.

author: VEGETA
author_rank: Super Contributor
timestamp: March 14, 2023, 12:45:30 pm
content: Quote from: MarkS on March 14, 2023, 12:28:01 pmso is it like this:Code:LE = low;data_input = input the 32-bit data that i require.wait until all 32-bits are done (32 clock cycles).LE = highso if I want any kind of output like for 8 bits 00001000 then i want 10010011... can i put them like this or they have to be counted and shifted?also, some nixies will have 0-9 and decimal point to be controlled but others like minutes have only 0-6 and 0-9, hours has 0-1 or 0-0 and 0-2... how can that be achieved in this automatic cascaded system?assume we got a function which outputs the latches once every second... how can we achieve this automatically? or should it be controlled directly by MCU?

author: MarkS
author_rank: Unknown
timestamp: March 14, 2023, 01:24:41 pm
content: Quote from: VEGETA on March 14, 2023, 12:45:30 pmPretty much, at least for the chip you specified. There are many different types of shift registers with differing control sequences, but all similar to this in some way.Quote from: VEGETA on March 14, 2023, 12:45:30 pmThis chip doesn't have a clear, so inputting 8 bits and then another 8 will push the first set of 8 down the output chain. Once you push in 32, the next bit will free the electrons associated with the first bit and they'll all scatter, losing the bit to the void.Quote from: VEGETA on March 14, 2023, 12:45:30 pmThat's application specific. Each output should correspond with one... segment? number? Nixie flashy thing? How your clock ultimately works will depend on how you wire up the shift register to the tubes.

author: VEGETA
author_rank: Super Contributor
timestamp: March 14, 2023, 03:24:20 pm
content: kindly take a look at this:this can work as nixie tube clock with decimal point as well as other indicator thing.so for a clock, we can get the entire time and convert it into 32 + 32 + 32 bits of binary and send them 3 at once to output to the entire tubes at once.then for each time of 1 second we update the entire display by sending 32 + 32 + 32 bits... this way no won't use individual bits shifting but purposefully remove the entire contents (send them to void as you mentioned) of all 3 chips' memory, and putting completely new set of numbers instead.and when we want a counter, it is a lot easier by just sending one bit or shifting it.if i want to display some random number with or without decimal point, i would also do the same as sending all 32+32+32 at the same time.is this good approach?

author: VEGETA
author_rank: Super Contributor
timestamp: March 14, 2023, 04:48:18 pm
content: what comes to my mind is this:we have 8 tubes each has 12 points to activate which means total of 96 lines. 3 of those chips are enough to drive all pins directly.we get the time, convert it to seconds, minutes, and hours. then get individual tube number. meaning tube 7 and 8 are for seconds, tube 6 is decimal, tube 4-5 are minutes, tube 3 is decimal point, tubes 1-2 are hours. ---> meaning if we got 45 on the seconds this will mean tube 8 is 5 and tube 7 is 4...etc.after determining each tube number, we have a function to use switch case to determine the signal output to drive the tube... so out of 12 lines which one is to be activated in order to lighten up digit 5 for example.we store this value in a 12-bit variable (or array?) and we call it tube8. we do the same for all tubes.now we get a big 96 bit variable (or array or what) which is like this: tube1_tube2_tube3_....._tube8 by doing something like this:Code:int total ;total = 0;total = total | ( tube1<<(96-12) ) // gets complete 96 bits value and OR it with tube1 12 bits which shifting tube1 bits to be the most significant 12 bits.total = total | ( tube2<<(96-24) ) // same as above but now arranges (shifts) tube2 12 bits to be just after tube1 bits.......// we do this until:total = total | tube8after getting all 96 bits ready and sorted out, we need to send them to our 3 32-bit chips, meaning dividing them to 3 packets, each is 32 bit:Code:out1 = total [0:31]out2 = total [32:63]out3 = total [64:95]// above is how to choose array parts in python, don't know how to do it in c. maybe using >>.serial_send(out1)serial_send(out2)serial_send(out3)latch_ON //now after all bits are sent, each 32-bit in their own chip's register... we latch all of them at once.is this the correct approach?

author: reboots
author_rank: Regular Contributor
timestamp: March 14, 2023, 04:50:37 pm
content: Here is a nixie tube clock I built using the HV5622. The page includes code, schematic, and various notes including an explanation of how to use the shift register. Maybe this will be useful to you.Amy Time! Nixie Tube ClockThis clock was the last project I did in 8-bit AVR assembly, almost ten years ago. I have another project in progress using the HV5622, this time in AVR C. I've attached the relevant code.

author: VEGETA
author_rank: Super Contributor
timestamp: March 14, 2023, 05:12:41 pm
content: thanks for your c code, will check it out.however, i am interested in you explaining to me how you wired stuff from shift registers to tubes outputs... and how you mapped them in software.kindly check my approach above and see if it is like you did.

author: reboots
author_rank: Regular Contributor
timestamp: March 14, 2023, 05:44:12 pm
content: The shift register outputs are routed directly to the tube cathodes. Both of my examples use a single HV5622, so your use case is a little more complex. However, I don't think you need to partition your data into per-chip packets. The three drivers appear to be cascaded correctly in the schematic you linked to, so simply send the full 96-bit sequence and then pulse _LE.You will need to translate your timekeeping abstraction into the 96-bit sequence of cathodes. The translation scheme you choose will probably dictate how the sequence is stored. Assembly makes bitwise operations very easy, so I operated directly on a set of bytes in memory and then read them out. For a higher-level language you could perform arithmetic on an array, or even use lookup tables. The hard part isn't displaying the data, but calculating the timekeeping sequence; e.g. 01:00:00 must follow 12:59:59* (and the first digit must blank, unless you want a leading zero displayed).*Assuming 12-hour time. 24-hour time is somewhat easier.

author: VEGETA
author_rank: Super Contributor
timestamp: March 14, 2023, 06:03:11 pm
content: Quote from: reboots on March 14, 2023, 05:44:12 pmthese projects are using a real-time clock, so data should be read by arduino library and I should get hours, minutes, and seconds. then convert those into single digits like 50 is 5 and 0...etc. after that is how I explained above. your design does not use an RTC as it seems, using RTC is always easier and better.you could do one major function to read rtc data, get hrs,mins,secs, convert them into individual tube digits (depends on how you get the time data itself), then output 96 bits to respective drivers... this gets repeated every second.I will be sending the 96 bits as one packet then do the latch, but i actually never used this stuff and don't know if arduino library supports more than 32-bit output at once.