User Tools

Site Tools


lego_rip_simulation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
lego_rip_simulation [2017/02/27 10:24] joaomatoslego_rip_simulation [2017/02/27 10:39] (current) joaomatos
Line 3: Line 3:
 Follow this simple tutorial to learn how to export your Lego assemblies using SolidWorks to Simulink. Simulink is a powerfull tool to develop and test your controller before you go to the actual project and start coding.  Follow this simple tutorial to learn how to export your Lego assemblies using SolidWorks to Simulink. Simulink is a powerfull tool to develop and test your controller before you go to the actual project and start coding. 
  
 +You can find a lot of useful things for this project under this kit: 
 +{{::rip_kit.rar| Kit for the RIP project}}
  
 +There is a **Matlab script** to run the LQR calculation and find the gains ( the derivation of the model is shown in the system modelling section). There is a folder including the **complete building** of the system . There is another folder that you will use to run the Simulink programs named **Only Sensors building**. There you will find Simulink programs to simulate only the balance , the swing-up and the balance , and a fuzzy logic controller.
  
 ---- ----
Line 10: Line 13:
 ==== How to export a SolidWorks Lego assembly into Simulink ==== ==== How to export a SolidWorks Lego assembly into Simulink ====
  
-You can get all the necessary .STL parts to build the RIP project on this file bellow. If you want the assembly already done, you can find inside the folder "only sensors building" named as “PendulumAssembly” +[[lego_rip_simulation_cad|How to export your SolidWorks model into Simulink]]
- +
-{{::rip_kit.rarKit for the RIP project}} +
- +
- +
- **Follow the following steps to export your Assembly from Solidworks to Simulink:** +
- +
-Download the latest Simscape Multibody Link Plug-in in the following link: +
-[[ https://www.mathworks.com/products/simmechanics/download_smlink_confirmation.html?elqsid=1486996771363&potential_use=Student | Link]] +
- +
-Follow these simple instructions on how to install a Plug-in if you don’t know how to. +
-[[https://www.mathworks.com/help/physmod/smlink/ug/installing-and-linking-simmechanics-link-software.html|Instructions]] +
- +
- +
-1-> If you did not make your assembly , Open the “RIP only Sensors building “ and open the “PendulumAssembly” file at SolidWorks. +
-Enable the SimMechanics Link add-in in SolidWorks: (on the top toolbar , click on the gear (add-ins) , scroll down and check the SimMechanics Link box) +
- +
-{{ :rip_sim1.jpg |}}+
  
  
 ---- ----
  
-2-> When you are done with your assembly, you can export it in the format to be used by Simulink following : (Tools > SimMechanics Link > Export > SimMechanics Second Generation ). Save the xml file with the SAME name as the assembly name! 
  
-{{ :rip_sim2.jpg |}}+==== Videos  ====
  
 +**You can use SolidWorks to build a virtual model of your project and get important data as Center of Gravity, Inertia and mass of your assembly.**
  
-----+{{youtube>smo7Lrn5lBA?medium}}
  
-3-> Now open your Matlab , make sure that you are in the correct folder on the matlab path and in the command window typesmimport (‘YourAssemblyName’) and hit enter. (change the argument to the name of your assembly). A simulink window should open and you can see the model of your system .+**You can test if you did the LQR calculation right simulating only the pendulum balance:**
  
-{{ :rip_sim3.jpg |}} +{{youtube>zrT3VJjqWLY?medium}}
- +
----- +
- +
- +
-4-> Hit the play button and see if the dynamics and the parts of your system are all correct. +
- +
-{{ :rip_sim4.jpg |}} +
- +
- +
----- +
- +
-5-If your model seems to be running with some lag, try to change the model parameters to the following : (decreasing the step size – set max step size to 0.001-  make the simulation to run smoother , but it will take more time to compile it. Also changing the Solver to ode23t will make it to compile faster) +
- +
-{{ :rip_sim5.jpg |}} +
- +
- +
-----+
  
-6-> The basics that you should know to start developing your control strategy is in the joints blocks. Double click any joint block (If you did everything correctly you should see only two revolute joints , one for the “motor” and one for the pendulum ).+**You can test your swing-up algorithms and test your switch controller to see if the integration of your swing-up controller and the balance controller will work:**
  
-{{ :rip_sim6.jpg |}}+{{youtube>J-HCzT4iq_I?medium}}
  
-**Under State Targets**, you can set the intitial position and the velocity that this joint will be at the beginning of the simulation. PS* try to save your assembly before you export to Simulink with the pendulum in the correct position – on the top or on the bottom position - otherwise 0/180 degrees will not correspond to the top and bottom position correctly .  +**Also you can try new ways to control the balance like using fuzzy logic controllers:**
  
-** Under Internal Mechanics** , you can set some parameters to the joints like stiffness and damping, it will make it to be more realistic - if you set everything to 0 you will have the ideal conditional of no friction.+{{youtube>B9Iyk7TM0Vs?medium}}
  
  
-**Under Actuation** ,you can enable/disable the input of some torque on this joint. Latter on the controlled version , we will enable torque input on the “motor” joint , to simulate the torque that the motor give to the system (provided by the LQR calculation). 
-Under Sensing , is where you can enable the option to get the “real time” data from this joint . For our controlled version , we will enable position and velocity data. 
  
-With this briefly explanation you should be able to wire some blocks and make your control scheme and see if it works. I will provide my block diagram with the controller using PD provided by the LQR calculation. There is a lot of ways to construct your block diagram , use your creativity!   
  
  
lego_rip_simulation.1488219843.txt.gz · Last modified: by joaomatos