Magnetometer and extras

Hello, i am new here and have zero Arduino experience. I have an idea for a project and was hoping someone could tell me if it is possible.

I would like to take the total magnetic field from something like the HMC5883L board, run some calculations on it, then send out a square wave that has a frequency that matches the calculated results. The first part seems easy enough, but not sure how to go about with the square wave so that there are no interruptions. So an option would be to send out a trigger signal to say a 555 timer chip. Not concerned that much with the duty cycle at this point. Any help would be appreciated. Thanks.

Probably didn't explain this very well. The calculation results would be something like 1500Hz. So I want to create a square wave and send it to another device. Or else just send a trigger signal.

Bit of an odd request but you could do it with a timer triggering on an interrupt when it overflows, then changing the starting point of the timer from your calculated results.

Mind you this is not a thing that a beginner with zero Arduino knowledge could do so you need to learn a bit of code skills first.

Thanks for your reply. Just trying to see if this is possible. Probably don't want to update the frequency too often, say every thirty seconds. So if there is a slight interruption at that point it should be no problem. Can the Arduino do two things at once like that? I guess I'd call it juggling. Maintain a square wave and collect and calculate data? This is the part I don't know what I am doing. Yes, need to do a lot of homework to learn code, etc.

Okay. my thinking now is to run the frequency then once every thirty seconds or so get a new set of data, run the calculations, then adjust the frequency. So a slight gap of no frequency should be okay. Probably answered my own question.

One of the on board timers can generate a square or rectangular wave of a given frequency continuously, once set up properly.

Wow, sounds like just what I need! Now which board? The Uno? Or do you have a better suggestion?

What is the application? What magnetic field are you sensing, what is the square wave for?

i don't know what it is. Don't really feel comfortable discussing it. Some kind of evil energy causing me psychological issues.

Evil energy applied by a secret CIA mind control program, cool. But what do you need the square wave for? What will the squarewave be fed to? The answer may help drive the design for how to best create the squarewave.

It's something similar to epilepsy doing some research on. It's evil energy to me. thanks for your concern. Think I have what I need for now, but I have a long ways to go. This is just in the idea stage right now.

The ATmega328 in many Arduinos has three built in timers that can generate continous pulse trains. The built in PWM and analogWrite functions make it simple to set them up.

Consult the on line documentation for those functions to get started.

This is a project I did recently detecting magnetic fields

Maybe not quite what the OP wanted but it plays notes or sounds dependant on the magnetic vector. It is for a Raspberry Pi but will work on an Arduino, and if you use a 3V3 Arduino the hardware is the same. The mag it was in has a free PDF download you can use to get a free copy of it.

This is a project I did recently detecting magnetic fields
Wind Chimes on Vimeo

A project from the future! :wink:

Yes :slight_smile:
Just nipped into my Tardis and put it in the right time frame.
Thanks

Very interesting. Must take a lot of code. The quality of the video is spectacular.

Been looking through the info and to say I am overwhelmed would be quite the understatement. I couldn't even find a magnetometer project that runs on Uno. I know it can't be that difficult what i would like to do, but I don't even know where to start. Thinking it would be much easier to hire this out to someone but don't know where to go for that, either. Just a lost soul right now.

If the book "Arduino for Dummies" any good? Or any suggestions would be greatly appreciated.

I couldn't even find a magnetometer project that runs on Uno.

As I said this will run directly on a 3V3 Arduino, see the full article here:-

The code is in python and most of it is devoted to drawing the graphics.

To do the same thing without the graphics you could use an Adafruit Feather M0 and a Music maker Feather wing board.

the book "Arduino for Dummies" any good?

Yes I know the author, he is from the North West of England, as has been commented are a lot of innovative makers.

Grumpy_Mike:
Yes I know the author, he is from the North West of England, as has been commented are a lot of innovative makers.

. . . and moderators :wink:

Okay, will check it out. Thanks for the help.

jremington:
The ATmega328 in many Arduinos has three built in timers that can generate continous pulse trains. The built in PWM and analogWrite functions make it simple to set them up.

Consult the on line documentation for those functions to get started.

My only concern is that you are limited to a certain subset of frequencies based on prescaler values. Maybe OP needs more resolution or a different Hz range than what the clocks/PWM can provide. That is why we should first consider what the squarewave will be fed to first before nailing down what to use to generate the wave.