Erlang Language Lab
General Description
The main purpose of this exercise is to make a control system similar to the one from the C programming exercise.
It should read the values of the induction motor current, calculate RMS and detect the
overload (when RMS exceeds some given value).
It should also provide self-diagnostics which make sure that data is read correctly.
Skills:
Grading: points are given in square brackets.
Details
1. Reading Data
Using your experience from previous labs, write a function which reads data from
ac_current.dat and counts the number of samples.
2. Simple diagnostic system
-
Write a function which calculates the RMS value from 20 consecutive samples (in this case it is the main period of the waveform) [6].
Make the above functions work together, displaying the calculated RMS value [3].
3. Implementation of "the protection"
Using the previous functions, write a function which reads data from a file, calculates the RMS value, checks if this value exceeds some given level x (given as an argument), and exits if it does so [4]. The function should return the number of the RMS values read before it exits [4] and the violating RMS value as well [2].
4. Watchdog
A watchdog is a process which makes sure that other processes work properly.
It is often used to make sure that data from sensors is read.
Enhance your program to accommodate a watchdog.
Hints:
Spawn a watchdog process [2].
Make the reading function to send a message to the watchdog every time a new value is read [4].
If the watchdog waits for a message too long it should display a message: 'Input data flow is too slow at index:' [4] followed by the index value [2].
There should be a way to terminate the watchdog by sending it a special message [2].