You are viewing an older revision! See the latest version

Locker

Task:

The locker team is tasked with securing the locker, following the instructions of the user via the interface, setting the battery to charge and relaying information between the battery and the interface.

Overview:

The locker is secured by a solenoid controlled latch. There is also an alarm system which can be armed or disarmed. The armed alarm sounds off if a metal contact is disconnected while the alarm is armed. The locking mechanism and the alarm only unlocks when instructed to by the interface.

<battery systems have yet to be implemented>

Securing the locker

The locker is secured via a solenoid controlled latch. When an unlock pulse is sent from the interface, the mbed turns off the alarm(sets alarmflag = 0), then activates the solenoid to pull the latch to unlock the door(function unlock() ). To prevent overheating, the solenoid only activates for a limited time, within which the user must open the door/springs will force the door to open.

There is a electrical contact surface where contact is established when the door is locked and disconnected if the door is opened. This allows the locker system to know if the door is open(via setting flag doorclosed=0). If the door is opened while the alarm is activated(alarmflag==1&&doorclosed==0), the loss of electrical contact sets off the alarm. This contact also allows the locker system to inform the interface system if the door is opened.

The function unlock() runs continuously as thread Tunlock. However, if unlockflag==0, the function does nothing. If an instruction to unlock the door comes in from the interface, unlockflag is set to logic 1 in the main thread which is then set to wait for a short time, allowing other threads to run. This allows the next instance of the Tunlock to run. As now unlockflag==1, the thread runs through the function's "if" statement. This consists of deactivating the alarm, activating the solenoid for a set time(passing control to other threads while waiting), and finally resetting the unlockflag to zero.

The code: The mbed continuously runs two threads, the main thread which monitors the status of the system and external flags, and the Tunlock thread which controls the entire unlock process.


All wikipages