2431 views|12 replies

297

Posts

0

Resources
The OP
 

[RVB2601 Creative Application Development] 3. RGB three-color breathing light of RVB2601 [Copy link]

 
 This post was last edited by kit7828 on 2022-3-10 14:00

There is a ch2601_rgb_marquee_demo in the routine of Pingtou Ge, which is a demo to realize the three-color marquee effect of RGB LED lamp beads. After decompression, open the project file directly (I can't find the option to open the project file directly in CDK. I don't know if I have to open the workspace first to have this function?)

After opening in CDK, there is still an error display

Still right click on sdk_chip_ch2601 to download related components

Then it will automatically download

You need to wait for a while after downloading, there are a lot of items to install

After the installation is complete, you can compile and download

After downloading is complete

You need to press the RST button on the right side of the development board to run

If the serial port is turned on, you can see debugging information appearing on the serial port

The overall effect is as follows

The code uses GPIO and PWM to control the three-color RGB light.

To further test the PWM effect, I want to change the routine to a three-color breathing light effect.

So, first enable PWM mode in app_config.h

Then modify void led_refresh() in led.c

void led_refresh()
{
	csi_error_t ret;
	uint32_t g_lux = 0;
	
	//udelay(10);
    
	g_dly ++;
	if(g_dly == 60) {
		g_dly = 0;
		
		g_ctr++;
		if (g_ctr == 3) g_ctr = 0;
		if (g_ctr == 0)
		{
			csi_pwm_out_stop(&r, 2 / 2);
			csi_pwm_out_stop(&r, 4 / 2);

		}
		else if (g_ctr == 1)
		{ 
			csi_pwm_out_stop(&r, 7 / 2);
			csi_pwm_out_stop(&r, 4 / 2);
		}
		else //2
		{
			csi_pwm_out_stop(&r, 7 / 2);
			csi_pwm_out_stop(&r, 2 / 2);
		}
	}
	
	if(g_dly <= 30) g_lux = g_dly;
	else g_lux = 60 - g_dly;
		
    if (g_ctr == 0)
    {
		ret = csi_pwm_out_config(&r, 7 / 2, 30, g_lux, PWM_POLARITY_LOW);
		if (ret != CSI_OK) {
				printf("===%s, %d\n", __FUNCTION__, __LINE__);
				return ;
		}
        csi_pwm_out_start(&r, 7 / 2);
        //csi_pwm_out_stop(&r, 2 / 2);
        //csi_pwm_out_stop(&r, 4 / 2);

    }
    else if (g_ctr == 1)
    {        
		ret = csi_pwm_out_config(&r, 2 / 2, 30, g_lux, PWM_POLARITY_LOW);
		if (ret != CSI_OK) {
				printf("===%s, %d\n", __FUNCTION__, __LINE__);
				return ;
		}
        csi_pwm_out_start(&r, 2 / 2);
        //csi_pwm_out_stop(&r, 7 / 2);
        //csi_pwm_out_stop(&r, 4 / 2);

    }
    else //2
    {
		ret = csi_pwm_out_config(&r, 4 / 2, 30, g_lux, PWM_POLARITY_LOW);
		if (ret != CSI_OK) {
				printf("===%s, %d\n", __FUNCTION__, __LINE__);
				return ;
		}
        csi_pwm_out_start(&r, 4 / 2);
        //csi_pwm_out_stop(&r, 7 / 2);
        //csi_pwm_out_stop(&r, 2 / 2);

    }
	
}

Among them, g_dly is a global variable

In this way, the breathing effect was found to be very poor. After checking, it was found that the delay time in the main loop was too long

If you reduce the delay parameter by 10 times, you can almost see the breathing effect

The finished effect is as follows

The breathing effect of the three-color light is achieved by PWM. Since I am not very familiar with the PWM control method of the Pingtouge chip, it is currently achieved by constantly adjusting the configuration function csi_pwm_out_config, rather than directly modifying the register method, so the overall effect is not perfect. I hope to learn more about this chip in the future and achieve more perfect control.

Latest reply

csi_pwm_out_stop(&r,7/2), why is the 7/2 channel a decimal?   Details Published on 2022-3-19 23:36
 
 

6587

Posts

0

Resources
2
 

The RGB adjustment of RVB2601 includes other color settings. In the app_config.h file, switch the macro definition and configure the function of the LED pin to CONFIG_PWM_MODE

Configure the duty cycle bright_ctr to change the brightness.

Comments

OK, thanks  Details Published on 2022-3-8 13:13
 
 
 

7452

Posts

2

Resources
3
 

Yes, it's too fast to see any effect, the frequency change is fleeting.

Comments

There is no breathing effect.  Details Published on 2022-3-8 13:14
Personal signature

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

 
 
 

297

Posts

0

Resources
4
 
Jacktang posted on 2022-3-7 21:02 The RGB adjustment of RVB2601 includes other color settings. In the app_config.h file, switch the macro definition and configure the function of the LED pin to CONFIG_PWM_ ...

OK, thanks

 
 
 

297

Posts

0

Resources
5
 
freebsder posted on 2022-3-7 22:31 Yes, it's too fast to see any effect, the frequency change is fleeting.

There is no breathing effect.

Comments

Yes, this frequency is not easy to adjust. I just used the breathing light for the first time last month. If it is too fast, it will not work. If it is too full, there will be a noticeable pause. It takes some effort to simulate the breathing frequency.  Details Published on 2022-3-8 22:59
 
 
 

7452

Posts

2

Resources
6
 
kit7828 posted on 2022-3-8 13:14 There is no breathing effect

Yes, this frequency is not easy to adjust. I just used the breathing light for the first time last month. If it is too fast, it will not work. If it is too full, there will be a noticeable pause. It takes some effort to simulate the breathing frequency.

Comments

I was lazy in this review and used linear PWM adjustment directly. In fact, if I change it to array mode and nonlinear mode, the effect will be much better.   Details Published on 2022-3-9 12:41
Personal signature

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

 
 
 

297

Posts

0

Resources
7
 
freebsder posted on 2022-3-8 22:59 Yes, this frequency is not easy to adjust. I just tried the breathing light for the first time last month. It has no effect when it is too fast, and there is a noticeable pause when it is full. It needs a real simulation...

I was lazy in this review and used linear PWM adjustment directly. In fact, if I change it to array mode and nonlinear mode, the effect will be much better.

 
 
 

149

Posts

0

Resources
8
 

How does CDK view the internal situation of a function?

Comments

Yesterday I saw a question in the group summary that mentioned that first you need to parse all projects in the CDK Project menu and then right-click goto declaration  Details Published on 2022-3-16 13:33
 
 
 

149

Posts

0

Resources
9
 

What is the effect of two consecutive csi_pwm_out_stops?

Comments

Three-color light, so turn off the PWM channels of the other two colors, only one color is lit  Details Published on 2022-3-16 13:34
 
 
 

297

Posts

0

Resources
10
 
Mengxi Kaiwu published on 2022-3-15 15:49 How to view the internal situation of a function in CDK?

Yesterday I saw a question summary in the group that mentioned that first, parse all projects in the CDK Project menu

Then you can right click goto declaration

Comments

Thank you  Details Published on 2022-3-17 09:46
 
 
 

297

Posts

0

Resources
11
 
Mengxi Kaiwu published on 2022-3-16 09:43 What is the function of two consecutive csi_pwm_out_stop

Three-color light, so turn off the PWM channels of the other two colors, only one color is lit

Comments

csi_pwm_out_stop(&r,7/2), why is the 7/2 channel a decimal?  Details Published on 2022-3-19 23:36
 
 
 

149

Posts

0

Resources
12
 
kit7828 posted on 2022-3-16 13:33 Yesterday I saw in the group's problem summary that it was mentioned that first, in the CDK Project menu, parse all projects and then...

Thank you

 
 
 

149

Posts

0

Resources
13
 
kit7828 posted on 2022-3-16 13:34 Three-color light, so turn off the PWM channels of the other two colors, and only light up one color

csi_pwm_out_stop(&r,7/2), why is the 7/2 channel a decimal?

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

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