11-03-2009 05:37 PM
hi all,
i have a very simple question,
i want to count iterations for my code, my code is weels forward (count +1) weels backwards (count +1)
that means after one main loop it should count 2 (forward and backwards).
how can i do it? can you correnct my .vi file?
11-04-2009 10:41 AM
The JPG of the code that you posted shows some very odd-looking code indeed. Wiring a "true" constant to a while loop's termination condition will cause that loop to get skipped completely. Wiring a "false" constant will cause the loop to run forever. So, the code you posted effectively does nothing, forever. That's probably not what you meant.
Can you tell us a little more about exactly what you are trying to get your NXT to do with this code? Looks like maybe move forward, then backward, over and over...
11-04-2009 10:45 AM
11-04-2009 12:30 PM
hi, the code is for running forward and reverse infinitly, i only need to count the motor turns.
my intention is to implement the general idea on some other code i am working on.
can you tell me what is odd about that code and how do i fix it?
11-04-2009 05:24 PM
The thing that's odd is all of the extra while loops that aren't actually looping. You only need the outer loop to make sure the program runs continuously.
Attached is a screenshot of how I'd probably program this. The sequence frames guarantee that I'm counting actual turns of the motor as those turns happen.
11-06-2009 03:53 PM
Dear James,
thanks a lot for you'r help.
i tried you'r solution and got some errors.
plus the shift reg. are orange instead of blue like you got.
itai.
11-06-2009 04:44 PM
The orange vs. blue wires are important and are, in fact, the cause of your errors.
The orange wire indicates a "double" data type, which is a floating point data type. Since the NXT doesn't support floating type, you get errors.
The blue wire indicates an "integer" data type, which doesn't use floating point. To change your orange wires to blue, right-click on the "0" constant and change the Representation to U32. You'll also need to do the same for the Numeric indicator.
See here for more info: http://zone.ni.com/reference/en-XX/help/371361F-01/lvhowto/changing_numeric_represent/
Hope that helps!