02-19-2014 05:23 AM
Hi,
Looking for help with a solution. I have a limit switch input on a digital line that is being used to change a case structure. The case structure True and False is for the Forward and Reverse for a motor. At the moment, when the limit is tripped/High the motor goes Forward but once it has passed the limit switch it returns to Reverse. How is it possible to keep/latch the case structure that only a True value from limit switch will change the case structure.
Regards,
Solved! Go to Solution.
02-19-2014 05:53 AM
02-19-2014 06:01 AM - edited 02-19-2014 06:01 AM
Hi GerdW,
Thanks for your reply, I'm very much a beginner but I am not sure it is possible edge detect, I am using a 6501, all DIO. The limit
switch is coming in as a simple boolean 0,1.
Regards,
02-19-2014 06:01 AM
Sounds like you need the limit switch to toggle a boolean in your code.
Perform a compare of the input to it's previous value, storing the previous value in a shift register for example, and if "new value > old value" then you have a rising edge detection. Feed that into the True case of your case structure to invert a boolean signal using a NOT function. That boolean signal will simply pass through in the False case. Keep this boolean the same for each iteration of your code by storing it in a shift register as well. When True, rotate clockwise, and when False rotate anti-clockwise.
02-19-2014 07:11 AM
Hi Thoric,
Thanks for your help, I have tried your approach, which I may not be doing correctly using a feedback node instead to store the last value but unfortunately it is not working for me. I have attached a simple VI of what the system is trying to do. The limit switch LED 1 should go High along with LED 2 however when LED 1 goes Low, LED 2 should remain high until the next time LED 1 is High.
Regards,
02-19-2014 08:15 AM
It seems you attached your original code as there is no feedback node in this VI?
Anyway, shown below is how to achieve what I was describing using a Select function instead of case structure. Note, I believe you can also use an Exclusive Or instead (as shown in the lower screenshot, but I haven't tested that)
02-19-2014 08:17 AM
maybe this....