MATLAB

MATLAB models for the Tunneling Ball Device express equations for ball kinematics, disc kinematics, and trajectory planning. This is the most useful tool for quickly verifying calculations and generating graphs. Most functions were designed to map 1:1 to equations in Elements of Model-Based Design; check errata for any revisions.

The starting point for understanding the MATLAB scripts is in the file "main.m", which can be executed from the command window by typing "main". This will save all system parameters (disc, ball, servo, and sys) to the workspace and run a simulation of a single ball drop.

The variables saved to the workspace are defined in "systemVars.m", and are returned in structures for the ball (radius, initial velocity, time of detection, initial altitude), disc (dimensions, weight, inertia), servo (physical parameters of the motor), and system (gear ratio, optical sensor separation, net inertia, system transfer function).

Once variables are loaded into memory, any of the simulation functions may be called by passing in the appropriate variables. Try typing in ‘disc’, ‘ball’, ‘servo’, or ‘sys’ into the command line to see the elements of these variables.

As a starting point, try calling any of the plot functions. Most (if not all) of the simulation functions available support passing in vectors when appropriate.

Code Generation in MATLAB

MATLAB is used to generate C lookup tables that may be used on an embedded platform in place of a costly direct evaluation of an equation. The functions will have the phrase "Codegen" in the filename. The code is intended to be copied and pasted into embedded code.