您好。
首先可以說,只是學了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的路吧。
希望可以幫助到您!