frobate Posted December 9, 2010 Share Posted December 9, 2010 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 More sharing options...
AzeoTech Posted December 9, 2010 Share Posted December 9, 2010 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 More sharing options...
frobate Posted December 9, 2010 Author Share Posted December 9, 2010 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 More sharing options...
AzeoTech Posted December 10, 2010 Share Posted December 10, 2010 OK, but its IIF() not iff(). It stands for inline if, so there are two i's not two f's Link to comment Share on other sites More sharing options...
frobate Posted December 10, 2010 Author Share Posted December 10, 2010 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 More sharing options...
AzeoTech Posted December 10, 2010 Share Posted December 10, 2010 Just use boolean math. Remember booleans evaluate to 0 when false and 1 when true, so you can just do: DIO_3 = (V.Zero_Calc != V.Zero_set) Link to comment Share on other sites More sharing options...
frobate Posted December 13, 2010 Author Share Posted December 13, 2010 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 More sharing options...
AzeoTech Posted December 13, 2010 Share Posted December 13, 2010 You can't put a while() loop inside a component action because that script runs in the thread of the UI and so the UI hangs. You need to create a sequence with the while loop and then have the component action start the sequence: beginseq(myseq) Link to comment Share on other sites More sharing options...
frobate Posted December 13, 2010 Author Share Posted December 13, 2010 I really suspected that, but didn't try it. Thank you Link to comment Share on other sites More sharing options...
frobate Posted December 13, 2010 Author Share Posted December 13, 2010 Works great thanks for your patience and knowledge Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.