Posts Tagged 'Pneumatic Controller'

Pneumatic Controller: FINAL PART (9)

Well here we are again. It’s always such a pleasure.

This is the thrilling conclusion to a long and varied adventure. There were lots of bumps along the way, but I’ve enjoyed the experience immensely. It’s a bit sentimental so forgive me. On the other hand, lots of pictures.

Part 1 Part 2 Part 3 Part 4 Part 5 Part 6 Part 7 Part 8

Onward!

After replacing my cowardly and broken Arduino,

Coward

Coward

I decided that I would also like to be able have an actual on/off switch that wasn’t locked inside the Box. I had two pieces the Box came with: the visible dial and the actual switch.

DSCN2347

DSCN2348

It had several powerful springs inside that made it very hard to turn, so I broke it open and removed those.

DSCN2350

Then I attached mounting pieces to some scrap wood to hold the switch in place.

DSCN2363

I don’t think I’ve ever used those metal things for actual picture hanging

DSCN2365 DSCN2366

DSCN2386

With some more on top to hold it down

DSCN2387

Holes drilled in the lid

DSCN2388

Bolted in place

DSCN2400

Wired

DSCN2401

This is what was sticking out from the switch

DSCN2402

The fit was a bit wobbly so I used a lot of glue for support

DSCN2403 DSCN2404

DSCN2405

Ta-da!

Now the entire face was used. Hooray!

Gorgeous

Gorgeous

You may remember from last time about my sensor interrupt troubles. As a quick recap, the smaller pistons were moving too fast for the program to catch their sensors, so I tried wiring them to an interrupt pin (which would make the program pay attention regardless of what it had been doing) so that every time a sensor was hit, the program would know. This time around I was able to test it with multiple sensors through a common interrupt pin.

The problem I ran into was that the interrupt would only trigger when the signal went from low to high. But if a piston stopped on a sensor for a while (like if it was done cycling), it would stay high and no other sensors could trigger it. What I needed was a way for the signal to start out as high, then drop quickly automatically. That way each sensor could trigger the interrupt no matter what else was happening.

My brother-in-law suggested using capacitors, which would change their voltage over time. I figured out a simple circuit of just a capacitor in series with a resistor, then measuring the voltage over the resistor. Using a diode as well meant that the signal wouldn’t also go back through the circuit and give a false positive reading for all the other sensors.

I added another resistor in parallel to the capacitor to allow it to discharge after the sensor reading went low (the diode prevented it from discharging through the normal circuit). The resistor values were found using science (below) and guessing and checking.

Science

The capacitor value was found using the age-old engineering method of it being the only one available.

Testing

It works!

A little bit of tweaking and voilà! Newer, nicer circuits. Just look at all the color!

new cap circuit

First and second (final) version of capacitor diagram

DSCN2622

I’m really liking all the color. The old PLC system was grey and dull.

To make some of the power wiring a bit easier, I also cut a piece of an unused breadboard and glued it onto the Arduino.

DSCN2603

Glued on

DSCN2604

Wired to power/ground

Then I had to wire everything back to the Arduino for the first time in several weeks, which was not terrifying at all. I totally remembered where everything went and didn’t have to triple check each step.

DSCN2606 DSCN2607 DSCN2608 DSCN2609 DSCN2610 DSCN2611 DSCN2612 DSCN2613 DSCN2614 DSCN2615

DSCN2615 (1)

A bit of a technicolor bird’s nest but no one ever needs to see it

And that’s it. It’s done. After months of design, coding, building, and fixing, it is completed. It has been a wild and exceptionally fun ride. To give some idea of how much the design has changed, here are the original and final circuit diagrams side by side:

comparison

Oh, Ari From The Past. So naive.

Also, I’ve gotten a lot of questions of what cycle testing is actually used for, so here is an example I set up for the “Demo mode” when we have tours through the department:

I have loved working on this project so much. This has easily been the biggest and most complex project I’ve tackled on my own and I’m very happy that I was given that chance. I’ve learned a lot while working on it, from technical stuff like how to use keypads and pistons, as well as more general things, like buying extra small, cheap components in case some break (they will) and assuming the project will take longer than you originally plan (it will).

Once again, I am so thankful that I was given this opportunity to improve my skills, learn new things, and work on a larger scale project. I’m also happy to have been able to share it with all of you.

Hopefully I will return shortly with a new project to document.

Until next time,

Ari

yeah

(Unfortunately I cannot find where I found this)

Advertisements

Pneumatic Controller: Part 8

So here we are at Part 8. The second to last post (unless something goes wrong).

Let’s get right to it.

The keypad had a hole for an LED but I wanted another so I could have both a red and a green one. This turned out to cause some problems, but more on that in a moment. I mounted both LEDs in a small piece of wood and soldered them to ribbon cable.

DSCN2191DSCN2192 (1)

Fancy

Fancy

The problem arose when I needed to take the keypad off the metal plate it was glued to. I didn’t know where in the keypad the circuitry was, so I didn’t know where I could safely cut through without damaging it. Also, cutting through the metal would be much easier if I could just cut all the way through and not have to stop at the plastic. So I got a flat head screwdriver and pried it off.

Unfortunately, this caused several buttons to stop working. See, the keypad is able to be so thin because the circuitry is on super thin layers of copper and the buttons are slightly bent pieces of metal, like this:

DSCN2207

The copper are the yellowish lines on the greenish background

When I was using the screwdriver, some of these pieces of metal got bent a little, so they didn’t pop back up after being pressed.

This wasn’t too bad because I could just take off the top layer of the keypad, take them out, and rebend them. This worked, but led to some of the thin layers of copper getting scratched. I tried fixing this with wire and conductive tape, but it didn’t work, leaving me with a broken keypad.

I decided it was simplest to just build one myself. Surprisingly, keypad diagrams are really simple, basically just being a matrix of buttons. With the Arduino keypad library, there aren’t even any power or resistors to deal with.

I decided to base mine off of the Festo one the Box came with. Since I don’t have any kind of circuit printing capabilities, I decided to use conductive tape as the circuit and plastic tape as an insulator, keeping my version nice and thin. The metal pieces would be reused.

First I marked where all the buttons would go so they would line up with the cover, which had the numbers printed on it.

DSCN2215

Also shown: the little button that started this great adventure

Then I put down layers of conductive tape to act as the rows. This would be what the metal pieces touched when they were pressed.

DSCN2218

Then, after some strategic plastic tape, came the columns, which would always be touching the metal.

DSCN2225

After some thought, I decided to just tape the wires to the metal. They would be pressed down by the tape and the keypad as a whole, so I didn’t feel that a more complicated approach was necessary.

DSCN2226 DSCN2227

After making sure each connection worked, I taped all the buttons in place.

DSCN2230

The red markings are on the ones that needed rebending

The different layers are more clearly shown here:

keypad layers

Finally, I added some double-sided tape and put back the face.

DSCN2231 DSCN2232

In a surprising turn of events, this worked really well and has been what I’ve been using for a while now. Not quite as elegant but looks pretty much the same and it works.

In between that whole mess, I drilled a new hole in the metal and scraped off a circle from the face, then mounted the LEDs.

DSCN2186 (1) DSCN2190 DSCN2195

However, the wire I was using made the system a little too thick for the LCD, so I needed to change how it was mounted. Holding the LCD in place was a hassle, since it had to line up with the window in the face, but I could only tell if it was lined up if it was on. I decided on a more secure method.

After some very careful measuring/sanding, I got a piece of thin wood that held the LCD in the perfect position.

Pictured: One of my most satisfying accomplishments

Pictured: One of my most satisfying accomplishments

From there it was pretty easy to build around everything and add thick layers of hot glue to hold everything securely. The wood would hold the LCD straight, and everything else would add pressure to hold it down. Even though I originally did this out of necessity, it actually worked a lot better.

DSCN2235 (1) DSCN2236

The other layers are the same as before.

While I had not been planning on using the big buttons on the face of the Box, I decided that they would actually be super helpful, so I wired them up for lighting (through the high power supply) and actual use (through the Arduino). 
DSCN2330 DSCN2298

DSCN2320

Now, the more complicated pause/unpause routine could be replaced with the simple START and STOP buttons. Also, I printed out a new label for the POWER ON button to make it RESET COMPUTER. It now resets the Arduino, which means it is no longer necessary to open up the entire thing each time.

This being done, it was time for more testing. This is where I ran into trouble. While everything worked fine for the most part, the sensors weren’t stopping the pistons. After some experimenting, I found that the function to check the sensors (sensorGrab) was only running every 200 ms, while the smaller, faster piston passed through the sensor’s range in about 5 ms. This was a problem.

The first thing I tried was putting more instances of sensorGrab in the code so it would run more frequently, but it wasn’t fast enough. Next I tried a timer interrupt. Remember those? Well it was simpler this time because there was no issue with the LCD, which wouldn’t be used inside the interrupt. However, this didn’t work either because having the interrupt run that quickly slowed the rest of the program down to a crawl.

So I thought about using an external interrupt common to all the sensors (6 individual ones would be too complicated). After all, I only needed to check the sensors when something actually happened to them anyway. So I wired a sensor to an interrupt pin as well as the normal pin in the Arduino and tried it.

It worked! The piston still couldn’t stop halfway, which was unfortunate, but at least it stopped no matter where the sensor was. However, when I tried it with more than one sensor, it stopped working. The problem was that the sensors were normally high and only became low when they were hit, so the interrupt waited for the signal to go low. But, if any of them were high, the interrupt wouldn’t recognize the signal of the one that wasn’t.

Fear not, readers! A solution presented itself in time. I realized I could change the transistor circuit so that the transistor ran on the lower Arduino power and would become high when the sensor was activated. This way, a common interrupt would work. Also, since I had to rewire it anyway, I changed the sensors from the stupid wire to ribbon cable.

DSCN2328

Unfortunately it was around this time that the Arduino stopped being recognized by either computer I was working with. I have recently determined that the problem is the comparator (which decides where the Arduino’s power comes from) and the USB-to-serial connection (which lets the computer talk to the Arduino).

The board still works, but I can’t program it. There is the possibility that I could program with the serial pins directly, but I have been advised that the Arduino is probably living on borrowed time and might stop working in the future, so I will most likely have to get a new one. More on this next time.

Until then, here are some pictures of the thing as a whole.

New circuit diagram

New circuit diagram

DSCN2237 DSCN2238

Until next time,

Ari

Pneumatic Controller: Part 7

Some people, like myself, really like when things fit really nicely together and everything’s all organized. This post will be good for those people, especially after the makeshift stuff I’ve been using until now. We begin!

I needed to find some way of attaching the pistons’ ribbon cable to the Arduino. For the sensors, I used the wire itself (their wire was thicker/stiff enough) but the ribbon cable can’t do that. Also, it’s a lot weaker/uglier.

Ugly and weak

Weak and ugly

Last time I tried attaching ribbon cable to headers, I wrapped each wire around the header and soldered it into place. While this worked, it was time consuming and messy. This time I decided to use some leftover female header, having found that I could put the wire into it, then press everything together using male headers, securing it with glue.

DSCN2129

DSCN2130 DSCN2137

DSCN2138This worked much better/neater, although still rather annoying. Eventually I figured out how to do it correctly, but that’s for later.

Next up was mounting the Arduino in place. I wanted something sturdy that would be secure in the long term, but could also be quickly removed in case I needed to change something. Conveniently, there was a metal rail near where I wanted to be, which meant I could use those plastic clippy things (so helpful!).

The Arduino needed to be mounted to something first so I cut a scrap piece of wood and drilled holes to line up with ones I made in the clippy thing.

DSCN2144 DSCN2143

Then I drilled holes to line up with the ones are are pre-made in the Arduino for mounting purposes. The Arduino also came with little plastic pieces to help with mounting, so I put a little hot glue into the holes and pressed the female ends in.

 DSCN2145 (1) DSCN2146Then I used the pins to hold it together. Everything fit nice and snug.

DSCN2147DSCN2142 DSCN2148 DSCN2149

To power the Arduino, I had an AC cable. I didn’t want the Box to have two separate plugs, so I planned on using the same power the Box was using. The Box took in the AC power and connected it to a transformer that would give the 24V output the solenoids/sensors needed. My plan was to connect the Arduino adapter to the same input the transformer had.

First up was to attach wires to the Arduino adapter in a safe way. I could have opened it up, but I figured that someone may want to change it in the future so not cracking open the plastic was better. I found some thick wires and wrapped them around the tongs of the plug with some heat shrink tubing. Heat shrink tubing is rubber tubing that will shrink when heat is applied (surprise). It’s very helpful for keeping wires covered and safe, since it’s held in place by the pressure of trying to be smaller than the wire inside of it is.

DSCN2151

After adding some hot glue for structure and applying heat, I had a strong safe connection that also looked very nice.

DSCN2152 DSCN2153

To attach to the transformer, I lucked out. All wires in and out were screwed in, so all I had to do was screw the existing wires in with my additions.

Before

Before

After

After

Then I wired up everything and did some test runs. Unfortunately, for one of these tests I confused the power sources and accidentally connected the higher 24V source to the LCD, which promptly shorted out.

As annoying as this was, it did show me how confusing things were becoming with wires, not to mention that the wires I had been using were stiff and unwieldy. I decided to upgrade.

First was to switch to ribbon cable, which is much more flexible. I figured there must be a better way of attaching it, so I did what I should have started with and googled the problem. What I found is that the best way is to tin the wire and the header, then heat them both and let them melt into each other, finishing with a layer of glue for structure. It worked beautifully.

At least compared to what it was before

At least compared to what it was before

To help keep the wires coming from the lid tidy, I mounted a piece of thin board on the edge and drilled some holes for zip ties.

DSCN2178 DSCN2179

To wrap things up, here are some pictures of what things are looking like now.

DSCN2180

Sensor circuitry

DSCN2181 DSCN2182

Everything’s going smoothly, plus or minus a few hiccups. Tests have been mostly successful and Part 8 should be done decently soon. It will probably be the second to last one.

Until next time,

Ari

Pneumatic Controller: Part 6

Okay so a lot has happened since the last update. In fact, at some point I realized that I wouldn’t be able to fit it all in update #6 and so I split it. Good stuff coming.

For the LCD shield, only 4 pins on the shield are used: V+, Ground, and two signal pins. This was good because I didn’t have a great way to connect to them without permanently soldering something to the shield, which I didn’t want to do in case I/someone wanted to change something later on. However, I did have 5 longer pins available, so I was able to make Franken-headers, with only the pins I wanted to use being longer.

DSCN2116

Franken-headers

DSCN2119

DSCN2123

LCD assembly fully built

DSCN2126

LCD assembly installed

I also finished the sensor circuitry.

DSCN2114 DSCN2112These may not seem very important, but the specifics of how these things would be mounted/attached to the main box required some finagling. The problem was that although there was plenty of room, I didn’t want the wires to crisscross too much and become a rat’s nest. There was also a metal plate bolted to the bottom of the box (toward the middle of the picture below) that I couldn’t remove and was preventing me from attaching the breadboards to the bottom. Eventually I decided on this arrangement. I was even able to use that metal thing to hold the leads for the solenoid transistors (and other things, as will be explained next update).DSCN2128Next update will have most of what remains of the project.

Talk to you soon!

Ari!

Pneumatic Controller: Part 5

First some coding, then building with pictures.

As promised, I’ve started on the main part of the code and testing the pistons and sensors. Because I didn’t want to go through the entire setup process each time I checked something, I got rid of all that and just gave some initial values. Then I made a small script to print out all the variables used (such as if a piston was in or out, or how many cycles it has done) so I could keep track easily.

I ran into two problems very quickly. One was that I couldn’t seem to make cycle periods (time in between cycles) that weren’t integers (I could only do 1s, 2s, 3s and not 1.5s, 2.75s, etc). The other was that the entire script was only running about once every two seconds. This second one was particularly frightening because I had expected it to run several hundred times a second and the fact that it was so slow implied that my code was outrageously inefficient. Now as a mechanical engineer, my programming education focused less on efficiency than a computer science major’s would. We learned a bit about it, but for our purposes, the difference between a very efficient code and a kind of efficient code were minor. My worry here is that my code was doing so much (which seemed dubious) that it was crossing that border into CS land, and I would have to learn a lot more about efficiency before continuing, something I was not looking forward to for a section I thought to be pretty simple.

Turns out both problems weren’t too bad. For the first, it was an issue of variable types. Two of the types you can use for numbers are int and float. An int (like integer) is a whole number (1, 2, 300) and a float is a decimal (1.5232., 6.5, 24.23542). There are other difference but this is all we need now. Because I wanted the cycle periods to have the option of times in between whole numbers, I used floats. What I neglected to realize, however, was that if you divide a float by an int (like 3.5/10), you will get an int. This meant that my program was constantly rounding these numbers and ignoring the decimal. The fix was just to change the 1000 I was using to 1000.0.

The next problem was trickier, only because the first problem helped it along. At one point I suspected the printing function was slowing it down, but when I removed it, it was still too slow. Turns out it was still slow because of the first problem. Once that was gone, I got rid of the function and the program ran smoothly and quickly.

Now the picture part. First up was some cleaning. The box had lots of wires and components that I wouldn’t be using, and they took up real estate and made everything more confusing and messy.

So one of the first things I did was to gleefully take out anything I wouldn’t be using in my version. Besides the controller and LCD, this meant about 12 miles of wiring. I left the buttons on the face of the lid in after disconnecting them, though, in case someone wanted to use them later. All I wanted was the transformer, pressure switch, and emergency shutoff button.

Cleaned up lid

Cleaned up lid

Cleaned up inside. You didn't see it before, but it was quite a mess

Cleaned up inside. You didn’t see it before, but it was quite a mess

The other thing I did, although it was after I took the picture, was to move the pressure switch (top left of above picture; black thing on grey thing connected to blue tube) to the bottom, basically flipping along the horizontal. This changed nothing in terms of the workings of the system, but gave me a lot more room on top.

Next, the main program. To test the program, I first wired up some LEDs, since they would be much easier to work with than pistons.

Arduino testing with LEDs

Arduino testing with LEDs

More Arduino testing with LEDs

More Arduino testing with LEDs

This showed me that at least the code worked (eventually). Next was to test it with an actual piston. For this, I used code that just opened and closed the solenoid every one second. All I wanted to know was whether the circuitry worked.

Arduino testing with a single piston (IN)

Arduino testing with a single piston (IN)

Arduino testing with a single piston (OUT)

Arduino testing with a single piston (OUT)

It did.

Next up was to make the permanent circuitry for the solenoids. This would be what went into the actual box when I was done. Luckily, when I cleaned up everything, I was left with these little connector things that had been used a lot. I had planned on ignoring them, or even getting rid of them to save space, but I actually found them incredibly helpful. Besides making connections a lot easier, they hooked onto rails that were installed in the box, making everything neater.

Cool attaching things for solenoids

Cool attaching things for solenoids

I put together the breadboard and wired it all up.

Solenoid circuitry

Solenoid circuitry; wires on left go to Arduino

I do not have pictures but I did test all the solenoids and it worked beautifully. For the Arduino end of this (coming out of the above picture on the left), I used some ribbon cable with one end soldered onto the resistors (above) and the other soldered onto male headers that would plug into the Arduino (below).

Pins for solenoids

Pins for solenoids

I had wanted to plug these wires into male headers directly, but the ones I bought were too short.

Finally, I rewired everything so that the pressure switch and emergency shut off button would still disconnect power to the pistons, and began setting up the rest of the circuitry.

All in all, it was a good week. On Monday, some more transistors and resistors arrived (UL had the oddest and least helpful collection of resistors) and so I can start putting together the sensor breadboard. I’m looking to finish in the next week or so (fingers crossed), depending on my workload.

Until next time!

Ari

Pneumatic Controller: Part 4

This is the post you’ve been waiting for! The one that shifts away from blocks of text and has more pictures. They should be more like this for a while.

Today I finished the debugging of the setup program! It now takes input, stores it correctly, and allows changes to be made in the confirmation section. There were many issues but they’re all gone now. While it’s possible that I’ll run into problems later on, those shouldn’t be too hard to deal with now that the more complicated stuff is done.

The other, more visual/shiny, thing I did today was make a more permanent base for the LCD/keypad. As lovely as electrical tape is, this one is much stronger and more stable, plus it looks a lot nicer.

DSCN2086 (1)

Arduino screwed into the board 

DSCN2085 (1)

LCD on the Arduino

DSCN2083 (1)

Keypad attached to the LCD

DSCN2081

Keypad screwed onto the base (the three nuts in the center are from the Arduino)

DSCN2082

Keypad screwed onto the base (the three nuts in the center are from the Arduino)

DSCN2079

Full assembly

DSCN2080

Full assembly – Side

DSCN2078

Full assembly – Top

Since the final version will have more things stacked on top, the Arduino won’t fit in this base. Plus, the lid to the box (which you will see in a later post) holds the LCD and tends to slam down, so I’d prefer to not have the brain of the operation jostled so much. But some of it should be salvageable and for now it’s perfect for my needs.

Tomorrow I start working on the pistons, sensors, and the main part of the code. Huzzah!

Ari

Pneumatic Controller: Part 3

That’s right, Part 3! Take that, Hand Typing project!

You will not believe how simple the solution to my interrupt woes turned out to be. I tried the code again with the Timer1 Arduino library and was able to use timer interrupts and the LCD, but still couldn’t change the LCD from inside the interrupt. While looking online, I found someone saying how interrupts were disabled inside other interrupts, but you could re-enable them.

Now until this point, I had thought that interrupts were disabled just as a function of how they work, but it seems that they are only disabled with the assumption that if you wanted to stop whatever you’re doing to do the interrupt, you probably don’t want to be interrupted while in it. But in my case, I did so that I could print to the LCD.

interrupts();

That’s it. That is literally all I added to the timer interrupt function to make it work perfectly. It is frustratingly simple. Anyway, it worked.

Luckily (?), it still had some problems. The timer interrupt had some confusion with the scrolling and would sometimes, but somehow not always, print random characters all over and stop the flow of the program. Naturally this was not something I wanted.

I thought of two solutions. The first was to change from an automatic scroll to one that scrolled when a button was pressed, using an external interrupt. This was significantly worse for some reason.

The second way was to get rid of the interrupts entirely.

“But Ari,” you exclaim. “You spent so much time getting them to work. They were so special to you!”

That’s true, imaginary commenter. But an important lesson i learned about writing papers is to kill your darlings. As much as I liked having timer interrupts in the code, ultimately they made it more complicated and worse than it needed to be.

So what would I use instead of interrupts? Well, the normal way would have been to just check for scrolling every loop through this part of the code, but I hadn’t originally because parts of the code stopped and waited for input, which would leave a break with no scrolling. What I realized is that only one function actually used the scroll function anyway so all I needed to do was reorganize it to use a loop instead of waiting (for those who have used the Arduino LCD, it was a switch from waitForKey() to getKey()).

This worked and the program now scrolls lovelily (it’s a word, look it up). It even makes the program a bit faster because there’s no extra memory taken up by interrupts and libraries. Hooray!

Besides a couple of smaller changes, the main thing I did last week was to make a temporary assembly for the keypad/LCD. Until now I had been leaning the keypad as best I could but this got a little annoying. I couldn’t put the full assembly together because I haven’t decided how things will be stacked (probably: Arduino – Generic shield to make disconnecting the Arduino a one step process – All wires besides the LCD – LCD), so I taped them together as best I could.DSCN2071

DSCN2072DSCN2073

The nice thing is that the keypad was built with a window for the LCD, so everything looks all neat and shiny. The text displayed is from the beginning of the setup and is asking how many pistons to use.

Things continue to go well with no obvious problems foreseeable. I hope to finish the debugging of the setup program this week and then start assembling/testing the actual pistons.

Until next time!

Ari