您好。
首先可以说,只是学了C语言,实际上和人工智能还靠不到边。
学习了C语言,其实C语言学好也是相当不容易的,学习跟学好,跟应用再到创新,不是一个概念,也不是一个量级。
我本身也会好几种语言,自己是搞电气自动化的,人工智能其实很早就有提出,1956年就有科学家提出了这个概念,只是由于传感器应用和计算机技术的限制一直到最近几年才有了飞速发展。
不知道您C语言掌握的程度。我简单说说我对C语言的认识。
1、C语言是学习编程的基础语言,一般情况下,在学习C语言之前都会讲计算机基础知识,讲计算机二进制算法,计算机工作原理等。学习这些就是为了深刻明白计算机是如何工作的。
这些学习完了,需要掌握计算机编写程序的一些基本思路,比如:程序循环、判断选择跳转程序、顺序程序等。还有一些,常用的程序算法,其实这样算法都是数学算法加上计算机速度得来的,比如冒泡法,累加法这些等。这些都是最经典的程序算法,也是学习程序前需要掌握的。
2、我上大学学习过,C、VB、VF、Basic、Fox等软件,都是基础的学科,本人也是比较爱好编程,虽然最后入行了工业控制自动化类型,但我想最终思路和创新才是永远不变的本质。
在工作岗位上,解决过很多控制类的问题,有时候也会再把之前学习的基础语言捡起来。
例如,单位现场有一个需要称重控制动作的料仓。就是成品灰块通过给料机给到一个可以秤重的料仓里,料仓每秤重40KG就控制上面给料机停止给料,然后稳定一下,把料通过料仓下面的开关门倒入下游的储料罐内。原设计就是简单的称40KG控制上游停止给料,下游开关门打开,就完了,实际上在应用中,根本测量不准。测量不准的原因有:给料机停止给料后,仍然许多石料下来,这个很好理解,比如洒水车,在关闭阀门后,阀门出水侧管道里还有水流出来,直到阀门后侧水全部没有为止。还有一点,因为是石料,一块可能有的就有1KG,有的就有0.2KG,大小不一,不会每次都正好40KG,时间长了累计值和设定值就会有非常大的偏差。所以,做程序的人员应该只是在办公室模拟写了非常理想化的程序,实际应用上还有太多的问题,我就自己带领人一起长期进行现场观察,记录,最后从新写了程序。这个正好是单片机仪表,所以,从新学习了一下C语言程序,从新给单片机写程序,现场调试,最后应用成功。
全部是用C写的,里面的一些硬件驱动是公共的。
主个程序我认为主要的精髓就是:
1、分区控制达到微积分效果。
2、几种世界时间和几种纬度的控制过程。
当然本人不是专业C出身,程序模块化还需要进一步优化。只是现场满足较好的应用效果。
以下是程序段,喜欢可以拿下研究或者收藏,将来应用时可以再拿来研究。
//ADS1232.h-----------------------------------------------------------------------------------------------------
//#include<reg52.h>
#include<STC10F08XE.h>
//#include"uart.h"
//#include
#defineNEGATIVE0x800000
#defineEFFECTIVE0x7FFFFF
#include<intrins.h>
#include<stdio.h>
#defineuintunsignedint
#defineulongunsignedlong
#definefloatfloat;
unsignedcharyi,syi,qwan,bwan,swan,wan,qian,bai,shi,ge,num,num1,tt;
sbitSDA1=P2^7;//串行数据输入,对应595的14脚SER
sbitSCL1=P2^5;//移位寄存器时钟输入,对应595的11脚SCK
sbitSCL2=P2^6;//存储寄存器时钟输入,对应595的12脚RCK
sbitp00=P0^0;//3wkey1
sbitp01=P0^1;//5wkey2
sbitp02=P0^2;//4wkey3
sbitp03=P0^3;//
sbitkey=P2^4;//公用线
sbitj1=P1^0;//p1.6
sbitj2=P1^1;
sbitj3=P1^6;
sbitp17=P1^7;
unsignedintma;
longADC_data;
unsignedcharcodeduan[]={0x18,0xde,0x34,0x94,0xd2,0x91,0x11,0xdc,0x10,0x90};
//unsignedcharcodeduan[]={0x01};//0123456789
unsignedcharcodewei[]={0x7f,0xbf,0xfe,0xfd,0xfb,0xf7,0xef,0xdf};//0156789
//unsignedcharcodewei[]={0x3f};
sbitGain0=P3^2;
sbitGain1=P3^4;
sbitSpeed=P3^5;
//sbitad_pdwn=P3^7;
//sbitad_sclk=P3^6;
//sbitad_dout=P3^3;
sbitSCLK=P3^6;
sbitDOUT=P3^3;
sbitPDWN=P3^7;
sbithc14d=P1^7;
sbitsda=P2^3;//THESDABITISPORT2BIT7//
sbitscl=P2^2;//THESCLBITISPORT2BIT6
sbitwp=P2^1;
voidDelayus(unsignedinti)
{
while(i--);
}
longADS1232_Read(bitCalibration)//Calibration:0x01:校正,0x00:不校正
{
unsignedcharloop=0x00;
signedlongResult=0x00;
while(DOUT);//等待数据到来
for(loop=0x00;loop<0x18;loop++)//循环读取数据
{
SCLK=0x01;
_nop_();
Result=(Result<<0x01)|DOUT;
SCLK=0x00;
}
SCLK=0x01;
_nop_();
_nop_();
SCLK=0x00;
if(Calibration)
{
SCLK=0x01;
_nop_();
_nop_();
SCLK=0x00;
}
if(Result>=NEGATIVE)//表示负值,defineNEGATIVE0x800000
{//defineEFFECTIVE0x7FFFFF
Result|=0xff000000;
}
returnResult;
}
voidADS1232_Init(void)
{
Gain0=0;
Gain1=0;
Speed=0;
SCLK=0x00;
PDWN=0x00;
Delayus(0x14);
PDWN=0x01;
ADS1232_Read(0x01);//复位后校准一下
ADS1232_Read(0x00);//先前不稳定的值读取掉
}
voiddelay()
{;;}
voidstart()//开始信号
{
sda=1;
delay();
scl=1;
delay();
sda=0;
delay();
}
voidstop()//停止
{
sda=0;
delay();
scl=1;
delay();
sda=1;
delay();
}
voidrespons()//应答
{
unsignedchari;
scl=1;
delay();
while((sda==1)&&(i<250))i++;
scl=0;
delay();
}
voidinit()
{
wp=0;
sda=1;
delay();
scl=1;
delay();
}
voidwrite_byte(unsignedchardate)
{
unsignedchari,temp;
temp=date;
for(i=0;i<8;i++)
{
temp=temp<<1;
scl=0;
delay();
sda=CY;
delay();
scl=1;
delay();
scl=0;
delay();
}
scl=0;
delay();
sda=1;
delay();
}
unsignedcharread_byte()
{
unsignedchari,k;
scl=0;
delay();
sda=1;
delay();
for(i=0;i<8;i++)
{
scl=1;
delay();
k=(k<<1)|sda;
scl=0;
delay();
}
returnk;
}
unsignedcharread_add(unsignedcharaddress)
{
unsignedchardate;
start();
write_byte(0xa0);
respons();
write_byte(address);
respons();
start();
write_byte(0xa1);
respons();
date=read_byte();
stop();
returndate;
}
voidwrite_add(unsignedcharaddress,unsignedintdate)
{
start();
write_byte(0xa0);
respons();
write_byte(address);
respons();
write_byte(date);
respons();
stop();
}
voiddelay1(unsignedcharx)
{
unsignedchara,b;
for(a=x;a>0;a--)
for(b=100;b>0;b--);
}
voiddelay2ms(void)
{
unsignedchari,j;
for(i=133;i>0;i--)
for(j=6;j>0;j--);
}
voidHC14D(void)
{
longi;
for(i=0;i<655350;i++)
{
Delayus(438);
hc14d=1;
Delayus(80);
hc14d=0;
}
}
voidch595_in(unsignedcharData)
{
unsignedchari;
for(i=0;i<8;i++)//循环8次,刚好移完8位
{
SCL1=0;//先将移位寄存器控制引脚置为低
_nop_();
if((Data&0x80)==0x80)
SDA1=1;
else
SDA1=0;
Data<<=1;//将数据的次高位移到最高位
SCL1=1;//再置为高,产生移位时钟上升沿,上升沿时数据寄存器的数据移位
_nop_();
}
}
voidch595_out(void)
{
SCL2=0;//先将存储寄存器引脚置为低
_nop_();
SCL2=1;//再置为高,产生移位时钟上升沿,上升沿时移位寄存器的数据进入数据存储寄存器,更新显示数据。
}
voidxianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi)
{
p00=1;
p00=0;//3W
ch595_in(0xff);
ch595_in(duan[bai]);
ch595_out();
Delayus(500);
p00=1;
p02=1;
p02=0;
ch595_in(0xff);
ch595_in(duan[qian]);
ch595_out();//4w
Delayus(500);
p02=1;
p01=1;
p01=0;
ch595_in(0xff);
ch595_in(duan[wan]);//5W
ch595_out();
Delayus(500);
p01=1;
ch595_in(wei[0]);//先传位码1w
ch595_in(duan[ge]);//再传段码
ch595_out();
Delayus(500);
ch595_in(wei[1]);//先传位码2w
ch595_in(duan[shi]);//再传段码
ch595_out();
Delayus(500);
ch595_in(wei[3]);//先传位码6w
ch595_in(duan[swan]);//再传段码
ch595_out();
Delayus(500);
ch595_in(wei[4]);//先传位码7w
ch595_in(duan[bwan]);//再传段码
ch595_out();
Delayus(500);
ch595_in(wei[5]);//先传位码8w
ch595_in(duan[qwan]&0xef);//再传段码
ch595_out();
Delayus(500);
ch595_in(wei[6]);//先传位码9w
ch595_in(duan[yi]);//再传段码
ch595_out();
Delayus(500);
ch595_in(wei[7]);//先传位码10w
ch595_in(duan[syi]);//再传段码
ch595_out();
Delayus(500);
ch595_in(wei[0xff]);//先传位码10w
ch595_in(duan[0xff]);//再传段码
ch595_out();
Delayus(500);
}
voidMA4_20(unsignedintx)
{
unsignedinti,y;
y=5000-x;
for(i=0;i<100;i++)
{
Delayus(x);
//xianshi(ge,shi,bai,qian,wan,swan,bwan);
hc14d=1;
Delayus(y);
//xianshi(ge,shi,bai,qian,wan,swan,bwan);
hc14d=0;
}
}
/*
voidtime0()interrupt1
{
TH1=(65536-10000)/256;
TL1=(65536-10000)%256;
tt++;
if(tt==2)
{tt=0;
MA4_20(ma);
}
}
voidtime1()interrupt3
{
TH1=(65536-10000)/256;
TL1=(65536-10000)%256;
num1++;
}
*/
voidmainz()
{bitm1,m2,m8;
inti,ti,miaobiao1,miaobiao2,miaobiao5,ti2;
unsignedlongtime1,bijiaozhi1,bijiaozhi2,leiji1,leiji1f1,leiji1f2,leiji1f3,leiji1f4,jingzhong,adk,adkb,cunpi,mg;
//ma=500;
ADS1232_Init();
init();
//以下写ADK,ADKB初始值。
/*
adk=3000;
adkb=1886220;
leiji1f1=adk%256;
leiji1f2=adk%65536/256;
leiji1f3=adk%16777216/65536;
leiji1f4=adk/16777216;
write_add(23,leiji1f1);
delay1(100);
write_add(24,leiji1f2);
delay1(100);
write_add(25,leiji1f3);
delay1(100);
write_add(26,leiji1f4);
delay1(100);
leiji1f1=adkb%256;
leiji1f2=adkb%65536/256;
leiji1f3=adkb%16777216/65536;
leiji1f4=adkb/16777216;
write_add(27,leiji1f1);
delay1(100);
write_add(28,leiji1f2);
delay1(100);
write_add(29,leiji1f3);
delay1(100);
write_add(30,leiji1f4);
delay1(100);
*/
//以上写adk,adkb初始值。
leiji1f1=read_add(31);
delay1(100);
leiji1f2=read_add(32);
delay1(100);
leiji1f3=read_add(33);
delay1(100);
leiji1f4=read_add(34);
delay1(100);
leiji1=leiji1f1+leiji1f2*256+leiji1f3*65536+leiji1f4*16777216;
//leiji1=0;
leiji1f1=read_add(23);
delay1(100);
leiji1f2=read_add(24);
delay1(100);
leiji1f3=read_add(25);
delay1(100);
leiji1f4=read_add(26);
delay1(100);
adk=leiji1f1+leiji1f2*256+leiji1f3*65536+leiji1f4*16777216;
leiji1f1=read_add(27);
delay1(100);
leiji1f2=read_add(28);
delay1(100);
leiji1f3=read_add(29);
delay1(100);
leiji1f4=read_add(30);
delay1(100);
adkb=leiji1f1+leiji1f2*256+leiji1f3*65536+leiji1f4*16777216;
/*
syi1=leiji1/1000000000;
yi1=leiji1%1000000000/100000000;
qwan1=leiji1%100000000/10000000;
bwan1=leiji1%10000000/1000000;
swan1=leiji1%1000000/100000;
wan1=leiji1%100000/10000;
qian1=leiji1%10000/1000;
bai1=leiji1%1000/100;
shi1=leiji1%100/10;
ge1=leiji1%10;
write7281b(0x12,0xc8);
delay1(100);
write7281b(0x15,0x00+ge1);
write7281b(0x15,0x10+shi1);
write7281b(0x15,0x20+bai1);
write7281b(0x15,0x30+qian1);
write7281b(0x15,0x40+wan1);
write7281b(0x15,0x50+swan1);
write7281b(0x15,0x60+bwan1);
write7281b(0x15,0x70+qwan1);
write7281b(0x15,0x80+yi1);
write7281b(0x15,0x90+syi1);
m39=1;
while(m39)
{
m40=0;
}
*/xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ADS1232_Init();
ADC_data=ADS1232_Read(0x00);
//ADC_data=time1;
mg=ADC_data*adk-adkb;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
cunpi=mg;
time1=0;
bijiaozhi2=35000000;
//miaobiao5=0;
m1=1;
m2=0;
ch595_in(wei[2]);//LED1开门继电器
ch595_in(0xff);//再传段码
ch595_out();
Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
while(1)
{
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
time1=time1+1;
//syi=time1%1000/100;
//wan=time1%100/10;
//qwan=time1%10;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
//x=405;
ADC_data=ADS1232_Read(0x00);
//ADC_data=time1;
mg=ADC_data*adk-adkb;//ADC值变毫克mg
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
if(ADC_data>5000000)
{
mg=0;
}
jingzhong=mg-cunpi;
if(jingzhong>(5000000*adk-adkb))
{
jingzhong=0;
}
if(jingzhong<0)
{
jingzhong=0;
}
//qwan=jingzhong%100000000000/10000000000;
//bwan=jingzhong%10000000000/1000000000;
//swan=jingzhong%1000000000/100000000;
//wan=jingzhong%100000000/10000000;
//qian=jingzhong%10000000/1000000;
//bai=jingzhong%1000000/100000;
//shi=jingzhong%100000/10000;
wan=leiji1%100000/10000;
qian=leiji1%10000/1000;
bai=leiji1%1000/100;
shi=leiji1%100/10;
ge=leiji1%10;
yi=jingzhong%100000000/10000000;
qwan=jingzhong%10000000/1000000;
bwan=jingzhong%1000000/100000;
swan=jingzhong%100000/10000;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
if(j1==1)
{
ch595_in(wei[2]);//LED1开门继电器
ch595_in(0xfb);//再传段码
ch595_out();
Delayus(500);
}
if(j2==1)
{
ch595_in(wei[2]);//LED2关门继电器
ch595_in(0x7f);//再传段码
ch595_out();
Delayus(500);
}
if(j3==1)
{
ch595_in(wei[2]);//LED3允许喂料继电器
ch595_in(0xbf);//再传段码
ch595_out();
Delayus(500);
}
if(m1==1)
{ti=ti+1;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
if((ti>=10)&&(ti<40))//开门
{
ch595_in(wei[2]);//LED1开门继电器
ch595_in(0xfb);//再传段码
ch595_out();
Delayus(500);
j1=1;//开门继电器,同时给开到位
j2=0;//关门继电器,同时给关到位
j3=0;//出灰允许信号
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ch595_in(wei[2]);//LED1开门继电器
ch595_in(0xfb);//再传段码
ch595_out();
Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ch595_in(wei[2]);//LED1开门继电器
ch595_in(0xfb);//再传段码
ch595_out();
Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
if((ti>=40)&&(ti<80))//关门
{
ch595_in(wei[2]);//LED2关门继电器
ch595_in(0x7f);//再传段码
ch595_out();
Delayus(500);
j1=0;//开门继电器,同时给开到位
j2=1;//关门继电器,同时给关到位
j3=0;//出灰允许信号
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ch595_in(wei[2]);//LED2关门继电器(为了不常给电,可以用PLC锁住信号)
ch595_in(0x7f);//再传段码
ch595_out();
Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ch595_in(wei[2]);//LED2关门继电器(为了不常给电,可以用PLC锁住信号)
ch595_in(0x7f);//再传段码
ch595_out();
Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
if(ti==81)
{
m1=0;
m2=1;
miaobiao1=0;
ti=0;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
}
if(m2==1)
{
miaobiao1=miaobiao1+1;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
if(miaobiao1==3)
{
cunpi=mg;
}
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
if((miaobiao1>=4)&&(miaobiao1<16))
{
ch595_in(wei[2]);//LED3允许喂料继电器
ch595_in(0xbf);//再传段码
ch595_out();
Delayus(500);
j1=0;//开门继电器,同时给开到位
j2=0;//关门继电器,同时给关到位
j3=1;//出灰允许信号
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ch595_in(wei[2]);//LED2关门继电器(为了不常给电,可以用PLC锁住信号)
ch595_in(0xbf);//再传段码
ch595_out();
Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
miaobiao2=0;
}
if(jingzhong>100000000)
{jingzhong=0;}//除去假信号;
if(jingzhong>1000000)
{
ti2=ti2+1;
}
if(jingzhong<1000000)
{
ti2=0;
}
if((jingzhong>=bijiaozhi2)&ti2>2)
{
m8=1;
ti2=0;
j3=0;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
if(m8==1)
{
miaobiao2=miaobiao2+1;
/*P17=0;
p00=0;
p01=0;
p02=0;
p03=1;
p04=0;//允许喂料
p05=0;
p06=0;
P17=1;
write7281b(0x18,0xe8);
write7281b(0x18,0xe9);
write7281b(0x18,0xea);
write7281b(0x18,0xeb);
*/
ch595_in(wei[2]);//LED3允许喂料继电器
ch595_in(0xff);//再传段码
ch595_out();
Delayus(500);
j1=0;//开门继电器,同时给开到位
j2=0;//关门继电器,同时给关到位
j3=0;//出灰允许信号out2
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ch595_in(wei[2]);//LED2关门继电器(为了不常给电,可以用PLC锁住信号)
ch595_in(0xff);//再传段码
ch595_out();
Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
if(miaobiao2==10)
{
//bijiaozhi1=T_voltage-bijiaozhi1;
//bijiaozhi2=10000000-(jingzhong-10000000);
if((jingzhong>=2000000)&&(jingzhong<25000000))
{
bijiaozhi2=bijiaozhi2+4000000;
}
if((jingzhong>=25000000)&&(jingzhong<28000000))
{
bijiaozhi2=bijiaozhi2+3000000;
}
if((jingzhong>=28000000)&&(jingzhong<31000000))
{
bijiaozhi2=bijiaozhi2+2000000;
}
if((jingzhong>=31000000)&&(jingzhong<34000000))
{
bijiaozhi2=bijiaozhi2+1500000;
}
if((jingzhong>=34000000)&&(jingzhong<37000000))
{
bijiaozhi2=bijiaozhi2+1000000;
}
if((jingzhong>=37000000)&&(jingzhong<38000000))
{
bijiaozhi2=bijiaozhi2+500000;
}
if((jingzhong>=38000000)&&(jingzhong<39000000))
{
bijiaozhi2=bijiaozhi2+300000;
}
if((jingzhong>=39000000)&&(jingzhong<40000000))
{
bijiaozhi2=bijiaozhi2+150000;
}
if((jingzhong>=40000000)&&(jingzhong<41000000))
{
bijiaozhi2=bijiaozhi2-150000;
}
if((jingzhong>=41000000)&&(jingzhong<42000000))
{
bijiaozhi2=bijiaozhi2-300000;
}
if((jingzhong>=42000000)&&(jingzhong<43000000))
{
bijiaozhi2=bijiaozhi2-500000;
}
if((jingzhong>=43000000)&&(jingzhong<46000000))
{
bijiaozhi2=bijiaozhi2-1000000;
}
if((jingzhong>=46000000)&&(jingzhong<49000000))
{
bijiaozhi2=bijiaozhi2-1500000;
}
if((jingzhong>=49000000)&&(jingzhong<52000000))
{
bijiaozhi2=bijiaozhi2-2000000;
}
if((jingzhong>=52000000)&&(jingzhong<55000000))
{
bijiaozhi2=bijiaozhi2-3000000;
}
if((jingzhong>=55000000)&&(jingzhong<58000000))
{
bijiaozhi2=bijiaozhi2-4000000;
}
if((jingzhong>=58000000)&&(jingzhong<70000000))
{
bijiaozhi2=bijiaozhi2-5000000;
}
if(jingzhong<20000000)
{
bijiaozhi2=35000000;
}
if(jingzhong>60000000)
{
bijiaozhi2=28000000;
}
/*
if((jingzhong<=15000000)||(jingzhong>=50000000))
{
bijiaozhi2=10000000;
}
if((jingzhong>=10000000)&&(jingzhong<15000000))
{
bijiaozhi2=33000000;
}
if((jingzhong>=15000000)&&(jingzhong<20000000))
{
bijiaozhi2=28000000;
}
if((jingzhong>=20000000)&&(jingzhong<25000000))
{
bijiaozhi2=23000000;
}
if((jingzhong>=30000000)&&(jingzhong<35000000))
{
bijiaozhi2=18000000;
}
if((jingzhong>=35000000)&&(jingzhong<40000000))
{
bijiaozhi2=13000000;
}
if((jingzhong>=40000000)&&(jingzhong<45000000))
{
bijiaozhi2=8000000;
}
if((jingzhong>=45000000)&&(jingzhong<50000000))
{
bijiaozhi2=3000000;
}
if(jingzhong>=50000000)
{
bijiaozhi2=15000000;
}
if(jingzhong<10000000)
{
bijiaozhi2=25000000;
}
*/
leiji1=(jingzhong/1000000)+leiji1;//累计
//以下累计1存入:
leiji1f1=leiji1%256;
leiji1f2=leiji1%65536/256;
leiji1f3=leiji1%16777216/65536;
leiji1f4=leiji1/16777216;
write_add(31,leiji1f1);
delay1(100);
write_add(32,leiji1f2);
delay1(100);
write_add(33,leiji1f3);
delay1(100);
write_add(34,leiji1f4);
delay1(100);
//以上累计1存入
//以下DA给出程序
//jingzhong=((jingzhong/10000)*3277)/5000+819;
//tlv5616_da(jingzhong);
//_nop_();
ma=((jingzhong/666666)*46)+400;
ti=0;
m1=1;
m2=0;
m8=0;
miaobiao5=0;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ti=3;
while(ti)
{
MA4_20(ma);
ti--;
}
ti=0;
}
}
}
ch595_in(0xdf);//按键4检测开
ch595_in(0xff);//再传段码
ch595_out();
Delayus(500);
p02=1;
while(key)
{
tt=1;//进清0真
while(tt)
{
tt=tt+1;
if(tt>100)
{tt=0;}
ch595_in(0x7f);//按键1
ch595_in(0xff);//再传段码
ch595_out();
Delayus(500);
p02=1;
if(key==1)
{
leiji1=0;//累计
//以下累计1存入:
leiji1f1=leiji1%256;
leiji1f2=leiji1%65536/256;
leiji1f3=leiji1%16777216/65536;
leiji1f4=leiji1/16777216;
write_add(31,leiji1f1);
delay1(100);
write_add(32,leiji1f2);
delay1(100);
write_add(33,leiji1f3);
delay1(100);
write_add(34,leiji1f4);
delay1(100);
ti=0;
tt=0;
}
wan=leiji1%100000/10000;
qian=leiji1%10000/1000;
bai=leiji1%1000/100;
shi=leiji1%100/10;
ge=leiji1%10;
yi=jingzhong%100000000/10000000;
qwan=jingzhong%10000000/1000000;
bwan=jingzhong%1000000/100000;
swan=jingzhong%100000/10000;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ch595_in(0xff);//先传位码10w
ch595_in(0xff);//再传段码
ch595_out();
Delayus(500);
p02=0;
if(key==1)
{
num1=1;
m1=1;
while(num1)
{xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ADC_data=ADS1232_Read(0x00);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
time1=time1+1;
//syi=time1%1000/100;
//wan=time1%100/10;
//qwan=time1%10;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
//x=405;
//ADC_data=time1;
mg=ADC_data*adk-adkb;//ADC值变毫克mg
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
if(ADC_data>5000000)
{
mg=0;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
jingzhong=mg-cunpi;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
if(jingzhong>(5000000*adk-adkb))
{
jingzhong=0;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
if(jingzhong<0)
{
jingzhong=0;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
//qwan=jingzhong%100000000000/10000000000;
//bwan=jingzhong%10000000000/1000000000;
//swan=jingzhong%1000000000/100000000;
//wan=jingzhong%100000000/10000000;
//qian=jingzhong%10000000/1000000;
//bai=jingzhong%1000000/100000;
//shi=jingzhong%100000/10000;
//wan=time1%100000/10000;
//qian=time1%10000/1000;
//bai=time1%1000/100;
wan=time1%100/10;
//ge=time1%10;
yi=jingzhong%100000000/10000000;
qwan=jingzhong%10000000/1000000;
bwan=jingzhong%1000000/100000;
swan=jingzhong%100000/10000;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
if(j1==1)
{
ch595_in(wei[2]);//LED1开门继电器
ch595_in(0xfb);//再传段码
ch595_out();
//Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
if(j2==1)
{
ch595_in(wei[2]);//LED2关门继电器
ch595_in(0x7f);//再传段码
ch595_out();
//Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
if(j3==1)
{
ch595_in(wei[2]);//LED3允许喂料继电器
ch595_in(0xbf);//再传段码
ch595_out();
//Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
if(m1==1)
{ti=ti+1;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
if((ti>=10)&&(ti<40))//开门
{
ch595_in(wei[2]);//LED1开门继电器
ch595_in(0xfb);//再传段码
ch595_out();
//Delayus(500);
j1=1;//开门继电器,同时给开到位
j2=0;//关门继电器,同时给关到位
j3=0;//出灰允许信号
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ch595_in(wei[2]);//LED1开门继电器
ch595_in(0xfb);//再传段码
ch595_out();
//Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ch595_in(wei[2]);//LED1开门继电器
ch595_in(0xfb);//再传段码
ch595_out();
//Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
if((ti>=40)&&(ti<80))//关门
{
ch595_in(wei[2]);//LED2关门继电器
ch595_in(0x7f);//再传段码
ch595_out();
//Delayus(500);
j1=0;//开门继电器,同时给开到位
j2=1;//关门继电器,同时给关到位
j3=0;//出灰允许信号
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ch595_in(wei[2]);//LED2关门继电器(为了不常给电,可以用PLC锁住信号)
ch595_in(0x7f);//再传段码
ch595_out();
//Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ch595_in(wei[2]);//LED2关门继电器(为了不常给电,可以用PLC锁住信号)
ch595_in(0x7f);//再传段码
ch595_out();
//Delayus(500);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
if(ti==81)
{
m1=0;
m2=1;
miaobiao1=0;
ti=0;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
if(m2==1)
{
miaobiao1=miaobiao1+1;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
if(miaobiao1==3)
{
cunpi=mg;
bijiaozhi1=ADC_data;
}
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
//ADS1232_Init();
//以下显示AD值程序//
//wan=ADS1232_Read(0x00)%100000/10000;
qian=adk%10000/1000;
bai=adk%1000/100;
shi=adk%100/10;
ge=adk%10;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
ch595_in(0xbf);//先传位码10w
ch595_in(0xff);//再传段码
ch595_out();
//Delayus(500);
p02=1;
if(key==1)
{
adk=10000000/(ADC_data-bijiaozhi1);
adkb=(ADC_data-10000000);
init();//IICfm24c04初始化
leiji1f1=adk%256;
leiji1f2=adk%65536/256;
leiji1f3=adk%16777216/65536;
leiji1f4=adk/16777216;
write_add(23,leiji1f1);
delay1(100);
write_add(24,leiji1f2);
delay1(100);
write_add(25,leiji1f3);
delay1(100);
write_add(26,leiji1f4);
delay1(100);
leiji1f1=adkb%256;
leiji1f2=adkb%65536/256;
leiji1f3=adkb%16777216/65536;
leiji1f4=adkb/16777216;
write_add(27,leiji1f1);
delay1(100);
write_add(28,leiji1f2);
delay1(100);
write_add(29,leiji1f3);
delay1(100);
write_add(30,leiji1f4);
delay1(100);
i=100;
while(i)
{
qian=adk%10000/1000;
bai=adk%1000/100;
shi=adk%100/10;
ge=adk%10;
i=i-1;
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
num1=0;
m1=1;
i=0;
tt=0;
}
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
/*
qwan=adk%1000000/100000;
bwan=adk%1000000/100000;
swan=adk%1000000/100000;
wan=adk%100000/10000;
qian=adk%10000/1000;
bai=adk%1000/100;
shi=adk%100/10;
ge=adk%10;
*/
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
xianshi(ge,shi,bai,qian,wan,swan,bwan,qwan,yi,syi);
}
}
main()
{
//P0M1=0x07;//推挽设置,P1.0,1.1,P1.6
//P0M0=0x07;//01000011
P1M1=0x00;//推挽设置,P1.0,1.1,P1.6
P1M0=0x43;//01000011
j1=0;//out3;
j2=0;//out1;
j3=0;//out2;
mainz();
}
/*
num=0;
tt=0;
TMOD=0x11;//设置定时器0为工作方式1
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
TH1=(65536-20000)/256;
TL1=(65536-20000)%256;
EA=1;//开总中断
ET0=1;//开定时器0中断
ET1=1;
TR0=1;//启动定时器0
TR1=1;
ma=500;
*/
当然了,我只是学了点皮毛。我用C语言主要是设计和应用于硬件的,比如小汽车的各种动作,现场各种工业控制设备的动作,当然了,用的最多的还是PLC语言,单片机这类的稳定性还是差了点,不过,单片机体积小,控制非常,成本特别低。目前很多电子设备应用还是相当比较广泛的。
说到人工智能,我也比较喜欢,但是,目前还是对人工智能算法还是自认为没有走进这个门里面,只是在外面徘徊,经常看一些人工智能的书,主要是看算法,神经算法,人脸识别这类的,我一直理解为都是快速无限循环接近真相的闭环控制。类似与人的神经感触温度后的一个传递,再反馈给手动作,如果80度,我认为会不受大脑控制直接走入应急动作程序,但是这只是一个太小的事件,大脑控制现场,神经传输真的太浩瀚了,还有自学习,自记忆功能这些,比如打字,手指的动作,对各种输入法的应用,对笔记本键盘和家用机键盘的认可,再比如:玩王者荣耀,大脑思路给手的动作,手的精准性,按到屏幕上的力度,这些都是大脑的多任务,无限循环快速闭环控制,并且熟练度上还有条件反射,人剑合一,协调指令,应急控制,情绪变化等等,太多控制发出,所以,我对用的软件还没有太深的接触,只是研究控制算法这类的,这感觉人工智能真的太浩瀚了,如果全部实现,把现场各类情况全部通过传感器转化为标准信号,给到CPU,CPU有自学习,自记忆,自响应,自编程,自更改控制方式等,再输出信号给现场动作设备,或液压、或气动、或电机等精密动作,每个动作都有反馈时间,行程反馈信号等等等等,我感觉每一部分拿出来都需要研究很长时间。
所以我认为,学了C语言,继续学习人工智能的话,如果学习是从0到100的一个路程,我认为,只学了c,应该只是这段路程的0.0001的路吧。
希望可以帮助到您!