当前位置:网站首页>Photoresist for learning of Blue Bridge Cup embedded expansion board
Photoresist for learning of Blue Bridge Cup embedded expansion board
2022-04-22 06:04:00 【*wj】
Hardware circuit

LM393 The voltage comparator pins are as follows


Photosensitive resistor

The acquisition of analog quantity uses stm32 Of ADC Of 12 Precision acquisition channel to collect , According to the resource distribution of the expansion board :

Program
//ADC -AO
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
//ADC -DO
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOA, &GPIO_InitStructure);
void ADC_Configuration(void)
{
ADC_InitTypeDef ADC_InitStructure;
// ADC1 Working mode configuration
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; // Single conversion The difference between the two is that continuous conversion does not stop until all data conversion is completed , A single conversion stops when the data is converted only once , The conversion must be triggered again
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(ADC1, &ADC_InitStructure);
ADC_Cmd(ADC1, ENABLE);
ADC_ResetCalibration(ADC1);
/* Check the end of ADC1 reset calibration register */
while(ADC_GetResetCalibrationStatus(ADC1));
ADC_StartCalibration(ADC1);
/* Check the end of ADC1 calibration */
while(ADC_GetCalibrationStatus(ADC1));
}
u16 Read_ADC(void)
{
u16 temp;
ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 1, ADC_SampleTime_1Cycles5); //ADC_AO Corresponding to the channel 4
ADC_SoftwareStartConvCmd(ADC1,ENABLE);
while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
temp = ADC_GetConversionValue(ADC1);
ADC_SoftwareStartConvCmd(ADC1,DISABLE);
return temp;
}
The main function
1. Digital output port DO: The switching value signal output is the high and low level value output through the comparator after the partial voltage of photosensitive resistance and potentiometer .
2. Analog output port AO: The analog output is the partial voltage value of photosensitive resistance and fixed value resistance
while(1)
{
temp_AO = Read_ADC();
sprintf((char *)str, " R-P:%.1fK ", temp_AO/(4096.-temp_AO)*10);
LCD_DisplayStringLine(Line6, str);
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3) == 1)
{
LCD_DisplayStringLine(Line7, (u8*)" DO:High ");
}
else
{
LCD_DisplayStringLine(Line7, (u8*)" DO:Low ");
}
Be careful :
because RP7 The resistance and of the potentiometer R45 Resistance difference of 500 times , And bright resistance and R46 The resistance of may differ by 1-50 Within times , So we can get the following phenomenon :
1. When adjusting the potentiometer RP7 bring DO Output hign When : Let the photoresist encounter strong light , The resistance of Photoforming photoresist decreases ,DO So as to output low ( This jump value is best adjusted RP7 It can just output when the photoresist is normal hign that will do , If the value of the potentiometer is too small , It may be illuminated into a photoresist. After encountering strong light, its resistance value is still greater than that of the potentiometer )
2. When adjusting the potentiometer RP7 bring DO Output low When : Because the same direction input and reverse input voltage values are relatively large , At this time, the photosensitive resistance may be no matter how large , The voltage of the same direction input terminal is still lower than that of the reverse input terminal , thus DO Output all the time low
版权声明
本文为[*wj]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220541420747.html
边栏推荐
- Maximum continuous subsequence sum (enumeration + divide and conquer + online processing)
- 蓝桥杯嵌入式扩展板学习之ADC按键
- 05 - variables and identifiers
- wgs84坐标转换,地图拾取wgs84坐标工具推荐
- RTL8367学习笔记3——ACL访问控制列表
- QT学习之安装QT
- Subsets and problems (backtracking & branch and bound)
- What compiler is used for beginners of C language (there is a surprise at the end of the article)
- 抓包工具mitmproxy和Anyproxy
- ubuntu20.0.4下在终端安装数据库
猜你喜欢

QT信号与槽的特点和用法

Blue Bridge Cup 31 day sprint Day10

蓝桥杯嵌入式扩展板学习之LIS302DL

LeetCode: 322. Change exchange (dynamic programming, recursion, memo recursion and backtracking)

Golang calculates the number of days rounded to time

Chapter 89 leetcode refers to offer dynamic programming (6) translating numbers into strings

03-pycharm

写一篇关于ddt数据驱动的自动化测试

本地搭建服务器后的访问问题

蓝桥杯嵌入式扩展板学习之数码管
随机推荐
初识数据链表
stm32学习笔记5——RGB屏相对位置计算
蓝桥杯嵌入式扩展板学习之LIS302DL
STM32学习笔记4——HC_SR04超声波测距模块的调试记录
Speed measurement based on 51 single chip microcomputer and Hall sensor
VB操作excel 格式设置及打印页面设置(精简)
Apple CMS builds a video website and collects videos regularly
Three lines of recursive output code of stack C
蓝桥杯嵌入式省赛第七届:模拟液位检测告警系统”
Part 84 leetcode sword refers to offer dynamic programming (I) Fibonacci sequence
10 - 流程控制-while循环语句
蓝桥杯嵌入式扩展板学习之光敏电阻
Chessboard coverage problem (divide and conquer)
Blue Bridge Cup 31 day sprint day4
蓝桥杯嵌入式学习之双路AD采集
stm32 printf 重定向 虚拟示波器
STM32学习笔记1——最简单的GPIO
pygame 简单的飞机大战
ShardingException: Cannot find data source in sharding rule, invalid actual data node is
ADC