Skip navigation
2015

This time I'm going to introduce the usage of a kind of magnetic sensors called digital magnetoresistive sensors. Magnetoresistive sensors are based on a property of several materials called magnetoresistance, consisting in the variation of their electrical resistivity when placed in a magnetic field. In practice, the current flow through a magnetoresistive wire depends on the strength and on the orientation of an external magnetic field. The adjective "digital" in the name of these sensors refers to the fact that they provide just two states: either they are sensing a magnetic field or they are not. In other words, they are not able to provide a precise and accurate measurement of the strength of any external magnetic field: they only react to magnetic fields stronger than a given threshold, providing a sort of signal that can be, in some cases, somewhat proportional to its strength. In most cases these devices are sensitive to the magnetic field only if it is oriented in a given direction (typically parallel to one of the sides of their package).

The Honeywell 2SS52MHoneywell 2SS52M is a device that belongs to the class of digital magnetoresistive sensors. It comes in a compact package with three pins (see picture): two of which are used to bias it (GND and Vcc), 2ss52m-imagewhile the third one is its "output".  The device is sensitive to magnetic fields oriented such that they are parallel to the longest side of its package (the white arrow in the figure). Being the sensor omnipolar, the orientation of the magnetic field doesn't matter: either south-north or north-south alignment triggers the device.

When the external magnetic field in the given direction is strong enough, the device works as a sink for the current. There are, in fact, two kinds of sensors: those whose output mode is source and those whose output mode is sink. A source is a point from which current flows from the device; a sink, on the contrary, is a point to which current flows. In order to operate a sink sensor, you need an external power supply to be connected to the sink through a resistor. If no magnetic field is detected, the sink works as an open switch and current does not flow from the power supply to the device. When a magnetic field is measured, instead, the sink acts as a closed switch and some current flows from the external power supply to the device.

According to the Ohm's Law, when a current I flows through a resistor R, the voltage drop across it is V=RI. In order to tell if the device is sensing a magnetic field, it is enough to measure V: if it is zero, no external magnetic field is present (apart, of course, the earth's magnetic field); if a strong enough magnetic field is placed close to the sensor you should be able to measure a voltage V.

schematic_bb

We can use an Arduino UnoArduino Uno board to build a device that is able to tell you when a magnet is close to a given position(see the schematic above The  2SS52M2SS52M can be operated with a wide variety of input voltages(from 3.8 V up to 30 V Connecting its leftmost pin to the Arduino ground(black wire and its rightmost pin to the Arduino 5V pin(red wire is enough to make it working Then we can use the Arduino 3.3V pin as an external power supply connecting this pin to the central pin of the sensor through a resistor chain will make some current flowing from Arduino to the device when a magnetic field is sensed It is important to limit such a current that must not exceed the maximum current that the Arduino board can provide through its pins 200 mA We must then connect the  2SS52M2SS52M central pin to the 3.3V Arduino pin by means of a resistor of at least

R = V/I = 3.3/0.2=16.5 Ω

Of course, since we do not need a large current flowing, using much higher values is recommended: this way the current flowing through the resistor will be much less, reducing power consumption and heating. For example, using a 2 kΩ resistor will cause a current of I = V/R = 3.3/2000=1.65 mA from Arduino to the sensor. On the other hand, the voltage drop across the resistor will still be 3.3V, independently of the current.

In the schema shown above we illustrate a possible alternative: the resistor through which the current flows from the Arduino to the sink is made by the series of two resistors. We then measure the voltage drop across one of them (we then expect that we are going to read 3.3/2=1.65 V). There is no special reason to do that, but to show how a voltage divider works!

The tricky part comes when trying to measure the voltage drop across the resistor. Voltages can be measured using the Arduino analog pins A0-A5. They measure a voltage up to 5 V with respect to the Arduino ground. However, the voltage drop across the resistor cannot be measured relative to it. Let's try to understand why. In the figure below you can see a schematic of our circuit.

2ss52mVwrong.png

The magnetic sensor is represented as a box connected to the ground and the 5V pin of the Arduino board. The sink is in fact a transistor that conducts when a magnet is close to the sensor and does not if the magnet is far from it. It is connected through a chain of resistors to the 3.3V Arduino pin. If you try to measure the voltage between the ground and the resistor lead connected to the Arduino pin you always see 3.3 V, irrespective of the presence of a magnet close to the sensor, since such a potential is always there with respect to ground.

If, however, you measure the voltage drop across the resistor, i.e. as shown in the picture below,

2ss52mVright.pngyou would see 0 V if no current is drawn from the 3.3 V pin to the sink, while you can measure 3.3 V in the opposite case. We must then measure the voltage difference between the leads of the resistors. To do that we can measure the potentials V0 and V1 at the two leads of the resistor with respect to the Arduino ground and obtain the voltage drop as V=V1-V0. We can, then, measure the voltage V0 connecting one lead of the resistor to the Arduino A0 pin (blue wire), and the voltage V1 connecting the other resistor lead to the Arduino A1 pin (orange wire).

magnets

When no current flows through the resistor the difference between the reading of A1 and A0 will be zero (or very small, because of possible fluctuations in the measurement). If the difference exceeds a given threshold, then, a current is flowing into the resistor, then an external magnetic field has been detected by the sensor.

This device can be used as a proximity sensor Fix the  2SS52M2SS52M to something and a small magnet(see e.g the small neodymium magnets in the picture to something else when the magnet is close enough to the sensor it gives you a signal In the Arduino sketch you can tell when the magnetic field is sensed waiting for a voltage drop different from zero using a function like this

void waitUntilSensed() {
  int j = 0;
  int thr = 100 + analogRead(A0); // get the "zero" level
  while (j < thr) {
    j = analogRead(A1); // read the other lead potential
  } 
  return;
}

When entering into the function, the first operation is to measure the voltage at A0, that is expected to be the same of A1, using the analogRead() function We then just continuously read the A1 pin until its value exceeds those of A0 plus 100 (or any other large enough value). The function returns as soon as a magnetic field is detected.

With two such devices you can build a system with which you can measure the speed of a cart or of a falling object Fix a small magnet to the cart and two  2SS52M2SS52M sensors on a rail at a reasonable small distance x(e.g 5 cm with respect to each other

With the Arduino connected to the sensors you can measure the times of passage of the cart in front of the first and the second sensor: t0 and t1. The time needed to the cart to travel for the corresponding distance x is t=t1-t0, then its average speed is v=x/t. Look at the following sketch.

// the sensor reading for which we can consider it as triggered
#define THRESHOLD 100
// the distance between sensors (in m)
#define S10 0.05

void sense(int pin, long int &t, long int &duration, float &resolution) {
/* This method return the time at which a magnetic field was sensed by a device read on pin*/
  int j = 0;
  int thr = THRESHOLD + analogRead(A0); // get the "zero" level  
  while (j < thr) {
    j = analogRead(pin);
  }
  // get the time at which the signal starts rising
  long int lead = micros();
  while (j > thr) {
    j = analogRead(pin);
  }
  // get the time at which the signal fall down
  long int trail = micros();
  t = (trail + lead)/2;
  duration = trail - lead;
  resolution = duration/sqrt(12);
} 

void loop() {
  // measures the times of passage
  int t0, w0, sigma0;
  int t1, w1, sigma1; 
  sense(A1, t0, w0, sigma0);
  sense(A2, t1, w1, sigma1);
  double v = S10/(t1-t0);
  ...
}

 

The sense() method waits until a non-zero voltage is provided from the sensor connected to the given pin. The micros() function returns the number of microseconds elapsed since the beginning of the sketch. Then, the sense() method provides a measurement of the time at which a magnet passed in front of the corresponding sensor, the duration of the pulse and its error (given by the statistical theory as the width of the pulse divided by the square root of 12). The ampersand in front of the parameters in the function tells the compiler to pass the address of the memory to the function and not its value, such that the readings are all passed to the variables used in the loop() function.

In fact we measure the time at which the voltage between A0 and another pin becomes different from zero, then we wait until it becomes zero again (in the second while loop). Measuring the time at which the signal starts to be non zero and the one at which it returns to zero, we can assume that the magnet passed in front of the sensor at a time given by the average of the two times. The duration of the passage is given by the difference of the two times.

Measuring the times of passage in front of two sensors we are then able to tell the speed of the cart as the ration between the distance traveled S0 and the time of travle t1-t0. With three or more sensors, you can then measure the speed at various positions of an object to study its motion. With such a system you can do many physics experiments, in fact. The cost of such a system can be below 40 EUR, while a professional system to make the same experiments with a comparable precision may cost from hundreds to even thousands of euros!

According to my very preliminary tests, I was able to trigger the device using a small neodymium magnet (4 mm diameter) when it was at about 2-3 cm distance from the sensor. My plan is to make a systematic measurement campaign that will be reported on my free e-book on scientific uses of Arduino boards. The e-book is in preparation and there is a very preliminary version at http://www.roma1.infn.it/people/organtini/publications/scientificArduino.pdf.

Hello mates.

 

Here I come again...I really continue figuring out how to reach a very mall and continous speed of rotation, with a very high precission.

What I want to make is a mount to put on a camera and shoot photos of the night skies. My original idea was in the line of control the movement of my telescope, but I think this is unreacheable in my monetary conditions.

 

So I am here with this paint schema

concept-astrophoto.jpg

 

The mechanism has aproximatelly 30 cm width and 30 cm height.

The structure will be made with plates of alluminium of 1,5 mm wide

You can think the camera is a small reflex camera (like Nikon D3200)

 

I had thought that I could reach this with an Arduino UNO board and a pair of sttepers. But when I have started to play with the Arduino board that I bought, some thoughts have come to me. I dont know how to choice the better options.

  1. Will I be able to make this mecha move with a pair of small sttepers 28BYJ-48 with ULN2003 driver?? I have not got the structure pieces yet, so I have not been able to probe this yet.
  2. What do you think will be the better way to control the movement of motors? Bluetooth, IR, RF?
  3. If I would wish to know the angle where the camera to be pointing, ¿what would be the better way? Would I need any optical sensor? or it would be enough with some variables in the code with which I control the sttepers to know this data?
  4. Whatever the choice of motor type, I need to know how to provide movement in the vertical axis. I mean: it would be better a small gear in motor axis and a big gear in the basis? or a wheel in the axis of the motor and a simple circle as basis?

 

Thank you in advance.

And please, escuse me if I explained it bad

The Arduino Yun is a 2 part device, half a conventional Arduino micro controller and half an embedded Linux using OpenWRT/Linino with Ethernet and Wifi connectivity.

 

Because there is an operating system as well as application code on the Linux side there is a need to keep that code up-to date. This guide compares the different techniques and discusses when best to use each one.

BridgeBlockDiag.png

The Linux portion is made up of the software components, the boot loader (U-Boot), the Kernel and the Applications/Configuration. Reflashing the Yun will update all of these so you will loose your configuration and applications. For the applications it is possible to upgrade those independently using the package manager OPKM.

 

Ensure that you've copied your applications and configuration or have a way of recovering those before continuing with these processes. Note that you may need to update packages using OPKM following a reflashing.

 

There are various versions of the instructions for updating the flash, many of these are specific to particular companies or projects. However there are generic instructions on the Arduino site. Arduino - YunSysupgrade

 

IMPORTANT!

Do not power off the Yun whilst doing a reflashing process!

 

It will take about 3 to 5 minutes so ensure that you have time and power to complete the process.

Powering off the Yun in a middle of a reflashing process may result in a device that won't boot.

 

Getting images

 

The Yun will support several different images including OpenWRT, you can even build your own images. For starting up or recovering a Yun you are probably best with the official Arduino image, an alternative that I've found to work is the Linino image.

 

http://www.arduino.cc/en/Main/Software

http://wiki.linino.org/doku.php

 

SD Card and Web UI

 

This is the standard approach, you copy the image file to the SD card and use the UI to load it. It's a fairly straight forward process with the only "gotcha" being that the Wifi is reset hence you need to connect to the Arduino's access point as if you'd just started from scratch.

 

SSH and sysupgrade

 

Using the console and sysupgrade is a good approach if you are comfortable with using the shell. It would also be a good approach if you had many devices to upgrade as it could be automated. You can also use the WGET command to download the image directly onto the Yun which is a good approach if you don't have another technique for getting images onto the SD Card. The Linino site suggests that you can preserve your configuration files with this approach but I've not tried that.

 

Arduino - YunSysupgrade

Linino Wiki - Upgrade using SysUpgrade

 

U-Boot and TFTP

 

WARNING!
Following this guide will VOID the WARRANTY of your Yún

 

The instructions at the top of the Arduino page tell you not to do this step unless you are really certain. I've not actually managed to find out what that warranty consists of so I'm not sure what you are giving away.

 

However I'd recommend trying the other approaches first as this technique is a little fiddly. The key thing about this process is that it will work even if your Yun does not boot up properly. I had to try this approach as I'd unthinkingly pulled the power in the middle of a reflashing step.

 

This approach requires 3 different images. It's worth doing these as a set because there may be incompatibilities between the different components. I ended up at one point with a board that would boot partially and then report lots of errors.

 

You must use the WIRED Ethernet connector for this approach.

 

You also need to setup a TFTP server, I found a simple one for windows that I could use. It's worth downloading a client too so you can test your server. Note that you might need to adjust your firewall settings to be able to use the server.

 

http://www.arduino.cc/en/Tutorial/YunUBootReflash

Abstract

As most of you know, I am doing a quadcopter from scratch project where I make almost everything from scratch. In doing so, I had to understand the dynamics behind the software/firmware and in order to explain the quadcopter, I can start by explaining a balancing robot. In this post, I explain the build and provide a video demo for the robot. Lets go!

 

The build

I usually build stuff from scrap and recycle what I can and this project is no different. I start with some scrap wood and made a simple box like frame. I trimmed off wood from the sides to reduce weight and to make it a little more presentable. Finally I added some paint and a quick and dirty job later, I have a robot frame.

IMG_20150411_201416.jpg

As you can see, in the above pic, I have some motors and wheels attached as well. I bought the wheels a long time back and the motors were purchased online. These motors are 288RPM 12V rated and have optical encoders so that we can track the distance moved by each wheel. I clamped these motors in place using some sheet metal pieces I cut up from the scrap tin boxes I had. You can use soft-drink Tins etc as a source of the sheet metal and self threading screws to attach them to the wooden base.

 

In order to drive the motors, I am using an L293D motor driver which came from an older robot which lost it's wheels in an accident.

Since we need a place to put the control board, I used a cardboard box and cut out an H shaped plane to sit atop the motor driver floor. The control board itself if an Arduino Uno which I received as a part of the Internet Of Holiday Lights Challenge from Element14 and I made a shield for the MPU9150 breakout board. The image below shows the same shield but on the FRDM K64F board which I was using for the quadcopter.

IMG_9611.jpg

I scraped together some libraries from the internet for the MPU9150 as well as PID control and a few hours of head scratching later, it actually worked! The video below shows the working robot in action.

I had some failures along the way but it was quite easy and only a few hours of work once you know what you are doing. In the next post, I will be sharing some more details on the code as well as things that you need to consider when making one yourself.

 

Cheers,

IP

This kit is a open project I have described in detail  on electroschematics.com, available on Tindie.com

Just yesterday I have published the tutorial on the assembly instructions on Instructables.com for who is interested. Further details on www.balearicdynamics.com

 

Cheers

4ringfan

Embrio for Arduino.

Posted by 4ringfan Apr 4, 2015

Has anyone seen or played wtih this visual, real-time development tool for Arduino programming yet?

Embrio - A visual, real time development tool for the Arduino

Program software for the Arduino in real time without writing code!

https://youtu.be/tiihsBPUkJ4

 

Kind of an interesting real time way to program.  Including waveform of the inputs and logic.

 

I just found it today.  Check it out!

And the winner was...

20150328_161248.jpg

Craig Terris. Here is is receiving his Arduino starter kit from Zac Colley, very kindly supplied by Element14! We drew the name from a hat, an actual hat; a room full of computer nerds and we fell back on good old tradition! Thanks odion

 

We had a brilliant day; we had a mum and her son who had the Ardunio for Christmas and had not got much further than blink, he had a go at a few of the projects in the starter kit book and had a good time. One of the strangest projects was "Party Face"; no pics unfortunately. This was an Uno with ethernet shield, (for the SD card capability), hooked up to a speaker and mounted in a cardboard mask. The guys worked extremely hard in getting the Uno to play a wav file stored on the sd card. The point? Well, as we all know, students like to party; when the partying gets too much, pop on the mask and have a sleep. The Uno then plays the messages stored on the SD card. We heard a lot of crackling to start then suddenly "Thanks for coming!" could be heard clearly. If there was more time I think the idea was to use ultra sonic detector to tell when someone approaches and the message plays to say, well whatever is programmed.

 

Roll over Apple, we have the coolest smart watch prototype here, Arduino style.

 

20150328_160754.jpg

As you can see, work in progress although we have working bluetooth connection and working displays. I am all for keeping it this size and having it strapped to the users forearm rather than making it smaller and watch-like but I am not sure how this will go. There is talk of making a custom PCB next although discussions were made about a 3d printed wrist mount.

 

We have python on Linux talking to and receiving from the serial output of the Mega, SMS powered RGB led with incoming messages changing the colour of the output and then sending back a text letting the sender know it had worked. But mostly people played and had fun; this was the whole point of the day. We will be setting up something else, hopefully on a regular basis, looking at names at the moment, Pompey Proto People seems likely!

 

So, that was it.

Filter Blog

By date: By tag: