3919 views|8 replies

6818

Posts

11

Resources
The OP
 

[Qinheng RISC-V core CH582] PWM control heater [Copy link]

 This post was last edited by lugl4313820 on 2022-3-24 22:21

[Qinheng RISC-V core CH582] Timer PWM drive servo https://en.eeworld.com/bbs/thread-1197629-1-1.html

[Qinheng RISC-V core CH582] Feasibility of using solid-state relays to control the heating tube of the heater in CH582 https://en.eeworld.com/bbs/thread-1197474-1-1.html

[Qinheng RISC-V core CH582] WeChat applet controls lighting https://en.eeworld.com/bbs/thread-1197168-1-1.html

[Qinheng RISC-V core CH582] BLE lighting https://en.eeworld.com/bbs/thread-1195457-1-1.html

[Foreword] The work I prepared for the evaluation was to make a mobile phone APP to control the heater. After a period of practice, including learning CH582 PWM, timer, Bluetooth, etc., and making WeChat applet, all of these are the preparation for today's comprehensive control. My main ideas are:

1. CH582 is used as the master control device. The timer is enabled and an interrupt is made every 500ms to count. 5 seconds is a process of controlling the heating wire heating. During this time interval, the solid-state relay works once, thus ensuring the life of the relay.

2. Monitor the instructions of the mobile phone APP through Bluetooth, and update the heating count cycle after receiving the instructions.

3. The timer interrupt determines the switch of the output high and low levels to control the relay according to the heating count cycle.

【Main steps】

1. Timer 0. According to the timer routine, I will copy the example and initialize the timer:

GPIOB_SetBits(GPIO_Pin_15); //开机设置低电平,以免误开电热管
GPIOB_ModeCfg(GPIO_Pin_15, GPIO_ModeOut_PP_20mA); //输出一定要选择20mA要不驱动不了继电器
TMR0_TimerInit(FREQ_SYS/2);         // 设置定时时间500ms
TMR0_ITCfg(ENABLE, TMR0_3_IT_CYC_END); // 开启中断
PFIC_EnableIRQ(TMR0_IRQn);

2. Define several functions to determine whether the relay is on or off:

uint8_t thisHeartTime; //Used for timer to calculate current time
uint32_t heatingTime; //Used to save the counting time sent by APP

#define allHeartTime 9 //Used to calculate the working cycle, 0-9 is exactly 5 seconds.

3. Timer interrupt function

void TMR0_IRQHandler(void) // TMR0 定时中断
{
    if(TMR0_GetITFlag(TMR0_3_IT_CYC_END))
    {
        TMR0_ClearITFlag(TMR0_3_IT_CYC_END); // 清除中断标志
        //500ms进中断一次
        GPIOB_InverseBits(GPIO_Pin_15);
        if (heatingTime == 0) //0为APP发过来关的指令
        {
            GPIOB_ResetBits(GPIO_Pin_15);
        }
        else if(heatingTime == allHeartTime) //如果发过来的指令等计数周期,则为全开的指令
        {
            GPIOB_SetBits(GPIO_Pin_15);
        }
        //用周期时间减出当前时间,来决定是否开启继电器
        else if ((allHeartTime - thisHeartTime)>= heatingTime) {
            GPIOB_ResetBits(GPIO_Pin_15);
        }
        else {
            GPIOB_SetBits(GPIO_Pin_15);
        }
        //计数器自增与周期归零
        thisHeartTime ++;
        if (thisHeartTime == allHeartTime) {
            thisHeartTime = 0;
        }
     }
}

4. Processing of receiving callback function:

static void simpleProfileChangeCB(uint8_t paramID, uint8_t *pValue, uint16_t len)
{
    switch(paramID)
    {
        case SIMPLEPROFILE_CHAR1:
        {
            uint8_t newValue[SIMPLEPROFILE_CHAR1_LEN];
            tmos_memcpy(newValue, pValue, len);
            PRINT("profile ChangeCB CHAR1.. %s\n",newValue);
            heatingTime = pValue[0]-'0'; //由于上位机发过来的是字符0-9,所以要减去‘0’
            break;
        }

5. Wiring diagram of relay and development board:

6. Development board working power supply: 220 to 5V power supply bought from a certain fish:

7. I also bought the solid-state relay from a certain fish market, 250V/10A. It cost about 10 yuan. This is the most expensive part.

8. Heater. I was going to dismantle my own heater in the morning, but when I went downstairs to mail a package, I happened to pick up a heater that a neighbor had lost. I originally wanted to use his power cord, but when I disassembled it, I found that the MOS tube he used was open, but the heating wire was still good, so I used his to modify it.

9. Mobile APP, I designed 5 levels as shown below:

【Experimental results】

After the power is turned on, the development board works with a 220 to 5V power supply to power on the development board. Since the power-on heatingTime is initialized to 0, the relay is in the closed state, which prevents the relay from turning on automatically after a power outage. After the phone is turned on, search for Bluetooth. After connecting, you can press 1-3 levels, from low to high temperature, or fully open. 1-3 levels are heating for a while and then off for a while, and fully open is always on. Attached is the video I uploaded.

【think】

1. I have been learning this development board for almost a month, from learning and operating Bluetooth, timer, spi, and USB. I feel that Qinheng's products are very easy to operate. RISC-V is simpler to operate than ARM. As long as you have the basics and read the routines carefully, you can basically operate this chip.

2. Regarding making a remote control heater, I used to throw away many heaters at home because of burnt switches, just like the one I picked up today. Also, the heater is placed under the table, which is not very convenient to operate. When you stretch your hand down, you may not be able to touch the switch immediately. Some heaters have only two gears, sometimes they are too hot, or the lower gear is not hot enough. So if you use a Bluetooth APP to control it, the comfort will be relatively better. In addition, using a solid-state relay to indirectly switch the heating wire is better than using a diode to reduce the conduction of the heating tube.

3. Of course, this work still needs to be improved. For example, the price is relatively more expensive than a switch or MOS switch that costs a few dollars, and the life of the solid-state relay remains to be verified.

【Next steps】

1. Use NTC to measure the ambient temperature and report it to the mobile phone APP. You can understand the temperature in real time to control the temperature more accurately.

2. Beautify the mobile APP and make the interface look more beautiful. After binding the device, you can open the applet and automatically connect the Bluetooth module, reducing the steps of manual search.

3. If there is a device that supports drawing boards, can you make one yourself? This way, the work will be more perfect.

Of course, there is still a lot to learn and master about the evaluation of this development board. As long as I have time, I will continue to share with forum friends. If there are any mistakes, please point them out enthusiastically so that I can grow further. Thank you!


This post is from Domestic Chip Exchange

Latest reply

The ultimate cost   Details Published on 2022-4-20 09:53
 
 

6547

Posts

0

Resources
2
 

Solid-state relays are indeed more expensive than switches or MOS switches that cost a few dollars, and their lifespan should not be as good as MOS electronic switches. They may achieve higher power, and each has its own advantages.

Looking forward to the following review content listed by the host

This post is from Domestic Chip Exchange

Comments

I just checked and found that the cost of bidirectional silicon + optocoupler is indeed much cheaper.   Details Published on 2022-3-25 09:39
 
 
 

6818

Posts

11

Resources
3
 
Jacktang posted on 2022-3-25 07:44 Solid-state relays are indeed more expensive than switches or MOS switches that cost a few dollars, and their lifespan should not be as good as MOS electronic switches. The power they may achieve will be larger. Each has its own advantages...

I just checked and found that the cost of bidirectional silicon + optocoupler is indeed much cheaper.

This post is from Domestic Chip Exchange
 
 
 

7422

Posts

2

Resources
4
 

Your 220->5 looks like it's about to boom at any moment.

This post is from Domestic Chip Exchange

Comments

It's ok, I've used it on other appliances for a year and still no BOOM!  Details Published on 2022-3-25 22:49
It's ok, I've used it on other appliances for a year and still no BOOM!  Details Published on 2022-3-25 22:48
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

6818

Posts

11

Resources
5
 
freebsder posted on 2022-3-25 22:01 Your 220->5 looks like it will boom at any time.

It's ok, I've used it on other appliances for a year and still no BOOM!

This post is from Domestic Chip Exchange
 
 
 

6818

Posts

11

Resources
6
 
freebsder posted on 2022-3-25 22:01 Your 220->5 looks like it will boom at any time.

The workmanship and materials are very solid. It should be separated from other boards. It is okay to finish it yourself, but it is definitely not suitable for commercial use.

This post is from Domestic Chip Exchange
 
 
 

6818

Posts

11

Resources
7
 

I found another broken heater today, hoping to get a new development board to revive it!

This post is from Domestic Chip Exchange
 
 
 

295

Posts

0

Resources
8
 

The ultimate cost

This post is from Domestic Chip Exchange

Comments

Yes, the heater I modified with ESP32 is very durable. I had to replace the previous heaters several times a year.  Details Published on 2022-4-20 13:02
 
 
 

6818

Posts

11

Resources
9
 

Yes, the heater I modified with ESP32 is very durable. I had to replace the previous heaters several times a year.

This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list