Systems Logic
Systems Logic
Logic is the step-by-step reasoning and rules your system must follow. It is up to you to program and create the logic of your system by determining the parameters that your system should react to.
There are a range of ways you can, and should, show the logic of your systems.
Block Diagrams
Block diagrams are the highest level of logic within your system. They do not show the nitty-gritty logic of your system, but show the logical flow from one sub-system to another.
They can be used as IPO diagrams, showing the input, process, and output:
They can also be used to show how sub-systems relate to each other.
Chicken Coop Example
For example, if you had a chicken coop that open and closed automatically with the sun rising and setting, your block diagrams might be:
Feedback Loops
As the door closes, we want to ensure the safety of the chickens. If we only detected the doorway being clear before the coop closed, then there is a risk of a chicken being caught after the process has started. The closing mechanism has a feedback loop that ensures the doorway is clear. The door will stop closing if doorway is blocked during the closing process.
Flowcharts
Flowcharts are more detailed, showing the "thinking" that your system is required to do. Different symbols represent different processes within the flowchart. See the image for an overview of basic flowchart symbols.
As part of your folio, you will need to research the components you will be using in order to determine how they would operate within your system, and what parameters they would need. You will also be required to test the components to determine their sensitivity. These parameters can then make it into your flowcharts, showing thresholds for input/output/feedback signals that your system will react to.
Chicken Coop Example
This is an overview of the logic of the automated chicken coop system.
Pseudocode
Pseudocode is plain language code that allows us to simply write what we want our code to do. If you are going to use AI to help generate your code, at minimum you should be providing it simple pseudocode as a skeleton to get code that aligns with your plans.
A function is a standalone process. Each process should have its own function. Functions can return a state, a value, or run a process.
For example, you might have a function to check the temperature, and once it hits a threshold, you want the state to turn from False (the temperature isn't hit) to True (the temperature is hit).
CHECK TEMPERATURE STATE FUNCTION
function check_temperature()
if temp_pin_data >= 100
return True
else
return False
GET VALUE FUNCTION
current_wind_speed_level = 0
function current_wind_speed()
current_wind_speed_level = read pin value A1
return current_wind_speed_level
ACTIVATE PIN FUNCTION
function run_motor(direction)
if directon is forward
set Pin 1 to forward speed
else if direction is backward
set Pin 1 to reverse speed
CLOSE CHICKEN COOP DOOR
This code calls a lot of other functions. There are state functions, such as doorway_is_clear(), which would return True or False depending on the value of an infrared or ultrasonic sensor. The function run_motor_to_close() is an output function that activates the motor pin.
function close_door_safely()
# this while loop runs while the door is still open
while door_closed() is False:
if doorway_is_clear()
run_motor_to_close()
set_indicator_light(green slow flash)
else
pause_motor()
set_indicator_light(red slow flash)
# this code only runs after the door is closed
stop_motor()
send_alert(door closed)
set_indicator_light(solid green for 10 seconds, then off)