Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

mathcad programming for threshold and duration

Status
Not open for further replies.

lgunseor

Electrical
Feb 28, 2013
10
US
Need some help, pulling my hair out trying to figure out how to program this in Mathcad. I'm reading data from a data file and plotting that on a graph. From the data I want to determine when the amplitude of the incoming data goes above a threshold for a certain duration. If both the amplitude above the threshold and duration are met, I then want to plot a pulse on another graph. Pulse would just be a "0" or a "1". See attached JPG file. Any help would be appreciated.
 
Replies continue below

Recommended for you

There may be a clever way to do it but I'd do it in 2 stages, first buid a pulse train where the original signal exceeds the trigger value, then find the length of each pulse and output a new train of single pulses at the start of relevant pulses (although that isn't what your jpg says)



Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
Your OP and picture are not equivalent. Your picture shows a Logic 101 state machine problem.

My only modification to Greg's solution would be to treat the intermediate train as an incrementer, i.e., starting at ground state, when the threshold is exceeded, you start incrementing a counter. If the count exceeds the duration in counts, you generate the output signal. The counter is reset only if the input drops below the threshold.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Greg,

Didn't think of that but your right that would be a round about way to get the results I'm looking for.

Larry
 
IRstuff,

I understand how to do this in conventional programming the problem I'm having is putting together the proper programming steps in Mathcad. I'm new to programming to Mathcad and trying to determine the right sequence/program structure to get the results I'm looking for.
 
I don't necessarily even think you need programming, per se. With some clever constructs, simply indexed variables should do the job.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Here ya go, as you can see there's no tricksiness in it, you get a red pulse at the start of any time the blue signal exceeds the black trigger level for the minimum duration, tho I've put the pulse at the start of the relevant period, which needs a time machine.

I haven't checked it for errors.





Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
Greg,

Thanks for the PNG file, however when typing it in exactly as you have it I get an error. Can you post the actual Mathcad file, and what version of Mathchad are you using

Larry
 
Want to thank everyone for their feedback, got me going in the right direction. Attached file and data now work the way I want. Once the input signal crosses the threshold then the counter starts. If the counter reaches the value of duration and the input is still above threshold then the data[sub]i[/sub]goes high. It stays high until the input signal falls below the threshold then it goes low. The counter is also reset at this time. The pulse widths can very but that's not a issue for my application. Note, data file is fairly large (accelerometer data) so only reading a portion of it in the program. Program and data attached in archive file.
 
 http://files.engineering.com/getfile.aspx?folder=9971f2e8-5c32-4e3d-9b5c-d05079cfada7&file=threshold_duration_program_and_data.rar
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top