Author Topic: Relay switching module, for selecting output from a PSU transformer  (Read 6038 times)

0 Members and 1 Guest are viewing this topic.

Offline Avelino SampaioTopic starter

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: br
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)
« Last Edit: April 30, 2023, 08:56:18 am by Avelino Sampaio »
 

Online inse

  • Frequent Contributor
  • **
  • Posts: 802
  • Country: de
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #1 on: February 05, 2023, 12:33:43 pm »
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.
 

Offline Avelino SampaioTopic starter

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: br
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #2 on: February 05, 2023, 01:32:21 pm »
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.

Despite 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
 

Offline CountChocula

  • Supporter
  • ****
  • Posts: 208
  • Country: ca
  • I break things—sometimes on purpose.
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #3 on: February 05, 2023, 01:49:27 pm »
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
Lab is where your DMM is.
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5144
  • Country: ro
  • .
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #4 on: February 05, 2023, 02:16:06 pm »
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 etc

https://www.digikey.com/en/products/detail/microchip-technology/PIC16F15224-E-P/12807398
https://www.digikey.com/en/products/detail/microchip-technology/PIC16F15323-E-P/7164774
https://www.digikey.com/en/products/detail/microchip-technology/PIC16F15324-I-P/6691275

No 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

 

Online inse

  • Frequent Contributor
  • **
  • Posts: 802
  • Country: de
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #5 on: February 05, 2023, 02:27:59 pm »
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.
 

Offline Avelino SampaioTopic starter

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: br
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #6 on: February 05, 2023, 02:35:32 pm »
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.

The 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.

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.

Thanks for reminding me about the hysteresis! My degree of difficulty with programming just went up from 1 to 10. :palm:
 

Offline CountChocula

  • Supporter
  • ****
  • Posts: 208
  • Country: ca
  • I break things—sometimes on purpose.
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #7 on: February 05, 2023, 02:37:35 pm »
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.
Fair—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).
Lab is where your DMM is.
 

Offline CountChocula

  • Supporter
  • ****
  • Posts: 208
  • Country: ca
  • I break things—sometimes on purpose.
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #8 on: February 05, 2023, 02:42:58 pm »
The 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.

OK—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 to implement current limiting, because in that case I suspect that it would be quite slow compared to an analog circuit.

Quote
Thanks for reminding me about the hysteresis! My degree of difficulty with programming just went up from 1 to 10. :palm:

I 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.
Lab is where your DMM is.
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4778
  • Country: dk
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #9 on: February 05, 2023, 03:07:30 pm »
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
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5144
  • Country: ro
  • .
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #10 on: February 05, 2023, 03:27:44 pm »
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 mode

This would require maybe a couple more relays to implement.
 

Offline Avelino SampaioTopic starter

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: br
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #11 on: February 05, 2023, 05:16:16 pm »
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).
 

Offline Avelino SampaioTopic starter

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: br
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #12 on: February 05, 2023, 10:02:43 pm »
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 etc

If you want to do it analogue, with just comparators, I'm attaching a couple examples that maybe could help

Thank 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!
« Last Edit: February 05, 2023, 10:19:36 pm by Avelino Sampaio »
 

Offline Avelino SampaioTopic starter

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: br
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #13 on: February 06, 2023, 08:03:55 am »
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.
« Last Edit: February 06, 2023, 08:09:23 am by Avelino Sampaio »
 

Offline Avelino SampaioTopic starter

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: br
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #14 on: February 08, 2023, 12:28:43 pm »
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 the maximum secondary 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/#msg4493065

I 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?
« Last Edit: February 08, 2023, 09:35:50 pm by Avelino Sampaio »
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4778
  • Country: dk
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #15 on: February 08, 2023, 04:27:03 pm »
Following the tests, today 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 the maximum secondary 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/#msg4493065

I 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?

you are already measuring the voltage after the BD139, just measure the voltage before too and do the difference in SW
 

Offline Avelino SampaioTopic starter

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: br
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #16 on: February 08, 2023, 09:32:25 pm »
Following the tests, today 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 the maximum secondary 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/#msg4493065

I 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?

you are already measuring the voltage after the BD139, just measure the voltage before too and do the difference in SW

It 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.
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4778
  • Country: dk
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #17 on: February 08, 2023, 09:59:40 pm »
Following the tests, today 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 the maximum secondary 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/#msg4493065

I 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?

you are already measuring the voltage after the BD139, just measure the voltage before too and do the difference in SW

It is not a suitable point, due to the large voltage variations.

not much larger than the output

 

Offline Avelino SampaioTopic starter

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: br
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #18 on: February 09, 2023, 12:16:22 am »
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.
 

Online inse

  • Frequent Contributor
  • **
  • Posts: 802
  • Country: de
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #19 on: February 09, 2023, 05:30:44 am »
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…
« Last Edit: February 09, 2023, 05:40:50 am by inse »
 

Offline Avelino SampaioTopic starter

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: br
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #20 on: February 09, 2023, 07:35:13 am »
What is the purpose of the circuit you have drawn?
Is this for a simulator?

Yes, and it's working great!

Quote
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.

What ?

Quote
The current limit will kick in at ~5mA.

Yes, 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.

Quote
For decades this transformer tap switching has been done with comparators, then one guy came along and decided to use a microcontroller…

I'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.


 

Online inse

  • Frequent Contributor
  • **
  • Posts: 802
  • Country: de
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #21 on: February 09, 2023, 08:13:42 am »
I probably got the zener voltages wrong, is it the numbers on the left or on the right, or none of them?
 

Offline Avelino SampaioTopic starter

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: br
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #22 on: February 10, 2023, 03:41:27 am »
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.
« Last Edit: February 15, 2023, 01:24:02 pm by Avelino Sampaio »
 

Offline Avelino SampaioTopic starter

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: br
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #23 on: February 12, 2023, 03:34:59 pm »
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 relays

Step 4: (Waiting for capacitor c1 to charge)

- MCU activates timer1, waiting 65ms for the complete charging of capacitor C1

Step 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.
« Last Edit: February 20, 2023, 10:17:32 am by Avelino Sampaio »
 

Offline Avelino SampaioTopic starter

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: br
Re: Relay switching module, for selecting output from a PSU transformer
« Reply #24 on: February 12, 2023, 04:53:13 pm »
4- startup behavior, about capacitor C1. 120ms for charging up to 24v
1- 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 !!!
« Last Edit: February 12, 2023, 04:56:01 pm by Avelino Sampaio »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf