简体   繁体   English

LabView:如何在labview中为VI添加内存?

[英]LabView: How to add a memory to a VI in labview?

I have been scratching my head trying to find a code that allows the change from on->off to cause something to happen while a change from off-->on not to work. 我一直在努力寻找一个代码,该代码允许从on-> off进行更改而导致某些事情发生,而从off-> on进行更改则不起作用。

For example, I have a sensor as an input. 例如,我有一个传感器作为输入。 At first it senses an object that passes by and rests for a few seconds, so its recording a off (so 0). 首先,它感测到经过的物体并静止了几秒钟,因此它记录了关闭(因此为0)。 When it records a off it causes a light to turn on. 当它记录为关闭时,将导致指示灯点亮。 After the few seconds, the object goes to the end (leaving the sensor) and then comes back and passes through the sensor again. 几秒钟后,物体到达终点(离开传感器),然后返回并再次穿过传感器。 But, I don't want the light to turn on this time. 但是,我不想这次灯亮。

If the system had a memory that its previous state was off and now its going to sense on, then I wouldn't let a off-->on to work, but a on-->off to work. 如果系统有一个内存,它的先前状态为关闭,现在将要开启,那么我不会让关闭->开启工作,而是让它->开启工作。 Is such a code possible on LabVIEW? 在LabVIEW上可以使用这样的代码吗? Are there any other alternatives to this? 还有其他选择吗?

I believe this will do it and it's very simple, correct me if I'm wrong because I don't know that I fully understand the logic desired. 我相信这可以做到,而且非常简单,如果我错了,请纠正我,因为我不知道我完全了解所需的逻辑。

在此处输入图片说明

The key here is the use of a shift register, it's more straight forward than the local variable option, I'm certain the right solution is there or some small tweak to this. 这里的关键是使用移位寄存器,它比局部变量选项更直接,我敢肯定有正确的解决方案或对此进行一些小的调整。

The shift register is initialized as false and whatever state appears on the output of the loop will reappear on that input on the next loop. 移位寄存器被初始化为false,并且在循环输出中出现的任何状态都将在下一个循环中再次出现在该输入上。

Another interesting solution would be with an event structure to trigger on a value change of "Sensor". 另一个有趣的解决方案是使用事件结构来触发“传感器”的值更改。 This solution can also be slightly more responsive, see below: 此解决方案的响应速度也可以稍高一些,请参见下文:

在此处输入图片说明在此处输入图片说明

You can use a local variable and a feedback node to accomplish this. 您可以使用局部变量和反馈节点来完成此操作。

Assuming this is in a while loop my solution is to create a local variable hasLit and a feedback node on the sensor input. 假设这是一个while循环,我的解决方案是在传感器输入上创建一个局部变量hasLit和一个反馈节点。 When the feedback node output is true and the sensor input is false (the object just passed out of the sensor view) we change hasLit to true. 当反馈节点的输出为true且传感器的输入为false(对象刚从传感器视图传递出去)时,我们将hasLit更改为true。 The state of the light will then be true if the sensor is true and not hasLit. 如果传感器为true而不具有hasLit,则指示灯的状态为true。

Image form 图像形式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM