Recess Week 19th September to 25th SeptemberEdit

During this week’s meeting, I explained the problem to the team. Jeffrey hinted that the team might have to experiment with different electromagnets and hall effect sensors that can produce a stronger reading. I suggested the use of Infrared Red (IR) or a camera system in order to pinpoint the position of the user input. However, Jeffrey wanted to maintain the same methodology as close as possible. That means the input interface must be analog and organic such as a liquid, rather than a digital input such as IR.

An alternative would be to reverse the magnetic fields of alternate electromagnets. That way, it would be significantly easier to discern the different PWMs the electromagnets are running on. It is an idea I will be trying out later in the week.

I pointed out that the main purpose of Hall Effect centric is to eliminate messiness. Jeffrey concurred and suggested we could use another type of material to replace ferrofluid. Several materials were brought, including iron filings and a clay like material, Silly Putty. Given that this involved a radical revamp of the entire system, we decided to table this option for now and only use it as a last resort.

In the meantime, I am to conduct an experiment with two electromagnet

Testing electromagnet

Testing out the effect on Hall Effect Sensor with only two electromagnets turned on

s and 1 hall effect sensor. The experiment entails trying to program the hall effect sensor to discern between only two electromagnets for now. The purpose is to figure out the best way to identify the different PWMs with just only two electromagnets. If even that is impossible, we will have to find another way to implement the system.

For the experiment, I connected an oscilloscope to the hall effect sensor and set the PWMs of the electromagnets to 200 and 100 (Maximum = 255).
Testing with oscilloscope

Testing out the Hall Effect Sensor Output with an oscilloscope

These values differ en
ough to generate a different voltage reading when the

hall effect sensor is placed approximately 1.5 cm directly above the electromagnet.

The results of this simple experiments are as follows:

Hall Effect Experiment 1 Results

With these readings, I set about to set the threshold to invoke the actuation of the different magnets using the equation ADC Value = [(Analog Input)/(Max Possible Analog Input)] X 255. The maximum possible analog input is found to be 4.92 V.

This is what the code looks like:

void Quantise(int value)


if(value > 200 ) //threshold value for electromagnet set at 200


SensorState = 1;


if(value >= 171 && value <=177) //threshold value for electromagnet set at 100


SensorState = 2;




SensorState = 0;



Over the rest of the week, I attempted to program the microcontroller to activate different notes at different ADC values from the hall effect sensor. Detection of the PWMs of two electromagnets was achieved fairly easily. Several problems arose as soon as I increased the number of electromagnets to three. Firstly, I had to work within a very small range, from 2.5V to 5.2V across all six electromagnets. As the number of electromagnets increased, I had to reduce the detection range of each electromagnet. As a result, the system often played the wrong music because of a slight deviation in the ADC value when the position of the hall effect sensor was shifted only slightly. To address this, I programmed the system to read in multiple ADC values and only play the notes when the hall effect sensor is within a certain range for a period of time. This worsened the problem as the system is unable to acquire enough readings due to the unstable readings I am getting from the hall effect sensor. As a result, the system was unable to meet the condition I have set to play the music.

The second problem was trying to find out the correct decimal value to send via the USART in order for the Java problem to recognise and play the corresponding notes. To address this issue, I had the system send every value from 0 to 100 with a delay in between. Having done that, I proceeded to jot down the values that elicited a musical note from the system. It was a tedious and time consuming way of tackling this issue, but I got it done nevertheless.


The next step I tried was to reverse the polarity alternate electromagnets so that the detection range can be extended. This has no impact on the actual physical deformation of the ferofluid because it is non-magnetic. It will respond in the same manner regardless of the polarity of the electromagnet beneath it. With the polarity inversed, I find that I can work within a much larger range, from 0.3 V to 5.2 V. As such, I have managed to programmed the system to recognise three electromagnet positions so far. That said, I noticed the difficulty in pinpointing the exact position of the hall effect sensor to initiate a music note. This is because the values are analog and fluctuate to a fairly large extent. This can be attributed to the fluctuating magnetic field generated by the PWM pulses I have set as well as magnetic noise, making it difficult to pinpoint the exact position of the hall effect sensor. Therefore, I need to find a way to eliminate these unwanted fields so that I can detect the exact position and height above the electromagnet to initiate a musical note.

To that end, I decided to consult Yu Shuang on the possibility of using Fast Fourier Transform or Cross Correlation to discern the electromagnets from each other. The idea is that since each electromagnets generate a unique waveform with different frequencies on the hall effect sensor, we could exploit that to identify the electromagnet that is generating that particular waveform. However, Yu Shuang pointed out that because the fluctuations of the electromagnetic fields varies widely with varying distance above the electromagnet, it will be difficult to pinpoint the exact waveform to use as a point of comparison. Fast fourier transform is difficult as well because we do not know the frequency the system’s running on.

I decided to research on possible electromagnets and hall effect sensors that may yield better results. Two possible solutions came to mind.

The first of which is to attach a rare earth magnet of varying strenghts to each of the six electromagnets. This will introduce an offset that is significant enough to produce a distinction in the overall magnetic field. This will translate to a wider detection range of values for the hall effect sensor and will give me more leeway to trigger each of the electromagnets.

An alternative would be to place one hall effect sensor above each of the electromagnets and perform a system calibration. In this calibration, each hall effect will measure the strength of the magnetic fields generated by each electromagnets at the closest possible distance. The reading will be used as an offset to be deducted or added to the hall effect input sensor. This eliminates the fluctuations of the magnetic field generated due to the PWM pulses I have set as well as magnetic noise. I will discuss this implementation next week with the team and seek their opinions on the matter.

Objective Checklist

  • Research on other methods of solving the problem of fluctuating electromagnetic fields
  • Research on more sensitive hall effect sensors that can yield a better result
  • Look for strong rare earth magnets that can generate a large enough change to the hall effect sensor reading
Community content is available under CC-BY-SA unless otherwise noted.