Author Topic: I have created a frequency response output delay formula. Is it correct ???  (Read 944 times)

0 Members and 1 Guest are viewing this topic.

Offline Xgentec JasonTopic starter

  • Contributor
  • Posts: 14
  • Country: gb
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.
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3930
  • Country: 00
  • STM32, STM8, AVR, 8051
What the ?

What is this supposed to model? Frequency response of what? Delay of output of what? When?  :-//
 
The following users thanked this post: hexreader

Offline Xgentec JasonTopic starter

  • Contributor
  • Posts: 14
  • Country: gb
It say it all in the message.
Delay in output from an STM32 microcontroller
Formula predicts the delay :palm:
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3930
  • Country: 00
  • STM32, STM8, AVR, 8051
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.
 

Offline Xgentec JasonTopic starter

  • Contributor
  • Posts: 14
  • Country: gb
Output A is shown in section A of the picture = this is the microcontroller output pulse frequency in KHz
Output 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. :palm:
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3930
  • Country: 00
  • STM32, STM8, AVR, 8051
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.
« Last Edit: November 07, 2020, 01:27:34 pm by Yansi »
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 9327
  • Country: fi
Sounds complete gibberish to me?
 
The following users thanked this post: Yansi

Offline emece67

  • Frequent Contributor
  • **
  • !
  • Posts: 614
  • Country: 00
.
« Last Edit: August 19, 2022, 04:04:29 pm by emece67 »
 

Offline Xgentec JasonTopic starter

  • Contributor
  • Posts: 14
  • Country: gb
OK
STM32 Maple mini microcontroller
Arduino IDE I ask it to output signal pulses starting from 0 up to 500 KHz
I 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
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 9327
  • Country: fi
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 actually know what 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 to verify what you did, but there should be no error (exceeding that of the original MCU clock source, obviously).
« Last Edit: November 07, 2020, 01:38:28 pm by Siwastaja »
 

Offline Xgentec JasonTopic starter

  • Contributor
  • Posts: 14
  • Country: gb
Re: I have created a frequency response output delay formula. Is it correct ???
« Reply #10 on: November 07, 2020, 01:43:53 pm »
Well many thanks.
This was just an exercise of my math more than anything.
Just wanted to make sure my math formula was done correctly ??? or 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. :-+
 

Offline Xgentec JasonTopic starter

  • Contributor
  • Posts: 14
  • Country: gb
Re: I have created a frequency response output delay formula. Is it correct ???
« Reply #11 on: November 07, 2020, 01:48:05 pm »
I will have to go over that formula as it is not easy to read on Excel
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 9327
  • Country: fi
Re: I have created a frequency response output delay formula. Is it correct ???
« Reply #12 on: November 07, 2020, 01:50:33 pm »
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 be anything.

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.
 
The following users thanked this post: Xgentec Jason

Offline Xgentec JasonTopic starter

  • Contributor
  • Posts: 14
  • Country: gb
Re: I have created a frequency response output delay formula. Is it correct ???
« Reply #13 on: November 07, 2020, 01:54:41 pm »
Well many thanks for your time on this Siwastaja.
My apologies if the face palms came over the wrong way. I meant no offence.  :-+
 
The following users thanked this post: Siwastaja


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf