Mathcad WHILE loop inside an IF statement
Mathcad WHILE loop inside an IF statement
(OP)
Having an problem with a Mathcad WHILE loop (using Mathcad 15). I'm reading data in from a file, the data is from an accelerometer. I want to set up an IF statement to set a variable to 1 when the rising edge of the signal is greater than 5 g's but I don't want to reset the variable back to 0 until the signal drops to below 2 g's. If I do just the IF statement it work fine but switches the variable to 1 on the rising edge of the pulse at 5 g's and sets it back to 0 on the falling edge at 5 g's. I want the variable to be reset back to 0 at 2 g's on the falling edge. Attached is my attempt of a WHILE loop inside a IF statement, I'm having issues trying to determine how to structure the WHILE loop. Any help with this would be appreciated. Attached is a PDF of the waveform and my attempt at the Mathcad programming.





RE: Mathcad WHILE loop inside an IF statement
RE: Mathcad WHILE loop inside an IF statement
RE: Mathcad WHILE loop inside an IF statement
RE: Mathcad WHILE loop inside an IF statement
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Mathcad WHILE loop inside an IF statement
I'm looking for a 1's and 0's graph (see attached). I can get this with the single if statement shown above the graphs but it is switching to a 1 at 5 (rising edge of pulse) and a 0 at 5 (falling edge of pulse). What I'm trying to do is switch to a 1 at 5 (rising edge of pulse) and switch to a 0 at 2 (falling edge of pulse). Graph would be 1's and 0's as shown. As I move the value down on the falling edge of the signal this will increase the width of the digital pulses i.e. the amount of time that it stays at a 1.
RE: Mathcad WHILE loop inside an IF statement
Understand state machines and doing this in standard software programming is straight forward, I'm trying to understand how this needs to be structured in Mathcad 15 so Mathcad understands the equation and can process it. If you have any suggestions on how to do this in Mathcad 15 I would be interested.
RE: Mathcad WHILE loop inside an IF statement
RE: Mathcad WHILE loop inside an IF statement
Thank you very much this is exactly what I was trying to do. Plotted out the 1 and 0 states against the waveform and you can see that it is triggering on 5 on the rising edge and 2 on the falling edge (see attached plot). Thanks again.