Jump to content
I2Cdevlib Forums

Leaderboard

Popular Content

Showing content with the highest reputation on 02/03/2015 in Posts

  1. Hello, Basically what I am doing is I have the ADS1115 in single channel mode, measuring the voltage across a resistor, which indicates the current flowing through the resistor. The current comes from an AC Current Clamp which sits on my mains power board. Basically what I am trying to do is measure the current flowing, using information I have found on the openenergymonitor.org site. They have a library which basically offsets the AC wave into the positive space, then filters out the wave in code and samples the wave to get an average, which then gives you the current flowing in the AC line. They have used the standard 10 bit ADC on the Arduino, but I wanted to use the 16bit ADS1115 instead. I have set the Gain to be 4.096, and have tried 860samples/second in continuous mode, but I am seeing very weird results sometimes. Its like Channel 0 is merging into Channel, and 2 into 3, or some other random combination, and I cannot fully understand what is going on. I found a similar problem described on the Adafruit website http://forums.adafruit.com/viewtopic.php?f=19&t=54496 This is however using their own library, but one guy mentions yours and said it has a similar problem. He describes a fix, but I cannot find where to apply that. I am also using a Chipkit board, so its running at 80Mhz compared to the 16Mhz of the Arduino. I was wanting to know if you could tell me if there is any reason why doing sampleI = adc.getConversionP1GND(); quite fast, would cause problems. I was under the impression that you could call this as often as you liked, and it would just report the current figure that the ADS1115 had measured at the time, since its in continuous mode. Is that right? Here are the 2 main functions I have in my code, which is mainly copied out of the example from the openenergymonitor.org website double calcIrms(int NUMBER_OF_SAMPLES, int Channel) { double ADC_COUNTS = 24512; //portion of 15bit count used for range double SUPPLYVOLTAGE = 3064; //3.064V is the full scale I can output into sensor from clamp double ICAL = 100; //current constant = (100 / 0.050) / 20 = 100 for (int n = 0; n < NUMBER_OF_SAMPLES; n++) { lastSampleI = sampleI; if(Channel == 1) { sampleI = adc.getConversionP1GND(); } else if(Channel == 3) { sampleI = adc.getConversionP3GND();; } else { return 0; } lastFilteredI = filteredI; filteredI = 0.996 * (lastFilteredI + sampleI - lastSampleI); // Root-mean-square method current // 1) square current values sqI = filteredI * filteredI; // 2) sum sumI += sqI; } double I_RATIO = ICAL * ((SUPPLYVOLTAGE / 1000.0) / (ADC_COUNTS)); double Irms = I_RATIO * sqrt(sumI / NUMBER_OF_SAMPLES); //Reset accumulators sumI = 0; return Irms; } void loop() { Irms1 = calcIrms(100, 1); // Calculate Irms only Irms3 = calcIrms(100, 3); // Calculate Irms only apparentPower1 = supplyVoltage * Irms1; //extract Apparent Power into variable apparentPower3 = supplyVoltage * Irms3; //extract Apparent Power into variable } I am displaying this to a TFT LCD and sometimes the figures just drop to 0 and stay there, and now and then the numbers blink to show something, and then go away again. Any help you could provide would be appreciative, esp if you see that I am doing something stupid. Regards WanaGo
    2 points
  2. Respected Sir, I got some data from accelerometer and gyrometer using MPU 6050 with arduino. But i am not able to interpret numerical values of it. Can you help me to figure out this information? here i am sending you some of data: Accelarometer Gyrometer Ax Ay Az Gx Gy Gz -6616 13880 -1380 915 -68 -49 -6624 13924 -1496 909 -41 -136 -6680 13896 -1408 917 -46 -148 -6636 13996 -1508 913 -35 -111 -6668 13896 -1616 902 -47 -47 -6716 13944 -1496 916 -43 -40 -6616 13972 -1412 879 -57 -5 -6584 13884 -1536 918 -47 -25 -6920 14192 -1584 892 -10 -164 -7792 15016 -1524 1022 -80 -68 -6928 14244 -1484 773 -112 261 -6396 13764 -1416 939 -72 112 -6636 14020 -1596 892 -43 -154 -6520 13836 -1524 946 4 -242 -6776 13916 -1552 926 8 -333 -6916 14008 -1568 891 -64 -54 -6592 13936 -1460 866 -113 216 Thanks.
    1 point
  3. wobl.in

    DMP?

    is there a technical reason that 9150_dmp has not been included? cheers Jonathan
    1 point
  4. hi, i want use 4 mpu6050 .. how i do it?? i cant find solution any where any body can help me? tanx
    1 point
  5. Sorry If this question is already answered or is way too noob.... I am a novice programmer and I dont really know how to get Degrees/second mpu.getRotation(&gx, &gy, &gz); gyroRoll = gx/131.0; gyroPitch = gy/131.0; gyroYaw = gz/131.0; Is this correct ? Does my gyroRoll, gyroPitch, gyroYaw give values in degrees/second? I want the values to use in my quadcopter code... Also I didnt change any default sensitivity in my MPU6050. Actually I am using Hextronik Nanowii V01 flight controller which is Arduino Leonardo. Also I got another doubt, Is ± 250 °/s more sensitive to changes and give wider range of raw values and ± 2000 °/s is less sensitive to changes and gives narrow range of raw values??? Sorry if these questions are way too noob, I just cant confirm anywhere the above assumptions that I have made.
    1 point
  6. This is probably not the right place to post this, but the forum won't allow me to create a new subtopic in the "Device Discussion" area. I have one of the ubiquitous GY-87 "10 DOF" boards that has a Honeywell BMP180 pressure sensor as well as a MPU6050 gyro/accel and HMC5883L magnetometer on an I2C bus. Does anyone know if the BMP085 library will work with this device or if it can be easily modified to work? Thanks Mark
    1 point
  7. bored

    MPU 6050

    So I converted your 6050 DMP code to the 9250 (ignoring the magnetometer) on the raspberry PI using SPI. I'm using emlid's 9250 ioctl transfer, Just wondering if anyone is interested. http://www.mathewoxenham.co.uk/files/pi/quadcopter/dmp.zip
    1 point
  8. ibrahims

    MSP430 + MPU 9150

    Hi im trying to access the magnetometers data. I am using Energia. THe following code is being used. The x,y,z values are all nearly the same. If anyone can please post a fix with code this would be helpful.
    1 point
  9. Hi! I'm trying to analyze a I2C dump from Saleae logic. When trying to upload the file, it get this error: "Error moving uploaded dump file from temporary directory. Please try again." I have tried Chrome and Safari Browser, same result. Even both a small/big file has been tried. (100kByte/6Megbyte) Also, while i'm here, can't you enable a "report spam"-button on the forum, as i can see that you have spammers on here: http://www.i2cdevlib.com/forums/topic/228-i-am-the-new-girl/ I tried attaching the .csv to this posting, but i get the error: "You aren't permitted to upload this kind of file" // Per.
    1 point
  10. Hi! I am using the DMP of the MPU6050 for a project at the University. I want to get the velocity from the gyro, but I have a problem. I want to change the scale of the gyro, that currently is in 2000º/seg. When I modify this value, for example to 1000º/seg (according to the Datasheet), I have observed that this modify the value of the gyro, and also the position. Doing the same movement, with differents values of the gyro scale, I obtain different angles. I think it is possible that the configuration of the DMP is responsible for that, but I am not sure. I want to know, when I use the function dmpMemory, what I am doing and what values I have to use to write the memory blocks. Sorry for my English, I am from Spain. Thanks for your help.
    1 point
  11. I am using RedBearLab's Blend Micro with Arduino/MPU6050/example/MPU6050_DMP6 from from https://github.com/jrowberg/i2cdevlib repo. Blend Micro is Arduino + BLE and works with https://github.com/RedBearLab/nRF8001 repo for BLE connection. Following two header files do not work together, causing "error:dmpMemory causes a section type conflict" #include "MPU6050_6Axis_MotionApps20.h" // https://github.com/jrowberg/i2cdevlib #include "RBL_nRF8001.h" // https://github.com/RedBearLab/nRF8001 /Arduino/libraries/MPU6050/MPU6050_6Axis_MotionApps20.h:133: error: dmpMemory causes a section type conflict /Arduino/libraries/MPU6050/MPU6050_6Axis_MotionApps20.h:273: error: dmpConfig causes a section type conflict /Arduino/libraries/MPU6050/MPU6050_6Axis_MotionApps20.h:315: error: dmpUpdates causes a section type conflict From https://github.com/jrowberg/i2cdevlib repo, I am able to successfully compile and run Arduino/MPU6050/example/MPU6050_DMP6 with Blend Micro and GY521/MPU6050, and see results on serial monitor. As soon as I modify Arduino code to support BLE connection, it gives above errors. If I comment out #include <RBL_nRF8001.h> and "ble_xxxx" calls defined in there, I am able to compile, run and see results on serial monitor again. Just to let you know, I am able to modify other example Arduino/MPU6050/example/MPU6050_raw and also establish BLE connection with OSX app on MacBook and see results on OSX app, and off course on serial monitor. This is exactly what I am trying to do with Arduino/MPU6050/example/MPU6050_DMP6 and getting errors mentioned above. Could anyone help?
    1 point
  12. According to the 6050 register map, the FIFO is 8-bit wide buffer. How, then, is it read? The 6050 does not have any 8-bit port! In my application, I need raw sensor data for use in a micro controller that doesn't have an I2C bus...
    1 point
  13. Hello , I experiencing some Problems with my MPU6050. I want to construct a self balancing robot on two wheels. Therefore i need the IMU and a Motorshield (RoboClaw 2x15A Motor Controller V4). If i run the IMU alone all works fine. Its the same with the Motorshield. But if i try to run the IMU and the Motorshield together i cannot initialize the IMU anymore. Both devices need serial communication. It would be really nice if someone could help me. The Motorshield is connected to the rx and tx (0,1) pin of my Arduino Uno. The Interrupt Pin of the IMU to digital pin 2, SCL to analog 5 and SDA to analog 4 Best Regards Arman Shakupbekow #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" #include "BMSerial.h" #include "RoboClaw.h" #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif #define address 0x80 #define LED_PIN 13 #define runEvery(t) for (static long _lasttime;\ (uint16_t)((uint16_t)millis() - _lasttime) >= (t);\ _lasttime += (t)) MPU6050 mpu; RoboClaw roboclaw (0,1,10000,true); Quaternion q; VectorFloat gravity; uint8_t devStatus; uint8_t mpuIntStatus; uint8_t fifoBuffer[64]; uint16_t packetSize; uint16_t fifoCount; bool dmpReady = false; bool blinkState = false; volatile bool mpuInterrupt = false; int tx = 1; int rx = 0; float ypr[3]; double intendedAngle; double setpoint, input, output; int posOutMax = 127; int negOutMin = -24; int posOutMin = 24; int negOutMax = -127; float lastError = 0; double ITerm =0; double kp = 1.0; double ki = 0.0; double kd = 1.0; void initIMU(); void dmpDataReady(); void initMotors(); void setSetpoint(double); float getAngle(); void initPID(); double computePID(float); void motorcontrol(double); void setup() { initIMU(); initMotors(); setSetpoint(0.0); initPID(); } void loop() { float Angle = getAngle(); double PIDOutput = computePID(Angle); motorcontrol(PIDOutput); //Serial.println(PIDOutput); } void initIMU() { #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin(); TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif Serial.begin(38400); while (!Serial); mpu.initialize(); devStatus = mpu.dmpInitialize(); mpu.setXGyroOffset(50); // 220 mpu.setYGyroOffset(76); mpu.setZGyroOffset(-85); mpu.setZAccelOffset(1788); if (devStatus == 0) { Serial.println(F("Enabling DMP...")); mpu.setDMPEnabled(true); Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)...")); attachInterrupt(1, dmpDataReady, RISING); mpuIntStatus = mpu.getIntStatus(); Serial.println(F("DMP ready! Waiting for first interrupt...")); dmpReady = true; packetSize = mpu.dmpGetFIFOPacketSize(); } else { Serial.print(F("DMP Initialization failed (code ")); Serial.print(devStatus); Serial.println(F(")")); } pinMode(LED_PIN, OUTPUT); } void dmpDataReady() { mpuInterrupt = true; } float getAngle() { while (!mpuInterrupt && fifoCount < packetSize) { } mpuInterrupt = false; mpuIntStatus = mpu.getIntStatus(); fifoCount = mpu.getFIFOCount(); if ((mpuIntStatus & 0x10) || fifoCount == 1024) { mpu.resetFIFO(); Serial.println(F("FIFO overflow!")); } else if (mpuIntStatus & 0x02) { while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); mpu.getFIFOBytes(fifoBuffer, packetSize); fifoCount -= packetSize; mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); //Serial.print("ypr\t"); //Serial.print(ypr[0] * 360/M_PI); //Serial.print("\t"); //Serial.print(ypr[1] * 360/M_PI); Serial.print("Pitch: "); Serial.println(ypr[1] * 360/M_PI); blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); return (ypr[1] * 360/M_PI); } } void initMotors() { roboclaw.begin(38400); } void setSetpoint(double setp) { intendedAngle = setp; } void initPID() { setpoint = intendedAngle; } double computePID(float pitch) { double error = setpoint - pitch; ITerm+= (ki * error); if(ITerm > posOutMax) ITerm= posOutMax; else if(ITerm < negOutMax) ITerm= negOutMax; double dError = (error - lastError); double output = kp * error + ITerm + kd * dError; if(output > 0) { output = posOutMin + output; } else if(output < 0) { output = negOutMin + output; } if(output > posOutMax) { output = posOutMax; } else if ( output < negOutMax ) { output = negOutMax; } lastError = error; //Serial.print("error: "); //Serial.println(error); return output; } void motorcontrol(double out) { if (out > 0) { byte vel = abs(out); if (vel<0) vel=0; if (vel > 127) vel=127; //roboclaw.BackwardM1(address,vel); //roboclaw.BackwardM2(address,vel); } else { byte vel = abs(out); if (vel<0) vel=0; if (vel > 127) vel=127; //roboclaw.ForwardM1(address,vel); //roboclaw.ForwardM2(address,vel); } }
    1 point
  14. Hi everyone, I'm trying to get the DMP working with pooling instead of interruptions. Is this possible? I'm using the invesense driver and I would like to know how to achieve that because all the examples I saw were using interrupts. Thank you very much
    1 point
  15. Why are we dividing by 8 and 4 before setting the offsets? Where is that documented? Or is just a step to prevent wide changes in the offset and help the optimization converge?
    1 point
  16. I am trying to get the data from an accelerometer , i.e BMA220. I am getting the data but the data is in 2's complement . So i have to change back the negative values and then there is one sensitivity thing i.e 16LSB/mg( i dunno the significance). the thing is i need data in g units but after conversion i am getting data as 125, 2 and like this. I am sure these can't be g values because i am not putting it in 125g situation. do anybody have any idea how to convert it properly..?What i am doing is below. sensor sending 2 's complement data' check the sign bit if negative data = (data ^ 0xff)+1 // decomplementing (data*1000)/16. //dividing because of 16LSB/mg.( 16LSB/mg?) final g value.. still I am wondering data is should be in g values like x m/s2 . but data does not seems like that... Am I doing things correctly, if not then what is the correct way? this is datasheet link.. http://zh.bosch-sensortec.com/content/language4/downloads/BST-BMA220-DS003-07.pdf
    1 point
×
×
  • Create New...