I have created a frequency response output delay formula. Is it correct ??? - Page 1
Forum section: electronics / general

author: Xgentec Jason
author_rank: Contributor
timestamp: November 07, 2020, 12:59:15 pm
content: Hello everyone.I have created a frequency response output delay formula from scratch regarding the output signal speed delay from a STM32 microcontroller.This formula matches the output data response from the (real world) oscilloscope readings virtually exactly.I have attached a picture of my oscilloscope readings Excel graph data with formula.Yes I know my math skills are not the best on the planet in fact I know they are my worst area so I thought I would reach out to get others to double check my work.Orange line is the real world oscilloscope readings of the output signal delay.Green Line is the delay time prediction formula.

author: Yansi
author_rank: Super Contributor
timestamp: November 07, 2020, 01:04:06 pm
content: What the ?What is this supposed to model? Frequency response of what? Delay of output of what? When?

author: Xgentec Jason
author_rank: Contributor
timestamp: November 07, 2020, 01:06:11 pm
content: It say it all in the message.Delay in output from an STM32 microcontrollerFormula predicts the delay

author: Yansi
author_rank: Super Contributor
timestamp: November 07, 2020, 01:09:33 pm
content: Output of what?Delay is usually measured from event A to event B. So what is event A and what is event B?Then you provide just some graph, where you even couldn't even write what units are on the Y axis.

author: Xgentec Jason
author_rank: Contributor
timestamp: November 07, 2020, 01:18:32 pm
content: Output A is shown in section A of the picture = this is the microcontroller output pulse frequency in KHzOutput B is shown in section B of the picture = the actual measured oscilloscope output pulse speed in KHz.The output delay time between intended output and actual output is clearly visible in the picture.The formula and formula line is clearly visible in the picture.

author: Yansi
author_rank: Super Contributor
timestamp: November 07, 2020, 01:24:45 pm
content: It is great you show us some kind of formula, but we can't check it, as I still have hard time interpreting, what you are presenting us.So how did your test setup look like?What software was running in the MCU, what did it do? What test signal were applied, to inputs, what outputs were measured and how?What you presented so far makes still exactly zero sense. Sorry, we don't have crystal balls.

author: Siwastaja
author_rank: Super Contributor
timestamp: November 07, 2020, 01:26:14 pm
content: Sounds complete gibberish to me?

author: emece67
author_rank: Frequent Contributor
timestamp: November 07, 2020, 01:32:23 pm
content: .

author: Xgentec Jason
author_rank: Contributor
timestamp: November 07, 2020, 01:33:49 pm
content: OKSTM32 Maple mini microcontrollerArduino IDE I ask it to output signal pulses starting from 0 up to 500 KHzI measure the signal output from the maple mini on Rigol dS1054z oscilloscope.There is clearly a delay time that increases as I go higher in frequency.The output at certain intervals I have graphed to show this increasing delay time.I made a formula to predict the delay time. KHz - KHz*KHz*LOG/100*2/100

author: Siwastaja
author_rank: Super Contributor
timestamp: November 07, 2020, 01:35:12 pm
content: OK, then it's all about the limitations of the Arduino library. You give it a parameter, "create 500kHz PWM", and it rounds it off based on its internal limitations. It's made for artists, by artists, not programmers, you need to remember that.You can generate far more accurate frequencies, and actuallyknowwhat you generate, if you read the relevant reference manual sections of the PWM generation timers, and set the registers by yourself. It's just a few lines of code. The relevant things to understand are:* timer kernel clock frequency. On simplest STM32's, it's the same as the CPU clock, but it can be something else, and possibly configurable.* timer prescaler. This divides the kernel clock.* timer comparison value register. This is how far the timer counts before changing the output value.These together form the final frequency and it will be exact. You can then use the oscillosscope toverifywhat you did, but there should be no error (exceeding that of the original MCU clock source, obviously).

author: Xgentec Jason
author_rank: Contributor
timestamp: November 07, 2020, 01:43:53 pm
content: Well many thanks.This was just an exercise of my math more than anything.Just wanted to make sure my math formula was done correctlyor is there a simpler way to predict a signal decline curve.This would apply to other things like signal degradation or other things in physics right.

author: Xgentec Jason
author_rank: Contributor
timestamp: November 07, 2020, 01:48:05 pm
content: I will have to go over that formula as it is not easy to read on Excel

author: Siwastaja
author_rank: Super Contributor
timestamp: November 07, 2020, 01:50:33 pm
content: Trying to model the behavior of an Arduino library limitations using a math formula is, IMHO, a futile task.It's a surprisingly good fit in this case, though, but the behavior could beanything.If you calculate the timer settings yourself, the limitations become obvious. For example, if the timer kernel clock is running at, say, 10MHz, you can create 5MHz, 3.33...MHz, 2.5MHz, 2MHz and so on, but you cannot create 4MHz, for example. So the Arduino library is rounding the settings. It will just be way more limited than what you get if you configure the timer peripheral yourself, because the Arduino folks have tried to keep everything very simple and chosen some fixed settings. And when you configure the device yourself, it's also obvious to you what you are doing and why.

author: Xgentec Jason
author_rank: Contributor
timestamp: November 07, 2020, 01:54:41 pm
content: Well many thanks for your time on this Siwastaja.My apologies if the face palms came over the wrong way. I meant no offence.