Shop OBEX P1 Docs P2 Docs Learn Events
Connector for SPI bus — Parallax Forums

Connector for SPI bus

Mr_NukeMr_Nuke Posts: 47
edited 2007-01-02 20:44 in General Discussion
I'm looking to implement a SPI bus master that controls up to eight SPI slave devices. What I want to do is have these peripheral devices located some distance away from the SX master, and thus requiring a connector and an external cable. I want each connector to have 6 lines (Vdd, GND, MOSI, MISO, SCLK, and SS). The connector should have some sort of a locking mechanism to prevent accidental disconnecting, and shoud be panel-mount.·The problem is that I don't know what connector to use for the SPI bus. I was thinking of using an RJ-45 connector. Is there a standard connector for the SPI bus? What connectors would be best suited for the application?
Thanks in advance for any help!

Comments

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-12-28 08:58
    SPI is intended for short distances [noparse][[/noparse]like inside the same chassis if not actually on the same board].· Speed is a consideration with any distance as transmission line losses and reflection of signals will come involved.

    Having said that, the easiest system to impliment is 8 wire internet cable and connectors [noparse][[/noparse]RJ-45].· The parts are everywhere and cable is often shielded.· It still is a somewhat of a hack approach as you cannot really take advantage of the twisted pairs with SPI to reduce noise. But wire is wire and with·SPI running at 100kHz or 400kHz maximum speed, it·can be·a good convienent resource.· If you want to run at Mhz, you may have trouble.

    I suggest you buy a cable that is about twice your distance and test the SPI for reliablity with that.· If it works reliably at twice the distance, you should have little or no trouble in actual use unless you plan to have all items on the same SPI bus.· IN that case, distribution pattern needs to be considered.· Also there·comes a question of having enough CS lines available·for each device.·For a shared bus, generally a star distribution pattern is the worst, while a daisy chain is best.

    The easiest solution to resolving problems is to slow down your speed unti none exist.· SPI, unlike I2C or One-wire, does not have an acknowledge signal to verify a byte is properly framed or other error verification schemes, so it is up to you to trap problems.

    This points out the obvious, you might be better using One-wire or I2C.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

    Post Edited (Kramer) : 12/28/2006 9:02:36 AM GMT
  • pjvpjv Posts: 1,903
    edited 2006-12-28 18:44
    Hi mr_Nuke;

    Depending on the speed you are looking for, and the length of the wire, I'd be very cautious in running such signals. Improper impedance terminations will cause reflections, and that can play havoc on the pulse timings.

    So, speed and distance are inter-related. The faster you need to go, the shorter the reliable distance. And alternately, the farther you need to go, the slower you better run. It's difficult to give precise information on this as it depends on so many things.

    That said, this applies more toward your approach where data and clock signals must not "skew" by much. There are other approaches such as RS485 which uses differential signalling that are a lot more tolerant, and using a serial-only technique can be made totally insensitive to skew.

    The water control system I designed for Kaoshiung in Taiwan (Kramer's territory I believe) uses RS485 over distances of hundreds of feet running at 10 Megabits per second over ordinary flat 4 conductor 'satin' telephone cable terminated in RJ connectors without error.

    If multiple signals such as clocks and data were involved things would be quite a bit more difficult. So what I'm suggesting, and again, this is valid only if you distances and speed requirements are significant, is to serialize your data onto an RS485 bus and use RJ style connectors. If your speeds or distances are modest, then the wider RJ 8 or 10 pin connectors for your multiple signals are a good choice.

    Cheers,

    Peter (pjv)
  • Mr_NukeMr_Nuke Posts: 47
    edited 2006-12-28 21:25
    Using RS485 is not such a bad idea, but that would require two things: A transciever, and a virtual UART. Unfortunately, my project doesn't allow me to do that, because the SX handling the slaves (Master Processor)·will be an SPI slave itself to anouther SX(Auxiliarry processor); The auxiliary processor·contains a 256000bps UART·a few other functions, and has the ability to update the firmware of the master·processor.

    The fact thet the master processor is an SPI slave means that I will have to integrate both the SPI slave code and the UART code in the interrupt. Even at 75MHz, this would cripple my data rate. I suppose I could make a 512kbps UART with an interrupt at 2.048 MHZ (2.0833 MHz actually, if I have an interrupt every 36 cycles), but I will only be able to have the master and auxiliary processors communicate at 512Kbps max also.

    I am thinking of implementing an SPI with RS485 levels. I would then have 1 reciever for the MOSI line and·10 transmitters for the SCLK, MISO, and one for each CS line, with a circuit that will only connect
    the SCLK, MOSI and MISO lines only to the active slave to prevent a short from disabling the bus.

    Which option do you think would be better, considering I need a high speed bus ?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-12-28 21:54
    Mr_Nuke asked...
    Which option do you think would be better
    I vote for using RS485 transceivers between the processor and the peripheral/s.
    [noparse][[/noparse]This is a Poll, isn't it?· : ) ]
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-28 22:40
    You will have problems with high speed and distances more than a few inches. If you use RS485, you will have better signal levels on one particular line, but the added delays through the driver/receiver will slow you down. SPI is already a serial protocol. An RJ-45 jack provides the mechanical and electrical connections, but you will want twisted pairs for the clock, MOSI and MISO, and SS signals with the 2nd wire of the twisted pair being ground. You could carry Vdd and ground in a 5th twisted pair. This isn't a standard Internet cable since it needs 5 pairs, but only 6 signal connections. If you can combine MOSI and MISO onto one line (if the devices are half-duplex), you can manage with only 4 twisted pairs. As pjv suggested, you'll have to experiment to see how high the speed can go reliably. If you need to push it, you may need to incorporate some kind of error checking (like a CRC or checksum) to protect against the occasional errors.
  • Mr_NukeMr_Nuke Posts: 47
    edited 2006-12-29 02:28
    I will try the RS485 transcievers, and probably incorporate some sort of delay into the slaves (They will also end up being SX chips).
    As for the error check, I already thought of implementing a checksum, and some sort of ID code, so that the master won't communicate with nothing. I think the challenge now·will be building the slave select circuit, since I don't want a short to disable the entire bus. I think a few high speed MOSFET's should do it though.
  • pjvpjv Posts: 1,903
    edited 2006-12-29 03:11
    Hi Mr_Nuke;

    Some more details would assist us in guiding you to a nice solution.

    Please ?? (Hi speed comms is one of my favourites)

    Cheers

    Peter (pjv)
  • Mr_NukeMr_Nuke Posts: 47
    edited 2006-12-29 04:04
    Hi pjv,

    What I want to do is have an RS485 transmitter for the SCLK, MOSI, and each SS line on the master side, and a reciever for the MISO line. Each Slave will have 3 recievers (MOSI, SCLK and SS), and one transmitter(MISO). As a safety feature, I want to connect the SCLK, MOSI and MISO lines only to the adressed slave. I don't want to use a separate transmitter/reciever·for each slave for the MISO, MOSI, ans SCLK lines, so I am thinking of using a multiplexer(actually, six of them in total)·to connect the right slave. I don't have a schematic at this point, since I don't even know if the multiplexer will not affect the differetial signal.
    ·
  • pjvpjv Posts: 1,903
    edited 2006-12-29 06:21
    Hi Mr_Nuke;

    OK, so you don't have a schematic, could you at least sketch a functional drawing of what you think should be done, as well as a more generic one as to what you are trying to achieve ?

    You are right, pushing RS485 through a (standard) multiplexer is problematic.

    What are the distances ?

    Cheers,

    Peter (pjv)
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-12-29 17:25
    You don't need transcievers. Use seperate reciever and tranciever transmiter pairs. Maxim has these chips and can provide the PDFs with good information about network configuration.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

    Post Edited (Kramer) : 1/1/2007 12:05:44 PM GMT
  • Mr_NukeMr_Nuke Posts: 47
    edited 2006-12-29 17:27
    Hi pjv,

    I've sketched an overall schematic of the project, but as for the RS485 level conversion,·I am still unsure of what to do. I also thought of using 3TX and 1RX for each channel, and use the multiplexer on the TTL logic levels. I am still thinking of a solution, and I will post a fresh·sketch once I figure out what I'm trying to do.

    Alex.
    2550 x 3509 - 1M
  • Mr_NukeMr_Nuke Posts: 47
    edited 2006-12-29 17:38
    Hi Kramer,

    Could you please post a link to the PDF files you mentioned?

    Alex.
  • Mr_NukeMr_Nuke Posts: 47
    edited 2006-12-29 20:54
    Hi pjv,

    I just finished a more detailed sketch.
    The MAX 3283 has an active-low enable, which I can connect directly to the SS line. This should enable me to select only the input from the desired slave, and thus any short to an external·cable will not affect or disable the bus.
    I have also decided to use standard 8-pin RJ-45 connectors, and distribute the power through a separate cable. This should save me some money on the cable and connectors. Of course, any suggestions are welcome.
    As for the distances, they will be at least two or three meters.

    Alex.

    MAX3283 datasheet: http://datasheets.maxim-ic.com/en/ds/MAX3280E-MAX3284E.pdf
    816 x 1123 - 78K
  • PJMontyPJMonty Posts: 983
    edited 2006-12-29 22:14
    Alex,

    I'm confused. According to your schematic, you're only using two lines of the RJ-45 connector. You mentioned in the previous post you're going to distribute power over a separate cable? Why? You have six more conductors that can be used to carry power. Why have two plugs and two cables for every one node in your system?
      Thanks, PeterM
  • Mr_NukeMr_Nuke Posts: 47
    edited 2006-12-29 22:54
    Hi PJMonty,

    The schematic only shows two wires, but one of then has a slash, with a 2 written next to it, wich means that it represents 2 lines, or wires. The other one has a slash with a 6 written next to it, which means it represents 6 wires. This is just a shorthand method to prevent the schematic from getting over-crowded. There are actually 8 lines that are used·on the RJ-45 connector.

    Alex.
  • geekythinggeekything Posts: 53
    edited 2006-12-31 13:23
    Hi Mr_Nuke,

    Not 100% sure what your application is, but have you considered 1-Wire? Good noise immunity over long distances, you can use Cat-5/5E/6 cabling just fine, you can use a spare pair for power or use parasite power.

    (Do note: I'm talking about using Maxim/DalSemi parts are the slaves -- implementing your own slave on the SX technically violates their IP).

    -marc
  • Mr_NukeMr_Nuke Posts: 47
    edited 2007-01-01 00:08
    Marc,

    I have considered other interfaces, unfortunately, 1-Wire and I2C are too slow for what I need. Also, because the slave SPI interface on the master processor will be driven by interrupts, I cannot accurately implement an asynchronious protocol with the peripherals, such as 1-Wire. I need to collect data from up to eight sensors (the peripheral devices), organize it, and send it to the computer as fast as possble.·Each peripheral will collect and send data a few thousand times per second, the master processor will send it to the auxiliary processor, and the auxiliary processor to the computer, through a 256000 bps UART. In order to do this effectively, I need speed.

    If there were an easier way, I'd certainly follow it.

    Another solution·might be to implement the RS232 UART @ 256000bps, and eight RS485 UARTS running at 128000 bps on a single processor, but even at 75MHz, I don't seem to have enough processing power for that. I'd really like to know if anyone thinks it's possible.

    Alex.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fear not that your project does not work, for it will,

    Fear not if you see·a long dark path ahead, but follow it,
    Fear not if what worked now refuses to,
    For the only thing that's perfect is imperfection.
  • pjvpjv Posts: 1,903
    edited 2007-01-01 08:54
    Hi Mr_Nuke;

    It's possible that this might all be done with a single or a pair of SX28.

    Please describe wat you are trying to accomplish rather than how you are trying to implement it !

    Please give sensor data formats or protocols, speed of updates, distances involved, organization required etc. Many of us have successfully implemented mutiple high speed interfaces in single SXes, and your requirements just might be a candidate for one of those.

    You keep dangling the challenge in front of us, but you have not revealed the whole story. For us to help in any serious way, you need to describe what you are trying to accomplish in some detail.

    Cheers,

    Peter (pjv)
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2007-01-01 12:12
    http://pdfserv.maxim-ic.com/en/an/AN723.pdf

    This may help you locate chips and resolve configuration. Sorry about the slow response. Taiwan's internet has really slowed since the quake and it is New Years.

    I think you DON'T want RS-485. You want RS-422 [noparse][[/noparse]full duplex].

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • Mr_NukeMr_Nuke Posts: 47
    edited 2007-01-01 23:03
    Hi pjv,

    I'm sorry if I·seemed to be·too reluctant in providing information. Overall, I want to monitor the status of a reaction vesel. I need to monitor temperature, pressure, voltage, and I need to do it very fast, at least 1000 times per second. This would enable me to detect sudden state changes, and prevent explosions. I need to be able to connect up to eight sensors to a sensor module, which collects the data and sends it to the PC. Most sensor readings will be 16 bits wide.
    The·peripherals will consist of an actual electronic sensor, and an SX-20. The SX-20 will take the raw data from the electronic sensor, convert it to a standard unit (such as volts, KPa, or degrees K) and send it to the sensor module. Every peripheral will have to identify itself before communicating the readings. From this identification, the master will now what sensor is connected. I still don't know what protocol to use between the master and peripherals, but I willl certainly include a checksum.
    The communication between the master and the computer will happen through a standard RS-232 port at 256000 bps. Every transmision will begin with a byte indicating a start (ASCII "S"), continue with eight bytes (or·more if·will prove to be necessary)·that may contain commands and data, and two bytes that will be the sum of the data/command bytes, LSB first.
    So far, I have the UART code finished, along with two 16 byte buffers, one for TX, and one for RX.

    Should you have any more questions about my project, please, feel free to ask.

    Sincerely,
    Alex

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fear not that your project does not work, for it will,

    Fear not if you see·a long dark path ahead, but follow it,
    Fear not if what worked now refuses to,
    For the only thing that's perfect is imperfection.
  • pjvpjv Posts: 1,903
    edited 2007-01-02 03:50
    Hello Alex;

    At first when I read your response I thought... hey, this all CAN be done with a single SX, thereby eliminating the bulk of the communications and concern about who's on line etc. Then on re-reading realized that the 'raw to engineering units' conversion of 8000 or so channels per second is probably over the top. So, unless you could do those conversions in the main computer, and send only the raw, or at most , simply scaled values, then yes, you are relegated to using multiple SXes, and the associated communications.

    So, is it a possibility to do those conversions in your host?

    If so, then the single SX approach should work; offering 256 Kbit/S to the host, simultaneous with 8,000 internal (virtual) A/D conversions(8 or 9 bits) per second. But with unit conversion thrown in .... it's too much.

    If the single processor approach could work for you, then the whole thing gets simplified tremendously.

    Cheers,

    Peter (pjv)

    P.S. Hmmmm... at 75 MHz it still might be possible to do the conversions, depending on their complexity.

    Post Edited (pjv) : 1/2/2007 3:57:09 AM GMT
  • Mr_NukeMr_Nuke Posts: 47
    edited 2007-01-02 20:44
    Peter,

    I could handle eight simultaneous 8-bit A/D convesions @ 1 KHz and get the raw data, send it to the computer (I have about 33 available ISR cycles every 4th interrupt). The only problem is that I need a 16-bit resolution. Rethinking the system for 8-bit resolution shouldn't be hard, but if I·perform the conversion in the same case as the Master processor, several problems arise:
    1) I cannot automatically determine the type of sensor that is attached.
    2) I cannot tell if the cable will become disconnected.
    3) Sending analog values over long distances (2 or more meters in my case) can induce noise.
    4) I would have to manually calibrate each sensor.

    The idea of having a SX control each sensor was that I could avoid all these problems, but, most importantly, have the ability to auto-calibrate each sensor. Although more complex and expensive·at design time, It becomes easier to use, and prevents problems, such as connecting a sensor in the wrong place.

    Yes, it would be possible to·do the·conversions in the computer, or even master processor, but I prefer the SX/sensor apporach. Imagine having the wrong sensor hooked up, and not realizing it until something goes wrong. It is unlikely, but possible.

    Sincerely,
    Alex

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fear not that your project does not work, for it will,

    Fear not if you see·a long dark path ahead, but follow it,
    Fear not if what worked now refuses to,
    For the only thing that's perfect is imperfection.
Sign In or Register to comment.