HV5812 Control from Raspberry Pi  - Page 1
Forum section: electronics / beginners

author: DJS1000
author_rank: Newbie
timestamp: March 28, 2025, 01:48:53 am
content: Hello. I am trying to control an HV5812 with a Raspberry Pi Pico. However, my intended control method is not working (no high voltage is measured on the output pin). I attached a schematic and the Micropython code is below. Any help would be appreciated.from machine import Pinfrom utime import sleepPin_6 = Pin(6, Pin.OUT, value=1) # DataPin_7 = Pin(7, Pin.OUT, value=1) # StrobePin_8 = Pin(8, Pin.OUT, value=1) # ClockPin_9 = Pin(9, Pin.OUT, value=1) # BlankingPin_6.off() # Data input logic highsleep(0.001)Pin_8.off() # Clock input logic highsleep(0.001)Pin_8.on()sleep(0.001)Pin_7.off() # Strobe logic highsleep(0.001)Pin_7.on()sleep(60.0)

author: pcprogrammer
author_rank: Super Contributor
timestamp: March 28, 2025, 07:29:27 am
content: Did you check the levels of the control signals on the HV5812? With a digital multi meter you can check the static states of them. It might be that the 10K pullups are to weak for this application.

author: ahsrabrifat
author_rank: Regular Contributor
timestamp: March 28, 2025, 08:12:07 am
content: HV5812 is a 20-bit shift resistor. So, you need to shift in 20 bits of data.https://ww1.microchip.com/downloads/en/DeviceDoc/20005629A.pdfThis task should be handled by your code. I assume your code needs to be like this.Code:from machine import Pinfrom utime import sleep_us# Define HV5812 control pinsdata = Pin(6, Pin.OUT) # Serial Data Input (SER IN)strobe = Pin(7, Pin.OUT) # Strobe (LATCH)clock = Pin(8, Pin.OUT) # Clock (CLK)blanking = Pin(9, Pin.OUT) # Blanking (BL)# Initialize pinsdata.off()strobe.off()clock.off()blanking.off() # Enable outputs (active LOW)def shift_out(data_word):for i in range(20): # Shift 20 bits (MSB first)bit = (data_word >> (19 - i)) & 1data.value(bit)# Clock pulse (minimum 100ns per datasheet)clock.on()sleep_us(1) # Can be reduced further if neededclock.off()# Example: Turn ON all outputs (20 bits of 1)shift_out((1 << 20) - 1) # 0xFFFFF (20 bits)# Latch data into outputs (pulse strobe)strobe.on()sleep_us(1) # Strobe pulse width >= 100nsstrobe.off()# Keep outputs active for 60 secondssleep(60)Here are some tutorials that may help.https://www.theengineeringprojects.com/2022/04/getting-started-with-raspberry-pi-pico.html

author: pcprogrammer
author_rank: Super Contributor
timestamp: March 28, 2025, 08:43:47 am
content: For just testing if the hardware works a single bit shift is enough. I have these IC's for a project of mine, and I just tested them with pulsing the signals by hand. Worked perfectly fine with a single bit.So yeah to make full use of the IC all bits can be clocked in and when daisy chained more bits can be clocked through.Using the optocouplers is not really needed though. A simple level shifter based on a 2N700 transistor also does the trick.

author: DJS1000
author_rank: Newbie
timestamp: March 30, 2025, 02:35:46 am
content: Quote from: pcprogrammer on March 28, 2025, 07:29:27 amWhat indicators should I look for to identify that the resistor is too weak? Would scoping the input show a rounded rising edge to the wave form or something like that? When you refer to using a DMM to check the static states, do you mean measuring the logic high voltage supplied by the pull up resistor to the input when the optocoupler output is not passing current to ground?

author: DJS1000
author_rank: Newbie
timestamp: March 30, 2025, 02:38:45 am
content: Quote from: ahsrabrifat on March 28, 2025, 08:12:07 amYour assessment of the code looks like a good approach to shift 20-bits of data to the register. My simpler code was primarily to test my understanding of how the shift register works. I also watched the tutorial videos you suggested, and they are great.

author: DJS1000
author_rank: Newbie
timestamp: March 30, 2025, 02:41:19 am
content: Quote from: pcprogrammer on March 28, 2025, 08:43:47 amWhat applications are level shifters preferable and what applications are optocouplers preferable? The assumption that caused me to consider an optocoupler went something like this… high voltage switching power supply = relatively noisy circuit?; and, optocoupler = physical separation of 3.3volt I/O terminals from relatively noisy high voltage circuit?.

author: DJS1000
author_rank: Newbie
timestamp: March 30, 2025, 03:00:07 am
content: I have another question related to the HV5812. The input terminal appears to connected to the gate of an internal MOSFET and there appears to be an internal resistor on the gate to limit the current drawn when charging the gate. Is that a correct interpretation of the attached input schematic?

author: pqass
author_rank: Super Contributor
timestamp: March 30, 2025, 05:53:23 am
content: Quote from: DJS1000 on March 30, 2025, 02:41:19 amOptocouplers are more trouble than they're worth sometimes. They can be slow and exhibit analog behaviour if you don't drive them hard enough or too fast. The 750R resistor in-series with the 1.2V Vf of the LED drives it at only 2.8mA. With a CTR of 20% translating into just barely enough current (560uA) to bring the collector to GND against the 10K pull-up resistor. But at what rise/fall time? You'd need to see the waveform on an oscilloscope to be sure it can deliver at your required frequency/bit rate.Optocouplers are really only needed when you have to maintain separate GNDs. Otherwise, you can just use a transistor+gate/base and pull-up resistors. If this isn't a requirement then what would be best (fewest, fastest components) would be to use virtually any TTL (LS, HCT) 4 or 6 gate IC (eg. 74LS08 AND, 74LS32 OR; with inputs tied together making a buffer, or 74LS34 buffer, or NAND and NOR but then you'd have to invert the Pico GPIO output). TTL inputs will accept anything 2V or greater as a logic HIGH which the Pico can produce.BEWARE of the HV5812 power-up/down requirements (see page 7 "POWER-UP AND POWER-DOWN SEQUENCE"). I was helping another fellow on this forum where he blew-up his HV518 (of similar vintage to yours) because (we believe) he kept Vpp up after Vdd was brought down (probably due to the capacitor on the Vpp rail discharging slower than that on the Vdd rail). If you're using a DC-to-DC converter to generate Vpp, then add an approriate discharge resistor on the output to make sure it goes to 0V before the Vdd rail.Before connecting the Pico or even just the 3V3 to 5V driver solution, I'd confirm that the chip still works via breadboard.Set BL=LOW, DATA=HIGH, then manually poke the CLK* a few times, then STROBE* once to emit Vpp on the first output pin.________________________________________________________* note: 10K pull-down resistors to keep CLK, STROBE from flapping in the breeze.See the NoritakeVFD Guideon how to drive VFDs.Datasheets:HV5812,LTV-844

author: pcprogrammer
author_rank: Super Contributor
timestamp: March 30, 2025, 07:17:57 am
content: Quote from: DJS1000 on March 30, 2025, 02:35:46 amThe value of the resistor is related to the rise time of the signal, so not really the rounded rising, but more the steepness of the edge and another issue can be ringing of the signal. The rounding is only an issue when it is very big, but then the rise time is also very long. It has to do with the hidden capacitance in circuits, like the input capacitance of the HV5812 signal lines.Ringing of the signal can cause unintended clock cycles when it is high enough to pas the high level on the input.With static I mean checking if both the low and the high levels are according to specification. So with a test program set the signals low and see if the voltages are below 0.8V. Then set the signals high and see if the levels are above 3.5V.qpass answered your other question and I concur with what he wrote.One addition is to the optocouplers only used when needing separate grounds, includes also having separate supply voltage. Take for instance a switched power supply, where you need a galvanic separation between the primary and secondary sides of it. Here an optocoupler is used to pass the feedback signal from the secondary side to the primary side.Another example is when you have to separate systems that need to communicate with each other over long wires. To keep the systems galvanically separated optocouplers can be used.

author: DJS1000
author_rank: Newbie
timestamp: March 30, 2025, 02:40:26 pm
content: Quote from: pqass on March 30, 2025, 05:53:23 amYour explanation of optocoupler application makes sense (required for separate grounds and for feed back signals). My circuit requires fairly slow response time (in the millisecond range) so I don't think the optocoupler is problematic from that vantage point. However, I can see how the current limiting resistor on the LED can have an adverse effect. If the amount of light transmitted from the LED is insufficient to drive the output transistor past the linear region of operation and into the saturated region of operation it would limit the current supplied to the HV5812 input excessively? Do I understand that correctly? Furthermore, this would result in the slow rise time and greater ramp angle on the rising edge we were discussing? I have an old budget scope and the wave form looks pretty square with decent rise time; although I can't say I evaluated the rise time carefully.My question about the internal resistor on the gate of the internal MOSFET of the HV5812 was along the same line. Does the value of the pull-up resistor in series with the internal resistor become a problem? And since there is an internal resistor on the input of the HV5812, is it best to supply 5V to the input with the lowest series resistance possible? In the case where you use a push button to test the input function of the HV5812 there could be virtually no resistance between the 5V supply and the input terminal but you would have to use a pull-down resistor instead of a pull-up resistor? In the case were you switch 5 volts to the HV5812 input with a MOSFET in a level shifting configuration, the resistance could be as little as the milliohm "Static Drain-Source On-Resistance" of the MOSFETs channel?I will certainly, pay attention to grounding the blanking terminal to make sure it is not over riding the outputs or floating as you mentioned. However, my lack of attention to the power up and power down sequence may be the problem I am struggling with. If so, I will bury the little guy in the back yard and say a few nice words about his short life...

author: DJS1000
author_rank: Newbie
timestamp: March 30, 2025, 02:55:23 pm
content: Quote from: pcprogrammer on March 30, 2025, 07:17:57 amI appreciate the additional context you added for optocoupler application. Long distance signal transmission also makes sense.I believe the logic low and high levels were pretty close to 0 volts and 5 volts and the ramp up and down time looked pretty short. But, I should probably evaluate that more carefully.Testing with push buttons may also introduce some signal bouncing that could result in strange operation of the HV5812, right? But I think my lack of attention to the power up and power down sequence is likely the cuplrit. One other testing problem I encountered was very high noise on one of my breadboards. I switched to a different bread board and the noise went away.

author: pcprogrammer
author_rank: Super Contributor
timestamp: March 30, 2025, 04:06:53 pm
content: Don't overthink it.The input resistor in the HV5812 won't make much of a difference compared to the resistance (reactance) of the FET gates. Probably included to reduce current through the protection diodes against static discharge and over voltage.To test things I did not look into the power supply sequence either and did not see harm done to the device. Only tested with something like 15V or so. For the clock I used a signal generator with a square wave output, but could have used a push button. First tried it with a wire alternating between ground and 5V, but as I needed to test more than one, I switched to my signal generator. (Bought them on Aliexpress, so testing is something I most of the times do when I receive parts. Especially when they are a bit more expensive.)For the pullup resistors in these sort of situations I usually use something in the range of 2k2 to 4k7 ohms.A simple test setup can be a small capacitor in the range of 1 to 10nF to ground and a 2k2 resistor to the 5V and the push button in parallel with the capacitor. This capacitor will take care of most of the bouncing of the switch.

author: pqass
author_rank: Super Contributor
timestamp: March 30, 2025, 10:28:45 pm
content: QuoteIf you limit your clock to a 1ms period (1KHz frequency) then it would take 1ms * 20 to transmit 20 bits (20ms or 50Hz). The STROBE will also be cycled after 20 bits (also 20ms or 50Hz) which is how fast the outputs can change given the clock rate. Is this sufficient for your application?The input pins of the CMOS HV5812 draw very little current (IIH=0.05uA) so they would have little effect on the collector voltage (causing it to rise if the transistor is in the linear region).Given the same collector pull-up, the LED resistor determines how low the collector voltage can go and collector fall-time. The collector pull-up determines the rise-time.See attached panel of waveforms of a breadboard setup of a TIL111 optocoupler (I needed to get experimental to confirm).The YELLOW trace is a 1KHz signal into the LED resistor. GREEN is the collector trace.Top to bottom change is the LED resistor: 330R, 1830R (1K5+330R), 2390R (560R+1K5+330R)Left to right change is the collector pull-up: 3K9, 10K, 18KYou will need to choose your resistors such that you're not exceeding the GPIO pin current rating and that a proper LOW (<0.8V) can be produced on the collector, all the while your bit-rate doesn't make the output look like a triangle wave. Even with a 330R LED resistor and 3K9 pull-up, the output started to look like a sawtooth at 5KHz. Your opto may be faster but you'll have to check. But why bother with this analysis when you can just use a TTL buffer.

author: DJS1000
author_rank: Newbie
timestamp: April 06, 2025, 04:59:25 pm
content: Quote from: pcprogrammer on March 30, 2025, 04:06:53 pmI tried a different HV5812 and concluded that the bread board connections may have been my problem. All of the HV5812s that I have now work in a different location on the bread board that seems to make better contact. I like the suggestion about using capacitors to filter out switch bouncing. I will have to play with that concept.

author: DJS1000
author_rank: Newbie
timestamp: April 06, 2025, 05:02:10 pm
content: Quote from: pqass on March 30, 2025, 10:28:45 pmSo, I purchased another HV5812 thinking maybe the power supply sequence killed the chip. However, it appears that the bread board was too loose in the location where I was attempting to test the circuit. I had moved my circuit on the bread board once before, so I thought I could eliminate the bread board as a source of error. I moved the circuit to a spot where the terminals seemed to make better contact, and the outputs began switching consistently on all of the HV5812s I have now. Previously, I was getting the same erratic output results with the optocoupler (LTV-844), the TTL buffer (74AHCT125), and the push buttons. Now I see the wave form discrepancies you are referring to clearly and can confirm that the 10k pull up resistor and 750ohm current limiting resistor are too weak for the 1kHz signal. Also, I was too stuck on the erratic behavior of the HV5812 that I wasn’t thinking about the fact that to obtain an output switching rate of 1khz you would need the serial data rate to be 20khz. So that is a good reason to switch to a TTL buffer for this application like you suggested. Also, I appreciate the scope measurements you provided. They were helpful to consider.