[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
* Proteus 原理图即解读
此次的实验选用的是无源蜂鸣器(500Hz~4.5KHz),即它的震荡源不是固定的,可以通过程序来设置,要注意有源及无源的区别(有无震荡源),粗俗一点就是无源的频率是可以调的。
蜂鸣器的工作原理是通电导通和截至后,在两个引脚产生磁场,将铁片吸下来,磁场消失后再恢复原状,以此来发出声音。原理图利用PNP型三极管作用在放大区充当开关,采用共发射极放大电路,以此来控制磁场的产生和消失。Ri充当输入电阻,输入电阻越大,放大电路所得到的输入电压越接近电源电压。R1充当限流电阻,目的是防止电流过大损坏蜂鸣器。另外,由于蜂鸣器内部是电磁线圈,在磁场消失时,电流不会立即消失,故接上二极管是为了消耗该电流。
* keil编程
为了更加精确的发出对应频率的声音,可以利用烧录器软件下的延时计时器。该程序并不能将所想的频率显示出,是因为在执行指令时,语句也要时间,故会将时间变长。由于我们所设置的时间非常小,所以影响的比较大。若是延时的时间较大,比如1ms,那么语句的执行时间的影响将不会那么大。
#include<reg51.h> #include<intrins.h> sbit BUZZ=P2^1; void Delay100us(unsigned
int j); void HZ(unsigned int k) { int j; j=10000/k/2;
//由于计算时间是1/f,1的单位是s,在此取10000是换成有几个100us Delay100us(j); } /*计算该频率下有多少个100us*/
void Delay100us(unsigned int j) //晶振@11.0592MHz { unsigned char i; while(j--) {
_nop_(); i = 43; while (--i); } } void main() { while(1) { BUZZ=1; HZ(2500);
BUZZ=0; HZ(2500); } }
* 个人程序和仿真调试过程中的错误点
1.没有申明自定义函数,由于程序在执行指令时遇到自定义函数时,是往上查找的,若函数没有放在前面,则应在在前面申明再加分号。并且格式像函数头差不多。
2.while(--j)和while(j--)的差别。前者比后者少运行以此。
3._nop_()是在intrins.h头文件中的,故应该定义。
4.示波器产生的疑问
疑点1:为什么呈现低电平时,电压是<0的?