当前位置:网站首页>Anonymous upper computer V7 waveform display
Anonymous upper computer V7 waveform display
2022-07-23 12:35:00 【Alone, sir】
Set the corresponding... According to the anonymous upper computer's flexible format frame Frame head

Because the format is relatively simple, the original code is directly pasted for reference ( General debugging pid Both are data comparison and debugging , So I only wrote two functions to send comparison , One int16 And a int32, It's enough )
Be careful : Due to the large sending volume, it is best to configure the serial port dma, The procedure here is stm32 Upper
#ifndef ANO_TC_H
#define ANO_TC_H
#include "main.h"
#define BYTE0(dwTemp) (*(char *)(&dwTemp))
#define BYTE1(dwTemp) (*((char *)(&dwTemp) +1))
#define BYTE2(dwTemp) (*((char *)(&dwTemp) +2))
#define BYTE3(dwTemp) (*((char *)(&dwTemp) +3))
void AnoTc_Send2Int32(int32_t _a,int32_t _b);
void AnoTc_Send2Int16(int16_t _a,int16_t _b);
void AnoTc_SendF1_Test(void);
#endif#include "ano_tc.h"
#include <stdio.h>
#include <math.h>
/* communication Interface */
#include "usart.h"
void Ano_Tc_Send_Dma(uint8_t *buf,uint8_t len)
{
while(huart1.gState!=HAL_UART_STATE_READY);
if(HAL_UART_Transmit_DMA(&huart1, buf,len)!= HAL_OK) // Judge whether the transmission is normal , If an exception occurs, enter the exception interrupt function
{
Error_Handler();
}
}
/* communication Interface end */
void AnoTc_Send2Int16(int16_t _a,int16_t _b)// Send two int16 The data of
{
static uint8_t DataToSend[10]={0XAA,0XFF,0XF1,4};//4 byte
uint8_t sc=0;
uint8_t ac=0;
uint8_t i=0;
DataToSend[4]=BYTE0(_a);
DataToSend[5]=BYTE1(_a);
DataToSend[6]=BYTE0(_b);
DataToSend[7]=BYTE1(_b);
for( i=0;i<DataToSend[3]+4;i++)
{
sc+=DataToSend[i];
ac+=sc;
}
DataToSend[8]=sc;
DataToSend[9]=ac;
Ano_Tc_Send_Dma(DataToSend,10);
}
void AnoTc_Send2Int32(int32_t _a,int32_t _b)// Send two int32 The data of
{
static uint8_t DataToSend[14]={0XAA,0XFF,0XF1,8};// Communication protocol decision 8byte
uint8_t sc=0;
uint8_t ac=0;
uint8_t i=0;
DataToSend[4]=BYTE0(_a);
DataToSend[5]=BYTE1(_a);
DataToSend[6]=BYTE2(_a);
DataToSend[7]=BYTE3(_a);
DataToSend[8]=BYTE0(_b);
DataToSend[9]=BYTE1(_b);
DataToSend[10]=BYTE2(_b);
DataToSend[11]=BYTE3(_b);
for( i=0;i<DataToSend[3]+4;i++)
{
sc+=DataToSend[i];
ac+=sc;
}
DataToSend[12]=sc;
DataToSend[13]=ac;
Ano_Tc_Send_Dma(DataToSend,14);
}
void AnoTc_SendF1_Test(void)
{
static double i;
int sum1,sum2;
i+=0.01;
if(i==6.28) i=0;
sum1=(int16_t)(1000*sin(i));
sum2=(int16_t)(1000*cos(i));
// AnoTc_Send2Int16(sum2,sum1);
AnoTc_Send2Int32(sum2,sum1);
}

1、 Execute... In a program void AnoTc_SendF1_Test(void)
2、 Set on the anonymous upper computer

data 1 And data 2 Set to int32 Of
3、 Waveform display

边栏推荐
- Interpretation of the paper: recognition of enhancer promoter interactions with neural networks based on pre trained DNA vectors and attention mechanisms
- 【基于UDS服务的BootLoader架构和刷写流程】
- Upper and lower case letter conversion
- 利用or-tools来求解路径规划问题(VRP)
- 硬件知识1--原理图和接口类型(基于百问网硬件操作大全视频教程)
- Using or tools to solve path planning problem (VRP)
- 【学习总结】
- Connaissance du matériel 1 - schéma et type d'interface (basé sur le tutoriel vidéo complet de l'exploitation du matériel de baiman)
- 【Autosar CP通用 1.如何阅读Autosar官方文档】
- (1)ASIO
猜你喜欢

单片机学习笔记9--常见的通信方式(基于百问网STM32F103系列教程)

ARM架构与编程3--按键控制LED(基于百问网ARM架构与编程教程视频)

ARM架构与编程5--gcc与Makefile(基于百问网ARM架构与编程教程视频)

Using pycaret for data mining: association rule mining

Introduction and practice of Google or tools for linear programming

ARM架构与编程7--异常与中断(基于百问网ARM架构与编程教程视频)

Review of basic principles of steel structure

【AUTOSAR COM 3.信号的收发流程TX/RX】

单片机学习笔记4--GPIO(基于百问网STM32F103系列教程)

博客搭建四:将自己的博客加入百度和谷歌收录的方法
随机推荐
高电压技术复习资料
单片机学习笔记4--GPIO(基于百问网STM32F103系列教程)
Blog building I: Framework selection
Object class
Summary of problems encountered during app audit
博客搭建四:将自己的博客加入百度和谷歌收录的方法
【存储器了解 RAM flash和eeprom存储器的区别和作用】
博客搭建五:图床选择
钢结构复习题
How to establish data analysis thinking
博客搭建六:绑定自己域名的方法
Interpretation of the paper: DNA enhancer sequence recognition transformer structure based on Bert and two-dimensional convolutional neural network
Baidu Shen Shuo: focus on the scene, deeply cultivate the industry, and bring practical results to enterprise Digitalization
Talent column | can't use Apache dolphin scheduler? The most complete introductory tutorial written by the boss in a month
【AUTOSAR CanDrive 1.学习CanDrive的功能和结构】
Using or tools to solve the path planning problem (TSP)
钢结构基本原理题库
Object based - two classic classes
Data analysis of time series (III): decomposition of classical time series
钢结构基本原理复习