Counting Code Progression

Stage One

We built the hardware so the PWM signal would output through port D pin 0. We also wired each trip wire individually to Port A pin 7, pin 5, and pin 3. Based on this we were able to create the basic logic for the code.

We came up with a basic state logic for a person entering and exiting the dining hall. The logic is illustrated in the diagrams below. In the diagram, “1” represents a wire trip, “0” represents a wire.

Person Entering: Initially all the wires are not tripped. As a person walks to enter, the wires would each trip individually in the order of 1-2-3. If and only if all three wires are tripped a person is considered to be entered and added to the total.

Person Exiting: Initially all the wires are not tripped. As a person walks to exit, the wires would each trip individually in the order of 3-2-1. If and only if all three wires are tripped a person is considered to be exited and subtracted from the total.

When this code was written and tested, we did not receive the output we had hoped for. When a set of wires were tripped indicating a “Person Entering” the count would jump to 32,000. When a set of wires were tripped indicating a “Person Exiting” the count would jump to -1,000. However it was still a step in the right direction because at least we were getting a positive or negative count depending on the instance.

Stage Two

We realized that the reason why the numbers reached extreme values with just one trip because the micro controller polls hundreds of times per second. So when we tripped a wire for a few moments it results in a massive count up or a massive count down. We received some grate advice from afterburn, which was to implement a wait function between each stage.

Logic Diagram:

count_.jpg

Our final commented code for this project can be found: Counting Code

Demo of our small scale model: Project Demo

Future developments on this project are discussed in this blog: january_20th_2010

 
Back to top
projects/hallsensor/countingcode.txt · Last modified: 2010/02/06 11:35 by chainfire
 
 
chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0