![]() |
anyone else use the I2C bus?
Hi All
I actually have a question. We figured out how to use the I2C bus and used a Devantech Electronic compass to give us feedback from the robot for positioning information. We thought about also using a Devantech ultrasonic detector on the same I2C bus but for some reason, we were only able to read one sensor at a time and the commands for the second sensor read were ignored. We asked the NI guy at nationals and he essentially said that "we didn't expect anyone to use this" so we never got an answer as to why we couldn't read multiple devices over the I2Cbus. So two questions: 1) Did you use the I2C Bus? (Brag a little! I'd love to hear what you did.) 2) Were you able to read two or more devices? Steve |
Re: anyone else use the I2C bus?
Quote:
Great Job! |
Re: anyone else use the I2C bus?
1 Attachment(s)
Quote:
The only issues we had with this were: 1) The I2C driver in WPIlib forces you to use a certain I2C "protocol" where the register address is always sent and then you can read or write up to 4 bytes. I would have preferred if it didn't impose this register address protocol on us (there's no reason in our application that we couldn't have issued a read without first writing a register address). This wouldn't impact you though since the Devantech sensors appear to use this fairly-standard protocol. 2) The I2C pullups in the digital sidecar were not sufficient to overcome the electronic noise on the robot. The sidecar uses the recommended value (3.6Kohm if I remember correctly). When we first tried our setup with those default values, we were getting corrupted readings a large percentage of the time (or the sensor wouldn't hear its own address because that was corrupted and it would simply not respond). We added an external 1Kohm parallel resistor to our SDA and SCL lines to increase the drive current (after checking the datahseets for the parts used inside the sidecar to make sure this wouldn't cause any issues) and that almost eliminated the problem. After that, once every few seconds we'd get a bad reading but mostly it was fine. It's possible this could have been your problem, but I'd have to hear more about what exactly happened when you hooked up both sensors to know for sure. Anyway, long story short, yes it was possible for us to read multiple sensors on the I2C bus. Attached is an image of one of our crab drive modules showing the custom sensor board we built. |
Re: anyone else use the I2C bus?
We used the I2C bus for our LCD menu system. Our display was purchased from New Haven Display. This was the only device we attempted to use.
Quote:
Code:
...From there on, we could only send a limited amount of commands (only those that did not require any parameters). Rather than asking the LCD to move the cursor to a specific location we had to keep sending move right/left commands. Also, text could only be written 2 characters at a time. In the end, it did work, but it's kind of sloppy. I'm hoping that the I2C driver will become a little more flexible in the future. |
Re: anyone else use the I2C bus?
Quote:
In general, teams have only begun to tap the potential of the new control system. I'd love to see teams create sensors and other interfaces (especially off-season). There will also be improvements made from season to season which will advance the system capabilities. So keep up the great work, and please do feel free to share :) |
Re: anyone else use the I2C bus?
We tried to use an I2C LCD from New Haven to work also, but unfortunately we weren't ever able to get it to work and gave up due to time constraints. I had noticed the same quirk with the I2C API on that, but it seems like we weren't ever able to initialize the device correctly or something.
We ended up doing our menu using using the DriverStation LCD when that ability was released, and thats worked for our needs perfectly. Of course, now that I have my embedded web server working on the bot, I'm not quite as interested in the LCD at this point. Probably should try again though... |
Re: anyone else use the I2C bus?
Quote:
|
Re: anyone else use the I2C bus?
Rather than repeating the information, go to the Google Code site that I created for the library: http://code.google.com/p/webdma/
Demo interface: http://www.virtualroadside.com/botface/index.html Its pretty sweet. I'm uploading a video to YouTube right now that shows our robot being driven around using the web interface. Not particularly controllable since I didn't intend for it to be used in that way, but theres no reason one couldn't redo the interface to make that work (its mostly javascript). |
Re: anyone else use the I2C bus?
Quote:
The second unit addressed just didn't respond, as if it were not even connected. We didn't have much time to play around with it so we didn't explored changing which we addressed first. We decided to wait until we could consult an NI guy and, well you know that story. I looked at their vi... as much as I was allowed, and saw that they had it fixed such that you had to send data when you addressed a register. We had to send a false data byte even though we only needed to address a register and then read. We correctly guessed the compass would ignore the extra data so it worked anyway. I'll try the extra resistors when we work on it again. Thanks for the suggestion. Your address scheme for the backup units is really elegant! Nice planning with the calibration mode! Nice crab system too! We didn't have time to add speed sensors, that's on our next years wish list Seve |
Re: anyone else use the I2C bus?
Quote:
Perhaps you had a wiring problem. Also, the Digital Sidecar has all the needed pull-up resistors. The devices should not have pull resistors in them. Quote:
Quote:
The intention is that it will be more flexible in the future so that other custom API types can be easily supported as well. |
Re: anyone else use the I2C bus?
Quote:
Quote:
|
Re: anyone else use the I2C bus?
Multiple sensors does work from labview, I have tested up to 5, though I have found once you put 4/5 with a wire length of 18" you do need to add additional resistors to get reliable responses.
Having a more flexible api would be very nice: 1. separate write/read will be useful - see HMC6343 below 2. Timeout on bus especially slave clock stretching. I have seen cases where a sensor goes wrong and holds the SCK low, the bus stalls, I2C read stalls, etc. Some comments about sensors: devantech - srf08, cmps03, tap81 should all work. I have tried the srf08 with the example and it works. I have used all the rest before and their I2C interface is similar. I2C-IT IR - works LIS3LV02DQ - works (need a 3.3V to 5V convertor). I have tried other LISX accelerometers in the past, they all have similar I2C so should work. HMC6343 - so far not working and I dont see a way to get the required timing. PSP-NX Mindsensors - works, the other mindsensors have the same I2C interface so should work though I haven't used them before. On a separate note - can we have the SPI interface more flexible as well. As far as I can tell, it supports mode 0 and 1 but not mode 2/3 (where clock is inactive high). |
Re: anyone else use the I2C bus?
Quote:
|
Re: anyone else use the I2C bus?
I believe all the lego sensors use I2C address 2. You can reprogram the I2C address for the mindsensors nxt sensors but I dont believe you can with lego sensors.
There is also a i2C bus switch that allows multiple sensors with the same address to be connected and you switch 1 sensor in at a time. I have used one but I dont rememebr it at the moment. If you are interested I can dig ti out. |
Re: anyone else use the I2C bus?
Quote:
Quote:
|
Re: anyone else use the I2C bus?
Quote:
|
Re: anyone else use the I2C bus?
Quote:
Wow… ok I must be overlooking something. Too many people are succeeding so it has to be something in our program. I’ve actually used the I2C bus before. 5 years ago I had three Devantech SRF08’s running from a basic stamp chip so I was aware of the addressing scheme and how to change addresses. We had both a SRF08 Ultrasonic detector and a CMP-S03 connected to the I2C Bus. We could run the demo for SRF08 and get good readings. Then we wanted to also read the CMP-S03 compass. The compass was our priority so we programmed to read it first, then the SRF08. We got data from the compass but nothing from the SRF08. Pretty much the SRF08 should have been a cut and paste of the demo as we left it at default address. We couldn’t see what we were doing wrong and after an hour of rechecking and trying various things, we had to move on and decided to ask the NI guys at the championship. One thing about the NI implementation, to read the Devantech CMP-S03 compass you do a write for the register number you want to read but the write doesn’t need a data byte sent. It will output one or two bytes on the next read according to which register you addressed. I opened up the VI I2C.lvlib:write.vi block diagram and looked at the I2C config, which requires you to send at least one byte of data but it has a password lock so there is no way for me to modify it to write the register number to the device without actually sending a byte of data. I would have to rewrite the vi but there just wasn’t time for that. Hope I didn’t slander the NI guys. They were really busy trying to be in two places at once. |
Re: anyone else use the I2C bus?
Quote:
|
Re: anyone else use the I2C bus?
Steve_Alaniz for the CMPS03 you should be able to do a I2C read of 2 bytes from register 2. Haven't tried it but I have one so I will connect it and see.
|
Re: anyone else use the I2C bus?
Quote:
Oh we DID do a two byte read initially, but that was too much resolution for our application so we dropped back to a one byte read. Steve |
Re: anyone else use the I2C bus?
Steve, I have tried 1 and 2 byte reads on CMPS03 without problem with SRF08 running at the same time.
I also found a way to cause the I2C bus to hang with both devices being accessed at the same time. Difference hang: 2 parallel while loops, 1 accessing CMPS03, 1 accessing SRF08 no hang: 1 while loop, accessing SRF08 then CMPS using a sequence If you remove 1 or the other device physically from the bus but leave the code running both 'work'. But with both connected it may hang - it normally works for a while then hangs the while loop - I would expect this unless the I2C FPGA code has locking behavor for multiple accesses, you would end up with multiple conflicting bus accesses. So you probably want to put all I2C accesses in 1 thread, store the results in local/global variables and access the variables when needed. |
Re: anyone else use the I2C bus?
Quote:
Thank you Tim... good information. We'll give it a try. Steve |
| All times are GMT -5. The time now is 15:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi