-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i2c connection problem with hmc 6352 compass module #17
Comments
So i've been trying to figure out this problem by debugging some js files in cylon lib folder. https://docs.google.com/document/d/1PMi3lyb1PIpfdH3ThgH2Ftx7nCoRRxQDfEaPOpANfJ4/edit?usp=sharing In the document, it shows some specific results from my debugging and I was just wondering if this could help you figuring out what's the problem with the program with not having the hardware. I tried to connect hmc6352's scl and sda to pin 2, 3 on Yun and pin sda and scl on Yun. |
my friend and i figured out that target[method] gets grabbed from your device list (target is an array? or json list including whole bunch of information about my program). We are wondering what i2cConfig: [function] does since when i print out target[method].appy(targer, arguments)), the result is undefine |
Hi @dongkibravo I'm working on this i2c issues right now, I'll update shortly. PS: BTW yes, the info you posted here helps |
It seems there is an issue either on how you wired up the sensor to the arduino or with the sensor itself, do you have any other way of testing if it is working correctly? I did a small fix in to of the repos, these are the branches and changes, I think this might fix the problem: hybridgroup/cylon-firmata@9ff319e I recommend that you just modified the files in your @dongkibravo I think there's a good chance this will fix the problem since it seems it was looking for those two calls to a function that does not exist. Let me know how it goes. |
How did you connect the compass? |
@dongkibravo http://cylonjs.com/documentation/drivers/hmc6352-compass/ See the image at the end, you actually do not need the pull-up resistors to connect it to the arduino, the arduino already has them wired up internally. SDA should be connected to pin A4 on the arduino and SCL to pin A5. Is your setup correct? |
A4 and a5 meaning analog pin 4 and 5? |
Yes, analog pin 4 is SDA and analog pin 5 is SCL |
@dongkibravo any progress? |
@edgarsilva my.hmc6352.heading(function(data){ why am i not going into that function |
@dongkibravo Could you pls paste all the code you are using for the example here? Are you using the changes I pasted in the branch yesterday? |
Also paste a gist of output when you run your program . |
@dongkibravo any progress? anything I can help you with? if you can share the code you are running and an actual picture of the setup, how you are connecting everything, I might be able to help some more. |
@edgarsilva This is code that i'm using var Cylon = require('cylon'); // define the robot work: function(my) { }); and this is the result I, [2011-09-08T19:46:57.524Z] INFO -- : Initializing connections. |
Seems like the sensor is either not working, or not connected properly can you share a pic of the setup of the sensor and how it is connected to the arduino? |
I confirmed that the chip works fine by using this code #include <Wire.h> void setup() { void loop() { and got result like this �247.00 degrees (ps the connected pins were digital 2,3) |
Are those accurate readings? I can't make the connections to the chip very well on the pic, but does not seem to be hooked up like this? |
yes the reading was pretty accurate compare to my iphone compass and the connection is exactly like it on the website |
Here are more examples, from the picture it seems some cables are swaped.... but the picture might not be that accurate, since I cannot make out the last pin: http://www.funnyrobotics.com/2011/03/arduino-with-hmc6352-digital-compass.html Check those examples and verify it works and it is 100% wired correctly if that is the case I can dig up some more in the code, try to debug the output. I'll start checking the driver while you test only on the arduino side. |
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit. i got this error in the middle of running the program. And can we assume that Uno board and Yun board have the same pin diagrams? |
yes, if you upload a sketch to the uno with the sensor connected should work just fine on the arduino Yun. |
That error is happening because the firmata lib never hears back from the I2C device, so it requests to read from the I2C bus and waits for a response that never arrives, then it just keeps adding listeners every time you call heading and all of them are waiting for a response, causing the EventEmitter error, which makes me think the sensor is not being detected by the arduino board. Let's log the heading function in the driver, could you replace the heading function with this one pls: // ./node_modules/cylon-gpio/lib/hmc6352.js
Hmc6352.prototype.heading = function(callback) {
var self = this;
console.log('BEFORE I2C read:');
this.connection.i2cRead(this.address, this.commandBytes('A'), 2, function(data) {
console.log('DATA FROM CALLBACK:', data);
callback(self.parseHeading(data));
});
}; Then run it and share the output, BUT before that run the examples I pasted above just on the arduino to make sure the sensor is hooked up correctly and working as expected, you'll need to upload the sketches and then reupload the modified firmata file to the arduino. |
I think this issue was addressed by the most recent release of cylon-i2c. Can you please give this a try? |
@dongkibravo did you ever got this to work? did you try the latest release? I will close the issue since it should be addressed by latest release. If you ever got it to work please let us know, so this info can be useful to someone else, regards. |
Currently I'm working on a drone navigation project using AR_Drone2 with Arduino Yun.
Basic setup to install cylon.js on Arduino Yun was based on this page with @edgarsilva 's help.
hybridgroup/cylon#212 (comment)
And now I'm trying to use the compass module (hmc6352) to get the heading of my drone but when i run a simple code
var Cylon = require('cylon');
Cylon.robot(
{connection:
{name: 'arduino', adaptor: 'firmata', port: '/dev/ttyATH0'},
device:
{name: 'hmc6352', driver: 'hmc6352'},
work: function(my) {
every((1).second(), function() {
my.hmc6352.heading(function(data) {
Logger.info("heading: " + data);
});
});
}}
).start();
I get this error
/root/drone/node_modules/cylon/lib/utils.js:124
return target[method].apply(target, arguments);
^
TypeError: Cannot call method 'apply' of undefined
at Adaptor.base.(anonymous function) as i2cConfig
at Connection.base.(anonymous function) as i2cConfig
at Hmc6352.start (/root/drone/node_modules/cylon-i2c/lib/hmc6352.js:26:19)
at Device.start (/root/drone/node_modules/cylon/lib/device.js:60:22)
at /root/drone/node_modules/cylon/node_modules/async/lib/async.js:568:25
at /root/drone/node_modules/cylon/node_modules/async/lib/async.js:118:13
at Array.forEach (native)
at _each (/root/drone/node_modules/cylon/node_modules/async/lib/async.js:39:24)
at Object.async.each (/root/drone/node_modules/cylon/node_modules/async/lib/async.js:117:9)
at _parallel (/root/drone/node_modules/cylon/node_modules/async/lib/async.js:567:20)
What is wrong with this code?
(I connected the compass module's sda scl pins to Arduino Yun's sda scl pins)
The text was updated successfully, but these errors were encountered: