The software of the system consists of several tasks as follows:

 

*  Scanning and Debouncing the Keypad

     

The keypad is connected to PORT C of the MCU (As described in Hardware Design page). In order to read the keypad the scanning code used in lab 4 was used.

 

*  Calibrating the Postage Meter

 

Considering the fact that the stepper motors have to turn different times for different sizes of envelopes, we added a calibrating part to the code which user can change the length of the envelops for each size. Initially the system is calibrated for three sizes and can be upgraded for up to nine sizes.

 

*  Running the System

 

This part of the code is responsible for turning each stepper motor based on the size of the envelope entered by the user. The system is set up in such a way that it first turns the first two motors and then stops for a short time, stamps and at the end turns the last two motors to push the paper out and continues this process until all the envelops are stamped. Number of envelopes to be stamped will be entered by the user.

 

The system was tested after completion of each test code and each component was also tested separately.

 

The final Code