• No results found

Filter implementation Arduino

5. Realisation

5.4. Implementation Arduino

5.4.1. Filter implementation Arduino

First of all, the filters needed to be implemented in the Arduino. To do this, an online program [116] was used that automatically generated Arduino code for a filter, based on the chosen type of filter, order, sampling frequency and cut off frequency.

Unfortunately, only a 2nd order filter could be made with this program. To check how much difference there would be between this Arduino code, using a 2nd order filter, and the Matlab results, the Arduino code was translated to an excel function and all steps done in Matlab (high pass, low pass, absolute values, second low pass) were now executed in excel using the Arduino code, with the only difference that now a 2nd order filter was used instead of a 4th order. The data that was filtered in excel was the data obtained during the emulation in the freezer for the ‘sitting straight’ posture and the ‘laying on the left side straight’ posture. This way, the graphs made in Excel could be compared with the Matlab graphs (figure 68 and 74).

Sitting straight

The values entered into the program for the high pass filter and both low pass filters can be found in table 6 and the corresponding code in appendix I-1. The result can be seen in figure 75. When comparing this to the Matlab graph in figure 68, it can be seen that there is now also a peak in the ‘moving’ signal that passes the amplitude threshold of 10 mg. Therefore, having a 2nd order filter

71

does decrease the differences in the signal between shivering and other types of movements, increasing the possibility of false positives.

Table 6: Values entered for different filter types

Figure 75: ‘Sitting straight’ signal obtained by using 2nd order Butterworth filters. There is now a false positive in the moving signal.

The program also gave as an option to use a 2nd order band pass filter, instead of using a high pass filter followed by a low pas filter. Therefore the filtered signal using this option, with the same cut off frequencies of 8 and 10 Hz, was also looked at and compared with the filtered signal using a high pass filter followed by a low pass filter. The values entered for the band pass filter can be found in table 6 and the corresponding code in appendix I-1. The results can be seen in figure 76. Based on these results, it was decided to continue with the band pass filter, because the amplitude of the peaks of the shivering movements became in general larger, while the amplitude of the peaks of the moving signal became a bit lower with this filter.

Furthermore it was decided to change the threshold value from 10 mg to 12 mg, such that, when using a band pass filter, no false positives are measured in the moving signal.

Filter type Character Frequency

Sitting straight

High pass Butterworth, high pass, 2nd order Samplerate checked, sample rate 50Hz, lower corner 8Hz

Low pass 1 Butterworth, low pass, 2nd order Samplerate checked, sample rate 50Hz, lower corner 10Hz

Low pass 2 (envelope) Butterworth, low pass, 2nd order Samplerate checked, sample rate 50Hz, lower corner 0.7Hz

Band pass Butterworth, band pass, 2nd order Samplerate checked, sample rate 50Hz, lower corner 8Hz, upper corner 10Hz Laying

side straight

High pass Butterworth, high pass, 2nd order Samplerate checked, sample rate 50Hz, lower corner 9Hz

Low pass 1 Butterworth, low pass, 2nd order Samplerate checked, sample rate 50Hz, lower corner 11Hz

Low pass 2 (envelope) Butterworth, low pass, 2nd order Samplerate checked, sample rate 50Hz, lower corner 0.7Hz

Band pass Butterworth, band pass, 2nd order Samplerate checked, sample rate 50Hz, lower corner 9Hz, upper corner 11Hz

72

Figure 76: Difference in ‘sitting straight’ signal between Butterworth 2nd order band pass filter and a combination of Butterworth 2nd order high pass and low pass filter. When the amplitude threshold is moved from 10 mg to 12 mg and the band pass filter is used, no more false positives are measured in the moving signal.

Laying on the left side straight

The values entered into the program for the high pass filter and both low pass filters can be found in table 6, the corresponding code can be found in appendix I-2. The result can be seen in figure 77. When comparing this with figure 74, in this case also the peak just after 40 seconds touches the threshold line and the peak at around 55 seconds does pass the threshold of 4 mg, resulting in at least two peaks of the moving signal that are passing the threshold. Therefore, having a 2nd order filter will also decrease the differences in the ‘laying on the left side straight’ signal between shivering and other types of movements, increasing the possibility of false positives.

73

When looking at the difference between the combination of a high pass filter and a low pass filter and a band pass filter, the peaks in the shivering signals are higher with the band pass filter, see figure 78. Therefore this filter was chosen to be implemented into the Arduino code. The values entered into the program for the band pass filter can be found in table 6, the corresponding code can be found in appendix I-2. Furthermore, it was decided to change the threshold value from 4 mg to 5 mg. Doing this will get rid of two of the false positives in the moving signal, while still three peaks in the shivering and the shivering+moving signal passes the threshold.

Figure 78: Difference in ‘laying on the left side straight’ signal between Butterworth 2nd order band pass filter and a combination of Butterworth 2nd order high pass and low pass filter. When the amplitude threshold is moved from 4 mg to 5 mg and the band pass filter is used, only one false positive is measured in the moving signal.

Related documents