当前位置:网站首页>匿名上位机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、波形显示

边栏推荐
- 单片机学习笔记8--按键和外部中断(基于百问网STM32F103系列教程)
- 利用pycaret:低代码,自动化机器学习框架解决分类问题
- Comment se développe le serveur GPU refroidi à l'eau dans le Centre de données dans le cadre de l'informatique est - Ouest?
- 单片机学习笔记4--GPIO(基于百问网STM32F103系列教程)
- ARM架构与编程4--串口(基于百问网ARM架构与编程教程视频)
- 钢结构基本原理题库
- 论文解读:《开发和验证深度学习系统对黄斑裂孔的病因进行分类并预测解剖结果》
- ARM架构与编程5--gcc与Makefile(基于百问网ARM架构与编程教程视频)
- Using pycaret: low code, automated machine learning framework to solve regression problems
- Summary of problems encountered during app audit
猜你喜欢

编码器的一点理解

Baidu Shen Shuo: focus on the scene, deeply cultivate the industry, and bring practical results to enterprise Digitalization

2021信息科学Top10发展态势。深度学习?卷积神经网络?

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

数据分析(二)

The online seminar on how to help data scientists improve data insight was held on June 8

NVIDIA 英伟达发布H100 GPU,水冷服务器适配在路上

Using pycaret for data mining: association rule mining

论文解读:《Deep-4mcw2v: 基于序列的预测器用于识别大肠桿菌中的 N4- 甲基胞嘧啶(4mC)位点》

硬件知識1--原理圖和接口類型(基於百問網硬件操作大全視頻教程)
随机推荐
ARM架构与编程1--LED闪烁(基于百问网ARM架构与编程教程视频)
NLP natural language processing - Introduction to machine learning and natural language processing (I)
Analyze the pre integration of vio with less rigorous but logical mathematical theory
How to develop the liquid cooled GPU server in the data center under the "east to West calculation"?
论文解读:《Deep-4mcw2v: 基于序列的预测器用于识别大肠桿菌中的 N4- 甲基胞嘧啶(4mC)位点》
2021可信隐私计算高峰论坛暨数据安全产业峰会上百家争鸣
Check the sandbox file in the real app
NVIDIA 英伟达发布H100 GPU,水冷服务器适配在路上
Interpretation of the paper: develop and verify the deep learning system to classify the etiology of macular hole and predict the anatomical results
Deep convolution generation countermeasure network
K-nucleotide frequencies (KNF) or k-mer frequencies
Summary of problems encountered during app audit
钢结构基本原理全面详细总结
In depth interpretation of Google or tools' complex scheduling program
把LVGL所有控件整合到一个工程中展示(LVGL6.0版本)
论文解读:《开发和验证深度学习系统对黄斑裂孔的病因进行分类并预测解剖结果》
高电压技术-名词解释题
Using pycaret: low code, automated machine learning framework to solve regression problems
Interpretation of the paper: iterative feature representation method to improve the prediction performance of N7 methylguanosine (m7G) sites
怎么建立数据分析思维