It looks like I am going the brain/ multiplexer route here and will make the ultimate line-follow sensor of death. Led's will be off of PWM for brightness control, white/black threasholds will be adjustable and now I have decided that adjustable pull-up resistors would be handy too. I figure that a simple trimmer pot connected to the common of my resistor array would do the trick, but I would not mind some feedback on the issue. I have added a second video with an explaination. Thanks in advance.
**Original Post***
I have been plugging away at my line follow sensor and my related I/O expander issue and have hit a bit of an impasse. My original idea of using a digital I/O expander to keep an eye on all 8 sensors has fallen-through and in hindsight, was probably not the way to go in the first place. As it stands now, I have a simple problem of reading 8 IR sensors via ADC without using 8 pins on the main microcontroller. I simply need a support chip to sit on the line follow board itself and communicate with the main brain. Here are my requirements:
Must speak UART serial or preferably I2c
Must have a minimum of 6 ADC's preferably 8 --I really want 8
Must be smaller than a 28-pin dip (a full-size arduino will not fit --I can use a SMD atmega 328 though)
The main options in my mind are an Arduino 328 or a Picaxe 18m2 (or something else). The arduino, even in SMD form, is a little cheaper than the picaxe but only allows for 6 ADC inputs. There are 8 ADC pins on the SMD version, but I have yet to figure out if I can get a hold of them. Whether I can or I can't, I am still going to loose 2 of them if I want to use the I2C lines (my preference).
The next choice is the Picaxe 18m2 which has a ton of ADC's (more than I need) and is only about $.50 more than the Arduino. This so far, seems to be the option I want to use, but alas, the picaxe has no provisions to become a I2C slave. It can actually, but unfortunately only to access it's memory functions (when in I2c slave mode, the picaxe becomes a fancy EEPROM really). This puts me back to using UART serial again which I would prefer not to do.
One more: I cannot use any of the MCP320x chips (which would solve all my problems) as they are SPI and the new Picaxe chips don't speak SPI. Arrggg.
Looks like somewhere around $7 minimum up to around 15 bucks for the chip. Plus, I have to bootload it. Not to mention, that is a TON of chip for such a simple task. Nope. Shucks.
Someone in this site suggested an analogue multiplexer to me some time ago. I can´t remember who it was. Sorry (if you are reading). I pass on the suggestion to you. It was the CD4097B. It has 8 channels and comes in a 24 pin IC package. I can´t remember about I2C, however.
Hope this helps.
PS: Remember to read the datasheet before soldering… (sorry, I couldn´t resist the temptation! :P)
Mouser has this guy for $.51 in an SMT version. I think I like this. I tell ya, one of these 4051’s, a SMD Atmega 328 and I got myself one fancy (and smart) line-follow board --Not to mention, I get the I2C I wanted.
Yup, I have my tiny soldering tip and my flux pen all ready! Some of the SMD parts I ordered are actually starting to come in now. I am getting excited. And yes, I will follow the rules when soldering these guys…
Yup, that is the nightmare chip. I have it, I have tried it, it is just way too complicated to communicate with. I could not imagine the tutorial needed to get a picaxe person through this guy…
Are you sure you want to give up on the ADS7830? Did you post anything on the issues you ran into? The chip doesn’t look to shabby, and could be quite useful if you could get it going. Aside from that, an MSP430 chip might work out. :D …but I digress…I hesitate to recommend using a proc actually for doing this sort of thing, I’d just get that support chip working…
EDIT: I haven’t looked, but you really can’t do spi with the new chips? You could always do it bitbang style, they have the source in the manual for it…shiftin/shiftout I think it was…
Tackling the problem from another angle…why use 8 sensors? wouldnt 5 be more than enough? I realize you already have the board made, but sometimes we have to go back to the drawing board. especially if you have another smaller ADC / I2C chip that would be easy to comm with, that can handle 5 or 6 channels. you could even dry-run the idea by using 5 of your 8 sensors. however, if all the ADC chips are a bear to comm with, then I agree with the MCU approach.
Doing a parametric search of Microchip, got me about 87 possible PICs w/ 8+ ADC and I2C. They ranged from $.71 to $5.87 direct from MIcrochip. The 18F24J50 that I looked at could be found at Newark for $2.79 in singles with 10 10bit ADCs. I was specifically looking for chips that would work with a newer release of JAL, because I am yet to be proficient in C which also can be used for free with the PIC chips.
I saw the same, Bird. Actually, I was quite amazed at how many different flavors of pics are out there --I had no idea. I was/am VERY temped to go this route but I wimper to myself a bit when I think about learning yet another language (even if it is just enough to make one of these guys a slave). To be more honest with you, after seeing all those options for features and packages, I thought for a moment of actually learning PICs well enough to use them in projects. Then I looked at my current to-do list and thought again. I will look into it but I think the Pic option may be a bit over my head at this point.
The arduino, even in SMD form, is a little cheaper than the picaxe but only allows for 6 ADC inputs
The SMD packages of the ATmega328P are equipped with 8-channel ADCs while the DIP package is 6-channel. The hardware is there but I’m not sure if the Arduino library supports it.
Chris, I see that you’re opening a busines here, very good! I don’t have the time to do it, although I wanted to add sensor boards to my products, so I’m glad someone else is doing it. Coupled with the LMR marketplace it will be a blast.
I don’t have ideas on a chip that will suit your needs, but I just wanted to share my thoughts on this project:
- use I2C. do not give up on this protocol, is the best way to go
- use an odd number of sensors, just like you found in your experiments
I re-read your post. I came into a similar situation recently with my own line follower. I started out using ADC for the output of 3 LDRs. The 256 shades of gray (literally) that I got were overkill for something as basic as high contrast line following. All you really need is a 1 bit digital response from each sensor. “Is there white (1) or black (0) beneath me?”, the sensor should ask itself. I was about to redo my line following board to add some comparators in the circuit that would enable me to send the output of the LDRs straight to digital pins, thus freeing up the ADC ones. Then Ignoblegnome suggested that I keep the board as is and incorporate the comparating function into the code. And I did. As an example: if the value coming from a LDR is <185, I read it as zero. If it is =>186, I read it as one. I have kept that solution and it is working. I am not about to consider it done. There are other problems that I need to address. But I am happy with the processing of the sensors´ output.
Besides, if you have 8 sensors it´ll work even better. If I can get away with it, with only 3, you most certainly can.