Kuva Vasemmalla - Zoom

this weeks assigment was to take data from the input devices week's board, and use it with a program.

As my board has multiple sensors, but not enough memory to run them all at the same time, I had to pick one sensor to use. So I chose my hall sensor, this did turn out to be problematic because the board gives out a float value of milligauss due to the math in the board's programming. Not only that but I had to calibrate the sensor, to get as close to 0 as possible, while the value varied a great deal. It was just matter of trial and error to finetune the calibration value down to 515, that gave me enough of accuracy that it was simple enough to then round out the error variance.

I chose to use processing language, as it was pleasantly simple to work with and java based. I essentially just merged two sample codes, the simple read to give me access to the datafeed from the board, and the bezier to give me the capacity to draw the lines.

Kuva Vasemmalla - Zoom

The purpose of the bezier lines, is to simulate the way magnetic fields are displayed when you add some ironfilings to the magnetic field. To create a proper simulation one would need atleast 2 sensors, and keep track of the changes in the field strength to get the proper number of the lines visible.

I needed to make some changes to the how the board gives its data out. Because in processing, to get the accurate values from the sensor I brought them in as string value that I then converted to float. This created the problem, that a good deal of the incoming data read as NaN. Using the readStringUntil(lf) allowed me to define the end of line, and it was easier for the software to process the incoming values. But the problem with NaN persisted, so I realized I had to sanitize my data feed from the board. I had calibrated my hallsensor pretty well so most of the data it sent was 0, so there was no data to send, thus the problems with the NaN. So I made a simple if loop, that cuts off the +-10 values and reports out everything beyond them. A magnetic field that weak, pretty much is as good as not there, to begin with.

Kuva Vasemmalla - Zoom

                            
  float gauss = (analogRead(hallPin) - NOFIELD) * TOMILLIGAUSS;
  //float temp = analogRead(tempPin);
  //float light = analogRead(lightPin);
  if (gauss > 10)
  {
  Serial.println(gauss, 2);
  }else
  {
    if(gauss < -10)
    {
      Serial.println(gauss, 2);
    }
  }
                            
                            

This gave me a nice clean feed of pure numbers to convert to float. So now it was just matter of using the figures to do something, so I chose to use them for bezier lines. With proper calibration of their values, I believe one could use them to create a simulation of the magnetic field lines.

One of the problems I ran into was lag, the incoming data processing didnt happen in true real time, even though when looking at the feed directly with putty, the values changed in real time. This would need to be addressed to develope the magnetic field simulation further, because of the way magnetic fields are. In direct feed you can see the steps at which the magnetic field strength changes, if you could process the data fast enough, you could use these steps to further improve the simulation. For example adding lines to the view as the chip senses the steps in the magnetic field, and that way making a simulation of the magnetic field. if one had a good number of hall sensors to work with the simulation could be more advanced.

The paperwork

Images List

The links