Skip to content
Snippets Groups Projects
Commit be460940 authored by skoch's avatar skoch :burrito:
Browse files

Merge branch 'SimulinkSimulator-ManualModeAddition' into 'master'

Simulink simulator manual mode addition

See merge request !47
parents afdf9935 7feb1691
No related branches found
No related tags found
1 merge request!47Simulink simulator manual mode addition
......@@ -18,6 +18,8 @@ This folder contains the files used in developing the model of the quadcopter.
3. Open a step function block by double clicking on it. Altering the step time will change when the quad begins to move towards a setpoint. Initial and final value have the format [x-position, y-position, z-position, yaw-angle], and any alterations to these fields will change where the quad starts and where it goes to respectively.
4. Setpoints can be added or removed by adding or removing step functions from the Simulink model diagram.
* The simulation automatically ends at 40 seconds unless the simulation time is changed from "runtime" to the desired simulation time.
*Note:
For this model, negative z values correspond to a position above the starting point [0,0,0,0] and positive z values correspond to a position beneath the starting point. (Example: If the quad is instructed to move from [0,0,-2,0] to [0,0,-1,0], it will be moving from a height of 2 units above the starting point down to a height of 1 unit above the starting point.) This means we will usually only work with negative z-values since our starting point is usually the ground and we cannot fly beneath it :)*
......@@ -26,8 +28,24 @@ This folder contains the files used in developing the model of the quadcopter.
1. To select which controller is used to simulate quad flight, navigate to the top level of the Simulink model and toggle the controller switch to either LQR or PID
**Comparing Simulated and Real Motor PWM Signals**
With the addtion of the Zybo PCB shield, MicroCART users can now compare motor PWM signals measured from test points on the PCB shield with simulated motor PWM signals created by the Simulink simulator. This is useful for verifying that a controller is behaving as expected without needing to risk damaging the quad during test flights. The physical test points are located on the JE2 header block on the PCB. The simulated signals are contained in the “motorCommands.signals.values” variable. This variable is created in MATLAB's workspace after running a simulation and is updated after each simulation is completed.
To measure the physical motor PWM signals:
1. Connect an oscilliscope probe to a motor PWM header pin and a ground pin.
2. Calculate the duty cycle of the signal by measuring the time the PWM signal is high and divide it by the period of the PWM signal (~2.2ms).
* The PWM signal should have a duty cycle of ~50% when the quad is on but there is no input sent to the motors.
To measure the simulated motor PWM signals:
1. Open and run the simulator as instructed in the sections above.
2. Locate the "motorCommands" variable in the MATLAB workspace.
3. Open "signals" then open "values" to observe the duty cycle values of each motor PWM signal.
* These signals roughly match the output of the physical system but the user should run tests to observe how accurately the simulation matches the physical results since motors and other components may be switched.
* In the simulink PWM data log, each 1000 data entries corresponds to 5 seconds, which means 0.005 seconds between samples. Ex: 2001 corresponds to 10 seconds into the simulation.
## Additional Documents
[Measuring Motor Resistance](documentation/MeasuringMotorResistance.pdf)
[Simulink Model](documentation/SimulinkModel.md)
\ No newline at end of file
[Simulink Model](documentation/SimulinkModel.md)
[Matt Rich's Thesis](documentation/Matt_Rich_s_Thesis.pdf)
\ No newline at end of file
This diff is collapsed.
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment