在线时间223 小时
UID3159710
注册时间2015-9-1
NXP金币150
TA的每日心情 | 擦汗 2017-12-29 14:09 |
---|
签到天数: 144 天 连续签到: 1 天 [LV.7]常住居民III
金牌会员
 
- 积分
- 1835
- 最后登录
- 2019-3-18
|
本帖最后由 liao122 于 2016-12-15 21:13 编辑
项目描述:以LPC824为主控,通过DS18B20进行温度采集,用0.96 OLED来显示,控制继电器开关电。
关键词:DS18B20 OLED LPC824
结构框图:
继电器控制电路:火线和零线分别用一个继电器控制,当三极管不导通时继电器断开,两个继电器用一个IO口控制
OLED和DS18B20和按键电路:
实物图:
实物连接图:
由于继电器是5V的,所以用arduino 来提供5V
按键可以设置断电的温度,当室内温度低于设置温度是排插将断电,当室内温度高于设置温度排插将通电,同时会记录通电的时长,断电时停止计时。
视频演示:
程序用多速率定时器提供10ms 节拍,和1s计时节拍,部分延时用SysTick 定时器,程序的执行采用分时复用的形式。
- void PowerControl(void)
- {
- if (current_temperature > stop_temperature)
- {
- LPC_GPIO_PORT->CLR0 |= RED;
- DROP_POWER_CLR; //低电平驱动光耦
- drop_power_flag = 1;
- }
- else
- {
- LPC_GPIO_PORT->SET0 |= RED;
- DROP_POWER_SET;//高电平驱动光耦
- drop_power_flag = 0;
- }
- }
- int main(void)
- {
- // Enable clocks to relevant peripherals
- LPC_SYSCON->SYSAHBCLKCTRL |= (WKT|MRT|GPIO|IOCON);
-
- //Configure the MRT
- //Give the module a reset
- LPC_SYSCON->PRESETCTRL &= (MRT_RST_N);
- LPC_SYSCON->PRESETCTRL |= ~(MRT_RST_N);
- //Mode = repeat, interrupt = enable
- LPC_MRT->Channel[0].CTRL = (MRT_Repeat<<MRT_MODE) | (1<<MRT_INTEN);
- LPC_MRT->Channel[1].CTRL = (MRT_Repeat<<MRT_MODE) | (1<<MRT_INTEN);
-
- LPC_MRT->Channel[0].INTVAL = ForceLoad | 30000000; // = ,30MHz, 1s
- LPC_MRT->Channel[1].INTVAL = ForceLoad | 00300000; // =, 0.3MHz,10ms
- //Enable the MRT interrupt in the NVIC
- NVIC_EnableIRQ(MRT_IRQn);
-
- Config_LEDs(RED);
- Config_OLED();
- LCD_Init();
- Config_DS18B20();
- Config_KEY();
- Config_PowerControlPin();
- DecToString(cur_temper_str,current_temperature);
- DecToString(stop_temper_str,stop_temperature);
-
- DecToString(second_str,second);
- DecToString(minute_str,minute);
- DecToString(hour_str,hour);
-
- LCD_P14x16Ch(0,0,0); //实
- LCD_P14x16Ch(14,0,1); //际
- LCD_P14x16Ch(28,0,2); //时
- LCD_P14x16Ch(42,0,3); //间
- LCD_P14x16Ch(56,0,4); //:
- LCD_P8x16Str(70,0,cur_temper_str);
- LCD_P14x16Ch(94,0,10); //℃
-
- LCD_P14x16Ch(0,2,5); //断
- LCD_P14x16Ch(14,2,6); //电
- LCD_P14x16Ch(28,2,7); //温
- LCD_P14x16Ch(42,2,8); //度
- LCD_P14x16Ch(56,2,4); //:
- LCD_P8x16Str(70,2,stop_temper_str);
- LCD_P14x16Ch(94,2,10); //℃
- LCD_P8x16Str(32,4,"liao122");
-
- LCD_P6x8Str(hour_position,6,hour_str);
- LCD_P6x8Str(hour_position+12,6,":");
- LCD_P6x8Str(hour_position+18,6,minute_str);
- LCD_P6x8Str(hour_position+30,6,":");
- LCD_P6x8Str(hour_position+36,6,second_str);
-
- while(1)
- {
-
- StartTaskTemperature();
- TaskTemperature();
- DecToString(cur_temper_str,current_temperature);
- LCD_P8x16Str(70,0,cur_temper_str);
- TaskKey();
- TimeCount();
- PowerControl();
- }
- } // end of main
复制代码
整个工程见附件,工程从例程中复制出来了,IAR环境
温控排插.zip
(770.32 KB, 下载次数: 33)
|
|