LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

how can I set a global variable for timertick?

hello,
in my program I need a global variable to store the timertick information. Is that feasible under the support of LEGO NXT Toolkit? What am I supposed to do?
0 Kudos
Message 1 of 5
(7,934 Views)
Are you sure you need a global variable for this information?  There are a couple of subVIs can provide the timer values on demand.  One is the Tick Count VI on the NXTToolkit : Time & Dialog palette.  Another is on the NXTToolkit : NXT Library palette and is called the Timer VI.

Will one of those VIs help you solve your problem?  Or are you trying to store an old value of the timer for later computation?  I guess I need a little more information about the constraints of your particular application.
------
James Blair
NI R&D
Message 2 of 5
(7,928 Views)
thanks, James B.
you're right, there're indeed a couple of available VIs for timer applications. But just as you said, I need to keep old value of the timer which starts counting from the beginning of the top level program, then I've tried to send the value in to sub VIs which actually does the computation. However, as to my experience, it doesn't work. In my case, I use Timer VI in top level program(main program), then send the value into a sub VI through a particular port. The Timer VI with the same index as the one in top level would fetch the old timer value from the input port of the sub VI then ...

It should work in this way. But I don't know why the app. doesn't run as it is supposed to do. So I thought maybe I can fix it through a particular global variable which used to transfer the value between top level program and sub VIs.

If you have some ideas or advices, just tell me. Thanks a lot! 🙂
0 Kudos
Message 3 of 5
(7,928 Views)
I've attached an example I threw together of how I might do something like this in LabVIEW without needing a global variable.  I guess technically I'm not using any subVIs, but I could easily move the (convert to string, write string to display) blocks into an independent subVI and pass in the value of the shift register.  I think this example maintains the spirit of your challenge.  Hopefully the comments I've included make things pretty clear.

One note: to create a shift register, wire a value across a loop boundary, right-click on the tunnel (colored square) that gets created, and select "Replace with Shift Register."  Let me know if you have any questions.
------
James Blair
NI R&D
Message 4 of 5
(7,922 Views)
nice, James B., thanks!
It's a good idea to use shift register. I'll try to optimize my programm in this fashion.
0 Kudos
Message 5 of 5
(7,918 Views)