Boosting AVR SPI for long distance communication

Discussion in 'General Electronics Chat' started by kevintu1987, Mar 28, 2010.

  1. kevintu1987

    Thread Starter New Member

    May 8, 2009
    8
    0
    Hello all,

    I know that SPI is not really used for long distance (4 feet), but the project is at a point where significant design modification is not a good option. I am assigned to solve this issue, and the previous student engineer who designed the system is not here in the project anymore.

    So, I have a few ideas that might work to boost SPI communication:

    1. Lower FCPU speed. (now the uC is running at 16MHz. This should be the last solution tho, I need the high speed for doing other functions)

    2. Use MAX232 for transceiving/level-shifting. (I think this might be a good solution)

    3. Use a UART-SPI (probably an uC) at slave device, and use Xbee's for transceiving. (wireless!)



    Any ideas?

    (I would like to know what do you think before I make a purchase ;) Most likely I will go for idea 2.)

    Thanks~!
     
  2. dsp_redux

    Active Member

    Apr 11, 2009
    182
    5
    Depends on what are your requirements, really. Do you have a lot of time before your deadline? How fast does it have to go? I had experience with Xbee modules. Quite impressive but could be a little time consuming depending on your level of understanding. The solution could be as simple as an FSK modem.
     
  3. kevintu1987

    Thread Starter New Member

    May 8, 2009
    8
    0
    I do have a month left until the project competition (it is a hybrid-car project), but I would like to solve this SPI issue soon. It works, but it is just that the end result analog signal is jumpy.

    When I tested the system in lab, it worked well with 2' SPI line. However, when I actually put the system onto the car, it just didn't work to my expectation (that is with 3' SPI line).

    A brief description of the purpose of this SPI communication line:
    The SPI communication is used by uC sending speed data to a motor controller. (uC -> optocoupler -> DAC -> motor controller; they need to be isolated because of the project rule: low-voltage and high-voltage should be isolated)

    The uC is running at 16MHz, so the lowest speed is 16MHz/128 (it is the prescaler inside ATMega128). I would like to keep the CPU running at 16MHz. The SPI does not have to be fast, but stable.
     
  4. dsp_redux

    Active Member

    Apr 11, 2009
    182
    5
    Are you familiar with RS-232/MAX232 ? That would work ok with not much problem if you know what you are doing. At 1 month from the due date, I'd "keep it simple". Especially if your first solution "works".
     
  5. kevintu1987

    Thread Starter New Member

    May 8, 2009
    8
    0
    Yes, I have used MAX232 and RS-232 in my other project before.

    My understanding of what MAX232 dose is that it level shifts TTL signals to a higher voltage level making the signal levels compatible to RS-232 protocol. And, RS-232 signals can travel up to 25' or so because of the voltage level.

    In fact, I think I only need BJTs or MOSFETs to do level shifting, but to do that, I will need additional voltage supplies. Thus, for the situation, MAX232 makes things easier, since it can provide its own +-15 power supplies with just a 5V power source.

    I hope this will work well with SPI and making the communication travels longer!

    The reason that I posted this thread is that I want to check with experienced engineers to see if the ideas make sense.
     
    Last edited: Mar 28, 2010
  6. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    I'd use balanced line drivers & receivers.

    Look as the DS8921 (one driver plus one receiver)
    or DS9637 / DS9638 (Two drivers or receivers).

    These are 8 pin, 5V devices so very easy to use.
    They are good for up to 10MBit over long lines. Just use data twisted pair (like cat5 patch cable) and terminate the pairs at the receive end.

    These will stand an offset of a few volts betwen the driver and receiver so it may also get around your separate ground requirement - as long as both ends have functional ground connections, you do not need a direct ground link.
     
  7. kevintu1987

    Thread Starter New Member

    May 8, 2009
    8
    0
    ! This looks good! Thx, I will put this into my ordering list too:D
     
  8. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    You didn't say how many digital lines your SPI uses. But I second the idea of differential data transmission. You can get 4 transmitters or 4 receivers in a chip (AM26LS31, AM26LS32) or for versatility, use the 75176; it can either receive or transmit.

    p.s. Use twisted-pair wiring. Preferably shielded.
     
  9. kevintu1987

    Thread Starter New Member

    May 8, 2009
    8
    0
    Thanks for the inputs! The ones that have 4 transmitters/receivers are the ones that I will use.

    There are 3 sets of SPIs. Each set has clock, set, and data. So three lines.
     
Loading...