PROJECT: Half-Life 2 AR2, Update #8 - Closed-loop Control

In this post I go over my current solenoid/firing pin control methodology and how I aim to improve it

With the current AR2 prototype I am driving the solenoid with a constant frequency/duty pulse, as there is no feedback in the engineering world this would be considered an open-loop system. Doing things this way is easy but as one might expect has some disadvantages, a couple of which are:

  1. The constant frequency/duty pulse must be carefully tuned, and once tuned the solenoid & spring must stay the same if you want reliable operation. For example set the pulse too fast/short and the firing pin would never reach the barrel, set it too slow/long and the solenoid could overheat
  2. As there is no feedback the system is unable to respond to changing/fault conditions. For example, say you are driving the solenoid directly from a lithium battery, well as the battery becomes more depleted the cell voltage will decrease. With an open-loop system this means your solenoid movement will become irregular unless you once again run through tuning

Hence the logical step was to introduce closed-loop control with the solenoid, as doing so would allow me to have the fastest possible firing rate while at the same time make the solenoid movement more resilient to external factors

Open-loop Control

As previously mentioned, this is how I was originally driving the solenoid, as in with no feedback. To go into a bit more detail, the control pulse had a period of ~190ms, ~80ms of which had the solenoid energized. The maximum reliable firing rate I could get in this configuration was ~5.3Hz (in HL2 the AR2 fires at ~9Hz)

Closed-loop Control (IR Photoreflector)

My first attempt at closed-loop control consisted of a couple of IR photoreflectors, one near the start position of the plunger and other near the end. The photoreflectors themselves consist of an IR emitter/LED paired with a matching (wavelength wise) sensor/photodiode, with both being positioned in such a way that the photodiode senses the IR light bounced from a reflective surface (like the polished solenoid plunger):

Results were somewhat promising though not as reliable as I had hoped, as the IR sensor kept getting confused by the non-reflective surface of the spring. Basically giving a fairly irregular firing rate:

Closed-loop Control (IR Photointerrupter)

With my second attempt I repositioned the IR emitter & sensor so that both were in a "line of sight" type of formation (more commonly known as an IR photointerrupter). With this arrangement the solenoid plunger now obstructs the IR light rather than reflect it:

This configuration proved to be way more reliable as the firing rate was now a consistent ~7Hz, which is a fairly good improvement over the original open-loop control ~5.3Hz

Other Options

Of course there are other ways to tackle this problem, for example Airzone has a very good video where he compares Hall effect & IR sensors. With that said here is my short summary of other methodologies:

  1. Using a Hall effect sensor to sense the slightly  magnetic plunger body. One thing to be wary of is that the solenoid will be producing it's own electromagnetic field, so you need to make sure that the Hall effect sensor does not get confused by it's presence (think sensor orientation & sensitivity)
  2. Using an Inductive sensor to sense the ferromagnetic plunger body. TI LDC0851 looks like a nifty sensor though to get best sensitivity it's best to use a planar inductor which increases the design complexity (as you need to use a 4L PCB if you want good accuracy)
  3. Using a Capacitive sensor to sense the metallic plunger body. Again TI has a cool IC, the FDC2214 which interestingly enough can also differentiate through a metallic sheet