当前位置:网站首页>After CANopen starts PDO timing transmission, the heartbeat frame time is wrong, PDO is delayed, and CANopen time axis is disordered
After CANopen starts PDO timing transmission, the heartbeat frame time is wrong, PDO is delayed, and CANopen time axis is disordered
2022-04-23 18:22:00 【Things will turn when they reach the extreme 1024】
CANopen In the case of , A simple way to use a lot is to use a 1ms Timer interrupt , Then rewrite... With global variables sertimer and getElapsedTime function , Then add... To the interrupt service function timerForCan
//Set the next alarm //
void setTimer(TIMEVAL value)
{
NextTime=(TimeCNT+value)%TIMER_MAX_COUNT;
}
// Get the elapsed time since the last occured alarm //
TIMEVAL getElapsedTime(void)
{
int ret=0;
ret = TimeCNT> last_time_set ? TimeCNT - last_time_set : TimeCNT + TIMER_MAX_COUNT - last_time_set;
last_time_set = TimeCNT;
return ret;
}
But there is a fatal problem with this approach , The time calculated in this way , When there are only heartbeat frames, there is no problem , Join in PDO Regularly send , Will be chaos , for example 1s Heartbeat frame 300msPDO timing , The phenomenon is 1s Heartbeat frame retention , stay 1s After heartbeat frame 300ms There will be one more heartbeat frame , and PDO Timed transmission does not appear !!!!!!, In this case, it should be changed to last_time_set = TimeCNT; Put it in timerForCan Before !!!!
```c
//Set the next alarm //
void setTimer(TIMEVAL value)
{
NextTime=(TimeCNT+value)%TIMER_MAX_COUNT;
}
// Get the elapsed time since the last occured alarm //
TIMEVAL getElapsedTime(void)
{
int ret=0;
ret = TimeCNT> last_time_set ? TimeCNT - last_time_set : TimeCNT + TIMER_MAX_COUNT - last_time_set;
//last_time_set = TimeCNT; The culprit
return ret;
}
In addition, there will be a 1 Millisecond timer , Every time 1 Call the following function in milliseconds .
void timerForCan(void)
{
TimeCNT++;
if (TimeCNT>=TIMER_MAX_COUNT)
{
TimeCNT=0;
}
if (TimeCNT==NextTime)
{
TimeDispatch();
}
}
//1ms Interrupt service function
void TIM7_IRQHandler(void)
{
if(TIM7->SR&0X0001)// interrupt
{
}
TIM7->SR&=~(1<<0);// Clears the interrupt flag bit
last_time_set = TimeCNT;
timerForCan();
}
版权声明
本文为[Things will turn when they reach the extreme 1024]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210610057187.html
边栏推荐
- Linux installs MySQL in RPM (super simple)
- 14 py games source code share the second bullet
- Test questions of daily safety network (February 2024)
- 解决报错max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
- Mode of interprocess communication
- kettle庖丁解牛第17篇之文本文件输出
- Const keyword, variable and function are decorated with const
- CISSP certified daily knowledge points (April 18, 2022)
- Daily CISSP certification common mistakes (April 11, 2022)
- 【ACM】455. 分发饼干(1. 大饼干优先喂给大胃口;2. 遍历两个数组可以只用一个for循环(用下标索引--来遍历另一个数组))
猜你喜欢

【ACM】455. Distribute Biscuits (1. Give priority to big biscuits to big appetite; 2. Traverse two arrays with only one for loop (use subscript index -- to traverse another array))

Use of regular expressions in QT

Win1远程出现“这可能是由于credssp加密oracle修正”解决办法

Map basemap Library

From introduction to mastery of MATLAB (2)

硬核解析Promise对象(这七个必会的常用API和七个关键问题你都了解吗?)

Halo 开源项目学习(七):缓存机制

MATLAB小技巧(6)七种滤波方法比较

解决允许在postman中写入注释请求接口方法

Custom prompt box MessageBox in QT
随机推荐
串口调试工具cutecom和minicom
WiFi ap6212 driver transplantation and debugging analysis technical notes
Daily CISSP certification common mistakes (April 14, 2022)
idea中安装YapiUpload 插件将api接口上传到yapi文档上
QT excel operation summary
Deep learning classic network analysis and target detection (I): r-cnn
Daily network security certification test questions (April 15, 2022)
Docker 安装 MySQL
Solution to Chinese garbled code after reg file is imported into the registry
According to the result set queried by SQL statement, it is encapsulated as JSON
Visualization of residential house prices
In shell programming, the shell file with relative path is referenced
Analysez l'objet promise avec le noyau dur (Connaissez - vous les sept API communes obligatoires et les sept questions clés?)
Realization of consumer gray scale
Daily CISSP certification common mistakes (April 15, 2022)
Closure type of rust (difference between FN, fnmut and fnone)
Daily network security certification test questions (April 14, 2022)
mysql自动启动设置用Systemctl start mysqld启动
QT tablewidget insert qcombobox drop-down box
CISSP certified daily knowledge points (April 12, 2022)