I am building a robot arm that is actuated by a pneumatic cylinder. Extending and retracting the piston would increase and decrease the joint angle respectively. This is done using a 5/3 solenoid valve controlled by a relay switch. The actual joint angle is feedback using a potentiometer connected to analog A0 pin of an Arduino Uno.
I have a basic idea of how the whole mechanism would work to control position of the piston but have some queries and also on the use of Analog Comparator to serve as interrupt.
The components I am using are:
- Pneumatic Cylinder that would be fitted with speed reducing connectors to hopefully slow down the piston action enough to be controllable
- 5/3 Solenoid Valve
- Relay Module
- Potentiometer
Basic idea of how the system would function:
- Potentiometer reading is mapped to joint angle range
- User keys in target joint angle
- If target joint angle < measured joint angle, switch on relay to power desired solenoid valve and extend the piston and the opposite when target joint angle > measured joint angle
- If target joint angle = measured joint angle, switch off relays and solenoid valve would be in closed position, i.e.: no air input and piston stays in position
Queries:
Interrupt vs Polling
- The control loop needs to know when the actual joint angle = target joint angle so as to switch off the relay and power down the solenoid valve. This requires an interrupt signal when the potentiometer reading reaches a certain value correct?
- Polling of the potentiometer using analogRead() may miss a reading? Or would polling simply be the more straightforward way to get joint angle feedback?
Analog Comparator
- If interrupt is the way to go, this would mean needing to use the in-built analog comparator on Uno. I read up on it and the idea is to put a reference voltage at D7 of Uno, while the potentiometer values are input at D6. When the input voltage passes the reference voltage, an interrupt (either falling or rising edge) would occur.
- But this would mean that there can only be one fixed reference voltage right? Or is there a means to have variable reference voltage sent in to D7 according to user input desired values?
- And the Uno only has these two pins for analog comparator, it would not be able to support a two-joint robot arm with angles measured by two different potentiometers correct?
Or are there smarter ways to achieve control of the piston position?