Magnetometers are able to measure the strength of magnetic fields. Combine the readings from two axes using trigonometry and you have a compass! This week in The Factory we're taking a look at the latest PiicoDev 3-axis Magnetometer prototype and brainstorming some fun and useful applications for magnetometers.

Transcript

Welcome back to the factory. We're in the Makerverse studio today because there's a bit of construction happening outside and I'm joined by Peter who is working on the latest PiicoDev module, a PiicoDev three-axis magnetometer.

What is, what's a magnetometer? What is this thing?

Yeah, so a magnetometer is a sensor that can measure the magnetic field strength in the x direction, the y direction, and the z direction. This is based around a QMC 6310 chip and it is tiny. That is. So I've got that here to show you. Amazing. And each of those pads is 0.2 millimetres in diameter. They're circular pads and I haven't worked with pads that tiny before. I bet assembling this must have been quite a challenge. Even just like the size of the pad and the thickness of the stencil. It was a challenge. In fact, I had one failure out of three of my tests. So yeah, what I found is that I just had to show an extra special bit of care around that, making sure that that solder paste got through into the chip. And I sort of showed it the same amount of care that I might have shown a one millimetre pad.

Yeah, right. Okay, so you've got something that can measure magnetic field strength in three axes, but what do you actually do with that information? What's that useful for?

Okay, so the most obvious use case is a compass to measure your bearing on the earth's crust. So we're going to just for now ignore the z component of the magnetic field and we're going to point this magnetometer into different directions and we can see that using some trigonometry, we can get a bearing. And that is surprisingly smooth. That is impressively free of any kind of jitter or noise. It's a very,Very flat line. Yeah, it's satisfying, isn't it? Yeah.

So at the moment, we can point this around to what is true north, and we can see that this office has got a bit of magnetic disturbances in it. Yes, we got this little pair of tweezers here. I wonder if they, you know, just moving those tweezers around the sensor is changing that heading. There's clearly something happening where if you have some metal around, it will interfere with that reading. So if moving just this pair of, like they're not magnetized, but they are ferromagnetic, just moving this pair of tweezers around is affecting the reading. Like there's metal on this board. There's like metal in these connectors, in these capacitors and resistors. Surely they're going to have some effect as well. What's going on with those? Yeah.

So I mean, all capacitors have got trace elements of iron that you just have to live with. So how do you calibrate a sensor like this? Like what's the procedure?

Okay. Well, let's just look at the procedure for an X and a Y direction, and we'll forget about the Z direction. So we're calibrating for a compass scenario. You hold your compass flat on earth. So that's, yeah, that's fine. That's right. So what you would do is you grab your magnetometer and rotate around slowly. So we're getting all readings of both the X and the Y component, and we do a full 180. And if we were in calibration mode, then the sensor, then the Raspberry Pi Pico logs all of that data and then runs a calculation. And it runs a calculation where it looks at the maximum and minimum values that it just observed and stores the average on a file on the Raspberry Pi Pico. So this is a reading.That we took when doing a few rotations in the XY plane of our magnetometer. And the top one is the X reading for the magnetic field strength and the bottom one is the Y reading. And as you can see, one lags the other in phase by about 90-degrees. By what looks like 90-degrees. That makes sense.

Yeah. So on this data, you can see zero is right down the middle of that plot. And these readings are heavily offset, heavily offset. So like in an ideal world, these would both have like a zero DC offset. They would both be just oscillating about that zero point.

That's right. And we designed this carefully so that we don't have these offsets right off the bat. So out of the box, these capacitors, these decoupling capacitors are spaced a little bit further away than you might normally space them for decoupling an IC.

Right. With decoupling, you want to get the capacitor as close as possible to the chip.

That's right. So on this particular case, well, there's little bits of iron in those capacitors and we wanted this thing to be the best experience out of the box without calibration. So they're spaced a little bit back, the tracks are a little bit thicker, but those readings on that graph look like it's shocking.

Yeah, that seems quite poor. Like the X axis, it doesn't even make it to zero at its lowest point.

That's right. So I was...

So what's going on there?

Well, in our lab, Brenton came up and got this magnet and just mashed the back of it with it for only about two or three seconds. That's all it takes. These are... Neodymium magnets? They might be. So it did a bit of damage and you can see that by a complete, like huge DC offsets there on the magnetic.Field strength. So this raw data, where you're taking it through a few full revolutions, once you take those max, that maximum and minimum value of each axis, you wind up with that.

That's right. So for the end user using this device after they've calibrated, then the readings just come out exactly like that without having to think twice.

Right. But this is still just raw, like XY magnitude data, like XY field strength data. This isn't a heading yet.

That's right. So it's corrected first. So we've added this correction and then we can do it through the magic of trigonometry. The magic of trigonometry. We can get a bearing.

So what are we looking at here? So this is the same data of us rotating the sensor around, but this is post calibration. So this is actually the same data set that we started with, but we're using the same algorithms that the user of this device would use, but we've just simulated it in Octave.

So when the user calls, like get heading or compass dot get heading without calibration, they'll get, they would have got this like pretty shocking red line, which goes from, I don't know what, positive 25 to negative 80 or so. And that was a full revolution.

That was a full revolution. And then by performing that offset, you've now got this like, this beautiful 180 to negative 180 sweep as you rotate it around.

That's right. So we're in the library. We're adding the normal reading, which is the calibrated reading option, but also you can get the raw readings if you want as well to see just to experiment and see what the performance is without calibration. And you can compare and play.

This is me moving the magnet. That is awesome. You'reMoving like 10 millimetres and you've got resolution across that whole 10 millimetres. Yep. And I'm all, and I'm about, what about 150 millimetres away from the sensor right now? Yeah. Like at least, at least a hundred mil. That is amazing.

So this has got a really cool use case or a bunch of use cases. You, well, do your oyster. Well, do your oyster. You could sense things that are. A non-line of sight proximity sensor. Yeah. How far out, how far out can you take it on this?

All right, let's drag it away. There we go. Look at this. So we're about, what about 20? I'd say we're getting close to 150. Oh, hurry up. Let's just go faster. That's wild. So look at this where we're sensing about 200 mil. No more. So you're moving like the width, the width of the nut that's on the end of that stack of magnets and you're able to, to detect that. Yeah. That's fun, isn't it?

Well, I guess that answers the question. Like, why might you want raw data? Because, you know, like a magnetometer, like, of course you just want to use it as a compass, but this is actually, this is pretty cool. You could use this as, you know, a really, really smart Hall effect sensor with like tunable in and out points. Yeah, that's right. You can have a whole bunch of thresholds and you could, yeah, you could almost use it like an analog situation. You'd have to take the earth's rotating field into account when you're setting up your project a little bit.

What happens if you turn the magnet around? Let's have a look at that. So you could. You could detect, you could detect a rotating shaft from that far away. I think we're about 300 mil now away. That's pretty cool. Yeah, pretty cool.The identity of magnets, but you know, you could, but that's, that's a sweep of like, let's just try with one. I'll have to take this away. I have to put them on the other side of the office.

That's just with one of those. Something that kind of makes intuitive sense, but it's like pretty amazing to see is when the magnet is sideways. So it's like co-planar with the sensor. You can move that magnet around and nothing happens. But then when you flip it up, you get that disturbance.

Yeah, that is, I mean, of course it makes sense. Like the field lines are going through the axis that we're not reading. But like, what a, what a great demonstration of how well isolated the axes are like the cross coupling between the axes is.

That's right. And you can experiment by reading X, Y, and Z all separately and seeing what values you get for the, for various positions of magnets. And this is giving us some ideas for the tutorials.

Yeah. Thanks for joining us for that little fireside chat about probably more than you wanted to know about a magnetometer. Thanks for joining me, Theodore. It's been fun. If you, if you have any questions or if you just want to see something a little bit closer, hit us up on the Core Electronics forums. Until next time. Thanks for watching.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.