Giter Site home page Giter Site logo

Random Crashes?? about qmc5883l HOT 13 CLOSED

dthain avatar dthain commented on August 18, 2024
Random Crashes??

from qmc5883l.

Comments (13)

Seabrand avatar Seabrand commented on August 18, 2024 2

😀I like spooky hardware, but for an engineer this smells like drawing current from an internal pull resistor. Are you sure nothing is shortning, or an LED perhaps?

from qmc5883l.

dthain avatar dthain commented on August 18, 2024

Hard to say, I haven't seen this behavior.
What's your hardware setup?

from qmc5883l.

elitewill1200 avatar elitewill1200 commented on August 18, 2024

I am using an Ardunio UNO hooked up to Sparkfun's GPS Mouse that has one of these onboard (although their documentation doesn't say how to interface with it, it's there and on the SCL and SDA lines).

from qmc5883l.

dthain avatar dthain commented on August 18, 2024

Just for comparison, I have been using this code for on an Arduino Nano, Ardunio Mega, and Teensy-2.0 on a soldered circuit board with a short (centimeters) I2C bus with three devices (BMP-180, MPU-6050, QMC5883L), and haven't observed any hanging problems.

For reference, I assume you are using this, right?
https://cdn.sparkfun.com/assets/learn_tutorials/5/7/1/GPM-808G--UAV_GNSS_receiver_ublox8030_QMC5883.pdf

It possible there is a problem in the QMC5883L driver. As a first debugging step, I would suggest adjusting your sketch to use readRaw() and print out the raw compass values instead of the calibrated values. If that runs stably for a long time, then it means there is some problem in the calibrated readHeading().

It's also possible there is a problem in the hardware. From the picture in the datasheet, I am somewhat concerned about the length of the leads: I2C isn't really designed to be used as an off-board connection, although it can work sometimes. You may also need to add (or adjust or remove) the termination resistors on the bus: some devices have them built in, and some don't. Sometimes the termination needs to be adjusted depending on the bus voltage.

And, just to eliminate all the possibilities, you might just try some other simple long running sketch (e.g. just print out the time once per second) and see if the board crashes. If that's the case, then you have some other underlying issue.

Hope that helps, let me know what you find.

from qmc5883l.

elitewill1200 avatar elitewill1200 commented on August 18, 2024

I did some digging and it turns out I was using 5 volt logic to the chip, however it was being powered with 3.3v. Now that I added a level shifter, the chip wont even init which is annoying. I am a little over my head here

from qmc5883l.

dthain avatar dthain commented on August 18, 2024

This seems to be a pretty common arrangement -- the chip runs at 3.3v, but the board has a regulator (and sometimes) a level shifter for the signals, so it appears as a 5V device externally.

from qmc5883l.

AugustineSena avatar AugustineSena commented on August 18, 2024

Yeah, I have same problem. For my case, i'm using Arduino Mega 2650 R3, I put directly SCL and SDA (that two without number - close to ICSP port). It works for me.
Arduino-MEGA-pinout

from qmc5883l.

dthain avatar dthain commented on August 18, 2024

Let's try to narrow down the source of the crash by eliminating some code.
This sketch just reads and prints the raw values, without calibrating.
If you run this, does it still crash?

#include <QMC5883L.h>
#include <Wire.h>

QMC5883L compass;

void setup()
{
        Wire.begin();
	compass.init();
	compass.setSamplingRate(50);

	Serial.println("QMC5883L Compass Demo");
	Serial.println("Turn compass in all directions to calibrate....");
}

void loop()
{
    int16_t x, y, z, t;
		compass.readRaw(&x,&y,&z,&t);
    Serial.print(x);
    Serial.print(" ");
    Serial.print(y);
    Serial.print(" ");
    Serial.print(z);
    Serial.print("\n");
}

from qmc5883l.

turnimator avatar turnimator commented on August 18, 2024

The code above still crashes on my Wemos Mega after about 20 values have been printed.

from qmc5883l.

turnimator avatar turnimator commented on August 18, 2024

I moved the QMC5883L closer to the SCL,SDA pins on the Wemos Mega.
Now, it appears to run like a dream.
The funny thing is, I didn't shorten the cable.
I'm a programmer, not an electronics engineer, so I'll just write that up as 'Spooky Hardware At A Distance'.

from qmc5883l.

turnimator avatar turnimator commented on August 18, 2024

I swear by my mother's cold, dark grave. With the cable attached, I moved the sensor closer to the board. Values are still ticking out. I can move it, I can shake it, I can rattle it.
Before I moved it, it would barely print 20 values before locking up.
It's probably something with picoFarads, but to me, it's magic.
Or microHenries? The cable was straight, now it's arced.
The sensor was at the other side of an L298N motor driver board, but I ran the Wemos Mega off the USB, so the L298N should be powered down.
Others have had similar experiences in the distant past:
http://www.catb.org/~esr/jargon/html/magic-story.html

from qmc5883l.

dthain avatar dthain commented on August 18, 2024

Ok, I think we have established that it's a hardware problem.
I2C was really designed as an on-board communication mechanism.
It can be carried by wires off-board, but they have to be kept very
short, otherwise strange things can happen...

from qmc5883l.

Seabrand avatar Seabrand commented on August 18, 2024

Ok, I think we have established that it's a hardware problem.
I2C was really designed as an on-board communication mechanism.
It can be carried by wires off-board, but they have to be kept very
short, otherwise strange things can happen...

Are you sure you are using the right pullup resistors on both the SDA&SCL pins? See https://en.m.wikipedia.org/wiki/I%C2%B2C, physical layer: measure the line capacitance C and pick a high resistance R allowing a bitrate up to 1/RC

from qmc5883l.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.