资讯专栏INFORMATION COLUMN

ABOV 程序 - 移动监测运动平台控制

XUI / 688人阅读

摘要:提示以下是本篇文章正文内容,下面案例可供参考一是什么半导体在年自韩国分离出来,有超过年单片机领域耕耘经验。

文章目录

提示:ABOV 实现多机通信控制,来实现移动监测运动平台的控制



前言

提示:这里可以添加本文要记录的大概内容:
例如:随着人工智能的不断发展,机器学习这门技术也越来越重要,很多人都开启了学习机器学习,本文就介绍了机器学习的基础内容。


提示:以下是本篇文章正文内容,下面案例可供参考

一、ABOV是什么?



ABOV半导体在2006年自韩国HYNIX分离出来,有超过20年单片机领域耕耘经验。ABOV半导体有单片机和标准IC另类产品

二、应用设定

1.应用场景设定

产品用于自动测试人体感应PIR对不同距离角度下感应效果

2.所使用的方法

1.Inventor 3维建模
2.ABOV单片机作为机械控制IC

IO输出 AD检测 串口通信

3.STM32单片机 作为系统终端控制IC
4.C# 作为电脑终端控制软件

3.最终实现的设定

实现对两台运动机构的控制,并完成机构上待测产品的测试 并将数据回传到多路终端

二、使用步骤

1.完成实验结构三维建模

主机构建模如下:


从机构建模如下:

两台构安装过后如下:

2.完成通信模式的构想

代码如下(示例):

3.完成从机调试

从机调试如下:

3.完成主机调试

三、从机制作

1.效果图

ABOV移动小车从机

ABOV从机移动效果

2.原理图


3.程序

代码源码下载---->

代码生成器配置:
Keil完成代码后续:

OCD2完成仿真:

1.主程序

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;	    //上电默认为0 坐标吧	while(1){   	   fn_function_check();  //在这里进行处理函数	   // 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}

1.IO程序

IO_code.h :

#ifndef		_IO_CODE_#define		_IO_CODE_#include	"MC95FG308.h"#include	"func_def.h"#define 	TIME_Goforward  	6	 //时间为前进控制时间#define 	TIME_GoBACK_Long    18	 //时间为回退长控制时间#define 	TIME_GoBACK_short   6	 //时间为回退短控制时间#define 	IO_Goforward  P11  //IO口为前进控制口#define 	IO_GoBACK	  P10  //IO口为后退控制口unsigned int fn_IO_run(unsigned char distance);	      //前进控制程序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){	  // 前进控制程序    unsigned  char xdistance;	if(distance<=placeX_MIN){return 0;}	      // 前进不能小于最小位移坐标	for(xdistance=0 ;xdistance<distance ;xdistance++ ){		IO_Goforward = 1 ;		delay_s(1);		IO_Goforward = 0 ;			   //循环前进	 	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){  //中断定时器里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  函数* @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; 	}		  }	}

2.USAR串口程序

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	  //位移到目标坐标附件 #define   U_Scom_code4   0x04	  //开始测试目标坐标#define   U_Scom_code5   0x05	  //返回起点#define   U_Scom_code6   0x06	 //复位#define   U_Scom_code7   0x07	 //故障extern unsigned char UART_SENDCODE[_DATA_GET_CODE];extern unsigned char dataR0 ;extern unsigned char UART_GETcommand_car;  //串口最终的设备地址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 ; //---------------------- 接收对应 码值 ---------------------------------const  unsigned char UART_GETCODE[_DATA_GET_MODE][_DATA_GET_CODE]
            
                     
             
               

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/123902.html

相关文章

  • 云计算、物联网崛起 智慧校园离不开智能照明系统

    摘要:智能照明控制系统的出现可以完美的解决以上问题,照明系统可以针对学生的活动规律人流量等特定的环境和条件自动实现开关和调光功能,。在云计算物联网以及移动互联网等新兴技术不断崛起的大背景下,智慧校园的建设成为实现教育新发展的必要途径。  每当夜幕降临,校园里的路灯都会自动亮起氤氲的光芒,透过树叶的缝隙洒下斑驳的光影,学生们脚下踩着碎碎的亮光,聊着身边的轶闻,传颂着城市的故事....每一盏路灯照亮了...

    骞讳护 评论0 收藏0
  • 不可思议的纯 CSS 实现鼠标跟随效果

    摘要:原理以上面的为例子,要使用实现鼠标跟随,最重要的一点就是如何实时监测到当前鼠标处于何处,其实很多效果,都离不开障眼法二字。 直接进入正题,鼠标跟随,顾名思义,就是元素会跟随着鼠标的移动而作出相应的运动。大概类似于这样: showImg(https://segmentfault.com/img/remote/1460000018405114); 通常而言,CSS 负责表现,JavaScr...

    sshe 评论0 收藏0
  • 不可思议的纯 CSS 实现鼠标跟随效果

    摘要:当然,本文的重点,就是介绍如何在不借助的情况下使用来模拟实现一些鼠标跟随的行为动画效果。原理以上面的为例子,要使用实现鼠标跟随,最重要的一点就是如何实时监测到当前鼠标处于何处,其实很多效果,都离不开障眼法二字。直接进入正题,鼠标跟随,顾名思义,就是元素会跟随着鼠标的移动而作出相应的运动。大概类似于这样: 通常而言,CSS 负责表现,JavaScript 负责行为。而鼠标跟随这种效果属于行为...

    phpmatt 评论0 收藏0
  • 启明云端分享:小米智能手环主控的秘密

    摘要:年末,年即将走进尾声,忙碌了一年准备给家里人买一份礼物,这些天看了很多产品,最终选定了小米智能手环。 年末,2021年即将走进尾声,忙碌了一年准备给家里人买一份礼物...

    wpw 评论0 收藏0
  • 《Android恶意代码分析与渗透测试》作者赵涏元:Android平台安全问题的特点和价值

    摘要:赵涏元的最新作品恶意代码分析与渗透测试详细地讲解了恶意代码在各种渠道的散播方式,并针对开发者和用户介绍如何应对此类威胁。问您撰写恶意代码分析与渗透测试的初衷是什么我每次写书的时候,最先考虑的是这个主题是否是韩国国内已有论述的。 非商业转载请注明作译者、出处,并保留本文的原始链接:http://www.ituring.com.cn/article/206074 赵涏元目前在KB投资证券公...

    venmos 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<