|
Hello,
I have a 2D waveform data (Sine/Square/Triangle). Could some one tell me how to calculate period and duty cycle from it.
Note:
I am new to this forum, if this is a wrong place to post this topic, some one re-direct me to correct place.
Thanks.
modified on Tuesday, July 14, 2009 2:47 AM
|
|
|
|
|
Hi,
I'm not ure what you asking, a quick Google should tell you how to calculate period & duty cycle. Try to think of a more specific programming question and perhaps someone here can help you.
Ali
|
|
|
|
|
I am just trying to implement the period and duty cycle calculation in a C++ class based on the waveform array data. Trying to figure out some formula to find those values.
|
|
|
|
|
Period - find the max/min values of your waveform. Now look for the times when the waveform crosses (min+max)/2. The period should be double the time between adjacent crossings of that value.
Alternatively, calculate the FFT of the waveform and look for the big peak - that'll show dominant frequency in your signal.
Duty cycle[^] - Wikipedia defines as Duty cycle is the proportion of time during which a component, device, or system is operated. First you need to decide what the 'active' state of your waveform is and work out what fraction of time it's active.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks Stuart.
But i have an unsymmetrical waveform data, so i couldnt use (max+min)/2 to determine the level crossing. Also without the sample rate of the waveform how can i find period by finding the total noOfSamples of a cycle.
|
|
|
|
|
sks83 wrote: without the sample rate of the waveform
If you don't know the sample rate, you can't calculate the period in terms of time - only in terms of samples.
sks83 wrote: But i have an unsymmetrical waveform data, so i couldnt use (max+min)/2 to determine the level crossing
In that case, find the number of samples between maxima or minima.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
If your waves are "pure" (square, sine or pure triangular), you could calculate the time were the signal is positive and negative. You add those two times and you end up with the total period. The ratio of those times will give you the duty cycle.
To calculate those times, this is quite easy: simply walk over your points and check when the sign changes. At that time, you keep the time (start time) and walk over the data until the sign change (stop time). The difference between stop and start time gives you the time were the signal is negative or positive (depending of the sign).
|
|
|
|
|
Thanks Cedric.
1. My waveform is not symmetric and it can have n number of cycles. Also waveform data may be clipped at the beginning.
2. If you could tell me how to determine the crossing level of the waveform. With that i can determine the period.
modified on Tuesday, July 14, 2009 5:18 AM
|
|
|
|
|
sks83 wrote: My waveform is not symmetric and it can have n number of cycles. Also waveform data may have clipped data at the beginning.
Not symetric is not a problem. What I mean is that if you have a very complex waveform (like sound), then this technique won't work. If a period of your signal is the time in which your signal is positive plus the time were the signal is negative, then this will work fine (and it is quite easy to implement).
If you have multiple cycles, that's fine, you can for instance do an average of all the positive times and all the negative times (well, that depends on your requirements of course).
For the clipping, simply skip the first half period: start your calculation were the sign of your signal is switching.
sks83 wrote: 2. If you could tell me how to determine the crossing level of the waveform. With that i can determine the period.
What do you mean by crossing level ? The time at which your signal sign changes ? If yes, then that is really easy to do: simply walk over your data points and check when the sign of your data changes.
|
|
|
|
|
Hello cedric,
I could not walk through each data points, since i have more than 20,000 samples.
FYI
Unsymmetrical Sine waveform data is as below,
ON time
Start - 5V.
Stop - 5V.
Max - 7V.
OFF time
Start - 5V.
Stop - 5V.
Min - 1V.
There will not be any negative data points. So how could i find that the waveform crosses at 5V.
|
|
|
|
|
Hi, You may well have 20,000 samples but you can still 'walk through' them, in fact you will have to analyse each point in some way to get the results you require.
I do not entirely follow the description of your waveform, but since you have no negative points you could find the time between two peaks (maximums) or troughs (minimums), this would be an equally valid measurement of period.
Hope that helps,
Ali
|
|
|
|
|
can we add command buttons to SDI application.
|
|
|
|
|
Yes
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Respected all,
I am working with win32 application for windows mobile 5.0. I need use datetime control on one of the my dialog box. after adding the datetime control on the dialog box. The application compiled successfully but that dialog box is not loaded while running application.
Thank you.
Hiren.
|
|
|
|
|
If you remove the control from the dialog template, does the dialog then display?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Any event fired by the windows on establishment of new socket?
|
|
|
|
|
|
Hi,
i am using comport communication in my application
so i have to detect whether the data is there on the tx line
or not and then send the data is there anyway to implement
this functionality
|
|
|
|
|
Why do you need that? Don't you like output buffering?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
no the output buffering was not working so
i want to implement this way... to transmit data
|
|
|
|
|
Output buffering usually works. Could you please give more details about your problem?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
actually i am implementing a functionality in
which the tx and rx will be in a session
so while i am sending the data at a baudrate(baudrate can be any)
this is coming out of session.even though its taking the whole value into the
tx buffer its abruptly comes out of session.
|
|
|
|
|
Are you changing the baud rate on the fly, without closing and the opening again the port? I don't know if it might work, anyway you've to make sure to flush the buffer, before even trying.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
baud rate is fixed before entering the session
it cannot be changed on the fly.once i enter the session
the communication occurs at fixed baud rate.
but the data sent through can be varied...
so if i am sending large bytes of data then its coming out of session..
|
|
|
|
|
Hello Friends
i updated my code from vs2002 to 2008.and after that i got error in vector functions on m1.clear(),then i add msvcrtd.lib file then it crashed at another funcion of vector m1.push_back(). Do I need to add any other lib file to work with vector in vs2008?
Thanks In advance.
Yogesh
|
|
|
|