News: Join the team! The Wunderbot V is looking for new memebers. Just contact someone on the contacts page!
Wunderbot - Motor Control Subsystem Tutorial
If there are any questions about this tutorial feel free to email me at patrickm@etown.edu and I will try to answer them.


Our Motor Control Subsystem implements a PID control system using optical encoders to recieve the information.

MotorSub:

This VI does the reading in of inputs and and setting th enecessary variables to control the robot's movement.


This first step in the case statement reads in a string over the serial port into a local variable response.



This section reads in all the bytes from the serial connection using built in LabVIEW commands for serial processing.



This section begins parsing the string and checks to make sure we haven't recieved an empty string back from the Motor Controller.



This sets our max speed at 40 for the left wheel in order to comply with IGVC regulations.



Again this sets our max speed to 40, this time for the right wheel.



This adjusts the Motor Controller string variable for use.



This takes care of setting up the reset for the controller.



This final section gets a tick count.

OpticalEncoders:



This VI allows us to interface with the optical encoders allowing feedback in our closed loop contol system.



The first section of the case statement initializes the reset counter.



This section of the case sets up the serial connection and begins reading in the data from the optical encoders.



This case is using another built in optical encoder VI to set the position based on the information being brought in.  In both cases we set the position the difference is in the constants provided.




The previous screen is executed if the reset flag is true.  If it is false the above is executed,.  In this case we output position values.

PID:



This is the front panel for the actual PID sub VI.  It reads in all the associated inputs and outputs the calculated adjustment




This VI sets our adjustment when we start from a stop.  This boolean case is executed if our previous speed is zero and current is not equal to zero.



This case applies a closed loop PID control loop to determine the adjustment for the wheels based on the error from the feedback of the optical encoders.

Turn VI:



This VI turns the robot based on the desired direction, the current bearing and the tolerance.



This VI checks to see if the current bearing of the robot and the desired bearing are within a tolerance.  If the are it outputs a flag saying so.

TurnSequence VI:



This VI executes a turning sequence setting the wheel speeds accordingly.


This brings in the absolute angle of the turn and the desired speed and determines if a right or left turn is being executed.



We then execute the turn by sending the speed information to the outside wheel.  Int he case above we are making a right turn  The left turn would swithch the left and right wheel speeds.

The Remote:



This VI takes care of conrolling the robot via the remote control.


The first case of the structure sets up the serial connection of the remote control.



This case then parses the serial string into the double type variables that are represented in the string.



We then process the information we parsed out in order to control the robot.  We generate left and right speeds.


Finally in the last statement of the structure we set a 300 ms wait to allow execution.