Using the output of an if or iif function


frobate

Recommended Posts

Title says it all. I am using an iff statement to zero a 360 degree display using a 0-10 vdc input.

It works fine but how do I use that ooutput of the iff function?

for example:

I have a 0-10 VDC input that represents 0-360 degrees (hall effect analog encoder) channel ROT_3.

I take the 0-10 vdc signal and using a conversion change that channels output to 0-360 degrees Value*36.

I need to reset zero anywhere around the rotation and I do this with an iff statement.

So if I reset zero with ROT_3 at 176

Link to comment
Share on other sites

Use a sequence, or in this case, probably in the event for your ROT_3 channel. Something like:

V.mychannel = iif(Rot_3[0] == 176, 0, Rot_3[0])

Not really sure what your ultimate expression is, but putting that in the ROT_3 event will cause V.mychannel to be updated every time Rot_3 gets a new value with the result of the iif() statement.

Link to comment
Share on other sites

Thank you I think I have tried that but not in the event panel.

here is the actual statement that I am using.

iff(ROT_3[0]<V.ZERO_SET[0]), (ROT_3[0]-V.ZERO_SET)+10,ROT_3[0]-V.ZERO_SET[0] *36

V.ZERO_SET is set with a button push anywhere between 0-360 degrees.

Link to comment
Share on other sites

Please excuse the syntax error.... But I have another related question.

I want to use this information to control a digital output to control a turntable, basically motion control application.

So I need to read the output of the iif statement and compare it to a fixed number.

For example, move to 11 degrees,

DIO_3=1 until V.ZERO_CALC(variable 0-360)=V.ZERO_SET(set to 11) then DIO_3=0

I have been messing with if and where statements but can't seem to make things work.

Any ideas?

Link to comment
Share on other sites

Thank you for the response, however, this appears as a single shot event. When I use this in a button push "Go to Position 1" for example, the script only happens once, as soon as I push the button.

I have tried to us the "while" command as shown in the documentation but that simply hangs the program and everything stops.

The problem is, from the time I push the button, I must monitor the position feedback channel, and compare that to the preset number. Not to mention the need to have a window (11 is actually some number between 10 & 12)

Really I just cannot figure out a way to continuously monitor my positioning channel without hanging the system.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.