06-12-2018 02:32 PM
Hello,
I'm apart of a team that's trying to develop an autonomous vehicle. We've acquired a HC-SR04 ultrasonic sensor to detect objects in our vehicle's path. To test our codes we've been running the VI on a Tetrix rover along with a MyRio. Currently we have a VI for the ultrasonic sensor that triggers a digital output if an object is within roughly 9 inches. Additionally we've written a VI that can be executed to make the rover avoid an object by going around it. What we are having trouble with is integrating the ultrasonic sensor and motors. What we want to do is have the sensor trigger the motors if there's an object within the range previously mentioned. We've tried putting in the motor VI into the sensor VI but it'll run the motors code continuously without going back to the sensor. We've tried a state machine, having the sensor VI call the motor VI, having both VI's running in separate while loops but nothing has worked. Is there anything y'all could suggest us doing to get the programs to work?
Ideally we would like for the programs to be separate and having one VI call the other.
We've attached screenshots and the files as well for anyone who is willing to help us.
Motor VI
Ultrasonic Sensor VI
Thank you,
Team EOS
06-20-2018 04:40 PM
Hi colleague
Based on the description of the application you are giving, it seems that we could use a closed loop control with feedback. In this way, I would like to know if you have considered the usage of a PID control paradigm. Additionally, the simplest way to address this would be to continuously pull the distance provided by the ultrasonic sensor, and if (case structure) an object is within the particular range, then you can perform a minimum step defined before. In other words, if the object is within the range predefine, then the motor should perform a minimum step, then we measure again the distance, if the object is still within the range, perform again the minimum step. Continue doing this until the distance measured indicates that the object is not close.
I think that this may be the overall logic, however, the implementation would be a while loop, where a subVI performs the ultrasonic measurement. Then its output is compared with the predefined range, the output of the comparison goes to a case structure where the subVI that perform the minimum step with the motor is included.
I hope this suggestion to help you, however the best logic as I mentioned before would be a PID control. The following manual may be useful.
08-07-2018 01:26 PM
Hello Bcortes,
So we've tried putting the sensor into a SubVI and doing the motor control but the sensor does not reset. The program gets stuck on the range that is outputted from the SubVI. We also tried putting the motor control into a SubVI but we encounter the same issue. Originally before we put in the motor control we had a digital output that was just a light and when something was within the predetermined range the light would turn and if you moved the object out the way the sensor would continuously run. Do you know of a way we could make the sensor start to run again once it runs through the motor control sequence? We've attached the program to see we could get some help.
12-01-2019 08:55 AM
can you please send me the Sensor code VI for the labview 2014 version