Auxiliary power system with PIC12F675 + CD4053 + LM723 - Page 1
Forum section: electronics / projects

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 03, 2021, 04:24:27 pm
content: Hello everyone.Image 1- Through the digital input (gp3-pin 4), the PIC will select the operating mode (supply or recharge). When the power supply is cut off, the output voltage of the HP source takes a while to reach the transition level (bit 0) of the gp3 port. I need to find a way to shorten this transition time. Any suggestions to replace the resistor divider (R1 - R2) with something that makes power failure recognition faster?

author: ledtester
author_rank: Super Contributor
timestamp: October 03, 2021, 04:49:55 pm
content: Quote from: Avelino Sampaio on October 03, 2021, 04:24:27 pmHow is the power supply being cut off? Are you disconnecting the AC side of the the notebook power supply and leaving the DC end plugged into your circuit or are you unplugging the DC output of the notebook power supply from your circuit?

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 03, 2021, 04:58:55 pm
content: Ledtester, I am disconnecting the AC side of the power supply and leaving the DC end connected to the circuit.

author: ledtester
author_rank: Super Contributor
timestamp: October 03, 2021, 05:14:37 pm
content: Note that most notebook power supplies have output capacitors which will continue to feed (decreasing) voltage and current for a while after the AC side is disconnected.Could that be what you are seeing?Also, how is the GP3 pin being monitored by the PIC? Are you using a pin-transition interrupt or polling its digital value in a loop or polling its analog value in a loop?

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 03, 2021, 06:09:37 pm
content: Ledtester, I'm looking up the digital value in a loop.I verified that the transition frombit 1tobit 0, from the gp3 port, occurs around 1.50v. Is it safe to work with resistive divider (r1-r2) at 2.0v? Note in the graph that the time was much shorter and at first it serves the project. Would it be an inadequate solution?

author: ledtester
author_rank: Super Contributor
timestamp: October 03, 2021, 09:23:11 pm
content: A couple of observations...- Generally it is not a good idea to hold a digital signal at an intermediate voltage (one that's between something that's recognized as a LOW vs. a HIGH signal). However, microcontroller GPIO pins are not standard digital inputs so it may not be a problem in this case.- The the threshold of 1.5V that you measured is probably not guaranteed by Microchip. It could vary from device to device or even pin to pin.- The 12F675 has an analog comparator. That might be a better way to detect a precise voltage level.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 04, 2021, 12:18:16 pm
content: Ledtester, changing the PIC12F code would be complicated for me. I was inclined to incorporate the LM393 comparator but I had an idea on using a pnp transistor. I had to make a small change to the code and it worked as expected. I adjusted p1 so that the transition occurs around 17v.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 05, 2021, 11:26:25 am
content: HiThe project is advancing, see the complete schematic. Replace the containment diode with a P-channel Mosfet, with RDSon=0.06R.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 06, 2021, 10:07:10 am
content: HiI am providing the "asm" and "hex" files from the PIC12F675.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 06, 2021, 09:55:22 pm
content: C3 will cause some delay to the response, too.Instead R1+R2, use a zener, the falling voltage will be detected much faster.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 07, 2021, 02:00:31 pm
content: DavidAlfa,thank you very much for your cooperation. I implemented and tested the suggested modifications. It worked great!I will keep C3 as it doesn't affect the transition. In case of power failure, the PIC12F will trigger PAUSE, setting the output of the LM723 to zero. Q6 will go into driving. In sequence, GP1 will trigger Q4, releasing the battery for use.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 07, 2021, 06:04:05 pm
content: Edit: Ignore all the following. You're already using the ADC. Just set GP1 as analog and read it too with the ADC.If you want to trigger the aux power supply at 17.5V, you know you'll have 1.59V.The ADC will read 325 with 5V VDD, that's your threshold!The best would be to use the internal comparator, as ledtester suggested.The comparator can use the internal reference, which has 2 range modes (Excel table attached), and can be adjusted in 16 steps.Then you only need to read the comparator output flag. 1=input is lowerthan reference, 0= input is higher, that simple!It's been a lot since I last played with PICs, but PIC16 peripherals are very easy to set up.Code:config:BSF GPIO,1 Set GPIO1 as inputBCF ANSEL,1 Set GPIO1 as analogMOVLW B'10000010' Enable Vref, set high range, internal vref, 1.56VMOVFW VRCONMOVLW B'00000100' Cin- to GPIO1, Cin+ to Vref, Cout pin unusedMOVWF CMCONscan:BTFSC CMCON,COUT Test COUT bitGOTO low_detected If 1, vin is lower than reference (Voltage is dropping)GOTO scan If 0, vin is higher (All ok), do other checks or keep scanningThen use a resistor divider R1(10K)+R2(1K) and connect it to RA1.Over 17.2V, the voltage will exceed 1.56V, and the comparator output will be 0.When it falls below that, it will trigger the comparator and read 1.You only need to swap GPIO1 and GPIO3 in your code.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 07, 2021, 06:44:00 pm
content: DavidAlfa,Yes, I initially configured GP3 to use ADC. The problem is that I didn't realize that GP3 is not configurable as an output port. GP3 being a digital input port, I had to use this external circuit with the transistor. The transition system is working very well, for both configurations (pnp and npn) tested.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 07, 2021, 08:06:30 pm
content: I see. That's what you get with these tight devices!Avoid these old pics when possible, there're newer, cheaper, much more powerful pics!

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 08, 2021, 08:54:15 pm
content: DavidAlphaAnd to further complicate the situation, I need to implement an alarm system. The PIC12F will disconnect the battery from the load when voltage reaches 11.0v. The alarm must be set to go off at 11.1v. The big question is: how will I implement this alarm while keeping the PIC12F ? Another issue is that the alarm cannot be with continuous sound, as it consumes battery power and will become very irritating. It should ring for 5 seconds at 20 second intervals.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 10, 2021, 11:22:00 am
content: HiIn supply mode (see flowchart), the GP2 port goes to high level (1), blocking the output of the LM723. With the LM723 output blocked, it doesn't matter the voltage value on Pin 5. This brings me the happy news that I will be able to freely use the GP4 and GP5 ports, to configure the alarm. It remains now to draw up a circuit for the alarm and here I accept suggestions.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 10, 2021, 03:20:40 pm
content: HiI have anActive Buzzerin my stock here, which will make my programming much easier. I will only have to worry about the on/off times (5 seconds ON and 20 seconds off). Now I have to remind myself how to activate and configure the PIC12F'sTimer1using the assembler.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 10, 2021, 06:53:30 pm
content: Why do you keep using the 12F? The low pin count is clearly limiting your project.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 10, 2021, 09:59:30 pm
content: DavidAlfaI have five PIC12F in my stock. It didn't limit the project, because I managed to implement everything I planned. It was just more challenging and as a bonus a little more knowledge gained. I managed to finish programming just now and if everything goes well in tomorrow's tests, I'll post theasmfile here.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 11, 2021, 09:58:57 pm
content: HiI finished rehearsals and programming. Everything working as planned. The updating of the scheme and the programming of the PICF12 follows, with the addition of the alarm.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 17, 2021, 08:07:46 pm
content: HiThe project is coming to an end. I decided to make the pcb like in ancient times (using the pen). It took me 8 hours to attach the modules to the cabinet and wire them together. Tomorrow will be more testing day.

author: ledtester
author_rank: Super Contributor
timestamp: October 18, 2021, 01:59:11 am
content: Looks nice!About how you made your PCB...- what pen did you use?- could you explain your process of laying out the tracks and transferring them to the pcb? Did you use a CAD / EDA or even a paint program to design the track layout?

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 20, 2021, 12:25:18 am
content: HiLedtester, I will comment on pcb when I finish testing.Giving sequences to tests, today was a day of a lot of learning. Testing the design with the values ​​at maximum capacity, I was revealed to have problems with temperatures in various components.image 1: I made the mistake of placing the MUR460 diode next to the pcb. I was cooking the pcb. The diode reached 90ºc. As you can see in the image, I put a new one far away. The Mosfets also had to be given a small heatsink.image 2: I was impressed with the temperature of the diode, so I decided to add a heatsink. I managed to get it down to 60ºc.images 3: When closing the case and testing for about 30 minutes, I noticed the temperature rise by more than 10ºC, in relation to the open case. Today the ambient temperature was 27ºC.Image 4: There was a risk that the transistor would overtake SOA, so I decided to use the fan. Transitor (tc) dropped to 45ºc. It also helped to minimize the diode temperature.image 5: Testing with the cabinet closed, with normalized temperatures .

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 20, 2021, 10:07:42 am
content: HiNew schematic update and PIC12F programming correction.1- The red LED did not provide the proper grounding point for the mosfet's drain (Q4 - Q6). A 10k resistor (R22) solved the issue.2- The regulation of the LM723 became unstable in float mode (low current to the battery). I solved the issue by adding a load with the 220R resistor (R21). With this it was possible to maintain a minimum current (around 70 mA), ensuring stability.3 - I detected a small error in the programming. I forgot to turn offtimer1when switching to charge mode.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 24, 2021, 04:16:57 pm
content: HiThe fan I had installed had a very loud noise level. I decided to replace it with one with PWM control (4 wires). Resistance values between 1k5 and 2k allows changing the fan rotation (36Hz - 110Hz). I inserted a potentiometer (p3) to adjust the minimum rotation, without harming the transistor cooling.The project followed the battery manufacturer's recommendation for two-stage charging. See highlighted what guides the manufacturer:Quote- I adopted the initial load current value at 0.18C. (0.25C maximum recommended).- The project does not have ambient temperature compensation. By adopting a "conservative" recharge, I didn't see this need for compensation.- Note in the table below that switching to float mode takes place within the manufacturer's recommendations (0.04~0.08C Amps).HourIcVbat8:001.2912.1958:301.2312.7349:001.2312.9459:301.2313.17010:001.2113.43510:301.1513.83011:000.6914.29011:300.2814.50011:380.2314.52311:380.1913.73111:500.1313.74912:300.0813.762

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: October 25, 2021, 04:19:47 pm
content: HiFinished work, went into operation.

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: November 02, 2021, 12:08:27 pm
content: Ledtester,As promised, follows the sequence of images, demonstrating how I assembled the PCB, by hand.1 - I developed the entire pcb layout in EasyEDA;2 - generated the gerb file;3 - from the gerb file, print the complete layout and the holes (image 1);4 - With a needle I pierced the paper at the perforation points (image 2);5 - With all the holes ready, I cut the paper so that I could properly fix it to the plate (image 3);6 - It is necessary to invert the drilling design when fixing on the plate (image 4);7 - fixing the paper to the plate (image 5);8 - With a mechanical pencil I mark the position of the holes on the plate (image 6). Observe the graffiti, marking the perforation on the plate (image 7);9- With the pcb layout inverted, my occupational therapy of joining the dots begins. I use the 1mm and 2mm pens. Retro Projector Pen. (figure.