Sine/Cosine angle measurement on math signals

  • Software
  • Sine/Cosine angle measurement on math signals
Tomaz Percic

Posted on 30.11.2021 14:35

Hello,


We have a resolver with modulated sine and cosine signal outputs connected to a Sirius DAQ. With some math we get envelopes of the two signals and are left with clean sine and cosine signals. At this point we want to calculate the angle and eventually speed. We use atan for the angle, but then we have steps in the signal when atan "overflows" and once we derivate this for speed, we of course have large spikes in the signal. Apart from these spikes the results look good.


I see two options here:

  • We somehow "unwrap" the atan result. Can Dewesoft do this in real-time?
  • Use "sensor angle math" somehow. But I haven't managed to set that up.

Attached files:
Aljaž Blažun
Project Manager
Posted on 30.11.2021 16:04

Dear Tomaž,


The simplest option is to use Sensor angle math. Since the input is the sinus signal, the sensor type should be set to “Tacho (Analog)”. Then you have to set the trigger edge, when the angle should reset. Under the frequency unit you should change to RPM, so you will directly get speed as output. Set Lower frequency limit below your sinus frequency.

In the attachment below you can see my setup in Sensor angle math for sinus signal with 5Hz frequency and results in the Measure window.


Best regards,

Aljaž Blažun



Tomaz Percic

Posted on 01.12.2021 07:44

Hello,


thank you for the quick response. I've managed to make it work, but I notice two "issues", or say specifics that come with using sensor angle math.

  • Since the only input into the calculation is the sine signal, the angle is probably not exactly the same as if we'd use atan (since that takes the cosine as input as well).
  • The speed is calculated from the sine trigger, so we get only one sample of speed per sine period. This would be OK for getting just some average speed, but we're interested in small speed fluctuations inside the revolution. I can derivate the angle and that gives me better time-resolution, but of course there are spikes on angle roll-overs.
Aljaž Blažun
Project Manager
Posted on 02.12.2021 08:47

Dear Tomaž,


Your assumptions are correct. Speed and angle is calculated once per cycle. If you want to calculate small fluctuations in speed you can calculate the atan signal from cosine and sine signal. Then you detect roll-overs and sum all the angles. You get a variable with the sum of all angles from the start of measurement. On that variable you can calculate the difference between the last two samples and divide it with a time (multiply with a sample rate). You get a speed value between those two samples. I am attaching a setup file, so you can better understand the process.


Best regards,

Aljaž Blažun



Attached files:
Tomaz Percic

Posted on 02.12.2021 08:54

Hello,


Thank you very much, that solves my issue. There are some nice tricks in your formulas that I didn't know I could do.


At what point do we have to worry about the "unwrapped/summed" angle reaching such high values that we lose some accuracy? Are the vars double precision (float64)? I suspect we could add some reseting once in a while to remain within the acceptable values.


Regards,

Tomaz

Aljaž Blažun
Project Manager
Posted on 02.12.2021 10:36

Dear Tomaž,


You can set the precision in the setup window of the channel. Position of the settings is shown in the attachment. If precision is set to double precision you will have float64 format as you have stated. I still suggest setting reset of angle in intervals you found acceptable. You can set this up using two additional formulas. I am sending you another setup with working formulas. Angle is reset every 100000 counts. You can increase the interval in the formula CountReset.


Best regards,

Aljaž Blažun


Attached files:
Tomaz Percic

Posted on 02.12.2021 12:44

Brilliant, thank you.


Regards,

Tomaz

Login to reply to this topic. If you don't have account yet, you can signup for free account .