Thursday, December 8, 2016

Clockwork Coop Version 1 Micro controller Capabilities

In order to design the mechanics, first we need to decide what sort of motors and sensors will drive the doors.  And, in order to decide on that, we need to know what capabilities our microcontroller has.  I'm using a Moteino R4 from lowpowerlabs.com.  And 5 pins on that controller are dedicated to running the transciever.  There are also 2 extra analog pins than a normal Arduino (A6 and A7) so I'll use one of those for light sensing.  This leaves 13 multipurpose pins left over (D3-D9 and A0-A5).

I decided to use two limit switches to detect each door's open and closed state.  This would require a total of 4 pins.  I considered using a single switch for each door but decided it would be too difficult to detect errors with only a single switch.  Imagine, for example, if I had used a single switch to detect open and closed.  This is easily accomplished by placing a switch near the top of the door and placing contacts on the door that would trigger the switch when it was either fully opened or fully closed.  But, what happens if the door experiences a mechanical failure while opening that causes it to drop back into the closed position?  The same switch would be triggered but the software would assume the door was now fully opened.  Even using known opening and closing times doesn't help since the door could drop into place just as it reached the point where it would indicate open.  Nope, we will need 4 pins to sense door state which means we are down to 9 available.

One of the door control requirements was to manually control the door locally.  Since I'll have 2 doors, two buttons will be used for this purpose.  This requires 2 more pins reducing the remaining count to 7.  If I had more doors, I might consider using an I2C keypad (this also requires 2 pins).

The indicator light and interior light require 2 more pins bringing us down to 5 pins.

With 5 pins, I could control a single stepper motor using the stepper.h library included with the Arduino IDE.  But that's not enough for 2 doors unfortunately.  However, if I had been clever at the time, I might have included a demultiplexer to route the 4 stepper control pins to the correct motor using the 5th available pin.  But I wasn't.  Instead, I abandoned the idea of using a stepper motor and considered using a DC motor instead.  I would control the DC motor using an L293E H-Bridge.  The Bridge required 2 input pins per motor (on/off and forward/backward) and could control up to 2 motors.  Additionally, I could get feedback about the motor performance from the sense pins.  This required 2 Analog pins and could be provided by one of the extra pins on the Moteino and one of the Analog multipurpose pins.  This was the initial plan.





No comments:

Post a Comment