help with uC/I2c and ADC?

Discussion in 'Embedded Systems and Microcontrollers' started by jasonson, May 2, 2013.

  1. jasonson

    Thread Starter New Member

    May 2, 2013
    3
    0
    Hi everyone i'm new here.

    I have a simple dilemma that i am researching but i figured i would ask any way as i find people with experience all ways have good ideas.

    I am working on home project and would like some advice.

    I need advice on a chip that has min (only need to use) 3 x ADC 0-5v inputs and can communicate via the I2C protocol (i chose this as it looks easy, robust and stable).

    The idea being the small board with the sensors will be connected to the I2C bus and the master controller unit will detect the new unit and assign it an address automatically. That address needs to be recorded and stored by the sensor board uC in case of power failure, so when re-energized the units are still addressed correctly.

    That side of things is my problem though just giving you a heads up on what i am trying to achieve.

    so my real question is, is it better to use a uC to handle the addressing and communicating and it simply (when requested) reads the values from a separate ADC chip connected to the sensors?

    or can i get away with a uC that has inbuilt ADC. I only need 8bit resolution. The sensors run linearly and don't fluctuate to much.

    The sampling rate will be low, perhaps a maximum of 5hz and the load and cost need to small. The idea being i can connect upto 40 on a single 5Vdc feed @ 1a so thats around 20-25ma per device. I could lift the current up if needed but im hoping to keep it small.

    Any advice is greatly welcomed as i am not an engineer and this is my first real attempt at designing my own integrated circuits. I have been playing with arduinos for a while now so i am understanding the programming side, but spec'ing the hardware side is a whole new world.

    Thanks in advance.
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,607
    There's lots of advantages to the I2C protocol as it's simple, only needs 2 wires, and can address up to 127 devices (or more).

    Umm... I don't like the master setting the slave's address. The master needs to know where the slave is to even start to talk to it. Now address zero is a general call address (every slave is supposed to listen for that) and then you can send sub bytes to further define...

    Heck, I'd just set up the slaves on their own different addresses. That way the master can attempt to talk to these addresses, and if it gets acknowledged it knows the device is there.


    40 devices??? Wow, that should have been up at the top. I'm using a MCP3424 now, a stand alone I2C A2D, 4 inputs, and you can set it to 16 different I2C addresses with 2 pins. That's a total of 4*16=64 different sensor possible, as long as you can live with grouping 4 sensors together.

    If you need the sensors all separate... you may want to look into a 1-wire interface. I've never used it but I believe it handles many more devices on the same bus as the address space is larger (48 bits). Maxim *used* to make an A2D device but it has been discontinued.

    So you may end up using a simple micro just to get 40 different slave addresses. I'd still fix them in the slave end, either in hard hex code or possibly an EEPROM read at power up... hard coding sounds simpler to me.
     
  3. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    Microcontrollers with 8-channel ADC are not uncommon.
    You only need 8 chips and 8 addresses to read 64 channels.
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,607
    Forgot to mention the I2C master device can discover on the fly which devices are connected. If a device is not there then it does not acknowledge the address it is sent, so each transaction is guarded to be safe, unless you remove a device *during* a transaction.

    It also should be fairly immune to hot plugging devices too. I don't now of anything offhand that would prevent that.
     
  5. jasonson

    Thread Starter New Member

    May 2, 2013
    3
    0
    The idea being that I can make a lot of the same device (sensors), each device will be small with a sensor and a chip onboard thats all. when hooked into the daisy chained bus it will be supplied with power and bus connection. I want the control unit to be able to handle more devices being added and automatically detect them and add them to the polling que which will then simply poll the the connected sensor boards and record the value replied along with the sensors address.

    What i wanted to achieve is modularity and ease of expansion. But maybe i'd be better off with CAN then I2C as each sensor will need to be on its own board.

    My next question is having only looked into CAN briefly, will i need a tranceiver chip seperate to the ADC chip or is there one on the market that has the 4 analog inputs and CAN connectivity. I am hitting the books and google after i type this.

    No i can't as each sensor will need to be on its own board.

    The idea behind this is if i can successfully get a unit functioning at home i will look into getting possibly selling them. (long way down the road)

    So I want to make it easy and so i can just add extra sensors by plugging them in. (each unit will have a BUS IN and BUS OUT connector allowing a small cable to loop from sensor to sensor)

    Then the master control unit will detect the new device and add it to the polling que. Once added, Software running on a PC connected to the master device can update the details of the new device so the data becomes usable.

    Thanks ALOT for your help and ideas. It is very much appreciated. I am self teaching myself about integrated circuits and microchip programming.

    I am currently an electrician and also write software in Visual studio (basic and c++) and also play with arduinos. So it is a very steep learning curve proto typing PCBs and matching components but i am having fun doing it.
     
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,607
    I getcha... on my way out in a few will have more time tonight.

    A single chip micro with I2C would be my way to go. You can handle addressing several ways to get a distinct address for each sensor unit, some way during discovery it gets it's own address. We could talk about that later.

    I2C has a huge advantage that there is no IN and OUT bus, the 4 connections are common to each and every board. Possibly uses a simpler connector.

    How large is the sensor array? How many feet from the master micro computer to the most distant slave sensor?
     
  7. jasonson

    Thread Starter New Member

    May 2, 2013
    3
    0
    The IN and OUT i mentioned were labelled connectors on the PCB, they will just be 4 wire connectors joined together. The OUT simply allows another sensor to be added to the daisy chain.

    I'd like to be able to extend the sensor arrays possibly as large as possible.

    If you had say 40 sensors i'd imagine the cable length to the final sensor would end up being probably around 1500mm max. But i'd look at keeping it as short as possible.
     
  8. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,607
    That's a very workable scheme.
    I make 1500mm to be about 59 inches, just under six feet. That shouldn't be an issue at all.

    Going much longer you'd want to use shielded cable, slow the data down (I2C doesn't have a minimum speed), and perhaps put a buffer every so often.

    How often? Close enough so any problems go away. But if you ask em three times and get the same thing back every time you should be very noise tolerant without any other hardware.
     
Loading...