基於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論文 點擊下載
上下位機源碼 點擊下載
……

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章