当前位置:网站首页>基于DAC0832的直流电机控制系统
基于DAC0832的直流电机控制系统
2022-07-29 05:22:00 【半生烟火一世迷离】
使用DAC0832来控制直流电机
输入数字量0X00~0XFF对应输出0~5V的电压值
运用模拟电路知识设计电路实现电机正反转,数码管实时显示速度值以及正反转。
四位数码管前一位显示正反转、1表示正转、0表示反转,后三位显示速度值
DAC0832采用双极性控制,D0~D7数据输入口,IOUT1、IOUT2互补输出口,RFB反馈端口、
VREF基准电压值(一般是5V)。
三极管部分仿真是通过两个I/O口来控制实现正反转,如果没有三极管部分只能单方向转动
主函数
#include <REGX52.H>
#include "Delay.h"
#include "Key.h"
#define DAC0832 P1//DAC0832数据口定义
sbit zz=P2^0;//正反转定义
sbit fz=P2^1;
sbit we1=P3^0;//位选定义
sbit we2=P3^1;
sbit we3=P3^2;
sbit we4=P3^3;
unsigned char NixieTable[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};//共阴极段码表
unsigned char KeyNum;
unsigned int Speed=70;//定义送给DAC0832的初始速度值
void Nixie();//数码管显示函数
void main()
{
DAC0832=0x00;
while(1)
{
KeyNum=Key();//获取按键值
switch(KeyNum)
{
case 0:
break;
case 1:
zz=0;
fz=1;
break;
case 2:
zz=1;
fz=0;
break;
case 3:
Speed=Speed+5;
KeyNum=0;
break;
case 4:
Speed=Speed-5;
KeyNum=0;
break;
}
DAC0832=Speed;//数字量输入转换电压值
Nixie();
}
}
void Nixie()
{
unsigned int x=0,y=0,z=0,peed;
peed=Speed;
x=peed/100;
y=(peed-x*100)/10;
z=peed%10;//取速度的每一位的数显示出来
if(zz==1&&fz==0)
{
we1=0;
P0=NixieTable[1]; //数码管显示1,正转
Delay(5);
we1=1;
}
if(zz==0&&fz==1)
{
we1=0;
P0=NixieTable[0]; //数码管显示0,反转
Delay(5);
we1=1;
}
we2=0;
P0=NixieTable[x];
Delay(5);
we2=1;
we3=0;
P0=NixieTable[y];
Delay(5);
we3=1;
we4=0;
P0=NixieTable[z];
Delay(5);
we4=1;
}
按键获取
#include <REGX52.H>
#include "Delay.h"
unsigned char Key()//得出按键值,按键消抖和松手检测
{
unsigned char KeyNumber=0;
if(P3_4==0){Delay(20);while(P3_4==0);Delay(20);KeyNumber=1;}//正转
if(P3_5==0){Delay(20);while(P3_5==0);Delay(20);KeyNumber=2;}//反转
if(P3_6==0){Delay(20);while(P3_6==0);Delay(20);KeyNumber=3;}//加速
if(P3_7==0){Delay(20);while(P3_7==0);Delay(20);KeyNumber=4;}//减速
return KeyNumber;
}
在这里说明一下三极管部分仿真是一个学长给出的,学长还是厉害啊

边栏推荐
- Pytorch Basics (Introductory)
- [target detection] generalized focal loss v1
- HAL库学习笔记- 9 DMA
- 六、基于深度学习关键点的指针式表计识别
- Improve quality with intelligence financial imaging platform solution
- Hal learning notes - Basic timer of 7 timer
- Set automatic build in idea - change the code, and refresh the page without restarting the project
- 基于STC51:四轴飞控开源项目原理图与源码(入门级DIY)
- Transformer回顾+理解
- 充电桩应用方案
猜你喜欢

Reading papers on false news detection (5): a semi supervised learning method for fake news detection in social media

HAL库学习笔记-11 I2C

Wechat built-in browser prohibits caching

Migration learning - geodesic flow kernel for unsupervised domain adaptation

预训练语言模型的使用方法

Review of neural network related knowledge (pytorch)

PyTorch的数据读取机制

ML7自学笔记
![[target detection] KL loss: bounding box progression with uncertainty for accurate object detection](/img/8c/1a561fab040730ae29901a04b70ac4.png)
[target detection] KL loss: bounding box progression with uncertainty for accurate object detection

Continue the new journey and control smart storage together
随机推荐
虚假新闻检测论文阅读(一):Fake News Detection using Semi-Supervised Graph Convolutional Network
2021-06-10
1、 What is the difference between transfer learning and fine tuning?
一、multiprocessing.pool.RemoteTraceback
Torch. NN. Parameter() function understanding
华为云14天鸿蒙设备开发-Day7WIFI功能开发
ML8自学笔记
HAL库学习笔记-10 HAL库外设驱动框架概述
ML7自学笔记
基于STM32开源:磁流体蓝牙音箱(包含源码+PCB)
引入Spacy模块出错—OSError: [E941] Can‘t find model ‘en‘.
MySQL inserts millions of data (using functions and stored procedures)
torch.nn.Embedding()详解
1、 Focal loss theory and code implementation
tensorflow中tf.get_variable()函数详解
Pytorch's data reading mechanism
Tf.get in tensorflow_ Detailed explanation of variable() function
二、多并发实现接口压力测试
虚假新闻检测论文阅读(二):Semi-Supervised Learning and Graph Neural Networks for Fake News Detection
ML15 neural network (1)