SignalExpress

cancel
Showing results for 
Search instead for 
Did you mean: 

Modulo arithmetic in SignalExpress

I'm performing arithmetic on the phase output of Tone Generator. I want to keep the output between 0 and 359. Is there any way to do modulo arithmetic in SignalExpress?
0 Kudos
Message 1 of 3
(6,235 Views)

There is not a direct modulo function, but you can construct just about anything you want with the Formula step.  For example, to look at an offset sine wave (0 - 1 volt range) modulo 0.5, you can use

 

 ( ( x0 / 0.5) - floor( x0 / 0.5) )*0.5

 

There is probably a more efficient formula for doing this, but this gives you the idea.

0 Kudos
Message 2 of 3
(6,232 Views)

I figured there was a way but it wasn't coming to me. Your example led me to this:

 

(phase2-phase1) - (floor((phase2-phase1)/360)*360)

 

This keeps the result between 0 and 360.

 

Thanks! 

0 Kudos
Message 3 of 3
(6,218 Views)