Adam,
Those photos look very familiar. I was in the same place about ten years ago. I am not familiar with the particular Arduino micro you are using, but I have made a few variants of this type of control system and can offer some advise. Also in case you don't know, the Tube Bandit was my brainchild and I also built a pretty neat auto-stop tube bender in college. :)
Before I get into this, take a look at my bender thread (link
here) and videos:
Initial Hydraulic Test - http://bender.xtremefabricator.com/BenderTest.wmv (2mb)
First Tube Bending Test - http://bender.xtremefabricator.com/BenderTestTube.wmv (18mb)
NC Controller Test- http://bender.xtremefabricator.com/BenderTestNC.wmv (5mb)
For everything below, I'm going to assuming your objective is to have a digital readout and autostop function for a Hossfield/PT105/JD2M3 type of bender, driven by a hydraulic cylinder.
Encoder and Mounting
The encoder should be of sufficient resolution to allow at the very least 0.5 degree increments. I prefer the 0.1deg resolution incorporated on Tube Bandit because you can get very consistent results, but keep in mind due to tubing material variation and slop in the bender, you are likely to see some variation in your zero position and the output angle at this resolution. The same variation exists with lower resolution, you just aren't able to detect it.
You have a choice of incremental or absolute encoders. The later is better, but more expensive by far, so the incremental you've chosen (looks like a Koyo?) should work great. With incremental encoders, you will get two signals that you read in quadrature to "count" movement and determine direction. Depending on how you read the two singals, you can obtain 4 times the resolution of the number of pulses; i.e. if the encoder has 900 pulses per revolution, you can read this at 4x and obtain a resolution of 3600 counts per revolution (perfect for 0.1deg increments).
Tube Bandit used a compact optical encoder with 300ppr. It was 3x "geared" through a belt-pulley system to produce 900 pulses per revolution of the die and read in quadrature to obtain 3600 counts per revolution.
The mounting of the Tube Bandit encoder and the overall design is something I was never 100% satisfied with in part because the pulley/gearing components added needless cost and complexity, but this design lent itself to easy bolt-on which was a primary objective for me at the time. For your design, I would recommend a 1:1 drive system directly off the center of the die. You can achieve this by adding a set screw in the side of the die that locks it with the center pin, then attaching the encoder on the bottom of the machine through a misalignment coupling.
Electrical Circuit
Since you've gotten this far, I assume you know the chip will not be capable of supplying necessary supply to run a solenoid, but if you have available I/O you should have no problem finding an appropriate relay so it can switch a heavy current, higher voltage solenoid. I would recommend using a 24VDC supply with reasonable current capacity since it is a relatively safe voltage to work with and easy to find industrial components like socketted ice cube relays or whatever flavor you prefer. You will want to use a relay designed for an inductive load or add protective circuitry (diode and resistor) to discharge the back voltage from the solenoid. Your logic circuit will still be lower voltage for the micro, but you use a relay to allow the low voltage, low current micro switch the higher current high voltage power needed for a solenoid.
For power supply, I do not recommend 9v batteries. Even with a good LDOC voltage regulator, you are going to waste a lot of energy. I'm assuming your circuit runs on 3.3v or 5v. Consider either using 4x AA batteries in series, lithium button cells, or even better go with a 24VDC wall-type power supply to power both your solenoid and logic circuits (regulated down accordingly)
Other components I recommend are a piezo or other "buzzer" to indicate you've reached target bend angle and indicators of power, fluid bypass, etc.
For input to set the target angle, I am a fan of the simple panel encoders that allow you to quickly adjust angle. There's no need to get complicated with it; a mechanical contact encoder will work just fine and they are cheap. Alternatively you can do something like I did with Tube Bandit with some momentary pushbuttons.
You will need a zeroing function also; another pushbutton should cover that.
For the display, if you have enough I/O I would recommend having a second readout for target angle.
Hydraulic Control Circuit
Assuming your system is hydraulic, you will want to find a solenoid valve that will bypass flow back to the tank when the desired angle is reached. I would recommend a 24VDC valve; how you plumb it will depend on the type of valve and plumbing. For my big bender, I used a double acting hydraulic cylinder and a manual control valve in conjunction with the bypass valve.
Here is the hydraulic circuit diagram
http://bender.xtremefabricator.com/hydraulics1.jpg
<I need to add more content here>
Software
This is a very simple system but you should think about your state machine and how exactly you want things to operate. I will assume you want your bender to operate something like mine where the process isn't 100% automated, but allows manual control with an automatic stop. I recommend this unless you are doing a production machine because it is safer; you are always on that "deadman" switch and you can stop/adjust if needed or go as slow or fast as you like.
Before you read this, I recommend reading the description of operation for my bender here:
http://www.offroadfabnet.com/forums/...2&postcount=51
There are a few states and processes to think about
:
- Power up: At this point you have no bend angle reference/zero, so you should make it obvious to the user they need to zero things. Tube Bandit flashes zeros in this state and you transition out of this after you hold the zero button
- Under angle: In this state you are simply monitoring the encoder and adjusting the display to show the current angle. The bypass valve is not activated and the user is free to use the manual control. During this state you should allow the user to adjust the target angle at any time.
- At/above angle: At this point when you reach an angle at or above the target angle, you want to open you bypass valve and give the user an indication(s) like a buzzer to tell them they are there. For the valve control, you need a transient function/timer to keep the valve open for some time rather than just opening for angles greater than target and close for less target because if the user just holds the manual valve in the forward position, it will cycle/bounce off that angle as the valve opens/closes.
Interrupts/parallel processes:
- Encoder reading: Ideally you are reading the incremental encoder at a high frequency. I have used slower micros and higher resolution encoders with disastrous results. You need either high processing speed and interrupt or dedicated process to monitor the encoder or you need a dedicated encoder IC that can keep up with movements on the encoder. If you don't, little bounces and jults or manual movement of the bender can result in missed counts. This is assuming you're using an incremental encoder; if you use an absolute encoder, speed is less of a concern.
- Input monitoring: you need to be able to respond to target angle adjustments or zeroing at any time.
Sorry - I'm unable to finish this post at the moment. Please check out my bender thread and start on post 44. There is an image of the hydraulic circuit and I think some descriptions of operation and video that can help you.
http://www.offroadfabnet.com/forums/...ead.php?p=7801