基于stm32的绘图机器人设计

基于stm32的绘图机器人设计

经过一段时间的折腾,终于算是把绘图机器人弄完啦。转载请注明出处

简介

这是我的大学毕业设计,平平淡淡才是真,本设计只为完成简单的绘图工作而设计

  1. 简单的图像处理算法
  2. 简单的机电控制算法

在此感谢布雷森汉姆直线算法理解 这篇博客的博主@Vicent_Chen
帮我理解了布雷森汉姆直线算法,并移植了部分代码。

这里粘贴出部分论文和代码(再整理一篇markdown的论文实在是吃不消),主要部分将以链接形式提供。
pdf论文 点击下载
上下位机源码 点击下载

摘要

在信息化发展迅速的当今时代背景下,人工智能与大数据成为热点话题,吸引了大部分人的关注,尤其是智能机器人更是令不少人为之折腰。计算机技术的飞速发展,让机器人渗入的领域更加广泛,代替人类进行的工作种类也越来越多。过快的发展、过多的需求以及领域的过于广泛反而容易让人们更沉浸于让机器人去代替原本人类进行的简单劳动,却忘记了一些原本就是大机器做的工作,比如绘图技术方面。绘图技术应用在很多设计方面,譬如服装设计、工业设计、教育教学、工程设计等。但就我查询得知,在目前很多还是采用由专业人士绘画出来之后,利用打印机进行打印或者彩印,对于普通的设计人员来说,并不是合适的选择。因此我们设计了一种更为低成本切对纸张无特殊要求的绘图机。
本设计采用STM32单片机作为处理控制的核心单元,结合使用上位机控制软件通过图像处理将位图转化为笔的路径信息,信息经串口发送到STM32控制器。控制器利用Bresenham直线算法计算前后的两个坐标之间的线段各点坐标,通过各点的位置转换为驱动步进电机转动的脉冲量、方向等量,最终达到控制笔头移动。绘图方案为绘制轮廓图。该设计方案可靠,成本低廉,同时拥有良好的绘图精度,该机器人能够应用于各种草图的绘制等领域。

关键字:STM32;Bresenham;图像处理;绘图机器人

Abstract

In the current era of rapid development of information technology, artificial intelligence and big data have become hot topics, attracting the attention of most people, especially intelligent robots, which are many people who are bent over. The rapid development of computer technology has made the field of robot penetration more extensive, and there are more and more types of work to replace humans. Too fast development, excessive demand, and too broad a field tend to make people more immersed in letting robots replace the simple labor that humans have done, but forget some work that was originally done by large machines, such as drawing technology. Drawing technology is used in many design aspects, such as fashion design, industrial design, education and teaching, engineering design. However, as far as I can find out, many of them are still used by printers for printing or color printing after being painted by professionals. It is not a suitable choice for ordinary designers. Therefore, we have designed a plotter that has no special requirements for paper at a lower cost.
The design adopts the STM32 single-chip microcomputer as the core unit of processing control. Combined with the upper computer control software, the bitmap is converted into the path information of the pen through image processing, and the information is sent to the STM32 controller through the serial port. The controller uses the Bresenham line algorithm to calculate the coordinates of the points of the line between the two coordinates before and after, and converts the position of each point into the pulse amount and direction of the stepping motor to finally control the movement of the tip. The drawing scheme is to draw a contour map. The design is reliable, low cost, and has good drawing accuracy. The robot can be applied to various sketches and other fields.

Key words: STM32; Bresenham; Image processing; Drafting robot
目录
第一章 绪论 1

  1. 基于stm32微控制器的绘图机器人研究设计的目的 1
  2. 基于stm32微控制器的绘图机器人研究设计的设计功能 1
    第二章 系统整体方案设计 2
    第三章 硬件设计 4
  3. 硬件电路资源使用设计 4
    1.1 STM32F103RBT6片上资源 4
    1.2 外围芯片资源 4
  4. 机械结构设计 5
  5. 通信原理 9
    第四章 软件设计 11
  6. 上位机程序设计 11
    1.1 二值化算法 11
    1.2 轮廓化算法 13
    1.3 描边算法 14
    1.4 串口通信数据格式 16
  7. 下位机程序设计 17
    2.1 缓冲区算法 17
    2.2 Bresenham直线算法 17
    2.3 坐标轴的确定 19
    第五章 系统调试与实验结果 21
  8. 系统调试 21
  9. 实验结果 24
    参 考 文 献 25
    致 谢 26
    附 录 27

……

主函数程序如下:

#include "stm32f10x.h"
#include "bsp.h"				//板件链接支持包 已经包含bitband.h
#include "stm32iic.h"
#include "codetab.h"
#include "LQ12864.h"
#include "function.h"
u16 x,y; 						//坐标变量
u16 R[10]; 
u8 Rok=0; 					//接受完成标志
u16 x1,y1; 					//接受的坐标
u16 pwmcount; 				//脉冲数目
u16 t=0; 						//执行次数
u8 Flag_Send=0; 				//0为没有发送过
u8 init_flag=0; 				//打印开始要先初始化
u8 Flag_MotST=1; 			//Holdon 状态  (1)
u8 TB=1; 						//抬笔标记
buf uart_buf[bufsize];
u16 front=0;
u16 rear=0;
int main()
{
	SW_GPIO_Config();
	IIC_Init();
	OLED_Init ();
	MOT_GPIO_Config();		//MOT pwm、GPIO初始化函数
	TIM_NVIC_Config();
	USART_Config();
	PWM_Config(15000);
	DJ_PWM_Config(50000); 	//Tim4 -ch4 50hz
	Pen_Up ;
	TIM_CDISEN ; 				//TIM不计数
	TOP_SDISEN ; 				//关闭top step通道
	BOT_SDISEN ; 				//关闭bot step通道
	LOC_Init ();
	OLED_CLS ();
	OLED_P8x16Str (0,2,(u8*)"Completed");
	LOOSEN ; 					//松开电机
	while(1)
	{
		if(Rok==1)
		{
			if(init_flag==0 ) 
			{
				LOC_Init ();
				OLED_CLS ();
				OLED_P8x16Str (0,2,(u8*)"Waiting...");
				init_flag =1; //不再初始化
			}
			line(x,y,uart_buf
	 	 	 	 [rear].data_x,
				 uart_buf [rear].data_y,
				 uart_buf [rear].data_act);
								//进行直线算法
		}
	}
}

pdf论文 点击下载
上下位机源码 点击下载
……

猜你喜欢

转载自blog.csdn.net/qq_18893055/article/details/94122676
今日推荐