SMT(SF)
示例一:
uint iPwmDuty;
double temp; temp = (double)AdConvert(AN_TEMPERATURE);
temp = temp/; iPwmDuty = (int)(temp+0.5)>(int)temp?(int)temp+:(int)temp;
如果参数在xx.5附近,易产生不稳定摆动
SMT(SF)
uint iPwmDuty;
uint temp,temp4,temp6;
static uint LastiPwmDuty; temp = AdConvert(AN_TEMPERATURE);
temp = temp/; //放大10倍,保留一位小数 temp6 = (temp+)/;
temp4 = (temp+)/;
temp = temp/; if(temp6 > temp)
{
iPwmDuty = temp6;
}
else if(temp4 == temp)
{
iPwmDuty = temp;
}
else
{
if(temp >= LastiPwmDuty)//由小到大
{
iPwmDuty = temp6;
}
else //(iPwmDuty < LastiPwmDuty)
{
iPwmDuty = temp4;
}
}
LastiPwmDuty = iPwmDuty;
示例二:
uchar CanCharge(void)
{
uint temp;
static uchar ChgState = FALSE; if(AdResult[AD_SUNBORD] > AdResult[AD_OPEN_BAT] )
{
temp = AdResult[AD_SUNBORD] - AdResult[AD_OPEN_BAT];
}
else
{
temp = ;
}
if (temp > )// 1V = 1/2.5/4.096*4096 = 400; 0.1V = 40;
{
ChgState = TRUE;
}
else if(temp <= )
{
ChgState = FALSE;
}
return ChgState;
}
示例三:
//#include<pic16f1828.h>
#include<htc.h>
#include "adc.h" __CONFIG(FOSC_INTOSC&WDTE_OFF&PWRTE_ON&MCLRE_OFF&CP_ON&CPD_ON&BOREN_ON&CLKOUTEN_OFF&IESO_OFF&FCMEN_OFF);
__CONFIG(WRT_ALL&PLLEN_OFF&STVREN_ON&LVP_OFF); #define uchar unsigned char
#define uint unsigned int #define RLY1 LATA5
#define RLY2 LATA4
#define RLY3 LATC4 #define RLY_ON 0
#define RLY_OFF 1
#define LED_ON 1
#define LED_OFF 0
#define TRUE 1
#define FALSE 0 #define LED1 LATC2 //LED1(DS3)-RLY1
#define LED2 LATC1 //LED2(DS2)-RLY2
#define LED3 LATC0 //LED3(DS1)-RLY3 #define Connect3 262 //26.2V
#define DisConnect3 238 //23.8V
#define Connect2 260
#define DisConnect2 225
#define Connect1 255 //25.5V
#define DisConnect1 215 //21.5V void DisplayLed(void); void main()
{
uint BAT_SENSE ,BAT_VOLT;
static uint LoadConnect3,LoadConnect2,LoadConnect1;
static uint LoadDisConnect3,LoadDisConnect2,LoadDisConnect1;
static uchar RLY1_States,RLY2_States,RLY3_States; init_a2d(); TRISA = 0x08; //MCLR = 1;
TRISC = 0x40;
ANSELC= 0x40; //set anolog in BAT_SENSE = MiddleADValue();
BAT_VOLT = (uint)(BAT_SENSE*0.78125);//AD/1024*5*16 = (V); 5*160/1024 =800/1024 = 0.78125(参数放大10倍) //Automatic system voltage recognition
if(BAT_VOLT <){//12V
LoadConnect3 = Connect3>>;
LoadDisConnect3 = DisConnect3>>;
LoadConnect2 = Connect2>>;
LoadDisConnect2 = DisConnect2>>;
LoadConnect1 = Connect1>>;
LoadDisConnect1 = DisConnect1>>;
}else if(BAT_VOLT >){//48V
LoadConnect3 = Connect3<<;
LoadDisConnect3 = DisConnect3<<;
LoadConnect2 = Connect2<<;
LoadDisConnect2 = DisConnect2<<;
LoadConnect1 = Connect1<<;
LoadDisConnect1 = DisConnect1<<;
}else{//24V
LoadConnect3 = Connect3;
LoadDisConnect3 = DisConnect3;
LoadConnect2 = Connect2;
LoadDisConnect2 = DisConnect2;
LoadConnect1 = Connect1;
LoadDisConnect1 = DisConnect1;
} RLY1_States = FALSE;
RLY2_States = FALSE;
RLY3_States = FALSE;
RLY1 = RLY_OFF;
RLY2 = RLY_OFF;
RLY3 = RLY_OFF; LED1 = LED_OFF;
LED2 = LED_OFF;
LED3 = LED_OFF;
} while()
{
BAT_SENSE = MiddleADValue();
BAT_VOLT = (uint)(BAT_SENSE*0.78125);//5*160/1024 =800/1024 = 0.78125 if(BAT_VOLT < LoadDisConnect1)
{
RLY1_States = FALSE;
}
else if(BAT_VOLT > LoadConnect1)
{
RLY1_States = TRUE;
} if(BAT_VOLT < LoadDisConnect2)
{
RLY2_States = FALSE;
}
else if(BAT_VOLT > LoadConnect2)
{
RLY2_States = TRUE;
} if(BAT_VOLT < LoadDisConnect3)
{
RLY3_States = FALSE;
}
else if(BAT_VOLT > LoadConnect3)
{
RLY3_States = TRUE;
}
//=====================================================
if(RLY1_States == TRUE)
{
RLY1 = RLY_ON;
}
else
{
RLY1 = RLY_OFF;
}
if(RLY2_States == TRUE)
{
RLY2 = RLY_ON;
}
else
{
RLY2 = RLY_OFF;
}
if(RLY3_States == TRUE)
{
RLY3 = RLY_ON;
}
else
{
RLY3 = RLY_OFF;
}
DisplayLed();
_delay();
}
} void DisplayLed(void)
{
//LED state set synchronization
if(RLY1_States == TRUE)
{
LED1 = LED_ON;
}
else
{
LED1 = !LED1;
} if(RLY2_States == TRUE)
{
LED2 = LED_ON;
}
else
{
LED2 = !LED2;
} if(RLY3_States == TRUE)
{
LED3 = LED_ON;
}
else
{
LED3 = !LED3; //One LED twinkle
}
}
//#include<pic16f1828.h>
#include<htc.h>
#include "adc.h" __CONFIG(FOSC_INTOSC&WDTE_ON&PWRTE_OFF&MCLRE_OFF&CP_ON&CPD_ON&BOREN_ON&CLKOUTEN_OFF&IESO_OFF&FCMEN_OFF);
__CONFIG(WRT_ALL&PLLEN_OFF&STVREN_ON&LVP_OFF); #define uchar unsigned char
#define uint unsigned int #define RLY1 LATA5
#define RLY2 LATA4
#define RLY3 LATC4 #define RLY_ON 0
#define RLY_OFF 1
#define LED_ON 1
#define LED_OFF 0 #define LED1 LATC2 //LED1(DS3)-RLY1
#define LED2 LATC1 //LED2(DS2)-RLY2
#define LED3 LATC0 //LED3(DS1)-RLY3 #define Connect3 262 //26.2V
#define DisConnect3 238 //23.8V
#define Connect2 260
#define DisConnect2 225
#define Connect1 255 //25.5V
#define DisConnect1 215 //21.5V void DisplayLed(void); void main()
{
uchar flag;
uint BAT_SENSE ,BAT_VOLT; static uint LoadConnect3,LoadConnect2,LoadConnect1;
static uint LoadDisConnect3,LoadDisConnect2,LoadDisConnect1; init_a2d(); TRISA = 0x08; //MCLR = 1;
TRISC = 0x40;
ANSELC= 0x40; //set anolog in BAT_SENSE = MiddleADValue();
BAT_VOLT = (uint)(BAT_SENSE*0.78125);//AD/1024*5*16 = (V); 5*160/1024 =800/1024 = 0.78125(参数放大10倍) //Automatic system voltage recognition
if(BAT_VOLT <){//12V
LoadConnect3 = Connect3>>;
LoadDisConnect3 = DisConnect3>>;
LoadConnect2 = Connect2>>;
LoadDisConnect2 = DisConnect2>>;
LoadConnect1 = Connect1>>;
LoadDisConnect1 = DisConnect1>>;
}else if(BAT_VOLT >){//48V
LoadConnect3 = Connect3<<;
LoadDisConnect3 = DisConnect3<<;
LoadConnect2 = Connect2<<;
LoadDisConnect2 = DisConnect2<<;
LoadConnect1 = Connect1<<;
LoadDisConnect1 = DisConnect1<<;
}else{//24V
LoadConnect3 = Connect3;
LoadDisConnect3 = DisConnect3;
LoadConnect2 = Connect2;
LoadDisConnect2 = DisConnect2;
LoadConnect1 = Connect1;
LoadDisConnect1 = DisConnect1;
} flag = ;
RLY1 = RLY_OFF;
RLY2 = RLY_OFF;
RLY3 = RLY_OFF; LED1 = LED_OFF;
LED2 = LED_OFF;
LED3 = LED_OFF;
} while()
{
BAT_SENSE = MiddleADValue();
BAT_VOLT = (uint)(BAT_SENSE*0.78125);//5*160/1024 =800/1024 = 0.78125 //Determine which range of BAT_VOLT
if(BAT_VOLT<LoadDisConnect1)
{
RLY1 = RLY_OFF;
RLY2 = RLY_OFF;
RLY3 = RLY_OFF;
flag = ;
}
else if((BAT_VOLT>=LoadDisConnect1)&&(BAT_VOLT<LoadDisConnect2))
{
if(flag > )//由大到小
{
//RLY1 = RLY1;
RLY2 = RLY_OFF;
RLY3 = RLY_OFF;
}else if(flag <= ){ }
flag = ;
}
else if((BAT_VOLT>=LoadDisConnect2)&&(BAT_VOLT<LoadDisConnect3))
{
if(flag > )
{
//RLY1 = RLY1;
//RLY2 = RLY2;
RLY3 = RLY_OFF;
}
flag = ;
}
/*-------------------------------------------------------*/
else if((BAT_VOLT>=LoadDisConnect3)&&(BAT_VOLT<LoadConnect1))
{
//RLY1 = RLY1;
//RLY2 = RLY2;
//RLY3 = RLY3;
flag = ;
}
/*-------------------------------------------------------*/
else if((BAT_VOLT>=LoadConnect1)&&(BAT_VOLT<LoadConnect2))
{
if(flag < ){ RLY1 = RLY_ON;
//RLY2 = RLY2;
//RLY3 = RLY3;
}
flag = ;
}else if((BAT_VOLT>=LoadConnect2)&&(BAT_VOLT<LoadConnect3))
{
if(flag < )
{
RLY1 = RLY_ON;
RLY2 = RLY_ON;
//RLY3 = RLY3;
}
flag = ; }else if(BAT_VOLT>=LoadConnect3)
{
RLY1 = RLY_ON;
RLY2 = RLY_ON;
RLY3 = RLY_ON;
flag = ;
}
DisplayLed();
_delay();
}
} void DisplayLed(void)
{
//LED state set synchronization
if(RLY1 == RLY_ON)
{
LED1 = LED_ON;
}
else
{
LED1 = !LED1;
} if(RLY2 == RLY_ON)
{
LED2 = LED_ON;
}
else
{
LED2 = !LED2;
} if(RLY3 == RLY_ON)
{
LED3 = LED_ON;
}
else
{
LED3 = !LED3; //One LED twinkle
}
}
施密特算法
SMT(SF)的更多相关文章
- 查看Unix/Linux的CPU个数和内存大小,系统位数(转载)
一.AIX 1.查看CPU数: (1) smtctl 从AIX5.3起,对于power5的机器,系统引入了SMT(Simultaneousmulti-threading)的功能,其允许两个处理线程在同 ...
- 备考2019年6月份PMP考试-分享一些考试笔记(二)
最新比较经典的100道试题,有备考的小伙伴可以练练手,文章末尾附答案. 1 一个项目经理在运作一个数据中心安装项目.他发现相关方很恼火,因为他超出了预算,原因是人员费用要高于原先的计划.另外项 ...
- (0)Lora及LoraWAN
Lora和LoraWAN的区别 LoRa经常被误用来描述整个LPWAN通信系统,其实Lora是Semtech拥有的专有调制格式. SX1272和SX1276 LoRa芯片使用称为chirp扩频(CSS ...
- (3)LoraWAN:链路控制、SF BW CR
三.Introduction on LoRaWAN options 本文件描述了一种用于可为移动的或固定在一个固定位置的电池供电的终端设备而优化的LoRaWAN™网络协议.LORA™是一个由Semte ...
- 机器学习算法整理(五)决策树_随机森林——鹃尾花实例 Python实现
以下均为自己看视频做的笔记,自用,侵删! 还参考了:http://www.ai-start.com/ml2014/ In [8]: %matplotlib inline import pandas a ...
- AIX常用命令汇总(转)
在本文中,我将讨论这其中的一些核心命令.其目的旨在为您提供一个可用作便捷参考的列表.虽然这些命令的行为在所有 AIX 版本中都应该相同,但是仅在 AIX 5.3 下对它们进行了测试. 注意:以下段落中 ...
- Vue.js学习笔记(1)
数据的双向绑定(ES6写法) 效果: 没有改变 input 框里面的值时
- 用C#实现MD5的加密(转载)
方法一 首先,先简单介绍一下MD5 MD5的全称是message-digest algorithm 5(信息-摘要算法,在90年代初由mit laboratory for computer scien ...
- 10分钟了解设计模式(C#)
最近把<大话设计模式>重温了下(看完序才知道原来作者是也是博客园园友,这本书的最早博客版本在这里).体会最深的就是面向接口编程的重要性,如何在自己的项目中进行抽象,合理的利用各种设计模式. ...
随机推荐
- vue.js 组件-全局组件和局部组件
这两天学习了Vue.js 感觉组件这个地方知识点挺多的,而且很重要,所以,今天添加一点小笔记. 首先Vue组件的使用有3个步骤,创建组件构造器,注册组件,使用组件3个方面. 代码演示如下: <! ...
- java初级应用:环境安装及配置
相关文件下载: jdk下载路径:http://www.oracle.com/technetwork/java/javase/downloads/index.html eclipse下载路径:https ...
- SVM中的间隔最大化
参考链接: 1.https://blog.csdn.net/TaiJi1985/article/details/75087742 2.李航<统计学习方法>7.1节 线性可分支持向量机与硬间 ...
- Java学习笔记十一:Java中的方法
Java中的方法 一:什么是方法: 所谓方法,就是用来解决一类问题的代码的有序组合,是一个功能模块. 学过C语言或者其他语言的应该都知道函数这个东西,在Java中,其实方法就是函数,只不过叫法不同,在 ...
- R语言学习笔记(十七):data.table包中melt与dcast函数的使用
melt函数可以将宽数据转化为长数据 dcast函数可以将长数据转化为宽数据 > DT = fread("melt_default.csv") > DT family_ ...
- POJ1426 Find The Multiple 解题报告
参考:http://www.cnblogs.com/ACShiryu/archive/2011/07/24/2115356.html #include <iostream> #includ ...
- Lucene如何实现多条件搜索?
有两种方式可以实现, 一是:Lucene搜索API中提供了一个布尔查询器(BooleanQuery),它可以包含多个查询器,每个查询器Occur枚举控制是“and” 还是“or” BooleanQue ...
- springboot2.x+maven+proguard代码混淆
由于需要将源码打包做代码混淆,选择proguard,开始使用各种问题,各种jar包版本问题,但最终成功了,记录一下,也希望能够帮助大家 在pom中添加代码: <build> <fin ...
- 【python3.X】Scrapy学习途径参考
如何爬取属性在不同页面的itemhttp://scrapy-chs.readthedocs.io/zh_CN/0.24/topics/request-response.html#topics-requ ...
- 网页设计简史看设计&代码“隔膜”
本文来自网易云社区 作者:马宝 设计与代码之间隔膜所在?既然你诚心诚意地问了,我就大发慈悲地告诉你.为了防止地球被破坏,为了维护世界的和平,为了贯彻爱与真实的邪恶~,我是穿梭在前端与设计之间爱与美丽的 ...