Combining four functions, the process of making my "dual-core independent graphics" power supply 12-06

Publisher:温柔心绪Latest update time:2012-12-22 Source: 电子发烧友 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Recently, I made a "four-purpose" power supply that combines current source, voltage source, charging and soldering iron in one, and also has a display screen. During the design process, I used two single-chip microcomputers, one for variable acquisition and the other for display. So my colleagues called this "monster" a "dual-core independent display" power supply.

The core is to control a voltage regulator board built by MOS tubes, which can digitally control the voltage, so as to obtain a voltage source; through current feedback, the voltage is adjusted to obtain a current source; through current and voltage feedback, a lithium battery charger is obtained; through soldering iron temperature feedback, a constant temperature soldering iron controller is obtained. This is the idea. The microcontroller is Freescale QD4, two 16-bit timers/PWM, four-channel 10-bit AD. Its main functions are: 1. Voltage source; 2. Current source; 3. Charger; 4. Constant temperature soldering iron controller.

The following is the circuit diagram:

Main control circuit

Voltage regulation circuit

The NMOS in the voltage regulation circuit is based on the circuit of the white light soldering iron, but in order to make a fast switch, R9 in the figure cannot be too large. I use 500 ohms, and PWM 2KHZ is OK. The pull-up resistor R13 is also very important. When the microcontroller is abnormal, it ensures that the output is turned off. For the circuit of the MOS back end, you can refer to the DC chip data.

I will not write about the specific welding process. I believe you can make the corresponding product based on the circuit diagram I gave.

Here are some general and test pictures:

Overall appearance

The power input is a laptop power supply. The output is a USB port. I don't usually need a large current, 3A is enough, step 10ma. The maximum output voltage is close to the input voltage, step 0.01V. The display is a nokia5110 display (the above picture is powered by 5V, the screen has spots, the following is changed to 3.7V, the screen is perfect).

The input consists of a potentiometer and a button. The potentiometer can be used like an oscilloscope, and can be selected up and down, or a set value can be entered. A short press of the button is used for "confirmation", and a long press is used for "return". This information is collected by microcontroller 1 and sent to microcontroller 2 through a single line for display. Single-line communication took a lot of effort. The sampling resistor is 50m ohms and is amplified by 358. After the current is collected, it needs to be calibrated to eliminate the deviation.
After making all these things, we need to perform basic functional tests on them.

1. Voltage Source

In the figure below: 9.22V is the real voltage collected in real time, S: set value, I: current

The voltage output responds very quickly, oscilloscope screenshot

Quickly twist the potentiometer and you can draw with an oscilloscope

2. Current Source

In the figure below: 0.44A is the real current collected in real time, S: set value, V: voltage

3. Charging Mode

For testing, I took out the battery core of my mobile power bank. At that time, the cross-current charging current was 300ma, which was really a wait.

But it's nice to see so much output information.

0264mA is the cumulative charging capacity, I: current charging current, V: battery voltage

4. Soldering Iron Mode

The smoke is curling up... The company's thermal imager was sent for inspection, but the temperature cannot be calibrated. I used the formula to calculate it directly, but it seems to be too low. However, it is powered by a laptop, just right. I love this soldering iron

Introduce this USB soldering iron

The soldering iron is modified from Baiguang 936 soldering iron handle, connected to a USB head, the outer side is used as power line, and the USB data line is connected to the feedback resistor. After testing, 3A current, the USB port has no problem, and the temperature rise is also good, so the program is limited to 3A. If the current is too large, the laptop power supply will protect.

Here is a picture of me assembling the product into the box:

The shell was made by removing the plastic shell of a 12V/2A power supply. It took a lot of effort to stuff such a big thing in there.

Finally it's almost full

Entered!! The left picture

The right one

The above is the boot-up picture (why does it look like a mobile phone)...

So far, all the production has been completed.
During the production process, I would like to tell you some of my programming experience.

1. Time base function

I now think that this function should be necessary for every project, but when I think back to the microcontroller books I have read, it seems that this point has not been mentioned. I regret not meeting it earlier.
void TimePro()
{
if (! b_8msFG)
return;
b_8msFG = 0;
Tim8ms++;
PIHtim++;
if (KeyTim < 255)
KeyTim++;
if (PIHtim > 4)
{
TPM2C0SC = 0x48; //Open external interrupt
}
LCDTim++;
LCDFlashTim++;
if (Tim1ms > 124)
{
Tim1ms = 0;
Tim1S++;
……
……
……
}
}
The above is a "time base function". When your program has several peripherals that need to be controlled at the same time, and then use NOP delay, the linear execution is already too busy, and you need to use the above function.
b_8msFG is set to 1 in the 8ms timer interrupt. TimePro() is called in the main function. In this way, the timing variables such as KeyTim and LCDTim are always timing. For example, when calling the keyboard program, it is determined whether KeyTim has reached the time. If it has reached the time, it will be executed, KeyTim will be cleared, if not, it will return, and then call other function bodies. In this way, the CPU is reused in time, avoiding NOP to waste system resources, especially when the execution cycles of several peripherals are different.

2. AD sampling (digital filtering)

This program is a standard module of the company. When I was in college, I used AD directly after sampling. I found that this was not good until I started working. After sampling, I had to do digital filtering. Digital filtering, I don’t know who gave it such a nice name, it fooled many people. In fact, it is very simple, but very practical. Here, the actual operation is: sample six times, remove the maximum and minimum values, and find the average of the remaining four. I didn’t have a deep understanding of its role before. When there was a project in which a single-chip microcomputer directly measured the true effective value of AC, an unsightly waveform entered the single-chip microcomputer. After digital filtering, the value was stable and did not jump randomly, which made me feel emotional.
Below is the program:
void ADPro()
{
uchar n, i;
if (ADTim < 10) return;
ADTim = 0;
for (n=0; n<6; n++)
{
ADChannel = Channelin; //Channel selection;
while (!ADC1SC1_COCO) NOP(); //Wait for conversion to complete
ADC1SC1_COCO = 0;
ADNum = ADC1R; //Get AD value
// ADNum = 298;
if (0==n)
{
m_ADCSum = 0;
m_ADCMax = ADNum;
m_ADCMin = ADNum;
}
if (ADNum < m_ADCMin)
{
m_ADCMin = ADNum;
}
else if (ADNum > m_ADCMax)
{
m_ADCMax = ADNum;
}
m_ADCSum += ADNum;
ADNum = 0;
}
m_ADCSum=m_ADCSum-m_ADCMax;
m_ADCSum = m_ADCSum-m_ADCMin; //Subtract the maximum and minimum values
​​m_ADCSum = m_ADCSum》》2; //Get the average
switch (Channelin)
{
case 0:
ADSet = m_ADCSum;
break;
case 1:
ADI = m_ADCSum;
break;
case 2 :
ADTemp = m_ADCSum;
break;
case 3:
ADV = m_ADCSum;
break;
default:
break;
}
Channelin ++; //Switch channel
if (Channelin 》 3)
Channelin = 0;
}
If AD is used to control the output, it is even more necessary to do this. Avoid malfunction at critical values.

3. Keyboard program

//---------------------------------
//Key program
//---------------------------------
void KeyPro()
{
if (KeyScanTim < 200) //20ms scan time base function timing
return;
KeyScanTim = 0;
//KeySet
if (!PI_KeySet)
{
if (b_KeySetBac)
{
if (KeySetCount < 255)
KeySetCount ++;
}
else
b_KeySetBac = 1;
if (KeySetCount > 6)
{
b_KeySetLong = 1; //Long press, no need to release to generate
KeyNum = 0;
KeySetCount = 0;
b_KeySetBac = 0;
LongKeyExitTim = 0;
}
}
else
{
if (b_KeySetBac && LongKeyExitTim > 2) //Prevent a redundant short key from being generated after a long press
{
b_KeySet = 1; //Short press, generates
KeyNum = 0 after releasing;
}
b_KeySetBac = 0;
KeySetCount = 0;
}
}
A button can respond to both long press and short press.

Reference address:Combining four functions, the process of making my "dual-core independent graphics" power supply 12-06

Previous article:Creative solar inflatable lamp: 360 degrees lighting in the room after power outage
Next article:Goal Zero Switch 8 Solar Charging Kit

Latest Power Management Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号