# Pneumatic Inverted Pendulum

## Construction

### Mechanical structure

Compressed air comes from air compressor and goes in the proportional valve. Coming out from the proportional valve, there are two branches of air flow (one is compressor air, the other one is exhausted air) which connect to the air cylinder (pneumatic actuator). The pneumatic actuator connects to a cart (the aluminum box) where the pendulum is attached, and underneath the cart lies the carrier, which guides the cart along straight line. The rotational encoder is inside the cart, and its shaft is fastened throught the cart. The pendulum is attached to the shaft and is able to rotate 360 degrees. At the back side of the cart, a linear encoder is attached. For more detail please refer to VIDEO 1.

Note: the flow control valve is unused.

### Control circuit board

Arduino is used as the data acquisition board and control unit. Signals from the linear encoder and rotational encoder are acquired into the Arduino, and then an output voltage is calculated, which will then control the proportional valve through a Digital Analog Converter and Operational Amplifier. The circuit schematic diagram is shown below:

Note that the “black green red yellow” in linear encoder diagram are just merely the color of wires. You might have different ones, but after watching VIDEO 3, it should be clear on how to use a linear encoder–the connection and programming are similar to rotational encoder. The operational amplifier should be connected to the +12 and -12 power supplies (not depicted). As noted above, if using separate power supplies, they must share a common ground.

### Rotational encoder

The rotational encoder used in this project is S1-1250-250-I-N-D (more detail available in TABLE 1).

This encoder has 1250 counts per 360 degree (2*pi radians). Therefore, we have:

1250/(2*pi) = angle_count/alpha
Which gives us:

And the angular velocity could be estimated via

Alternatively, a moving average can be utilized, in which an array of the last x average values are stored, and the average of them is taken. This is more computationally heavy, but may filter out some of the noise.

When you rotate the encoder’s shaft, there will be signals from Channels A and B. Channels A and B are square waves with the same amplitude and frequency, but offset by 90 degrees. Note that when rotating in a different direction at the rising edge of channel A, channel B signal will be different–say, if rotating clockwise results a low valve of channel B at the rising edge of channel A; then when rotating counterclockwise, at the rising edge of channel A, channel B will give a high valve.

### Linear encoder

Inside the black box of the linear encoder, there is a rotational encoder. The black box travels along a track. Therefore, linear encoder and rotational encoder are the same thing–there are also channel A and B in linear encoder, and their signals are the same as rotational encoder. The stroke of air cylinder is 0.1512m, and the linear encoder results 2993 counts travelling that distance. So, we have:

2993/0.1512 = pos_count/x_c
Which gives us:

x_c = 0.0000505*pos_count (unit: meter)
And we could estimate cart velocity using

### Digital-analog converter and operational amplifier

The DAC in used is DAC0808, and the operational amplifier in used is LM324. Basically what Digital Analog Converter (DAC) does is: given a digital signal from Arduino, DAC outputs an analog signal, which is used to control proportional valve. But because the DAC’s output is current and has very little power, we need an amplifier to drive the proportional valve. DAC0808 is an 8-bit DAC, and we give VREF = 12V. If we want a 6.6V output, here is how to calculate the digital value for it:

For more detail: Pneumatic Inverted Pendulum

#### This Post / Project can also be found using search terms:

• arduino libreria dac0808
• dac0808 circuit
• inverted pendulum control using arduino
• Uno with dac 0808