Automatic Pneumatic Cannon. Portable and Arduino Powered.
by gabbapeople in Circuits > Arduino
6163 Views, 22 Favorites, 0 Comments
Automatic Pneumatic Cannon. Portable and Arduino Powered.
Hi all!
This is the instruction to assemble a portable pneumatic cannon. The idea was to create a cannon that can shoot different stuff. I set a few main goals. So, what my cannon should be:
- Automatic. In order not to compress air manually with a hand or foot pump;
- Portable. In order not to be dependable from home electricity power grid, so I can take it outside;
- Interactive. I thought that it is great to attach a touchscreen display to a pneumatic system;
- Cool looking. The cannon should look like some kind of a sci-fi weapon from outer space =).
Next, I'll describe the whole process and tell you how to create such a device, and what components do you need.
Please notice, I wrote this instruction exclusively for the components that I used or for their analogs. Most likely your parts will be different from mine. In this case, you will have to edit the source files to make the assembly suitable for you and finalize the project yourself.
Instruction chapters:
- Video Review.
- Components. Pneumatics.
- Components. Couplings, Hardware, and Consumables.
- Design. Pneumatics.
- Components. Electronics.
- Preparation. CNC Cutting.
- Assembling. Pump, Solenoid, and Pneumatic Housing.
- Assembling. Handle, Air Tank, and Barrel.
- Assembling. Electronics, Valves and Gauges.
- Assembling. Wiring.
- Programming. 4D Workshop 4 IDE.
- Programming. XOD IDE.
- Programming.
Video Review.
Components. Pneumatics.
Ok, let's begin from the pneumatic system design.
Air pump.
To compress the air automatically, I used a portable car air pump (Pic. 1). Such pumps work from the 12V DC electricity car grid and are capable of pumping air pressure up to 8 bars or about 116 psi. Mine one was from a trunk, but I'm almost sure that this one is a complete analogue.
From such car kit, you only need a compressor in its native metal case. Therefore, get rid of unnecessary pneumatic exits (for example, for a pressure gauge), remove the side plastic cover, the carrying handle, and the on/off switch.
All these things only take place, so you do not need them anymore. Leave only the compressor itself with two wires sticking out of its case. A flexible hose can also be left if you do not want to bother with the new one.
Usually, such compressors have a pneumatic output with the G1/4" or G1/8" pipe inch thread.
Air tank.
To store the compressed air, you need a tank. The maximum pressure value in the system depends on the maximum pressure generated by the compressor. So in my case, it does not exceed 116 psi. This pressure value isn't high, but it excludes the use of plastic or glass containers for storing air. Use metal cylinders. Most of them have a margin of safety that is more than enough for such tasks.
Empty air tanks are available in stores specialized in car suspension systems. This one is an example:
1 x Viking Horns V1003ATK, 1.5 Gallon (5.6 Liter) All Metal Air Tank ≈ 46$;
I eased my task and took the tank from the 5-liter powder fire extinguisher. Yep, its not a joke (Pic. 2). The air tank from the extinguisher came cheaper than the purchased one. I exhausted the 5 -liter BC/ABC dry chemical powder fire extinguisher. I couldn't find an exact product reference, so my one looked something like this:
1 x 5kg BC/ABC dry chemical powder fire fighting extinguisher with store gas pressure ≈ 10$;
After disassembling and cleaning up the powder lees, I got my cylinder (Pic. 3).
So, my 5-liter tank looks very usual except for one detail. The extinguisher that I used is ISO standardized; that's why the tank has the M30x1.5 metric thread on its inlet hole (Pic. 4). At this step, I faced a problem. Pneumatic connections usually have inch tube threads, and it is difficult to add such metric thread cylinder to the pneumatic system.
Optional.
In order not to bother with a bunch of adapters and fittings I decided to make a G1" to M30x1.5 tube fitting by myself (Pic. 5, Pic. 6). This part is very optional, and you can skip it if your air tank can be linked with the system easily. I attached a CAD drawing of my fitting for those who can face the same problem.
Solenoid valve.
To release the air accumulated in the cylinder a valve is needed. In order not to open the valve manually but automatically the solenoid valve is the best choice. I used this one (Pic. 7):
1 x S1010 (TORK-GP) GENERAL PURPOSE SOLENOID VALVE, NORMALLY CLOSED ≈ 59$;
I used a normally closed valve to apply current on it only when fired and not waste battery power. The valve DN 25 and its permissible pressure is 16 bar, which is twice more the pressure in my system. This valve has a coupling connection female G1" - female G1".
Safety blow off valve.
This valve is operated manually (Pic. 8).
1 x 1/4" NPT 165 PSI Air Compressor Safety Relief Pressure Valve, Tank Pop Off ≈ 8$;
It is used to exhaust the pressure from the system in some critical situations, like leakage or failure of electronics. It is also very convenient for setting up and checking the pneumatic system when connecting electronics. You can just pull the ring to relieve the pressure. The connection of my valve is male G1/4".
Pressure gauge.
One aneroid pressure gauge to monitor pressure in the system when electronics are off. Almost any pneumatic one fits, for example:
1 x Performance Tool 0-200 PSI Air Gauge for Air Tank Accessory W10055 ≈ 6$;
My with male G1/4" tube connection is in the picture (Pic. 9).
Check valve.
A check valve is needed to prevent the compressed air from coming back into the pump. The small pneumatic check valve is ok. Here is an example:
1 x Midwest Control M2525 MPT In-Line Check Valve, 250 psi Max Pressure, 1/4" ≈ 15$;
My valve has male G1/4" - male G1/4" thread connection (Pic. 10).
Pressure transmitter.
A pressure transmitter or pressure sensor is a device for pressure measurement of gases or liquids. A pressure transmitter usually acts as a transducer. It generates an electrical signal as a function of the pressure imposed. In this instructable, you need such transmitter to control the air pressure automatically by electronics. I bought this (Pic. 11):
Exactly this one has the male G1/4" connection, acceptable pressure, and powers from 5V DC. The last feature makes this sensor ideal for connecting to Arduino like micro-controllers.
Downloads
Components. Couplings, Hardware, and Сonsumables.
Metal fittings and couplings.
Ok, to combine all pneumatic stuff you need some tube fittings and couplings (Pic. 1). I can not specify the exact product links to of them, but I'm sure you can find them in the hardware store nearest to you.
I used metal fittings from the list:
- 1 x 3-Way Y Type Connector G1/4" BSPP Female-Female-Female ≈ 2$;
- 1 x 4-Way Connector G1/4" BSPP Male-Female-Female-Female ≈ 3$;
- 1 x 3-Way Connector G1" BSPP Male-Male-Male ≈ 3$;
- 1 x Fitting Adapter Female G1" to Male G1/2" ≈ 2$;
- 1 x Fitting Adapter Female G1/2" to Male G1/4" ≈ 2$;
- 1 x Fitting Union Male G1" to G1" ≈ 3$;
Air tank fitting.
1 x Fitting Adapter Female G1" to Male M30x1.5.
You need one more coupling, and it depends on the specific air cylinder that you will use. I manufactured mine according to the drawing from the previous step of this instruction. You should pick up fitting under your air tank yourself. If your air tank has the same thread M30x1.5, you can make coupling according to my drawing.
PVC Sewer pipe.
This pipe is a barrel of your cannon. Choose your diameter and length of the tube, but keep in mind that the larger the diameter, the weaker the shot. I took the DN50 (2") pipe with the 500mm length (Pic. 2).
Here is an example:
1 x Charlotte Pipe 2-in x 20-ft 280 Schedule 40 PVC Pipe
Compression fitting.
This part is to link the 2" PVC pipe with the G1" metal pneumatic system. I used the compression coupling from DN50 pipe to female G1,1/2" thread (Pic. 3), and the male G1,1/2" to female G1" adapter (Pic. 4).
The examples:
1 x Compressed air Fitting Piping System Air Compressor Connections Female Straight DN 50G11/2 ≈ 15$;
Pneumatic hose.
Also, you need a flexible hose to link the air compressor with the pneumatic system (Pic. 5). The tube should have 1/4 NPT or G1/4" threads on both ends. It's better to buy the one made from steel one and not too long. Something like this is ok:
1 x Vixen Horns Stainless Steel Air Compressor Braided Leader Hose 1/4" NPT Male to 1/4" NPT ≈ 13$;
Some of such hoses may already have a check valve installed.
Fasteners.
Screws:
- Screw M3 (DIN 912 / ISO 4762) 10mm length - 10 pieces;
- Screw M3 (DIN 912 / ISO 4762) 20mm length - 20 pieces;
- Screw M3 (DIN 912 / ISO 4762) 25mm length - 21 pieces;
- Screw M3 (DIN 912 / ISO 4762) 30mm length - 8 pieces;
Nuts:
- Hex nut M3 (DIN 934 / DIN 985) - 55 pieces;
Washers:
- Washer M3 (DIN 125) - 75 pieces;
Standoffs:
- PCB hex standoff M3 Male-Female 24-25mm length - 4 pieces;
- PCB hex standoff M3 Male-Female 14mm length - 10 pieces;
Corner brackets.
You need two 30x30 mm metal corner brackets to attach the electronics plate. All this stuff can be easily found in a local hardware store.
Here is an example:
1 x Hulless Shelf Bracket 30 x 30mm Corner Brace Joint Bracket Fastener 24 pcs
Pneumatic tube sealant.
There are many pneumatic connections in this project. For the system to hold the pressure, all its couplings must be very tight. For sealing, I used a special anaerobic sealant for pneumatics. I used Vibra-tite 446 (Pic. 6). Red color means very fast solidification. My advice If you are going to use the same one, then tighten the thread quickly and in the desired position. It will be challenging to Unscrew it after.
1 x Vibra-Tite 446 Refrigerant Sealant – High Pressure Thread Sealant ≈ 30-40$;
Design. Pneumatics.
Look at the scheme above. It'll help you to figure out the principle.
The idea is to compress the air into the system by applying the 12V signal to the pump. When the air fills the system (green arrows in the scheme), the pressure starts to rise.
The pressure gauge measures and display the current pressure, and the pneumatic transmitter sends a proportional signal to the microcontroller. When the pressure in the system reaches the value specified by the microcontroller, the pump shuts down, and the pressure increase stops.
After this, you can exhaust the compressed air manually by pulling the blow-off valve ring, or you can make a shot (red arrows in the scheme).
If you apply the 24V signal to the coil, the solenoid valve momently opens and releases the compressed air at a very high speed due to the large inner diameter. So that the air flow can push the ammo in a barrel and by this makes a shot.
Components. Electronics.
So what electronic components you need to operate and automate the whole thing?
Microcontroller.
A microcontroller is the brain of your gun. It reads the pressure from the sensor as well as controls the solenoid valve and pump. For such projects, Arduino is the best choice. Any kind of Arduino board is ok. I used the analog of an Arduino Mega board (Pic. 1).
1 x Arduino Uno ≈ 23$ or 1 x Arduino Mega 2560 ≈ 45$;
Of course, I understand that I don’t need such many input pins and I could save money. I chose the Mega solely because of several hardware UART interfaces so I can connect a touchscreen display. In addition, you can connect a bunch more fun electronics to your cannon.
Display Module.
As I wrote earlier, I wanted to add some interactivity to the cannon. For this, I installed a 3.2" touch-screen display (Pic. 2). On it, I show the digitized value of pressure in the system and set the maximum pressure value. I used a screen from the 4d Systems company and some other stuff for flashing it and connecting to Arduino.
1 x SK-gen4-32DT (Starter Kit) ≈ 79$;
For programming such displays there is 4D System Workshop development environment. But I tell you about it further.
Battery.
My cannon should be portable as I want to use it outside. This means that I need to take energy from somewhere to operate the valve, pump and Arduino controller.
The valve coil operates on 24V. Arduino board can be powered from 5 to 12V. The compressor of the pump is an automobile and is powered by 12V car electrical grid. Thus, the maximum voltage I need is 24V.
Also, while pumping the air, the compressor motor does a lot of work and consumes a considerable current. Furthermore, you need to apply a large current to the solenoid coil to overcome the air pressure on the plug of the valve.
For me, the solution is the use of Li-Po battery for radio-controlled machines. I bought a 6 cell battery (22.2V) with the 3300mAh capacity and 30C current (Pic. 3).
1 x LiPo 6S 22,2V 3300 30C ≈ 106$;
You can use any other battery or use a different type of cells. The main thing is to have enough current and voltage. Note, the more capacity is, the longer the cannon work without recharging.
DC-DC Voltage converter.
The Li-Po battery is 24V, and it feeds the solenoid valve. I need a DC-DC 24 to 12 voltage converter to power the Arduino board and the compressor. It should be powerful because the compressor consumes a considerable current. The way out of this situation was the purchase of a 30A car voltage converter (Pic. 4).
An example:
1 x DC 24v to DC 12v Step Down 30A 360W Heavy Duty Truck Car Power Supply ≈ 20$;
Heavy trucks have an onboard voltage of 24V. Therefore, to power 12V electronics such converters are used.
Relays.
You need a couple of relay modules to open and close circuits — the first one for compressor and the second for the solenoid valve. I used this ones:
2 x Relay (Troyka Module) ≈ 20$;
Buttons.
A couple of standard momentary buttons. The first one to turn on the compressor and The second to use as a trigger to make a shot.
2 x Simple Button (Troyka Module) ≈ 2$;
Leds.
A pair of leds to indicate the cannon state.
2 x Simple LED (Troyka Module) ≈ 4$;
Preparation. CNC Cutting.
To assemble all pneumatic and electronic components, I needed to make some case parts. I cut them with CNC-milling machine from 6 mm, and 4 mm plywood then painted them.
Drawings are in the attachment so you can customize them.
Next is a list of parts that you need to obtain to assemble a cannon according to this instruction. The list contains part names and minimum necessary quality.
- Handle - 6 mm - 3 pieces;
- Pin - 6 mm - 8 pieces;
- Arduino_plate - 4 mm - 1 piece;
- Pneumatic_plate_A1 - 6mm - 1 piece;
- Pneumatic_plate_A2 - 6mm - 1 piece;
- Pneumatic_plate_B1 - 6mm - 1 piece;
- Pneumatic_plate_B2 - 6mm - 1 piece;
Downloads
Assembling. Pump, Solenoid, and Pneumatic Housing.
The material list:
At first assembling step, you need to make a housing for pneumatic components, assemble all pipe fittings, install a solenoid valve and a compressor.
Electronics:
1. Heavy duty car air compressor - 1 piece;
CNC cutting:
2. Pneumatic_plate_A1 - 1 piece;
3. Pneumatic_plate_A2 - 1 piece;
4. Pneumatic_plate_B1 - 1 piece;
5. Pneumatic_plate_B2 - 1 piece;
Valves and tube fittings:
6. DN 25 S1010 (TORK-GP) Solenoid valve 1 piece;
7. 3-Way Connector G1" BSPP Male-Male-Male - 1 piece;
8. Fitting Adapter Female G1" to Male G1/2" - 1 piece;
9. Fitting Adapter Female G1/2" to Male G1/4" - 1 piece;
10. 4-Way Connector G1/4" BSPP Male-Female-Female-Female - 1 piece;
11. 3-Way Y Type Connector G1/4" BSPP Female-Female-Female - 1 piece;
12. Fitting Union Male G1" to G1" - 1 piece;
13. Fitting Adapter Female G1" to Male M30x1.5 - 1 piece;
Screws:
14. Screw M3 (DIN 912 / ISO 4762) 20mm length - 20 pieces; 15. Hex nut M3 (DIN 934 / DIN 985) - 16 pieces;
16. Washer M3 (DIN 125) - 36 pieces;
17. M4 Screws from the air compressor - 4 pieces;
Other:
18. PCB hex standoff M3 Male-Female 24-25mm length - 4 pieces;
Сonsumables:
19. Pneumatic tube sealant.
Assembling process:
Look at the sketches. They will help you with the assembly.
- Scheme 1. Take two CNC-cut panels B1 (pos. 4) and B2 (pos. 5) and connect them as shown in the picture. Fix them using M3 screws (pos. 14), nuts (pos. 15), and washers (pos. 16).
- Scheme 2. Take the assembled panels B1+B2 from scheme 1. Insert the G1" to M30x1.5 adapter (pos. 13) into the panel. The hexagon on the adapter should fit under the hexagonal groove in the panel. Therefore, the adapter is fixed and does not rotate. Then, install the compressor into the round slot on the other side of the assembled panels. The slot diameter has to be the same as the outside diameter of the compressor. Fix the compressor with the M4 screws (pos. 17) that came with the car pump.
- Scheme 3. Insert the 3-Way Connector G1" (pos. 7) into the solenoid valve (pos. 6). Then, screw the connector (pos. 7) into the G1" to M30x1.5 adapter (pos. 13). Fix all threads using pneumatic tube sealant (pos. 19). The free outlet of the 3-Way connector and the magnetic coil of the solenoid valve should be directed upwards as shown in the figure. The compressors body (pos. 1) can prevent you from rotating the connector so you can temporarily detach it from the assembly. Disassemble the side surface of the compressor. Replace four screws that secure the side cover to the M3 hex standoffs (pos. 18). Thread holes on compressors of this type are usually M3. If they are not, you need to tap the M3 or M4 thread holes in the compressor by yourself.
- Scheme 4.Take assembly 3. Screw the G1" to G1/2" adapter (pos. 8) to the assembly. Screw the G1/2" to G1/4" adapter (pos. 9) to the adapter (pos. 8). Then install the 4-Way G1/4" connector (pos. 10) and 3-Way Y Type G1/4" connector (pos. 11) as it is shown in the scheme. Fix all threads using pneumatic tube sealant (pos. 19).
- Scheme 5. Take two panels CNC-cut panels A1 (pos. 2) and A2 (pos. 3) and connect them as shown in the picture. Fix them using M3 screws (pos. 14), nuts (pos. 15), and washers (pos. 16).
- Scheme 6. Take the assembled plates A1+A2 from scheme 5. Insert the G1" to G1" fitting (pos. 12) into the panels. The hexagon on the fitting should fit under the hexagonal groove in the panel. Therefore, the fitting is fixed in the panel and does not rotate. Then, screw the panels A1+A2 with the fitting (pos. 12) inside to the solenoid valve from the assembly 4. Rotate A1+A2 panels until they are at the same angle as B1 and B2 panels. Secure the thread between the solenoid valve and the fitting (pos. 12) with a pneumatic tube sealant (pos. 19). Then, complete the assembly by screwing A1+A2 panels to the compressor using M3 screws (pos. 14).
Assembling. Handle, Air Tank, and Barrel.
The material list:
At this step, make a handle of the cannon, and install the pneumatic housing on it. Then add barrel and air tank.
1. Air tank - 1 piece;
CNC cutting:
2. Handle - 3 pieces;
3. Pin - 8 pieces;
Tubes and fittings:
4. DN50 PVC sewer pipe a half meter long;
5. PVC compression coupling from DN50 to G1";
Screws:
6. Screw M3 (DIN 912 / ISO 4762) 25mm length - 17 pieces;
7. Screw M3 (DIN 912 / ISO 4762) 30mm length - 8 pieces;
8. Hex nut M3 (DIN 934 / DIN 985) - 25 pieces;
9. Washer M3 (DIN 125) - 50 pieces;
Assembling process:
Look at the sketches. They will help you with the Assembly.
- Scheme 1. Take three CNC-cut handles (pos. 2) and combine them as shown in the picture. Fix them using M3 screws (pos. 6), nuts (pos. 8), and washers (pos. 9).
- Scheme 2. Take assembled handles from scheme 1. Insert eight CNC-cut pin parts (pos. 3) into the grooves.
- Scheme 3. Install the pneumatic housing from the previous step to the Assembly. The joint has a snap-fit design. Fix it on the handle using 8 M3 screws (pos. 7), nuts (pos. 8), and washers (pos. 9).
- Scheme 4.Take Assembly 3. Screw the Air tank (pos. 1) to the pneumatic housing. My air tank was sealed with a rubber ring which was installed on the fire extinguisher. But, depending on your air tank you may need to seal this joint with a sealant. Take the DN 50 PVC sewer pipe and insert it into the PVC compression coupling (pos. 5). It is the barrel of your cannon =). Screw the other side of the coupling to the pneumatic Assembly. You may not seal this thread.
Assembling. Electronics, Valves and Gauges.
The material list:
The last step is to install the remaining pneumatic components, valves, and pressure gauges. Also, assemble the electronics and the bracket for mounting Arduino and display.
Valves, hoses, and gauges:
1. Aneroid pressure gauge G1/4" - 1 piece;
2. Digital pressure transmitter G1/4" 5V - 1 piece;
3. Safety blow off valve G1/4" - 1 piece;
4. Check valve G1/4" to G1/4" - 1 piece;
5. Pneumatic hose about 40cm long;
CNC-cutting:
6. Arduino plate - 1 piece;
Electronics:
7. Car voltage DC-DC converter 24V to 12V - 1 piece;
8. Arduino Mega 2560 - 1 piece;
9. 4D Systems 32DT display module - 1 piece;
Screws:
10. Screw M3 (DIN 912 / ISO 4762) 10mm length - 10 pieces;
11. Screw M3 (DIN 912 / ISO 4762) 25mm length - 2 pieces;
12. Hex nut M3 (DIN 934 / DIN 985) - 12 pieces;
13. Washer M3 (DIN 125) - 4 pieces;
Other:
14. PCB hex standoff M3 Male-Female 14mm length - 8 pieces;
15. Metal corner 30x30mm - 2 pieces;
Variable components to mount DC-DC converter:
16. PCB hex standoff M3 Male-Female 14mm length - 2 pieces;
17. Washer M3 (DIN 125) - 4 pieces;
18. Screw M3 (DIN 912 / ISO 4762) 25mm length - 2 pieces;
19. Hex nut M3 (DIN 934 / DIN 985) - 2 pieces;
Сonsumables:
20. Pneumatic tube sealant;
Assembling process:
Look at the sketches. They will help you with the Assembly.
- Scheme 1. Screw the Check valve (pos. 4) and pressure transmitter (pos. 2) to the 4-Way Connector of the Assembly. Screw the Safety blow off valve (pos. 3) and Aneroid pressure gauge (pos. 1) to the 3-Way Y Type Connector. Seal all thread joints with a sealant.
- Scheme 2. Connect the check valve (pos. 4) to the compressor with a hose (pos. 5). There is usually a rubber ring on such tubes, but if not, use a sealant.
- Scheme 3. Mount the DC-DC voltage converter (pos. 7) to the Assembly. Such car voltage converters can have completely different sizes and connections, and it is unlikely that you will find precisely the same as mine. So figure out how to install it yourself. For my converter I prepared the two holes in the handle and fixed it using M3 standoffs (pos. 16), screws (pos. 18), washers (pos. 17), and nuts (pos. 19).
- Scheme 4.Take CNC-cut Arduino plate (pos. 6). Mount the Arduino Mega 2560 board (pos. 8) to the one side of the plate using four standoffs (pos.14), M3 screws (pos. 10), and nuts (pos. 12). Mount the 4D display module (pos. 9) to the other side of the plate (pos. 6) using four standoffs (pos.14), M3 screws (pos. 10), and nuts (pos. 12). Attach two 30x30mm metal corners (pos. 15) to the panel as shown. If the mounting holes on the corners you have do not match the ones on the panel, then drill them yourself.
- Scheme 5. Attach the assembled Arduino plate to the handle of the cannon. Fix it with M3 screws (pos. 11), washers (pos. 13), and nuts (pos. 12).
Assembling. Wiring.
Here, connect everything according to this diagram. The display module can be connected to any UART; I chose Serial 1. Don't forget the thickness of the wires. It is advisable to use thick cables to link the compressor and solenoid valve with the battery. Relays should be set to normally open.
Programming. 4D Workshop 4 IDE.
4D System Workshop is the UI development environment for the display used in this project. I won't tell you how to connect and flash the display. All this information can be found on the official website of the manufacturer. At this step, I tell you which widgets I used for the cannon UI.
I used a single Form0 (Pic. 1) and the following widgets:
- Angularmeter1 Pressure, Bar
This widget displays the current system pressure in bars.
- Angularmeter2 Pressure, Psi
This widget displays the current system pressure in Psi. The display doesn't operate floating point values. Thus it is impossible to know the exact pressure in bars for example if the pressure is in the range of 3 to 4 bar. The psi scale, in this case, is more informative.
- Rotaryswitch0
A rotary switch to set the maximum pressure in the system. I decided to make three valid values: 2, 4, and 6 bar.
- Strings0
The text field that reports that the controller has successfully changed the maximum pressure value.
- Statictext0 Spuit Cannon!
- Statictext1 Max pressure
- Userimages0
Are just for lulz.
Also, I attach the Workshop project for the display firmware. You might need it.
Downloads
Programming. XOD IDE.
XOD libraries.
To program Arduino controllers, I use the XOD visual programming environment. If you are new to electrical engineering or maybe you like to write simple programs for Arduino controllers like me, try XOD. It's the ideal instrument for fast device prototyping.
I've made an XOD library that contains the cannon program:
This library contains a program patch for the whole electronics and the node to operate the pressure transmitter.
Also, you need a few XOD libraries to be able operate 4D systems display modules:
This library contains nodes to operate basic 4D-ulcd widgets.
This library extends the capabilities of the previous one.
Process.
- Install the XOD IDE software on your computer.
- Add the gabbapeople/pneumatic-cannon library to the workspace.
- Add the gabbapeople/4d-ulcd library to the workspace.
- Add the bradzilla84/visi-genie-extra-library library to the workspace.
Programming.
Ok, the whole patch of the program is quite large so let's look at its parts.
Initializing the display.
The init node (Pic. 1) from the 4d-ulcd library is used to set up the display device. You should link the UART interface node to it. UART node depends on how exactly your display is connected. The screen feels great with the software UART, but if possible, it is better to use hardware one. The RST pin of the init node is optional and serves to reboot the display. Init node creates a custom DEV data type which helps you to handle display widgets in XOD. The BAUD speed of communication should be the same as set when flashing the display.
Reading the pressure transmitter.
My pressure transmitter is an analog device. It transmits an analog signal proportional to the air pressure in the system. To find out the dependence, I did a little experiment. I pumped the compressor to a certain level and read the analog signal. So I got a graph of the analog signal from the pressure (Pic. 2).
This graph shows that the dependence is linear and I can easily express it by the equation y = kx + b. So, for this sensor the equation is:
Analog read voltage * 15,384 - 1,384.
Thus I get the exact (PRES) value of the pressure in the bars (Pic. 3). Then I round it up to an integer value and send it to the first write-angular-meter widget. I also translate pressure with the help of the map node map to psi and send it to the second write-angular-meter widget.
Setting up the maximum pressure.
The maximum pressure value is set reading rotary switch (Pic. 4). The read-rotary-switch widget has three positions with the indexes 0, 1, and 2. which correspond to 2, 4, and 6 bar pressure values on the display.
To convert the index to (EST) maximum pressure, I multiply it by 2 and add 2. Next, I update the string0 widget with the write-string-pre node. It changes the string on the screen and informs that the maximum pressure is updated.
Operating solenoid valve and compressor.
The first button node is connected to pin 6 and turns on the compressors relay. Compressor relay is controlled via digital-write node that is connected to pin 8. If the button is pressed and the system pressure (PRES) is less than the set one (EST), the compressor turns on and start pumping air until the system pressure (PRES) is greater than maximum value (EST) (Pic. 5).
The shot is made by pressing the trigger button. It's simple. The trigger button node that is connected to pin 5 switches the solenoid relay using the digital-write node connected to Pin 12.
Indicating the state.
LEDs are never enough =). The gun has two LEDs: the green one and the red one. If the compressor is not switched on and the pressure in the system (PRES) is equal to the estimated (EST) or slightly less than it, then the green led lights up (Pic. 6). It means that you can safely press the trigger. If the pump is running or the system pressure is lower than that which you have set on the screen, then the red led lights up, and the green goes down.