# timer help with labview

my team needs help with some last minute programming, my team wants to put a motor on the robot and have it run on a cycle of on for 1ms and off for 11ms…I was trying to program it and cannot figure this out.

any help would be greatly appreciated.

I’ve attached a picture of two simple examples. I’m sure a labview expert could do better.

In the top one I used a stacked sequence inside a while loop. This [sets the motor speed to 1, waits a millisecond], [sets the motor speed to 0, waits 11 milliseconds] repeat.

The top one uses the system timer. It grabs the current time in milliseconds (Tick Count), computes the remainder of that divided by 12 (Quotient and Remainder), and checks if the answer is 0 (Equal to 0?). (Select) is used to pass 1 if the remainder is 0 and 0 if the remainder isn’t 0 to (Set Speed). This code would need to be run in a loop more often than once per millisecond.

For reference, the Jaguars are updated every 5ms, and the victors and spikes are updated slower. It is likely that this code will not behave as expected due to this. 12 milliseconds is a very short amount of time: why do you need to control them like this?

More to the point, why don’t you simply set the speed to 1/12?

…I forgot to mention I was using a relay and not a speed controller.
we currently don’t have the weight for a speed controller and we already had an extra spike on there…

but thanks for the code and help…

In that case, just replace the motor VIs with relay VIs.

With spikes, you’ll need to slow way down.

to answer the question of why we need it this way is because we are putting a coconut half on the robot and the motor we are using is extremely fast, we are wanting the coconut to look sort of like a radar dish…

and I’m not sure how to replace the motor vi’s with the relay vi’s

Right click on the motor VI in the block diagram and use “replace->” to search for the appropriate relay VI. You’ll probably have to change the reference input from a “motor type” to a “relay type”. You may also have to change a “start” and “stop” VI from motor to relay types.

Russ

after working on this for about 2 hours one of the mentors said we could use a victor…so I’ll be able to use one of the two sample codes…

thank you for the help, hopefully we do good at our regional so everyone with FIRST can see the “CO-DAR” (coconut radar) on our robot…by the way, my team has a theme this year of Gilligan’s Island so the coconut radar is more of a novelty item.