简体   繁体   English

STM32(使用Mbed在线)在较高的模拟输入频率下显示延迟

[英]STM32 (using Mbed online) showing delay at higher analog input frequency

I am new to the use of controllers. 我是控制器的新手。 I am setting up a STM32F769 Controller(Using Mbed online compiler), my target is to get a PWM output which changes its frequency according to an analog input. 我正在设置一个STM32F769控制器(使用Mbed在线编译器),我的目标是获得一个PWM输出,它根据模拟输入改变其频率。 I did some basic coding but there is a problem. 我做了一些基本的编码,但是有一个问题。 When i check the output on oscilloscope with analog input 1Hz frequency, its working perfectly, but when i check it with 100Hz analog input there is delay in the output, and i get wrong values. 当我用模拟输入1Hz频率检查示波器上的输出时,它工作正常,但是当我用100Hz模拟输入检查它时输出有延迟,我得到错误的值。 I do not understand why, because this board is faster(216 MHZ) and i should not face such issue. 我不明白为什么,因为这个板更快(216 MHZ),我不应该面对这样的问题。 (If someone could also explain, is it possible to use the board at 216MHz or other max frequency? and how?) (如果有人也可以解释,是否可以在216MHz或其他最大频率下使用电路板?以及如何?)

1st time user 第一次用户

{
 meas_r=0;
 for(int i=1;i<=1024;i++)
 {             
    meas_r = meas_r+analog_value.read(); 
 }
 meas_r=meas_r/1024;
 meas_v = meas_r * 3300;
 out_freq=50000+(meas_v*50);   
 pulse.period( 1.0 / out_freq);  
 }
}

It should be working on 100Hz analog input as it works on 1 Hz. 它应该在100Hz模拟输入上工作,因为它工作在1 Hz。

216MHz might be the maximum clock frequency at which your processor can operate, however it does not mean that it can input/output that much frequency from its ports. 216MHz可能是处理器可以运行的最大时钟频率,但这并不意味着它可以从其端口输入/输出那么多频率。

  • The delays are caused by time it takes to read analog values and compute required math operations. 延迟是由读取模拟值和计算所需数学运算所需的时间引起的。 You are using multiple multiplications and divisions which are more complex than adding and subtracting for almost any hardware device. 您正在使用多个乘法和除法,这些乘法和除法几乎比任何硬件设备的加法和减法都要复杂。 Obviously, you are using library/libraries as well (pulse.period(), analog_value.read()), there are some hidden computations on top of those multiplications and divisions. 显然,你也在使用库/库(pulse.period(),analog_value.read()),在这些乘法和除法之上有一些隐藏的计算。 Finally, it is possible that your device is working with other stuffs as well (only you know about this). 最后,你的设备也可能正在使用其他东西(只有你知道这一点)。 All those computations need time. 所有这些计算都需要时间。 At lower frequencies you might not be able to notice the delay, however when the frequency is high enough, the delays can be noticed. 在较低的频率下,您可能无法注意到延迟,但是当频率足够高时,可以注意到延迟。 Also consider time required to read the analog values many times . 还要考虑多次读取模拟值所需的时间
  • Wrong signal and period is due to the delays and some other uncertainties. 错误的信号和周期是由于延迟和其他一些不确定因素造成的。 If the processor is working with other tasks as well, then it will be hard to predict time it takes to finish them all. 如果处理器也在处理其他任务,那么很难预测完成所有任务所需的时间。 As the processor executes the instructions line by line and waits for previous computation to finish before the new one starts, it causes some uncertainty in timing. 当处理器逐行执行指令并等待先前的计算在新的计算开始之前完成时,它会导致时序上的一些不确定性。 Data path and frequency of peripheral devices (getting input from peripherals) play crucial role in timing uncertainty and delays. 外围设备的数据路径和频率(从外设获得输入)在定时不确定性和延迟方面起着至关重要的作用。

If timing and accuracy is really important in solving the problem you have, and if you can't solve the problem with DSP, MPU, MCU, CPU, GPU, etc. I would suggest you to use an FPGA to solve the problem. 如果时间和精度对于解决您遇到的问题非常重要,如果您无法解决DSP,MPU,MCU,CPU,GPU等问题,我建议您使用FPGA来解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM