0~10V 模拟输出电路,基于51单片机控制,DA采用TI 10bit 串行DA TLC5615
/*
MCU:STC89C516RD+
OSC:22.1184MHZ
*/
#include "reg51.h"
typedef unsigned char uint8;
typedef unsigned int uint16;
sbit SCK = P2^0;
sbit CS = P2^1;
sbit DIN = P2^2;
void Delay(uint16 n)
{
while(--n);
}
void DA_Out(uint16 dat)
{
uint8 i;
uint16 dat_temp;
dat_temp = (dat<<6);
CS = 0;
Delay(10);
SCK = 0;
for(i = 0; i < 12; i++)
{
DIN = (bit)((dat_temp&0x8000));
Delay(10);
SCK = 1;
Delay(10);
dat_temp <<= 1;
SCK = 0;
Delay(10);
}
CS = 1;
Delay(50);
SCK = 0;
Delay(50);
}
void main()
{
while(1)
{
DA_Out(0x01ff);
Delay(30000);
}
}
文章评论(0条评论)
登录后参与讨论