S215   08 1024     Revised 11:55 a.m.

Lab HJ24-09 Input-Signal Stabilizer
Unloading System
30 points
OEES 215

Back to Main Page
 
For this project, you'll be writing a program to match the flowchart below.

For the Unloading System, we'll be having one microcontroller dedicated to filtering  input signals. For this project, you'll be writing a program to process two input signals. The multsamp( ) function will be used to filter out intermittent fluxuations of the input signals, and only allow through input signals that have been steady for a specified length of time. Click here to get a reference page explaining multsamp( ).

To use multsamp, you'll need to download S215XC_Std_func_4.bas and put it into the xcsb-2.0.1-pic-lite-win folder on the C: drive. Right-click here to get this file. Also, right-click here to get a template that is compatible with S215XC_Std_func_4.bas.

In the flowchart below, the first few blocks accomplish the task of getting values for the desired delay between samples and for the number of samples to be taken. The values for both of these come from the DIP switches.

At the very top of the flowchart, Initp(1, 1) specifies that Port A will be for inputs, Port B will be for outputs, and that inverted I/O will be used (as usual).

Glossary
  • Multsamp( ) = Multiple-samples function. (Contained in S215_Std_func_4.bas)
  • nosamps = Number of samples to be taken of the input being filtered.
  • out0, out1 = Stabilized signals from switches 0 and 1 (respectively).
  • sampdly = Sample delay (delay between samples).
  • sbin = Stabilized bit input.
After we're through getting the values for sampdly and nosamps, the next thing we do is turn on LED 3 to let us know that Multsamp( ) is busy sampling input signal 0. When Multsamp( ) is finished, we turn off LED3.

Four arguments are sent to Multsamp( ).
  1. The first argument is 0, which means that we want to stabilize input 0.
  2. The second argument is sampdly, which tells Multsamp( ) how long to wait between samples.
  3. The third argument is nosamps, which tells Multsamp( ) how many samples to take before returning to the calling routine (the main program in this case).
  4. The fourth argument is 0, which tells Multsamp( ) that we want all the samples to be the same before it returns a 1 or a 0. In other words, we want the samples to be unanimous. (If we were to use a 1 for the fourth argument, we would be telling Multsamp( ) that the "vote" can be a majority rather than being unanimous.)
At present, the fourth argument has not been implemented. In other words, Multsamp( ) will ignore the fourth argument. The next version of  the standard functions will probably implement Multsamp( )'s fourth argument. We're just including the fourth argument now so that our program will be compatible with the next version of the standard functions.

sbin is used to contain the number sent back by Multsamp( ). The acronym stands for "stabilized bit input."

out0 and will function as a flip-flop. Two if statements are used to determine whether out0 is to be "set" or "reset," to use flip-flop terminology. Specifically, if  sbin is a 1, we put a 1 into out0. If sbin is a 0, we put a 0 into out0. If sbin is a 2, Multsamp( ) is telling us that the input wasn't stable. In this case, we leave out0 unchanged.

For input 1, we repeat the same code that was used to stabilize input 0. The only difference is that we're using input 1 instead of input 0.


Input Switches (Port B)
0 = input 0
1 = input 1
2, 3, 4, & 5 = sampling delay
6 & 7 =  number of samples

Output LEDs (Port A)
0 = stabilized input 0
1 = stabilized input 1
2 = input 0 is being filtered
3 = input 1 is being filtered
 







Back to Main Page