摘要:提示以下是本篇文章正文內(nèi)容,下面案例可供參考一是什么半導(dǎo)體在年自韓國分離出來,有超過年單片機(jī)領(lǐng)域耕耘經(jīng)驗(yàn)。
提示:ABOV 實(shí)現(xiàn)多機(jī)通信控制,來實(shí)現(xiàn)移動監(jiān)測運(yùn)動平臺的控制
提示:這里可以添加本文要記錄的大概內(nèi)容:
例如:隨著人工智能的不斷發(fā)展,機(jī)器學(xué)習(xí)這門技術(shù)也越來越重要,很多人都開啟了學(xué)習(xí)機(jī)器學(xué)習(xí),本文就介紹了機(jī)器學(xué)習(xí)的基礎(chǔ)內(nèi)容。
提示:以下是本篇文章正文內(nèi)容,下面案例可供參考
ABOV半導(dǎo)體在2006年自韓國HYNIX分離出來,有超過20年單片機(jī)領(lǐng)域耕耘經(jīng)驗(yàn)。ABOV半導(dǎo)體有單片機(jī)和標(biāo)準(zhǔn)IC另類產(chǎn)品
產(chǎn)品用于自動測試人體感應(yīng)PIR對不同距離角度下感應(yīng)效果
IO輸出 AD檢測 串口通信
實(shí)現(xiàn)對兩臺運(yùn)動機(jī)構(gòu)的控制,并完成機(jī)構(gòu)上待測產(chǎn)品的測試 并將數(shù)據(jù)回傳到多路終端
主機(jī)構(gòu)建模如下:
從機(jī)構(gòu)建模如下:
兩臺構(gòu)安裝過后如下:
代碼如下(示例):
從機(jī)調(diào)試如下:
ABOV移動小車從機(jī)
ABOV從機(jī)移動效果
代碼生成器配置:
Keil完成代碼后續(xù):
OCD2完成仿真:
main.c:
//======================================================// Main program routine// - Device name : MC95FG308// - Package type : 28SOP//======================================================// For XDATA variable : V1.041.00 ~#define MAIN 1// Generated : Fri, Nov 12, 2021 (21:10:31)#include "MC95FG308.h"#include "func_def.h"#include "IO_code.h"#include "usart_code.h"#include "function_code.h"void main(){ cli(); // disable INT. during peripheral setting port_init(); // initialize ports clock_init(); // initialize operation clock ADC_init(); // initialize A/D convertor Timer0_init(); // initialize Timer0 UART_init(); // initialize UART interface sei(); // enable INT. // TODO: add your main code here placeX_now = 0; //上電默認(rèn)為0 坐標(biāo)吧 while(1){ fn_function_check(); //在這里進(jìn)行處理函數(shù) // TODO: add other code here }}//======================================================// interrupt routines//======================================================void INT_USART0_Rx() interrupt 6{ // USART0 Rx interrupt // TODO: add your code here dataR0 = UART_read(0); fn_check_usart(0,&dataR0); //UART_write(0,dataR0);}void INT_USART1_Rx() interrupt 10{ // USART1 Rx interrupt // TODO: add your code here}void INT_Timer0() interrupt 12{ // Timer0 interrupt // TODO: add your code here Led_Time_Change(100);}void INT_ADC() interrupt 18{ // ADC interrupt // TODO: add your code here}void INT_BIT() interrupt 22{ // BIT interrupt // TODO: add your code here}//======================================================// peripheral setting routines//======================================================unsigned char UART_read(unsigned char ch){ unsigned char dat; if (ch == (unsigned char)0) { // UART0 while(!(USTAT & 0x20)); // wait dat = UDATA; // read } if (ch == (unsigned char)1) { // UART1 while(!(USTAT1 & 0x20)); // wait dat = UDATA1; // read } return dat;}unsigned int ADC_read(){ // read A/D convertor unsigned int adcVal; while(!(ADCM & 0x10)); // wait ADC busy adcVal = (ADCRH << 8) | ADCRL; // read ADC ADCM &= ~0x40; // stop ADC return adcVal;}void ADC_init(){ // initialize A/D convertor ADCM = 0x00; // setting ADCM2 = 0x04; // trigger source, alignment, frequency IEN3 |= 0x01; // enable ADC interrupt}void ADC_start(unsigned char ch){ // start A/D convertor ADCM = (ADCM & 0xf0) | (ch & 0xf); // select channel ADCM |= 0x40; // start ADC}void Timer0_init(){ // initialize Timer0 // 8bit timer, period = 9.984000mS T0CR = 0x96; // timer setting T0DR = 0xE9; // period count IEN2 |= 0x01; // Enable Timer0 interrupt T0CR |= 0x01; // clear counter}void UART_init(){ // initialize UART interface // UART0 : ASync. 9615bps N 8 1 UCTRL2 = 0x02; // activate UART0 UCTRL1 = 0x06; // Async/Sync, bit count, parity UCTRL2 |= 0xAC; // interrupt, speed //UCTRL2 |= 0x10; // enable line when you want to use wake up in STOP mode UCTRL3 = 0x00; // stop bit UBAUD = 0x4D; // baud rate // UART1 : ASync. 9615bps N 8 1 UCTRL12 = 0x02; // activate UART1 UCTRL11 = 0x06; // Async/Sync, bit count, parity UCTRL12 |= 0xAC; // interrupt, speed //UCTRL12 |= 0x10; // enable line when you want to use wake up in STOP mode UCTRL13 = 0x00; // stop bit UBAUD1 = 0x4D; // baud rate IEN1 |= 0x11; // enable UART interrupt}void UART_write(unsigned char ch, unsigned char dat){ if (ch == (unsigned char)0) { // UART0 while(!(USTAT & 0x80)); // wait UDATA = dat; // write } if (ch == (unsigned char)1) { // UART1 while(!(USTAT1 & 0x80)); // wait UDATA1 = dat; // write }}void clock_init(){ // external clock cli(); IEN3 |= 0x10; // Enable BIT interrupt sei(); BCCR = 0x05; // 16msec BIT SCCR = 0x81; // External clock PCON = 0x03; // STOP1 mode entry _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); SCCR &= ~0x80; // clock changed IEN3 &= ~0x10; // Disable BIT interrupt}void port_init(){ // initialize ports // 3 : AN4 in // 8 : P10 out // 9 : P11 out // 16 : TxD1 out // 17 : RxD1 in // 19 : XIN in // 20 : XOUT out // 25 : TxD0 out // 26 : RxD0 in // 28 : P31 out P0IO = 0xE7; // direction P0PU = 0x08; // pullup P0OD = 0x00; // open drain P0DB = 0x00; // debounce P0 = 0x00; // port initial value P1IO = 0xFB; // direction P1PU = 0x00; // pullup P1OD = 0x00; // open drain P1DB = 0x00; // debounce P1 = 0x00; // port initial value P2IO = 0xFE; // direction P2PU = 0x00; // pullup P2OD = 0x00; // open drain P2DB = 0x00; // debounce P2 = 0x00; // port initial value P3IO = 0x7F; // direction P3PU = 0x80; // pullup P3OD = 0x00; // open drain P3DB = 0x00; // debounce P3 = 0x00; // port initial value // Set port function PSR0 = 0x10; // AN7 ~ AN0 PSR1 = 0x00; // I2C, AN14 ~ AN8}
IO_code.h :
#ifndef _IO_CODE_#define _IO_CODE_#include "MC95FG308.h"#include "func_def.h"#define TIME_Goforward 6 //時(shí)間為前進(jìn)控制時(shí)間#define TIME_GoBACK_Long 18 //時(shí)間為回退長控制時(shí)間#define TIME_GoBACK_short 6 //時(shí)間為回退短控制時(shí)間#define IO_Goforward P11 //IO口為前進(jìn)控制口#define IO_GoBACK P10 //IO口為后退控制口unsigned int fn_IO_run(unsigned char distance); //前進(jìn)控制程序unsigned int fn_IO_goback(unsigned char back_time); //后退控制程序void delay_ms(unsigned int count);void delay_us(unsigned int count);void delay_s(unsigned int count);void Led_Time_Change(unsigned int count);void Led_flash(void);#endif
IO_code.c :
#include "IO_code.h"#include "usart_code.h" #include "function_code.h"/************************************************************* @brief * unsigned int fn_IO_run(unsigned char distance)* @param * @retval *************************************************************/ unsigned int fn_IO_run(unsigned char distance){ // 前進(jìn)控制程序 unsigned char xdistance; if(distance<=placeX_MIN){return 0;} // 前進(jìn)不能小于最小位移坐標(biāo) for(xdistance=0 ;xdistance<distance ;xdistance++ ){ IO_Goforward = 1 ; delay_s(1); IO_Goforward = 0 ; //循環(huán)前進(jìn) delay_s(TIME_Goforward); if(bdata_effect==1){ //中通接收到新的指令就出去了 return xdistance; } } return xdistance;}/************************************************************* @brief * unsigned int fn_IO_goback(unsigned char back_time)* @param * @retval *************************************************************/ unsigned int fn_IO_goback(unsigned char back_time){ // 后退控制程序 IO_GoBACK = 1 ; delay_s(1); IO_GoBACK = 0 ; delay_s(back_time); if(bdata_effect==1){ return 2; } return 0;} /************************************************************* @brief * void Led_Time_Change(unsigned int count)* @param * @retval *************************************************************/ unsigned char count_Ledtime;void Led_Time_Change(unsigned int count){ //中斷定時(shí)器里IO閃爍 if(count_Ledtime++>count){ count_Ledtime=0; P31 = ~P31; } }/************************************************************* @brief * void Led_flash(void)* @param * @retval *************************************************************/ void Led_flash(void){ P31 = ~P31; delay_ms(100); P31 = ~P31; delay_ms(100); P31 = ~P31;}/************************************************************* @brief * Delay 函數(shù)* @param * @retval *************************************************************/ void delay_us(unsigned int count){ unsigned int a=0 ; for(a=0;a<count;a++){ ; } }//-----------------------------------------------------void delay_ms(unsigned int count){ unsigned int a=0,b=0; for(a=0;a<count;a++){ delay_us(400); } }void delay_s(unsigned int count){ unsigned int a=0,b=0; for(a=0;a<count;a++){ delay_ms(1100); if(bdata_effect==1){ return; } } }
usart_code.c:
#ifndef _USART_CODE_#define _USART_CODE_#include "MC95FG308.h"#include "func_def.h"extern volatile unsigned char bdata_begin ;extern volatile unsigned char bdata_judge ;extern volatile unsigned char bdata_effect ;extern volatile unsigned char bdata_error ; #define _DATA_GET 0xAB #define _DATA_GET_CODE 4#define _DATA_GET_MODE 7 #define U_Scom_car 0xBA#define U_Scom_code1 0x01 //開始#define U_Scom_code2 0x02 //暫停#define U_Scom_code3 0x03 //位移到目標(biāo)坐標(biāo)附件 #define U_Scom_code4 0x04 //開始測試目標(biāo)坐標(biāo)#define U_Scom_code5 0x05 //返回起點(diǎn)#define U_Scom_code6 0x06 //復(fù)位#define U_Scom_code7 0x07 //故障extern unsigned char UART_SENDCODE[_DATA_GET_CODE];extern unsigned char dataR0 ;extern unsigned char UART_GETcommand_car; //串口最終的設(shè)備地址extern unsigned char UART_GETcommand_code; //串口最終的命令extern unsigned char UART_GETcommand_X; //串口最終的X命令extern unsigned char UART_GETcommand_Y; //串口最終的Y命令 void fn_usart_senddata(unsigned char ch, unsigned char *dat ,unsigned int num ); void fn_check_usart(unsigned char ch,unsigned char *dataget);void fn_usart_sendcommande(unsigned char com_car, unsigned char com_code ,unsigned char com_X , unsigned char com_Y ); #endif
usart_code.c :
#include "usart_code.h"#include "IO_code.h"volatile unsigned char bdata_begin ;volatile unsigned char bdata_judge ;volatile unsigned char bdata_effect ; //---------------------- 接收對應(yīng) 碼值 ---------------------------------const unsigned char UART_GETCODE[_DATA_GET_MODE][_DATA_GET_CODE]
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/123902.html
摘要:智能照明控制系統(tǒng)的出現(xiàn)可以完美的解決以上問題,照明系統(tǒng)可以針對學(xué)生的活動規(guī)律人流量等特定的環(huán)境和條件自動實(shí)現(xiàn)開關(guān)和調(diào)光功能,。在云計(jì)算物聯(lián)網(wǎng)以及移動互聯(lián)網(wǎng)等新興技術(shù)不斷崛起的大背景下,智慧校園的建設(shè)成為實(shí)現(xiàn)教育新發(fā)展的必要途徑。 每當(dāng)夜幕降臨,校園里的路燈都會自動亮起氤氳的光芒,透過樹葉的縫隙灑下斑駁的光影,學(xué)生們腳下踩著碎碎的亮光,聊著身邊的軼聞,傳頌著城市的故事....每一盞路燈照亮了...
摘要:原理以上面的為例子,要使用實(shí)現(xiàn)鼠標(biāo)跟隨,最重要的一點(diǎn)就是如何實(shí)時(shí)監(jiān)測到當(dāng)前鼠標(biāo)處于何處,其實(shí)很多效果,都離不開障眼法二字。 直接進(jìn)入正題,鼠標(biāo)跟隨,顧名思義,就是元素會跟隨著鼠標(biāo)的移動而作出相應(yīng)的運(yùn)動。大概類似于這樣: showImg(https://segmentfault.com/img/remote/1460000018405114); 通常而言,CSS 負(fù)責(zé)表現(xiàn),JavaScr...
摘要:當(dāng)然,本文的重點(diǎn),就是介紹如何在不借助的情況下使用來模擬實(shí)現(xiàn)一些鼠標(biāo)跟隨的行為動畫效果。原理以上面的為例子,要使用實(shí)現(xiàn)鼠標(biāo)跟隨,最重要的一點(diǎn)就是如何實(shí)時(shí)監(jiān)測到當(dāng)前鼠標(biāo)處于何處,其實(shí)很多效果,都離不開障眼法二字。直接進(jìn)入正題,鼠標(biāo)跟隨,顧名思義,就是元素會跟隨著鼠標(biāo)的移動而作出相應(yīng)的運(yùn)動。大概類似于這樣: 通常而言,CSS 負(fù)責(zé)表現(xiàn),JavaScript 負(fù)責(zé)行為。而鼠標(biāo)跟隨這種效果屬于行為...
摘要:年末,年即將走進(jìn)尾聲,忙碌了一年準(zhǔn)備給家里人買一份禮物,這些天看了很多產(chǎn)品,最終選定了小米智能手環(huán)。 年末,2021年即將走進(jìn)尾聲,忙碌了一年準(zhǔn)備給家里人買一份禮物...
摘要:趙涏元的最新作品惡意代碼分析與滲透測試詳細(xì)地講解了惡意代碼在各種渠道的散播方式,并針對開發(fā)者和用戶介紹如何應(yīng)對此類威脅。問您撰寫惡意代碼分析與滲透測試的初衷是什么我每次寫書的時(shí)候,最先考慮的是這個(gè)主題是否是韓國國內(nèi)已有論述的。 非商業(yè)轉(zhuǎn)載請注明作譯者、出處,并保留本文的原始鏈接:http://www.ituring.com.cn/article/206074 趙涏元目前在KB投資證券公...
閱讀 1138·2021-11-19 09:40
閱讀 980·2021-11-12 10:36
閱讀 1278·2021-09-22 16:04
閱讀 3122·2021-09-09 11:39
閱讀 1279·2019-08-30 10:51
閱讀 1894·2019-08-30 10:48
閱讀 1237·2019-08-29 16:30
閱讀 483·2019-08-29 12:37