当前位置:网站首页>匿名上位机v7波形显示
匿名上位机v7波形显示
2022-07-23 05:43:00 【一个人先生咯】
根据匿名上位机灵活格式帧设置对应的 帧头

由于格式较为简单直接贴上原码供参考(一般调试pid都是两个数据对比调试,所以我只写了两个发送对比的函数,一个int16和一个int32,已经完全够用了)
注意:由于发送量较大最好配置串口dma,这里的程序是stm32上的
#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) //判断是否发送正常,如果出现异常则进入异常中断函数
{
Error_Handler();
}
}
/* communication Interface end */
void AnoTc_Send2Int16(int16_t _a,int16_t _b)//发送两个 int16 的数据
{
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)//发送两个 int32 的数据
{
static uint8_t DataToSend[14]={0XAA,0XFF,0XF1,8};//通信协议决定 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、在程序中执行 void AnoTc_SendF1_Test(void)
2、在匿名上位机设置

数据1和数据2设置成int32的
3、波形显示

边栏推荐
- Uni native plug-in development -- Youmeng one click login
- 【分清楚常量指针与指针常量 Const int *与Int * Const的含义与用法】
- 论文解读:《开发一种基于多层深度学习的预测模型来鉴定DNA N4-甲基胞嘧啶修饰》
- Interpretation of the paper: DNA enhancer sequence recognition transformer structure based on Bert and two-dimensional convolutional neural network
- K-nucleotide frequencies (KNF) or k-mer frequencies
- With statement
- 绿色数据中心:风冷GPU服务器和水冷GPU服务器综合分析
- NVIDIA NVIDIA released H100 GPU, and the water-cooled server is adapted on the road
- 高等代数100道题及答案解析
- UE4 solves the problem that the WebBrowser cannot play H.264
猜你喜欢

2021 TOP10 development trend of information science. Deep learning? Convolutional neural network?
![[talent column] can't you use Apache dolphin scheduler? It takes a month to write the most comprehensive introductory teaching [2]](/img/34/abc6ef91d0b735f713f76da5a4b537.png)
[talent column] can't you use Apache dolphin scheduler? It takes a month to write the most comprehensive introductory teaching [2]

深度学习-神经网络

ARM架构与编程1--LED闪烁(基于百问网ARM架构与编程教程视频)

利用or-tools来求解带容量限制的路径规划问题(CVRP)

永磁电机参数的测量获取(电感、电阻、极对数、磁链常数)

NLP natural language processing - Introduction to machine learning and natural language processing (I)

高电压技术重点知识整理

论文解读:《提高N7-甲基鸟苷(m7G)位点预测性能的迭代特征表示方法》

利用google or-tools 求解逻辑难题:斑马问题
随机推荐
2021可信隐私计算高峰论坛暨数据安全产业峰会上百家争鸣
论文解读:《开发一种基于多层深度学习的预测模型来鉴定DNA N4-甲基胞嘧啶修饰》
利用pycaret:低代码,自动化机器学习框架解决分类问题
钢结构基本原理试题及答案
NLP natural language processing - Introduction to machine learning and natural language processing (2)
利用or-tools来求解带容量限制的路径规划问题(CVRP)
高分子物理考研概念及要点、考点总结
线性规划之Google OR-Tools 简介与实战
Uni native plug-in development -- Youmeng one click login
Smart pointer shared_ PTR and unique_ ptr
Interpretation of the paper: DNA enhancer sequence recognition transformer structure based on Bert and two-dimensional convolutional neural network
Using pycaret for data mining: association rule mining
高等代数知识结构
Hardware knowledge 1 -- Schematic diagram and interface type (based on Baiwen hardware operation Daquan video tutorial)
数据分析的重要性
ARM架构与编程4--串口(基于百问网ARM架构与编程教程视频)
C语言中,对柔性数组的理解
CPC client installation tutorial
Interpretation of the paper: attention based multi label neural network for comprehensive prediction and interpretation of 12 widely existing RNA modifications
3D image classification of lung CT scan using propeller