EEVblog Electronics Community Forum
Electronics => Projects, Designs, and Technical Stuff => Topic started by: Avelino Sampaio on October 03, 2021, 04:24:27 pm
-
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?
-
...
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.
...
How 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?
-
Ledtester, I am disconnecting the AC side of the power supply and leaving the DC end connected to the circuit.
-
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?
-
Ledtester, I'm looking up the digital value in a loop.
I verified that the transition from bit 1 to bit 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?
-
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.
-
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.
-
Hi
The project is advancing, see the complete schematic. Replace the containment diode with a P-channel Mosfet, with RDSon=0.06R.
-
Hi
I am providing the "asm" and "hex" files from the PIC12F675.
-
C3 will cause some delay to the response, too.
Instead R1+R2, use a zener, the falling voltage will be detected much faster.
-
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.
-
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.
config:
BSF GPIO,1 Set GPIO1 as input
BCF ANSEL,1 Set GPIO1 as analog
MOVLW B'10000010' Enable Vref, set high range, internal vref, 1.56V
MOVFW VRCON
MOVLW B'00000100' Cin- to GPIO1, Cin+ to Vref, Cout pin unused
MOVWF CMCON
scan:
BTFSC CMCON,COUT Test COUT bit
GOTO 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 scanning
Then 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.
-
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.
-
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!
-
DavidAlpha
And 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.
-
Hi
In 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.
-
Hi
I have an Active Buzzer in 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's Timer1 using the assembler.
-
Why do you keep using the 12F? The low pin count is clearly limiting your project.
-
DavidAlfa
I 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 the asm file here.
-
Hi
I 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.
-
Hi
The 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.
-
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?
-
Hi
Ledtester, 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 .
-
Hi
New 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 off timer1 when switching to charge mode.
-
Hi
The 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:
Constant Voltage Charge in Two Stages
This charging mode is recommended to charge the battery quickly and keep it floating. In the initial charging stage, the battery is charged by a constant current up to a voltage of 2.45 V/element. At this point the load is automatically switched to a constant voltage load. After the constant current charging stage (A~B), the battery is charged by a float voltage of 2.3V/he (B~C). Switching to constant load voltage takes place after the battery reaches 80% charge of its rated capacity. This method is efficient because it minimizes charge time during the initial charge stage and protects the battery from overcharging during the final float charge stage. This charging method cannot be used in applications where the charge and battery are connected in parallel.
Initial load current: 0.25C Amps (maximum)
load voltage
First stage: 2.45 V/he (2.40~2.50 V/he maximum)
Second stage: 2.28 V/he (2.25~2.30 V/he maximum)
Switching: 0.05C Amps (0.04~0.08C Amps)
- 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).
Hour | Ic | Vbat |
8:00 | 1.29 | 12.195 |
8:30 | 1.23 | 12.734 |
9:00 | 1.23 | 12.945 |
9:30 | 1.23 | 13.170 |
10:00 | 1.21 | 13.435 |
10:30 | 1.15 | 13.830 |
11:00 | 0.69 | 14.290 |
11:30 | 0.28 | 14.500 |
11:38 | 0.23 | 14.523 |
11:38 | 0.19 | 13.731 |
11:50 | 0.13 | 13.749 |
12:30 | 0.08 | 13.762 |
-
Hi
Finished work, went into operation.
-
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 8).