User Tools

Site Tools


4bar

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
4bar [2017/08/04 18:56] – [MATLAB Program] rebeccacao4bar [2017/08/23 08:17] (current) – [Coding in NXC to Read Sensor Data] rebeccacao
Line 1: Line 1:
 ====== How to Analyze a 4 Bar Linkage with LEGOs, Solidworks, MATLAB, Gyroscope, and Accelerometer ====== ====== How to Analyze a 4 Bar Linkage with LEGOs, Solidworks, MATLAB, Gyroscope, and Accelerometer ======
-**Author:** <Xinke (Rebecca) Cao> Email: <[email protected]+**Author:** <Xinke (Rebecca) Cao>  
 +\\ 
 +**Email:** <[email protected]
 \\ \\
 **Date:** Last modified on <07/27/2017> **Date:** Last modified on <07/27/2017>
Line 65: Line 67:
 \\ \\
  
-===== Analyzing the 4-Bar Mechanism By Hand =====+===== Analyzing the 4-Bar Mechanism =====
 See the picture below for a 4-bar mechanism: See the picture below for a 4-bar mechanism:
 \\ \\
Line 90: Line 92:
 ===== MATLAB Program ===== ===== MATLAB Program =====
 Please see [[4bMATLAB|this]] page. Please see [[4bMATLAB|this]] page.
 +\\
 +Please download the MATLAB model of the 4-bar mechanism [[https://drive.google.com/open?id=0B4prKwfGK8d2Z0FIN2Nwb3NjZ1U|here]].
 \\ \\
 This is divided so that the readers won't have to scroll up and down constantly due to the large amount of information on this page. This is divided so that the readers won't have to scroll up and down constantly due to the large amount of information on this page.
Line 95: Line 99:
 \\ \\
 ===== Modeling in Solidworks ===== ===== Modeling in Solidworks =====
-Since all of the parts can be found in [[http://www.education.rec.ri.cmu.edu/downloads/lego/solidmodel/ NXT Parts Library]], the only knowledge of Solidworks needed is the knowledge of knowing how to assemble the parts.+Please see [[4bSW|this]] page.
 \\ \\
-The instructions can be found in [[https://www.youtube.com/edit?o=U&video_id=DkepJ3yaSwo |this]] YouTube link. +Please download the Solidworks assembly [[https://drive.google.com/open?id=0B4prKwfGK8d2Nm56al8yc0Y0MTQ|here]].
- +
- +
-==== Sec 1: Motion Analysis in Solidworks ==== +
-After you have successfully assembled the parts, you can start motion analysis in Solidworks, where the instructions can be found in [[https://www.youtube.com/edit?o=U&video_id=KvBB7KIOGFA|this]] Youtube link. +
-\\ +
- +
-==== Sec 2: Results from Solidworks ==== +
-The results for the linear motion of node "a1" is shown: +
-{{ :xinke:4b:solidworks_linear_a1.png?500 |}} +
-\\ +
-The results for the linear motion of node "b1" is shown: +
-{{ :xinke:4b:solidworks_linear_b1.png?500 |}} +
-\\ +
-The results for the angular motion of bar "V" is shown: +
-{{ :xinke:4b:solidworks_alpha_data.png?500 |}} +
-\\ +
-The results for the angular motion of bar "U" is shown: +
-{{ :xinke:4b:solidworks_gamma_data.png?500 |}} +
-\\ +
-\\ +
- +
-Although the results from Solidworks and MATLAB has the same trend and the same overall shape, there is an apparent vertical shrink in the results from Solidworks. In addition, the first derivative terms are worse than the original terms, and the second derivative terms are the worst out of the three.  +
-\\ +
-\\ +
- +
-Since the MATLAB code is based on numerical methods, where there isn't as many decimal places saved in the file compared to Solidworks, rounding and error propagation can present itself as the MATLAB code runs on. For example, in the MATLAB code, there is a zero tolerance, meaning, the two displacement equations derived above doesn't have to add up to zero, but it has to be less than 4e-4. This already presents an approximation of the initial state of the 4 bar mechanism. However, the zero tolerance value is needed, because the lengths and the angles measured from Solidworks are all rounded values. +
-\\ +
-\\ +
- +
-Furthermore, the results from the velocity equations are dependent on the displacement equations and the results from the acceleration equations are dependent on both the displacement and velocity equations. Therefore, the error from the solutions of the displacement equations will propagate onto the solutions of the velocity equations, then the acceleration equations+
 \\ \\
 +Please download the excel file that contains all of the Solidworks data [[https://drive.google.com/open?id=0B4prKwfGK8d2TTBmdElwMExRNHM|here]].
 \\ \\
 \\ \\
Line 218: Line 193:
 \\ \\
 --> -->
-====== Coding in NXC to Read Sensor Data ======+===== Coding in NXC to Read Sensor Data ===== 
 +Please download the [[https://drive.google.com/open?id=0B4prKwfGK8d2SkRGZ3JIMGZqUjA|code]]. 
 +\\
 First, the mechanism with the sensors are placed on a flat surface, a function is run, as seen from [[https://www.youtube.com/watch?v=WCTdTN7qPOg|this]] video that will calibrate the gyrosensor to read zero on the chosen surface.  First, the mechanism with the sensors are placed on a flat surface, a function is run, as seen from [[https://www.youtube.com/watch?v=WCTdTN7qPOg|this]] video that will calibrate the gyrosensor to read zero on the chosen surface. 
 \\ \\
Line 249: Line 226:
 \\ \\
 ===== Accelerometer and Gyroscope for the 4 Bar Mechanism ===== ===== Accelerometer and Gyroscope for the 4 Bar Mechanism =====
-==== Sec 1: Connecting Accelerometer to the LEGO Bars ==== 
-** Constructing the Sensors Mounts ** 
-\\ 
-{{:xinke:4b:s1.jpg?200 |}} 
-{{:xinke:4b:s2.jpg?200 |}} 
-{{:xinke:4b:s3.jpg?200 |}} 
-{{:xinke:4b:s4.jpg?200 |}} 
-{{:xinke:4b:s5.jpg?200 |}} 
-{{:xinke:4b:s6.jpg?200 |}} 
-{{:xinke:4b:s7.jpg?200 |}} 
-{{:xinke:4b:s8.jpg?200 |}} 
-{{:xinke:4b:s9.jpg?200 |}} 
-{{:xinke:4b:s10.jpg?200 |}} 
-{{:xinke:4b:s11.jpg?200 |}} 
-{{:xinke:4b:s12.jpg?200 |}} 
-{{:xinke:4b:s13.jpg?200 |}} 
-{{:xinke:4b:s14.jpg?200 |}} 
-{{:xinke:4b:s15.jpg?200 |}} 
-{{:xinke:4b:s16.jpg?200 |}} 
-{{:xinke:4b:s17.jpg?200 |}} 
-{{:xinke:4b:s18.jpg?200 |}} 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
  
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-** Attaching the 4 Bar to the NXT Motor ** 
-\\ 
-{{:xinke:w1.jpg?200 |}} 
-{{:xinke:w2.jpg?200 |}} 
-{{:xinke:w3.jpg?200 |}} 
-{{:xinke:w4.jpg?200 |}} 
-{{:xinke:w5.jpg?200 |}} 
-{{:xinke:w6.jpg?200 |}} 
-{{:xinke:w7.jpg?200 |}} 
-{{:xinke:w8.jpg?200 |}} 
-{{:xinke:w9.jpg?200 |}} 
-{{:xinke:w10.jpg?200 |}} 
-{{:xinke:w12.jpg?200 |}} 
-{{:xinke:w13.jpg?200 |}} 
-{{:xinke:w14.jpg?200 |}} 
-{{:xinke:w15.jpg?200 |}} 
-{{:xinke:w16.jpg?200 |}} 
-{{:xinke:w17.jpg?200 |}} 
-{{:xinke:w18.jpg?200 |}} 
-{{:xinke:w19.jpg?200 |}} 
-{{:xinke:w20.jpg?200 |}} 
-{{:xinke:w21.jpg?200 |}} 
-{{:xinke:w22.jpg?200 |}} 
-{{:xinke:w23.jpg?200 |}} 
-{{:xinke:w24.jpg?200 |}} 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
  
-\\ +==== Sec 1: Connecting Sensors to the LEGO Bars ==== 
-\\ +The hardware construction guide can be found on [[4bConstru|this]] page.
-\\ +
-\\ +
-\\ +
-\\ +
-\\ +
-\\ +
-\\ +
-\\ +
-\\ +
-\\+
 \\ \\
 \\ \\
  
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
  
 +==== Sec 2: Realistic Motor Data ====
 +The results for measuring the motor speed can be found on [[4bmotor|this]] page.
 \\ \\
 \\ \\
 \\ \\
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
- 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-** Attaching the Sensors to Bar "W" ** 
-\\ 
-The purpose of attaching to bar "W" is to measure the state values of node "a1." 
-\\ 
-{{:xinke:4b:r1.jpg?200 |}} 
-{{:xinke:4b:r2.jpg?200 |}} 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
- 
-** Attaching the Sensors to Bar "U" ** 
-\\ 
-The purpose of attaching to bar "U" is to measure the state values of node "b1." 
-\\ 
-{{:xinke:4b:l1.jpg?200 |}} 
-{{:xinke:4b:l2.jpg?200 |}} 
-{{:xinke:4b:l3.jpg?200 |}} 
-\\ 
-\\ 
- 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
-\\ 
- 
- 
-==== Sec 2: Realistic Motor Data ==== 
-To ensure that the model in MATLAB matches the realistic model, the motor data from the NXT are collected such that the steady state rotational speed of the NXT motor will be known and will be used as an input to the MATLAB code.  
- 
-{{ :xinke:4b:screen_shot_2017-07-26_at_1.12.38_pm.png?300 }} 
-\\ 
-As shown on the figure above, the steady state rotational speed of the NXT motor with the brick used for the experiment is roughly 89 RPM. 
- 
 \\ \\
 ==== Sec 3: Data Processing in MATLAB ==== ==== Sec 3: Data Processing in MATLAB ====
Line 537: Line 305:
 \\ \\
 \\ \\
-==== Sec 5: MATLAB Program ====+==== Sec 4: MATLAB Program ==== 
 +Please download the data and the filtering program for node "a1" [[https://drive.google.com/open?id=0B4prKwfGK8d2RURFSjNEOFNfQ1U|here]]. 
 +\\ 
 +Please download the data and the filtering program for node "b1" [[https://drive.google.com/open?id=0B4prKwfGK8d2VjJ5Tk95N3lnX1k|here]]. 
 +\\
 First, I need to read data from a .csv file and store it in MATLAB. First, I need to read data from a .csv file and store it in MATLAB.
   M = csvread('Acc.csv',1,0);   M = csvread('Acc.csv',1,0);
Line 602: Line 374:
 \\ \\
 \\ \\
-==== Sec 4Results from MATLAB ==== +==== Sec 5Filtered Data ==== 
- +The resultant filtered data from MATLAB can be found on [[4bdata|this]] page.
- +
-** For Node a1 ** +
-{{ :xinke:a1.png?500 |}} +
-\\ +
-{{ :xinke:a2.png?500 |}} +
-\\ +
-{{ :xinke:a3.png?500 |}} +
-\\ +
-{{ :xinke:a4.png?500 |}} +
-\\ +
-{{ :xinke:a5.png?500 |}} +
-\\ +
-\\ +
-** For Node b1 **    +
-\\ +
-{{ :xinke:4b:b1.png?500 |}} +
-\\ +
-{{ :xinke:4b:b2.png?500 |}} +
-\\ +
-{{ :xinke:4b:b3.png?500 |}} +
-\\ +
-{{ :xinke:4b:b4.png?500 |}} +
-\\ +
-{{ :xinke:4b:b5.png?500 |}} +
-\\ +
-\\ +
-\\ +
-\\ +
-** Causes for Error ** +
-\\ +
-Hardware wise, the errors are caused by the oscillation of the sensors when the 4 bar linkage is moving to obtain data. The frictions in the pins will also prevent the experimental results to deviate from the theoretical results from MATLAB, where MATLAB is based purely on kinematics (which doesn't consider forces, or how things started to move).  +
-Software wise, the errors are from the error propagation in rounding and smoothing of the data from the sensor. The sensor themselves have a lot of noise (especially accelerometer) and the gyroscope sensor is known to drift. Although all of these problems was corrected to a certain extend in the MATLAB code when I processed the data. But without prior knowledge on data processing, the filters are definitely not perfect+
 \\ \\
 \\ \\
 \\ \\
 \\ \\
 +
 ===== Final Words ===== ===== Final Words =====
  
4bar.1501898191.txt.gz · Last modified: 2017/08/04 18:56 by rebeccacao