[STM32F103C8T6]基于stm32的循迹,跟随,避障智能小车

目录

1.小车驱动主要是通过L9110S模块来驱动电机

motor.c

2.我们可以加入串口控制电机驱动(重写串口接收回调函数,和重定向printf)

Uart.c

main.c 

3.点动功能

uart.c

main.c

为什么使用的是HAL_Delay()要设置滴答定时器的中断优先级呢?

4.小车PWM调速, 

6.跟随功能

7.避障功能

超声波测距流程

 CSB.c

SG90.c

main.c


1.小车驱动主要是通过L9110S模块来驱动电机

 本次STM32与L9110s的接线是:

B-1A -- PB0
B-1B -- PB1
A-1A -- PB2
A-1B -- PB10

通过对GPIO口的配置,可以写出电机的驱动程序(全速模式)

motor.c

#include "motor.h"
#include "gpio.h"void GoForward(void)
{//右轮HAL_GPIO_WritePin(GPIOB,GPIO_PIN_0,GPIO_PIN_SET);HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_RESET);//左轮HAL_GPIO_WritePin(GPIOB,GPIO_PIN_2,GPIO_PIN_SET);HAL_GPIO_WritePin(GPIOB,GPIO_PIN_10,GPIO_PIN_RESET);
}void GoBack(void)
{//右轮HAL_GPIO_WritePin(GPIOB,GPIO_PIN_0,GPIO_PIN_RESET);HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_SET);//左轮HAL_GPIO_WritePin(GPIOB,GPIO_PIN_2,GPIO_PIN_RESET);HAL_GPIO_WritePin(GPIOB,GPIO_PIN_10,GPIO_PIN_SET);
}void GoLeft(void)
{//右轮HAL_GPIO_WritePin(GPIOB,GPIO_PIN_0,GPIO_PIN_SET);HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_RESET);//左轮HAL_GPIO_WritePin(GPIOB,GPIO_PIN_2,GPIO_PIN_RESET);HAL_GPIO_WritePin(GPIOB,GPIO_PIN_10,GPIO_PIN_RESET);
}void GoRight(void)
{//右轮HAL_GPIO_WritePin(GPIOB,GPIO_PIN_0,GPIO_PIN_RESET);HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_RESET);//左轮HAL_GPIO_WritePin(GPIOB,GPIO_PIN_2,GPIO_PIN_SET);HAL_GPIO_WritePin(GPIOB,GPIO_PIN_10,GPIO_PIN_RESET);
}void Stop(void)
{//右轮HAL_GPIO_WritePin(GPIOB,GPIO_PIN_0,GPIO_PIN_RESET);HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_RESET);//左轮HAL_GPIO_WritePin(GPIOB,GPIO_PIN_2,GPIO_PIN_RESET);HAL_GPIO_WritePin(GPIOB,GPIO_PIN_10,GPIO_PIN_RESET);
}

2.我们可以加入串口控制电机驱动(重写串口接收回调函数,和重定向printf)

加入串口控制,我们需要在cubeMX中开启串口中断用于接收串口发来的数据

Uart.c

void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
{if(uartHandle->Instance==USART1){/* USER CODE BEGIN USART1_MspDeInit 0 *//* USER CODE END USART1_MspDeInit 0 *//* Peripheral clock disable */__HAL_RCC_USART1_CLK_DISABLE();/**USART1 GPIO ConfigurationPA9     ------> USART1_TXPA10     ------> USART1_RX*/HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);/* USART1 interrupt Deinit */HAL_NVIC_DisableIRQ(USART1_IRQn);/* USER CODE BEGIN USART1_MspDeInit 1 *//* USER CODE END USART1_MspDeInit 1 */}
}/* USER CODE BEGIN 1 */
//串口接收缓存(1字节)
uint8_t buf=0;
//定义最大接收字节数 200,可根据需求调整
#define UART1_REC_LEN 200
#define SIZE 12
// 接收缓冲, 串口接收到的数据放在这个数组里,最大UART1_REC_LEN个字节
uint8_t UART1_RX_Buffer[UART1_REC_LEN];
// 接收状态
// bit15, 接收完成标志
// bit14, 接收到0x0d
// bit13~0, 接收到的有效字节数目
uint16_t UART1_RX_STA=0;char buffer[SIZE];
// 接收完成回调函数,收到一个数据后,在这里处理
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
// 判断中断是由哪个串口触发的
if(huart->Instance == USART1)
{
// 判断接收是否完成(UART1_RX_STA bit15 位是否为1)
if((UART1_RX_STA & 0x8000) == 0)
{
// 如果已经收到了 0x0d (回车),
if(UART1_RX_STA & 0x4000)
{
// 则接着判断是否收到 0x0a (换行)
if(buf == 0x0a)
{
// 如果 0x0a 和 0x0d 都收到,则将 bit15 位置为1UART1_RX_STA |= 0x8000;
//	printf("1");// 车控指令if(!strcmp((const char*)UART1_RX_Buffer, "M1")){	printf("Forwad......");GoForward();}else if(!strcmp((const char*)UART1_RX_Buffer, "M2")){printf("Back......");GoBack();}else if(!strcmp((const char*)UART1_RX_Buffer, "M3")){printf("Left......");GoLeft();}else if(!strcmp((const char*)UART1_RX_Buffer, "M4")){printf("Right......");GoRight();}else if(!strcmp((const char*)UART1_RX_Buffer, "Stop")){printf("Stop......");Stop();}memset(UART1_RX_Buffer, 0, UART1_REC_LEN);UART1_RX_STA = 0;}else
// 否则认为接收错误,重新开始UART1_RX_STA = 0;
}else // 如果没有收到了 0x0d (回车)
{//则先判断收到的这个字符是否是 0x0d (回车)if(buf == 0x0d)
{	
// 是的话则将 bit14 位置为1UART1_RX_STA |= 0x4000;}
else
{
// 否则将接收到的数据保存在缓存数组里UART1_RX_Buffer[UART1_RX_STA & 0X3FFF] = buf;UART1_RX_STA++;
// 如果接收数据大于UART1_REC_LEN(200字节),则重新开始接收if(UART1_RX_STA > UART1_REC_LEN - 1)UART1_RX_STA = 0;}}
}
// 重新开启中断
HAL_UART_Receive_IT(&huart1, &buf, 1);}
}int fputc(int ch, FILE *f)
{unsigned char temp[1]={ch};HAL_UART_Transmit(&huart1,temp,1,0xffff);return ch;
}

main.c 

extern uint8_t buf;int main(void)
{/* USER CODE BEGIN 1 *//* USER CODE END 1 *//* MCU Configuration--------------------------------------------------------*//* Reset of all peripherals, Initializes the Flash interface and the Systick. */HAL_Init();/* USER CODE BEGIN Init *//* USER CODE END Init *//* Configure the system clock */SystemClock_Config();/* USER CODE BEGIN SysInit *//* USER CODE END SysInit *//* Initialize all configured peripherals */MX_GPIO_Init();MX_USART1_UART_Init();/* USER CODE BEGIN 2 */HAL_UART_Receive_IT(&huart1, &buf, 1);//开启串口接收/* USER CODE END 2 *//* Infinite loop *//* USER CODE BEGIN WHILE */while (1){/* USER CODE END WHILE *//* USER CODE BEGIN 3 */}/* USER CODE END 3 */
}

 切记主函数内需要调用开启串口接收函数!!!!!!

将HC08模块接入STM32,连接蓝牙就可以通过蓝牙APP控制

3.点动功能

如果用蓝牙app实现遥控车模式,我们会发现,点了前进按钮,小车会一直前进,按下左转会一直左转,而遥控车应该是点动功能,按一下向前就向前走一下,一直按一直走

我的思路是,主程序一直跑Stop(); 接收到来自蓝牙(串口)的数据后执行动作(几毫秒),从而实现点动

uart.c

void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
{if(uartHandle->Instance==USART1){/* USER CODE BEGIN USART1_MspDeInit 0 *//* USER CODE END USART1_MspDeInit 0 *//* Peripheral clock disable */__HAL_RCC_USART1_CLK_DISABLE();/**USART1 GPIO ConfigurationPA9     ------> USART1_TXPA10     ------> USART1_RX*/HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);/* USART1 interrupt Deinit */HAL_NVIC_DisableIRQ(USART1_IRQn);/* USER CODE BEGIN USART1_MspDeInit 1 *//* USER CODE END USART1_MspDeInit 1 */}
}/* USER CODE BEGIN 1 */
//串口接收缓存(1字节)
uint8_t buf=0;
//定义最大接收字节数 200,可根据需求调整
#define UART1_REC_LEN 200
#define SIZE 12
// 接收缓冲, 串口接收到的数据放在这个数组里,最大UART1_REC_LEN个字节
uint8_t UART1_RX_Buffer[UART1_REC_LEN];
// 接收状态
// bit15, 接收完成标志
// bit14, 接收到0x0d
// bit13~0, 接收到的有效字节数目
uint16_t UART1_RX_STA=0;char buffer[SIZE];
// 接收完成回调函数,收到一个数据后,在这里处理
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
// 判断中断是由哪个串口触发的
if(huart->Instance == USART1)
{
// 判断接收是否完成(UART1_RX_STA bit15 位是否为1)
if((UART1_RX_STA & 0x8000) == 0)
{
// 如果已经收到了 0x0d (回车),
if(UART1_RX_STA & 0x4000)
{
// 则接着判断是否收到 0x0a (换行)
if(buf == 0x0a)
{
// 如果 0x0a 和 0x0d 都收到,则将 bit15 位置为1UART1_RX_STA |= 0x8000;
//	printf("1");// 车控指令if(!strcmp((const char*)UART1_RX_Buffer, "M1")){	printf("Forwad......");GoForward();HAL_Delay(10);}else if(!strcmp((const char*)UART1_RX_Buffer, "M2")){printf("Back......");GoBack();HAL_Delay(10);}else if(!strcmp((const char*)UART1_RX_Buffer, "M3")){printf("Left......");GoLeft();HAL_Delay(10);}else if(!strcmp((const char*)UART1_RX_Buffer, "M4")){printf("Right......");GoRight();HAL_Delay(10);}else if(!strcmp((const char*)UART1_RX_Buffer, "Stop")){printf("Stop......");Stop();HAL_Delay(10);}memset(UART1_RX_Buffer, 0, UART1_REC_LEN);UART1_RX_STA = 0;}else
// 否则认为接收错误,重新开始UART1_RX_STA = 0;
}else // 如果没有收到了 0x0d (回车)
{//则先判断收到的这个字符是否是 0x0d (回车)if(buf == 0x0d)
{	
// 是的话则将 bit14 位置为1UART1_RX_STA |= 0x4000;}
else
{
// 否则将接收到的数据保存在缓存数组里UART1_RX_Buffer[UART1_RX_STA & 0X3FFF] = buf;UART1_RX_STA++;
// 如果接收数据大于UART1_REC_LEN(200字节),则重新开始接收if(UART1_RX_STA > UART1_REC_LEN - 1)UART1_RX_STA = 0;}}
}
// 重新开启中断
HAL_UART_Receive_IT(&huart1, &buf, 1);}
}int fputc(int ch, FILE *f)
{unsigned char temp[1]={ch};HAL_UART_Transmit(&huart1,temp,1,0xffff);return ch;
}

main.c

extern uint8_t buf;int main(void)
{/* USER CODE BEGIN 1 *//* USER CODE END 1 *//* MCU Configuration--------------------------------------------------------*//* Reset of all peripherals, Initializes the Flash interface and the Systick. */HAL_Init();/* USER CODE BEGIN Init *//* USER CODE END Init *//* Configure the system clock */SystemClock_Config();/* USER CODE BEGIN SysInit *//* USER CODE END SysInit *//* Initialize all configured peripherals */MX_GPIO_Init();MX_USART1_UART_Init();/* USER CODE BEGIN 2 */HAL_UART_Receive_IT(&huart1, &buf, 1);//开启串口接收HAL_NVIC_SetPriority(SysTick_IRQn,0,0);//提高滴答定时器优先级/* USER CODE END 2 *//* Infinite loop *//* USER CODE BEGIN WHILE */while (1){/* USER CODE END WHILE */Stop();/* USER CODE BEGIN 3 */}/* USER CODE END 3 */
}

提高滴答定时器优先级,这样的话在串口中断中使用HAL_Delay()不会出现卡死的bug

为什么使用的是HAL_Delay()要设置滴答定时器的中断优先级呢?

从英文解释中(别说看不懂哈),Systick被配置为系统时基,并且被配置为了1ms,做技术,要有刨根问底的精神,奥利给,继续跟进去看看

 

 

 关于滴答定时器可以看这篇文章,us级延时怎么实现

(77条消息) HAL库与Cubemx系列|Systick-系统滴答定时器详解_hal库 systick 中断_小飞哥玩嵌入式的博客-CSDN博客https://blog.csdn.net/qq_16519885/article/details/117756815?ops_request_misc=&request_id=&biz_id=102&utm_term=HAL_Delay%E6%98%AF%E6%BB%B4%E7%AD%94%E5%AE%9A%E6%97%B6%E5%99%A8%E5%90%97&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-2-117756815.142%5Ev83%5Epc_search_v2,239%5Ev2%5Einsert_chatgpt&spm=1018.2226.3001.4187

//使用TIM2来做us级延时函数
void TIM2_Delay_us(uint16_t n_us)
{
/* 使能定时器2计数 */__HAL_TIM_ENABLE(&htim2);__HAL_TIM_SetCounter(&htim2, 0);while(__HAL_TIM_GetCounter(&htim2) < ((1 * n_us)-1) );/* 关闭定时器2计数 */__HAL_TIM_DISABLE(&htim2);
}

4.小车PWM调速, 

通过实验我们又发现了bug,如果是全速驱动的话,小车转弯,比如左转就会左边轮子不动右边动,理论上是这样的,但是实际上会出现小车转弯一卡一卡的bug,于是我想到了用PWM调速,转弯的时候左右轮分开调速,左转就左轮速度低于右轮,右转就右轮速度低于左轮

STM32与51单片机不同,STM32具有硬件PWM调速

根据查数据手册可知,我使用的是TIM2的CH1和CH2,CH1,CH2分别对应左右轮

更改后连线为

B-1A -- PA0
B-1B -- PB1
A-1A -- PA1
A-1B -- PB10

  

具体PWM可以参考之前写的PWM实现呼吸灯文章

(77条消息) [STM32F103C8T6]PWM呼吸灯_stm32f103c8t6呼吸灯_TX564的博客-CSDN博客https://blog.csdn.net/weixin_63303786/article/details/129047166?spm=1001.2014.3001.5502

 根据前面L9110s模块的运用可知,A-1A,A-1B,B-1A,B-2B是分别为一高一低电平才能驱动

当PWM调速时,PWM使用的TIM2对应端口PA0,PA1会出现占空比,占空比内为高电平,那么其他两个IO口就必须为低电平,才能驱动L9110s,所以PWM调速,必须将对应电机驱动的所有的IO口都拉低

 

 PWM主要用的两个函数 一个是PWM启动函数,一个是PWM比较函数

HAL_TIM_PWM_Start ( & htim2 , TIM_CHANNEL_1 );
HAL_TIM_PWM_Start ( & htim2 , TIM_CHANNEL_2 );
__HAL_TIM_SetCompare ( & htim2 , TIM_CHANNEL_1 , 8 );//8是PWM_Val的值,小于8都是高电平,大于8是低电平,这个数的值要小于设定的 CCRx
void main()
{HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_1);HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_2);while(1){__HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_1,8);__HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_2,15);HAL_Delay(1000);__HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_1,15);__HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_2,8);HAL_Delay(1000);}
}

解决过弯一卡一卡的bug就可以将

         __HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_1,8);
        __HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_2,15);

替换motor.c中的GPIO_PIN_WritePin函数

5.小车循迹功能

小车循迹主要用到的模块是循迹模块

  

小车循迹主要是通过循迹模块,黑色会续收红外线,当红外线被吸收,就没法返回,于是模块输出高电平,灯灭,如果是白色区域,红外线会返回,灯亮,输出低电平

本次接线是将两个循迹模块的DO接入PB5,PB6

于是循迹的逻辑就是,左右两边各安一个循迹模块,当两个模块都返回红外线输出低电平灯亮的时候,小车向前进,如果左边模块没有返回红外线高电平灯灭,右边模块返回红外线低电平灯亮,那么就说明遇到左转弯道,左转,相反就右转----->哪边高电平往哪边转

#define LeftWheel_Value HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_3)
#define RightWheel_Value HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_4)void xunji(void)
{if(LeftWheel_Value == GPIO_PIN_RESET && RightWheel_Value == GPIO_PIN_RESET){__HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_1,19);__HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_2,19);}
if(LeftWheel_Value == GPIO_PIN_SET && RightWheel_Value == GPIO_PIN_RESET){__HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_1,15);__HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_2,8);}
if(LeftWheel_Value == GPIO_PIN_RESET && RightWheel_Value == GPIO_PIN_SET){__HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_1,8);__HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_2,15);}
if(LeftWheel_Value == GPIO_PIN_SET && RightWheel_Value == GPIO_PIN_SET){__HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_1,0);__HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_2,0);}
}// main函数里
while (1)
{xunji();
}

6.跟随功能

跟随功能的实现主要是跟随模块

 

 哪边低电平,往哪边转(因为跟随模块是有物体挡着才会返回红外线,返回为低电平)

#define LeftWheel_Value HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_5)
#define RightWheel_Value HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_6)void gensui(void)
{if(LeftWheel_Value == GPIO_PIN_RESET && RightWheel_Value == GPIO_PIN_RESET)goForward();if(LeftWheel_Value == GPIO_PIN_SET && RightWheel_Value == GPIO_PIN_RESET)goRight();if(LeftWheel_Value == GPIO_PIN_RESET && RightWheel_Value == GPIO_PIN_SET)goLeft();if(LeftWheel_Value == GPIO_PIN_SET && RightWheel_Value == GPIO_PIN_SET)stop();}// main函数里
while (1)
{gensui();
}

7.避障功能

避障功能主要是依靠SG90舵机和超声波实现的,当超声波测距小于一个值,比如35cm,SG90舵机开始转动角度,实现超声波摇头,摇头:显示中间位,然后左转,然后右转

超声波测距流程

1.Trig至少10us的高电平

2.发送波,定时器启动,开始计时

启动定时器的函数:HAL_TIM_Base_Start(&htim2);//启动定时器2

开始计算时间函数:__HAL_TIM_SetCounter(&htim2,0);//计算时间

2.1怎么判断是否发送波了呢?:当波发送出去echo会由低电平变为高电平 while(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_7) == GPIO_PIN_RESET);//卡低电平

3.接收到波,定时器关闭停止计时

停止定时器的函数:HAL_TIM_Base_Stop(&htim2);//停止定时器

3.1怎么判断接收到波了呢?:当接收到波echo会由高电平变为低电平

while(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_7) == GPIO_PIN_SET);//卡高电平

4.读取定时器计时时间

获取时间的函数:cnt = __HAL_TIM_GetCounter(&htim2);

5.distance = (340m/s * 时间)/2(注意换算单位 100cm/1000000us) 

 CSB.c


//使用TIM2来做us级延时函数
void TIM2_Delay_us(uint16_t n_us)
{
/* 使能定时器2计数 */__HAL_TIM_ENABLE(&htim2);__HAL_TIM_SetCounter(&htim2, 0);while(__HAL_TIM_GetCounter(&htim2) < ((1 * n_us)-1) );/* 关闭定时器2计数 */__HAL_TIM_DISABLE(&htim2);
}
double get_distance(void)
{int cnt=0;
//1. Trig ,给Trig端口至少10us的高电平HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET);//拉高TIM2_Delay_us(20);HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET);//拉低
//2. echo由低电平跳转到高电平,表示开始发送波
//波发出去的那一下,开始启动定时器while(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8) == GPIO_PIN_RESET);//等待输入电平拉高HAL_TIM_Base_Start(&htim2);//启动定时器2__HAL_TIM_SetCounter(&htim2,0);//计算时间
//3. 由高电平跳转回低电平,表示波回来了while(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8) == GPIO_PIN_SET);//等待输入电平变低
//波回来的那一下,我们开始停止定时器HAL_TIM_Base_Stop(&htim2);//停止定时器
//4. 计算出中间经过多少时间cnt = __HAL_TIM_GetCounter(&htim2);//获取时间
//5. 距离 = 速度 (340m/s)* 时间/2(计数1次表示1us)return (cnt*340/2*0.000001*100); //单位:cm
}

SG90.c

void initSG90(void)
{HAL_TIM_PWM_Start(&htim4,TIM_CHANNEL_4); //启动定时器4,启动PWM__HAL_TIM_SetCompare(&htim4, TIM_CHANNEL_4, 9); //将舵机置为90度
}
void sgMiddle(void)
{__HAL_TIM_SetCompare(&htim4, TIM_CHANNEL_4, 9); //将舵机置为75度
}
void sgRight(void)
{__HAL_TIM_SetCompare(&htim4, TIM_CHANNEL_4, 5); //将舵机置为0度
}
void sgLeft(void)
{__HAL_TIM_SetCompare(&htim4, TIM_CHANNEL_4, 14); //将舵机置为135度
}

main.c

#define MIDDLE 0
#define RIGHT 2
#define LEFT  1int main(void)
{/* USER CODE BEGIN 1 */char dir;double disMiddle;double disLeft;double disRight;/* USER CODE END 1 *//* MCU Configuration--------------------------------------------------------*//* Reset of all peripherals, Initializes the Flash interface and the Systick. */HAL_Init();/* USER CODE BEGIN Init *//* USER CODE END Init *//* Configure the system clock */SystemClock_Config();/* USER CODE BEGIN SysInit *//* USER CODE END SysInit *//* Initialize all configured peripherals */MX_GPIO_Init();MX_TIM4_Init();MX_TIM2_Init();/* USER CODE BEGIN 2 */initSG90();//一开始先让超声波在中间位HAL_Delay(1000);/* USER CODE END 2 */void csb(void){/*为了不歪头卡死,每次必须测完回到中间位*/if(dir != MIDDLE){sgMiddle();dir = MIDDLE;HAL_Delay(300);}/*为了不歪头卡死,每次必须测完回到中间位*/disMiddle = get_distance();if(disMiddle > 35){//前进GoForward();}else if(disMiddle < 10){GoBack();}else{//停止Stop();//测左边距离sgLeft();HAL_Delay(300);disLeft = get_distance();sgMiddle();HAL_Delay(300);sgRight();dir = RIGHT;HAL_Delay(300);disRight = get_distance();if(disLeft < disRight){GoRight();HAL_Delay(150);Stop();}if(disRight < disLeft){GoLeft();HAL_Delay(150);Stop();}}}/* Infinite loop *//* USER CODE BEGIN WHILE */while (1){/* USER CODE END WHILE */csb();HAL_Delay(50);//必须要延时,不然执行代码速度太快就会一直前进或者后退,不会摇头/* USER CODE BEGIN 3 */}/* USER CODE END 3 */
}

将所有模块的函数封装好后,可以通过按键或者其他方式切换循迹,跟随,避障模式

#define Key_On 0
#define Key_Off 1unsigned char Scanf_Key(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
{unsigned int status;status = HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);if(status == GPIO_PIN_RESET)return 0;else if(status == GPIO_PIN_SET)return 1;
}void main()
{while(1){if(Scanf_Key(GPIOA,GPIO_PIN_0) == Key_On){csb();}if(Scanf_Key(GPIOA,GPIO_PIN_1) == Key_On){gensui();}if(Scanf_Key(GPIOA,GPIO_PIN_3) == Key_On){xunji();}}
}

测速功能

测速功能主要是用测速模块配合码盘实现

 

配置cubeMX

使用定时器计时1s,获取码盘每1s转了多少圈,通过计算可获得速度

 定时器公式:

T = {(PSC+1)*(Counter Period + 1)}/72000000HZ

轮子走一圈,经过一个周长, C = 2x3.14x 半径 = 3.14 x 直径( 6.5cm
对应的码盘也转了一圈,码盘有 20 个格子,每经过一个格子,会遮挡(高电平)和不遮挡(低电平),
那么一个脉冲就是走了 3.14 * 6.5 cm /20 = 1.0205CM
定时器可以设计成一秒,统计脉冲数,一个脉冲就是 1cm
假设一秒有 80 脉冲,那么就是 80cm/s

 开启定时器中断和外部中断

 代码实现

先找到定时器中断服务函数,外部中断服务函数,再重写回调函数


void HAL_GPIO_EXIT_Callback(uint_t GPIO_pin)
{if(GPIO_pin == GPIO_PIN_14)//判断是不是PB14产生的中断if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_14) == GPIO_PIN_RESET)//判断PB14是否为低电平,从而判断是否产生下降沿SpeedCnt++;// dis = SpeedCnt * time 定时器1s产生中断所以dis = SpeedCnt
}void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{printf("speed:%d\r\n",SpeedCnt);//重定向printf,打印到串口SpeedCnt = 0;
}int main(void)
{HAL_Init();HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000); //1msSystemClock_Config();MX_GPIO_Init();MX_USART1_UART_Init();MX_TIM2_Init();HAL_UART_Receive_IT(&huart1, &buf, 1);//开启串口接收中断HAL_TIM_Base_Start_IT(&htim2);//开启定时器中断while (1){}
}

通过oled显示实时的车速

oled.c

#include "oled.h"
#include "i2c.h"
#include "oledfont.h"void Oled_Write_Cmd(uint8_t dataCmd)
{HAL_I2C_Mem_Write(&hi2c1, 0x78, 0x00, I2C_MEMADD_SIZE_8BIT,&dataCmd, 1, 0xff);
}
void Oled_Write_Data(uint8_t dataData)
{HAL_I2C_Mem_Write(&hi2c1, 0x78, 0x40, I2C_MEMADD_SIZE_8BIT,&dataData, 1, 0xff);
}
void Oled_Init(void)
{Oled_Write_Cmd(0xAE);//--display offOled_Write_Cmd(0x00);//---set low column addressOled_Write_Cmd(0x10);//---set high column addressOled_Write_Cmd(0x40);//--set start line addressOled_Write_Cmd(0xB0);//--set page addressOled_Write_Cmd(0x81); // contract controlOled_Write_Cmd(0xFF);//--128Oled_Write_Cmd(0xA1);//set segment remapOled_Write_Cmd(0xA6);//--normal / reverseOled_Write_Cmd(0xA8);//--set multiplex ratio(1 to 64)Oled_Write_Cmd(0x3F);//--1/32 dutyOled_Write_Cmd(0xC8);//Com scan directionOled_Write_Cmd(0xD3);//-set display offsetOled_Write_Cmd(0x00);//Oled_Write_Cmd(0xD5);//set osc divisionOled_Write_Cmd(0x80);//Oled_Write_Cmd(0xD8);//set area color mode offOled_Write_Cmd(0x05);//Oled_Write_Cmd(0xD9);//Set Pre-Charge PeriodOled_Write_Cmd(0xF1);//Oled_Write_Cmd(0xDA);//set com pin configuartionOled_Write_Cmd(0x12);//Oled_Write_Cmd(0xDB);//set VcomhOled_Write_Cmd(0x30);//Oled_Write_Cmd(0x8D);//set charge pump enableOled_Write_Cmd(0x14);//Oled_Write_Cmd(0xAF);//--turn on oled panel
}
void Oled_Screen_Clear(void)
{int i,n;Oled_Write_Cmd (0x20); //set memory addressing modeOled_Write_Cmd (0x02); //page addressing modefor(i=0;i<8;i++){Oled_Write_Cmd(0xb0+i); //PAGE0 - PAGE7Oled_Write_Cmd(0x00); //每个page从第0列开始Oled_Write_Cmd(0x10); //每个page从第0列开始for(n=0;n<128;n++)Oled_Write_Data(0x00);//每个page的127列全写0}
}/*移植源代码*//显示单个字符/
void Oled_Show_Char(char row,char col,char oledChar){ //row*2-2unsigned int  i;Oled_Write_Cmd(0xb0+(row*2-2));                           //page 0Oled_Write_Cmd(0x00+(col&0x0f));                          //lowOled_Write_Cmd(0x10+(col>>4));                            //high	for(i=((oledChar-32)*16);i<((oledChar-32)*16+8);i++){Oled_Write_Data(F8X16[i]);                            //写数据oledTable1}Oled_Write_Cmd(0xb0+(row*2-1));                           //page 1Oled_Write_Cmd(0x00+(col&0x0f));                          //lowOled_Write_Cmd(0x10+(col>>4));                            //highfor(i=((oledChar-32)*16+8);i<((oledChar-32)*16+8+8);i++){Oled_Write_Data(F8X16[i]);                            //写数据oledTable1}		
}/显示字符串/
void Oled_Show_Str(char row,char col,char *str){while(*str!=0){Oled_Show_Char(row,col,*str);str++;col += 8;	}		
}

oledfont.h

const unsigned char F8X16[]=	  
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 00x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 10x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 20x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 30x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 40xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 50x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 60x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 70x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 80x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 90x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 100x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 110x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 120x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 130x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 140x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 150x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 160x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 170x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 180x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 190x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 200x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 210x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 220x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 230x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 240x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 250x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 260x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 270x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 280x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 290x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 300x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 310xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 320x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 330x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 340xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 350x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 360x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 370x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 380xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 390x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 400x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 410x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 420x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 430x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 440x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 450x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 460xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 470x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 480xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 490x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 500x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 510x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 520x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 530x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 540xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 550x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 560x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 570x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 580x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 590x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\ 600x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 610x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 620x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 630x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 640x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 650x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 660x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 670x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 680x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 690x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 700x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 710x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 720x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 730x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 740x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 750x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 760x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 770x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 780x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 790x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 800x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 810x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 820x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 830x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 840x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 850x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 860x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 870x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 880x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 890x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 900x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 910x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 920x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 930x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94
};
#include "oled.h"
#include "main.h"
#include "i2c.h"
#include "tim.h"
#include "gpio.h"char speedMES[24];void HAL_GPIO_EXIT_Callback(uint_t GPIO_pin)
{if(GPIO_pin == GPIO_PIN_14)//判断是不是PB14产生的中断if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_14) == GPIO_PIN_RESET)//判断PB14是否为低电平,从而判断是否产生下降沿SpeedCnt++;// dis = SpeedCnt * time 定时器1s产生中断所以dis = SpeedCnt
}void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{sprintf(speedMES,"speed:%dcm/s",SpeedCnt);//将数据以speed:xx的形式传给speedMES数组Oled_Show_Str(2,2,speedMES);printf("speed:%d\r\n",SpeedCnt);//重定向printf,打印到串口SpeedCnt = 0;
}int main(void)
{HAL_Init();HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000); //1msSystemClock_Config();MX_GPIO_Init();MX_USART1_UART_Init();MX_TIM2_Init();HAL_UART_Receive_IT(&huart1, &buf, 1);//开启串口接收中断HAL_TIM_Base_Start_IT(&htim2);//开启定时器中断Oled_Init();Oled_Screen_Clear();//实时显示其实就是不断刷屏显示新的数据while (1){}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/71025.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

国外调查项目的一个新难点及解决方案

国外调查项目&#xff0c;基本的东西就那么多&#xff0c;早就说完了&#xff0c;余下的都是积累的经验之类&#xff0c;毕竟&#xff0c;任何项目&#xff0c;也不可能光靠看就能完全掌握的&#xff0c;纸上得来终觉浅&#xff0c;绝知此事要躬行嘛 很多朋友反映现在调查比以前…

阿里云原生开源大家族加入中科院软件所开源软件供应链点亮计 - 暑期 2021

来源 | 阿里巴巴云原生公众号 2021 年&#xff0c;由中国开源软件推进联盟 COPU 牵头发布了《2021 中国开源发展蓝皮书》&#xff0c;涵盖当今全球开源的总体情况分析、开发者分析、项目分析、领域案例&#xff0c;绘制了一副"开源数字生态地图"。让我们全面地看到了…

开源开放|CCKS2021入选开放图谱资源简介

笔记整理 | 王萌&#xff08;东南大学&#xff09;、张宁豫&#xff08;浙江大学&#xff09; 全国知识图谱与语义计算大会&#xff08;CCKS&#xff09;由中国中文信息学会语言与知识计算专委会定期举办的国内知识图谱、语义技术等领域的核心会议。知识图谱以结构化的形式描述…

CSDN上传图片

一般情况下&#xff0c;直接复制粘贴就可以直接在文章中显示&#xff0c;但有时会有不成功的情况&#xff0c;如图所示 &#xff0c;这个就是我复制粘贴的效果。 我想选择通过CSDN的博客上面的上传按钮来上传 但出现的效果是 上传卡在那了&#xff0c;那怎么办&#xff1f; 我…

Typora自动图片上传|CSDN上传5MB以上图片小技巧

效果 提示: Typora 1.0版本后收费 , 可找历史版本下载 . 配合Snipaste截图工具 , 粘贴到 Typora实现自动上传到 七牛云对象存储地址. 不占用本地空间, 且只要联网就可以随处使用,不担心因图片地址不对应,无法查看图片. 配置文件 创建一个txt文件,存入,修改填入对应信息.保存…

CSDN上传图片提示上传失败

遇到写博客发现了本地代码截图无法上传&#xff0c;并且一直提示上传失败。 1.打开目录C:\Windows\System32\drivers\etc下的hosts文件使用记事本打开 2.在记事本中加入&#xff1a; 49.7.22.7 csdn-img-blog.oss-cn-beijing.aliyuncs.com 保存文本&#xff0c;如果出现无…

关于微信小程序上传多张图片的问题

直接帖代码 wxml <view style"background-color: #ffffff;padding: 30rpx;margin: 25rpx;border-radius: 40rpx;"><view style"display: flex;flex-direction: column;margin-left:30rpx"><view style"display: flex;margin-top: 40…

CSDN写文章上传图片失败原因

问题&#xff1a;PC登录CSDN写作上传图片时&#xff0c;图片格式&#xff0c;大小都符合规范&#xff0c;但上传时一直提示“上传失败&#xff0c;使用谷歌浏览器、IE浏览器、火狐浏览器等问题依旧存在&#xff0c;如下图所示 原因&#xff1a;电脑连接的网络是手机联通的网络&…

[微信小程序] 单张、多张图片上传(图片转base64格式)实践经验

本文首发自个人自有博客&#xff1a;【FaxMiao个人博客】&#xff0c;一个关注Web前端开发技术、关注用户体验、记录前端点滴&#xff0c;坚持更多原创&#xff0c;为大家提供高质量技术博文&#xff01; 定义初始数据&#xff1a; data: {imgList: [], // 图片集合baseImg: […

解决CSDN上传图片失败的问题

最近写博客的时候发现本地图片上传不了的问题&#xff0c;图片大小也没有超过5m&#xff0c;就是上传失败呢 于是找了客服小哥哥or小姐姐已成功解决 1、以记事本的方式打开 C:\Windows\System32\drivers\etc 目录下的 hosts文件 2、添加 49.7.22.7 csdn-img-blog.oss-cn-b…

csdn上传图片过程

CSDN上传图片流程 首先在工具栏里点击富文本编辑器 然后点击图像按钮 然后会出现选择图片的按钮&#xff0c;点击按钮选择你要上传的图片&#xff0c;或者直接将图片复制到标题下方 最后用CV大法&#xff0c;将图片复制到你的文本中&#xff0c;这样基本就可以了 如果出现…

马斯克回应多年前嘲笑比亚迪;360 周鸿祎训练数字人代替演讲;微软发布自己的 Linux | 极客头条...

「极客头条」—— 技术人员的新闻圈&#xff01; CSDN 的读者朋友们早上好哇&#xff0c;「极客头条」来啦&#xff0c;快来看今天都有哪些值得我们技术人关注的重要新闻吧。 整理 | 苏宓 出品 | CSDN&#xff08;ID&#xff1a;CSDNnews&#xff09; 一分钟速览新闻点&#xf…

chatgpt赋能python:Python验证码校验程序介绍

Python 验证码校验程序介绍 随着网络的发展和普及&#xff0c;大量的网站需要使用验证码来防止机器人攻击。验证码技术在保证网络安全方面起到了关键作用。Python 作为一种高级编程语言&#xff0c;在验证码校验程序中也得到了广泛的应用。 Python 的验证码校验程序是一种基于…

【1】VScode 中文界面方法-------超简单教程

相关文章&#xff1a; 【一】tensorflow安装、常用python镜像源、tensorflow 深度学习强化学习教学 【二】tensorflow调试报错、tensorflow 深度学习强化学习教学【三】tensorboard安装、使用教学以及遇到的问题【四】超级快速pytorch安装 【1】VScode中文界面方法-------…

chatgpt赋能python:Python读取GBK编码文本文件的方法

Python读取GBK编码文本文件的方法 在中文环境中&#xff0c;GBK编码是一种常见的字符集&#xff0c;因此&#xff0c;在使用Python处理中文文本时&#xff0c;我们经常需要读取GBK编码的文本文件。本文将介绍Python读取GBK编码文本文件的方法&#xff0c;以帮助Python开发者更…

电子科技大学格拉斯哥学院基础实践————寝室情况及存在问题

** 电子科技大学格拉斯哥学院基础实践————寝室情况及存在问题 ** 调查报告小组人数&#xff1a;5人 小组成员&#xff1a; 刘浩宇 2018190607034 李子贤 2018190607014 夏侯淏 2018190607022 刘思言 2018190607026 梁渝佩 2018190607032 所在学院&#xff1a;格拉斯哥学院…

电子科技大学 格院实践 大学生上网娱乐时间

调查报告小组&#xff1a;4人小组成员&#xff1a;王伯文2018190607021包经纬2018190607011袁晨 2018190607001 孙一飞 2018190607023所在学院&#xff1a;格拉斯哥学院年级及专业&#xff1a;2018级 通信七班摘要&#xff1a;网络已成为现代生活中必不可少的一部分&#xff0…

有python专业的世界大学_2020年QS计算机专业排名进入世界前50的,除了G5,还有这所大学!...

上周&#xff0c;QS最新的世界大学专业排名出炉&#xff0c;计算机科学与信息系统方向&#xff0c;英国共有50所大学上榜&#xff0c;其中排名世界前50的有5所&#xff0c;分别是牛津大学、剑桥大学、帝国理工学院、UCL、爱丁堡大学。 完整榜单如下&#xff1a; 爱丁堡大学作为…

2020ubc大学计算机硕士录取条件,2020Fall录取|研究牛校UA阿尔伯塔大学计算机硕士两年全奖!...

2020Fall正在进行时&#xff0c; 君明offer收不停~ 恭喜君明学子T同学收到 阿尔伯塔大学 计算机硕士项目offer两年全额奖学金 祝贺祝贺&#xff01; OFFER -展示- 学校概况 阿尔伯塔大学(University of Alberta)简称UA&#xff0c;坐落于加拿大阿尔伯塔省, 是一所历史悠久的世界…