## ASSIGNMENT PROBLEMS

1. Write a ladder logic program that will implement the function below, and if the result is greater than 100.5 then the output ’too_hot’ will be turned on.

2. Write ladder logic to calculate the average of the values from thickness[0] to thickness[99]. The operation should start after a momentary contact push button A is pushed. The result should be stored in ’thickness_avg’. If button B is pushed, all operations should be complete in a single scan. Otherwise, only ten values will be calculated each scan. (Note: this means that it will take 10 scans to complete the calculation if A is pushed.)

3. Write a ladder logic program that will calculate the standard deviation of numbers in the locations f[0] to f[29] without using the STD function.

4. A program is to perform the following actions for a self-service security check. The device will allow bags to be inserted to the test chamber through an entrance door. If the bag passes the check it can be removed through an exit door, otherwise an alarm is sounded. Create a state diagram using the steps below.

1. The machine starts in an ‘idle’ state. The ‘open_entry’ output is activated to open the input door. The ‘open_exit’ output is deactivated to close the output door.

2. When a bag is inserted the ‘bag_detected’ input goes high. The ‘open_entry’ input should be deactivated to close the door.

3. When the ‘entry_door_closed’ and ‘exit_door_closed’ inputs are active then a ‘test’ output will be set high to start a scan of the bags.

4. When the scan of the bags is complete a ‘scan_done’ input is set. The ‘test’ output should be turned off.

5. The scan results in two real values ‘nitrates’ and ‘mass’. The calculation below is performed. If the ‘risk’ is below 0.3, or above 23.5, then the machine enters an alarm state (step 8), otherwise it continues to step 6.

6. The ‘open_exit’ output is activated to open the exit door. The machine waits until the ‘bag_detected’ input goes low.

7. The ‘open_exit’ output is deactivated to close the door. The machine waits until the ‘exit_door_closed’ input is high before returning to the ‘idle state.

8. In the alarm state an operator input ‘key’ must be active to open the exit door. After this input is released the door will close and return to the ‘idle’ state.