Relay switching module, for selecting output from a PSU transformer - Page 1
Forum section: electronics / projects

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 05, 2023, 11:20:41 am
content: I ordered a PSU transformer, with multiple outputs on the secondary. I intend to elaborate a relay switching module, using a PIC12F675. I will use assembly language.What should I observe in the behavior of a PSU, with CV and CC module, to work out a correct switching of the relays? For example, my first perception is that I should start the PSU with the secondary selected at the maximum voltage of 28v. My second perception is that the PIC must wait for C1 to fully load and the output to stabilize. It is only from this moment on that the PIC starts to monitor the output and thus adjust the switching of the relays. Are my two initial perceptions correct or would you start with a different schedule?29/04/2023: Project update (Reply #29)

author: inse
author_rank: Super Contributor
timestamp: February 05, 2023, 12:33:43 pm
content: The switch control also could be achieved by a couple of comparators monitoring the actual output voltage.I would spend more effort on the voltage regulation circuit, current control would also be favorable.Is your OPAMP capable of driving the power transistor?It might require several 100mA of base current.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 05, 2023, 01:32:21 pm
content: Quote from: inse on February 05, 2023, 12:33:43 pmDespite my low experience with assembly programming, I believe I can use the microcontroller for this task. So far the programming is not appearing complex for me.The drawing shown is just a sketch. Forget the cv and cc module part. The PSU will resemble the design on our friend Bram (blackdog).https://www.circuitsonline.net/forum/view/110029#highlight=01+na

author: CountChocula
author_rank: Unknown
timestamp: February 05, 2023, 01:49:27 pm
content: Have you considered having the MCU monitor the wiper of your voltage-setting pot instead? This would make it follow the intent of the user, which intuitively seems to me would deliver a better experience, and doesn't require you to worry about that cap charging, or about the time it takes the pass transistor to transition to a new voltage.Regardless of whether you use software or a series of comparators, you're going to need some hysteresis in your logic; otherwise you'll get oscillations when you're close to the threshold voltage between one tap and the next.—CC

author: mariush
author_rank: Super Contributor
timestamp: February 05, 2023, 02:16:06 pm
content: If you insist on using MCU, I would suggest using a slightly better PIC chip with an internal voltage reference.For example, I see on Digikey PIC16F15xxx micros at around 1$ each, and these have 10 bit ADC, internal reference configurable at 1.024/2.048/4.096v levels, and some have 5 bit DAC, comparators etc etchttps://www.digikey.com/en/products/detail/microchip-technology/PIC16F15224-E-P/12807398https://www.digikey.com/en/products/detail/microchip-technology/PIC16F15323-E-P/7164774https://www.digikey.com/en/products/detail/microchip-technology/PIC16F15324-I-P/6691275No assembly required, just get MPLAB-X and program them in C, super fast.You'll want to implement some hysteresis ... ex you have steps at 7v AC , 14v AC, 21v AC, 28v AC ... that's around 8v DC, 18v DC, 27v DC , 37v DC ....If setting goes above 25v dc, then switch taps to full 37v dc , but only switch it back to 27v dc if the voltage goes down below let's say 24v DC , something like that.If you want to do it analogue, with just comparators, I'm attaching a couple examples that maybe could help

author: inse
author_rank: Super Contributor
timestamp: February 05, 2023, 02:27:59 pm
content: How would monitoring the wiper position deliver a better experience?I see it as disadvantage, if current limit kicks in, the input voltage wouldn’t be reduced accordingly.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 05, 2023, 02:35:32 pm
content: Quote from: CountChocula on February 05, 2023, 01:49:27 pmThe MCU has to act, mainly monitoring the CC mode, to guarantee the integrity of the power transistor. So the monitoring has to be on the output.Quote from: CountChocula on February 05, 2023, 01:49:27 pmThanks for reminding me about the hysteresis! My degree of difficulty with programming just went up from 1 to 10.

author: CountChocula
author_rank: Unknown
timestamp: February 05, 2023, 02:37:35 pm
content: Quote from: inse on February 05, 2023, 02:27:59 pmFair—there is no current limiter in this circuit; if you had one, it would just work by reducing the output voltage, so you could monitor that.The reason why I think it would deliver a better experience is that, as the user, I would expect that PSU to do what I want; if I tell it to output a particular voltage, I would want the internals to optimize for that (minus current limiting if it is implemented).

author: CountChocula
author_rank: Unknown
timestamp: February 05, 2023, 02:42:58 pm
content: Quote from: Avelino Sampaio on February 05, 2023, 02:35:32 pmOK—I still think that you could monitor the CC circuit to determine which tap to select, but I just want to make sure that you're not suggesting that you want to use the MCU toimplementcurrent limiting, because in that case I suspect that it would be quite slow compared to an analog circuit.QuoteI don't think that's necessarily the case; implementing hysteresis in software is relatively straightforward, though I will say that you're making things way harder by using assembler… why not C? It's similarly easy to implement it in hardware, like Mariush suggested.

author: langwadt
author_rank: Super Contributor
timestamp: February 05, 2023, 03:07:30 pm
content: seems simple enough to just monitor the voltage across the output transistor. When it gets below a limit increase the input voltage, when it gets above another limit decrease in the input voltage.might make sense to use a diode from each winding and the relays as simple on/off switches, that way there is always an input connected

author: mariush
author_rank: Super Contributor
timestamp: February 05, 2023, 03:27:44 pm
content: To add : with 4 secondary windings, you also have the opportunity to connect two at a time in series, and then connect these two pairs in parallel to get double the current amount but maximum half the voltage. You could probably even have some slide switch or on/off button that the microcontroller could monitor and switch between this mode and the full modeThis would require maybe a couple more relays to implement.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 05, 2023, 05:16:16 pm
content: As the transformer will take some time to arrive, I designed a circuit to be able to carry out simulations with the MCU. Now it's time to concentrate on the programming, which by the way I'm having trouble working out the logic of this hysteresis. I believe that using a hysteresis of 0.5v is enough to avoid oscillations. In this simulation I will work with the following transition values: 4v(4.5v), 10v(10.5v) and 16v(16.5v).

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 05, 2023, 10:02:43 pm
content: Quote from: mariush on February 05, 2023, 02:16:06 pmThank you very much for the suggestion, however I have 5 in stock of the PIC12F and its ADC is also 10 bit but I intend to use only 8 bit (ADRESH). It doesn't seem necessary to capture Vout with great precision.Thank you very much for the schematics, they will be of great help!

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 06, 2023, 08:03:55 am
content: After a good beating with the programming, I got it to work as desired. Notice in the flowchart that I save the last Vout reading to compare with the next reading. Honestly, I don't know if it was the most appropriate logic, but it's working.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 08, 2023, 12:28:43 pm
content: Following the tests, I identified a situation that I did not like. I simulated a short circuit between collector and emitter of q1(bd139) and it turned out that the MCU triggered the relays, so that themaximumsecondary voltage was seen by the DUT. In this project of mine I intend to implement a dropout system, as I did with this other project:https://www.eevblog.com/forum/projects/psu-with-discrete-components-any-tips-for-cc-control/msg4493065/#msg4493065I believe that the triggering of the dropout circuit will occur before the MCU can reset the position of the relays; however I would like to know if there is any way to at least prevent the MCU from changing the position of the relays in this scenario. In this PIC12F I have the AN1 input available. Any idea how I could use this input (AN1) to measure the VCE voltage of bd 139?

author: langwadt
author_rank: Super Contributor
timestamp: February 08, 2023, 04:27:03 pm
content: Quote from: Avelino Sampaio on February 08, 2023, 12:28:43 pmyou are already measuring the voltage after the BD139, just measure the voltage before too and do the difference in SW

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 08, 2023, 09:32:25 pm
content: Quote from: langwadt on February 08, 2023, 04:27:03 pmIt is not a suitable point, due to the large voltage variations. I'm opting to capture the output of P1 but I'm stuck with the math.

author: langwadt
author_rank: Super Contributor
timestamp: February 08, 2023, 09:59:40 pm
content: Quote from: Avelino Sampaio on February 08, 2023, 09:32:25 pmnot much larger than the output

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 09, 2023, 12:16:22 am
content: I ended up coming up with a good solution. In the AN0 input I used a divider by ten and the opamp gain I also adjusted to ten. With this modification, the AN1 input now has the same value as the AN0 input. What I did in the programming was monitor the overshoot.

author: inse
author_rank: Super Contributor
timestamp: February 09, 2023, 05:30:44 am
content: What is the purpose of the circuit you have drawn?Is this for a simulator?The string of zener diodes will not deliver the desired voltage as the entire zener voltage is greater than the supply voltage.It will deliver 30V, 6V and 0V.The current limit will kick in at ~5mA.For decades this transformer tap switching has been done with comparators, then one guy came along and decided to use a microcontroller…

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 09, 2023, 07:35:13 am
content: Quote from: inse on February 09, 2023, 05:30:44 amYes, and it's working great!QuoteWhat ?QuoteYes, Q2 current limiter is configured to limit the output to 5mA. And with the 20k potentiometer at the output, I force the Q2 limiter to work, to perform tests with the MCU.QuoteI'm not bound by rules! It doesn't matter if I hit a wall in the end, because I'm definitely learning a lot in the process.

author: inse
author_rank: Super Contributor
timestamp: February 09, 2023, 08:13:42 am
content: I probably got the zener voltages wrong, is it the numbers on the left or on the right, or none of them?

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 10, 2023, 03:41:27 am
content: Today was a good day for me with this project!Some perceptions I had, to implement changes:* Nowadays we work with lower voltages (3.3v, 4.2v, 5v, 6v, 9v). So why not initialize the source, with the relays configured for the lowest secondary output? Another benefit observed here is that this way, the relays would be saved absurdly.* Why not initialize the power supply with the output in PAUSE, until the MCU activates the relays, if necessary, and wait for the complete charging of the electrolytic capacitors?* To implement these changes I would need an MCU with more ports and so I chose the PIC16F676.There are still some adjustments to be made in the firmware, but I believe that by tomorrow I will be able to fix it.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 12, 2023, 03:34:59 pm
content: The ideas for this project are flowing! I think I'll end up using all the MCU ports. Follows the startup steps I devised for this PSU.Step 1: (Powering on the PSU)- relays in the off position.- initial voltage of C1 at 6v.- transistor Q4 initializes saturated, which cut transistor Q2.- mosfet Q1 in the cut.- mcu takes 72ms to boot.Step 2: (tests the integrity of Q2 transistor)- activates RC4 port, releasing 5v for R16 and D6- AN2 input reads the point between R16 and D6.- if a voltage drop between R16 and D6 is detected, PSU initialization is interrupted and the fault indicator LED is activated.- not presenting fault, deactivate the RC4 port and activate the RC5 port to activate the mosfet.Step 3: (reading potentiometer P1)- AN1 captures P1 reading- reconfiguring the position of the relaysStep 4: (Waiting for capacitor c1 to charge)- MCU activates timer1, waiting 65ms for the complete charging of capacitor C1Step 5: (Enable PSU output)- Enable RC3 port to release PSU output- MCU activates timer1, waiting 65ms for the complete charging of capacitor C4- After duly stabilized output, start monitoring (An0 and An1) of the output voltages and the potentiometer.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 12, 2023, 04:53:13 pm
content: 4- startup behavior, about capacitor C1. 120ms for charging up to 24v1- Initialization of Vout. 51ms time to load C4.2- Vout behavior when output short circuit. Protection transistor Q3 acts very fast.3- Vout behavior when exiting the short circuit condition. Small unevenness in the trajectory, due to the switching of the relays. Very good !!!

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 12, 2023, 05:17:22 pm
content: Simulating a short circuit of Q2, the response time is lengthened due to capacitor C4. Rock in my shoe.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 12, 2023, 08:34:46 pm
content: I managed to take the capacitor charge out of the equation, using the Q7 transistor, but I'm not sure if 400us is still too much...

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 14, 2023, 04:23:02 pm
content: Trying to understand the reason for the 400us, I discovered that a good part of this time was associated with the conservative settings I defined for the ADC.osc: 4mhzFosc/1611Tad80us waiting for capacitor charging11*(16/4mhz) =44us +80us ::> 124usConclusion, of the 400us for the MCU to react to the event, 248us came from the ADC.I changed the ADC settings to:osc: 4MHzfosc/211Tad20us waiting for capacitor charging11*(2/4Mhz) = 5.5us + 20us ::> 25usNotice in the image that the response time reduction was significant (from 400us to 140us). Also notice that the transistor(BD139) starts to add a delay. I'll replace it with a mosfet and run some more tests.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: February 14, 2023, 08:37:25 pm
content: With the mosfet the response was much better.Follow the asm file.Now it's waiting for the transformer.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: April 29, 2023, 06:06:37 pm
content: Hi!The transformer arrived and in the first tests I realized that I made a gross mistake. The 7vac tap is a very low value, as it has to discount the rectifier bridge drop, the minimum VCE value, the shunt resistor drop and the resistance of the transformer,. To get around the problem, I resorted to an overwind, adding another 3.5 vac to the 7 vac.The control of the relays with PIC is working very well! I am also using the PIC to monitor the maximum heatsink temperature.I finished the preliminary tests, using a protoboard and now it's time to have a PCB manufactured. I used RC4558 for CV control and OP27 for CC control.