Today I am introducing “Four bar mechanism made of paper”

The four-bar mechanism is very useful in the design of mechanical components. The best way to understand four-bar mechanisms is to build it by yourself. Here, I am introducing how to make a four-bar mechanism with only a paper, screws and nuts. It is very easy to follow.

If you want to know the theories of four-bar mechanisms, see the wiki. Here

1. What you need to prepare

One sheet of paper, four screws and nuts, and a nail (or any sharp one)

2. Procedure

Prepare a sheet of paper

Tear the paper like this

Fold two times

Write numbers like the picture

Make holes

Now you should have four bars with eight holes

Connect bars. Here the sequence is very important. If you do not follow this sequence the linkage will not rotate because interference with other linkages.

Connect all

Hold (4) and rotate (1)

This is the result.

This is a Grashof mechanism.

So far, I have introduced how to build a four-bar mechanism made of paper. I hope that this post helps your projects. If you have any question, please leave a reply.

Hi, Today I am sharing ADS7813 ADS7812 Arduino Code. <Download>

1. ADS7813 ADS7812: Low-Power, Serial 16/12-Bit Sampling ANALOG-TO-DIGITAL CONVERTER

ADS7813/ADS7812 is a general purpose ADC made by Texas Instrument, and it is pretty easy to operate through SPI. You can see the datasheet from here.

2. Connections

This is the electric connection diagram that I used for my setup. I have used ADS7813 but all configurations are same with ADS7812. Just only difference is that the resolution of ADS7812 is 12bit .

This electric connection is actually a reference connection provided by TI datasheet. With this connection, I made the Arduino code like this.

I hope this Matlab code for numerical Hessian matrix helps your projects

This Matlab code is based on another Matlab function, NumJacob, which calculates a numerical Jacobian matrix. If you are interested in this, visit here.

If you want to know the theory on Hessian matrix, please read this Wiki.

I acknowledge that this code is originally made by Parviz Khavari, a visitor of this blog, and I modified to post here.

In this post, I am sharing how to compile a C code generated by Matlab C coder with GCC compiler. Let me explain with an example.

1. Generating a C code with Matlab C coder.

I will use a very simple Matlab code, and the below is the code

function y = add_coder(a,b) y=a+b

With the Matlab C coder, let’s auto-generate the C code. You have to specify the types of variables and some other options. If you just read the dialog box, it might not be difficult.

As a result, you can see this kind of result. If your Matlab version is not 2015, it might be little different, but its big flow is almost same.

2. Let’s compile the code generated by Matlab C coder

This is my main.cpp file that is modified from the auto-generated main.cpp by Matlab C coder

#include "rt_nonfinite.h"
#include "add_coder.h"
#include "add_coder_terminate.h"
#include "add_coder_initialize.h"
#include "stdio.h"
int main()
{
/* Initialize the application.
You do not need to do this more than one time. */
add_coder_initialize();
/* Invoke the entry-point functions.
You can call entry-point functions multiple times. */
double a=10;
double b=20.0;
double y;
y = add_coder(a, b);
printf("y: %lf\n",y);
/* Terminate the application.
You do not need to do this more than one time. */
add_coder_terminate();
return 0;
}

I located this main.cpp file with other all codes.

Now let’s compile all codes. Just compile main.cpp with all other cpp files. like this.

I am attaching all related files as a zip file. <Download>

I am sharing a Matlab code to get a vertex angle from three points.

This is the code, and you can download this one from here <Download>

function [ang] = get_vertex_ang_from_three_points(p0,p1,p2)

% get the vertex angle at p0 from three points p0,p1,p2 % p0, p1,p2 are two dim vector % %%% example % p0=[0;0];p1=[1;0];p2=[0;1]; % get_vertex_ang_from_three_points(p0,p1,p2) % answer = 1.57 (45 deg) %%%

v1 = p1-p0; v2 = p2-p0; ang = acos(v1′v2/(norm(v1)norm(v2)));

It is very easy to use. you can get the vertex angle from three points, It is written in Matlab code

In this post, I will explain how to derive a dynamic equation with Lagrange Equation by MATLAB with Examples. As an example, I will derive a dynamic model of a three-DOF arm manipulator (or triple pendulum). Of course you may get a dynamic model for a two-DOF arm manipulator by simply removing several lines. I am attaching demo codes for both two and three DOF arm manipulators.

If you know all theories and necessary skills and if you just want source code, you can just download from here.

In the attached file, “Symb_Development_3DOF.m” generates a dynamic model. “main_sim_three_dof_arm.m” runs a simulation. You may get a result like this.

1. Example system

Let’s suppose a three DOF arm manipulator shown in the below figure. I am assuming all of masses (M1, M2, M3) exist at the end of links for simplicity. Three actuators exist at each joint, and directly actuate the torques (u1,u2,u3). The manipulator kinematics is governed by three joint angles (q1, q2, q3).

three DOF arm manipulator

2. Theoretical Background

We will get a dynamic equation of this system by using Lagrangian mechanics. If you do not have a background knowledge of Lagrangian mechanics, please refer here.

The general dynamic equation is obtained by

Where, T is the total kinetic energy, V is the total potential energy of the system. where is the generalized force, t is time, is the generalized coordinates, is the generalized velocity. For the example of three-DOF arm manipulator problem, is the torque at the j-th joint, is the angle of the j-th joint, is the angular velocity of the j-th joint.

3. Using Matlab symbolic toolbox

First, let’s define the symbols.

I am using x to represent q, xd for , xdd for L is the length of each link. u is the torque of each joint. g is the gravity constant.

In the attached file, “Symb_Development_3DOF.m” generates a dynamic model. “main_sim_three_dof_arm.m” runs a simulation. Then, you can get this result.

So far, I have explained how to derive a Lagrange Equation by MATLAB with Examples.I hope that this post helps your project and save your time. Please leave a message if you have any question.

Update on 02/21/2016

I updated some code and posting about typo. “simple” -> “simplify” There is no function “simple” Now all programs are running well.