I am using DAQmx to acquire and generate digital inputs and outputs to run a car forward and reverse, triggering off of lasers. The trip lasers are normally High (1) and then go low (0) when something breaks the beam. The code attached functions. The car drives forward when you press start, drives to the end and when the laser is tripped it flips to reverse and comes back. When it gets to the left sensor it trips and goes forward and keeps doing that. I have been trying to figure out how to stop the car (output 0 to FWD and REV) for a second before it flips direction and I can't figure it out for the life of me. Any help is appreciated. Maybe there is a better way to do it all together???
If it is any use:
Forward output: Mod4/port0/line1
Reverse output: Mod4/port0/line0
Left sensor input Mod3/port0/line1
Right sensor input Mod3/port0/line0
Hi abindas - When you click stop, does the car currently stop completely and never restart? But you would like the car to stop briefly at either end before it starts driving again in the opposite direction. Is that correct?
You could try using a sequence structure inside the "stop" event where the car first stops completely (both false), and then you turn the forward or reverse direction true depending on which way it needs to drive next. You can save the current value for forward and reverse in shift registers and check to see which one needs to be turned true next.
I ended up figuring it out and have it running currently. I wrote a new program all together and it now uses shift registers to check the previous state of the motor outputs and then when a laser is tripped it runs a Flat sequence to stop it and then flip the logic on the shift registers.
Thanks for the advice