I'm in the process of making the basic layout of all components and wires in a very complex project. The question is, which serial port to interface with which component? (This post contains two questions, see below!)
1) Components/Setup:
-
3x motor drivers, standard SPI, only setup
-
motion sensor, standard SPI, continous data stream while operating
-
display/memory, standard SPI, continous data stream while operating
-
RF modul, UART, continous data stream while operating
-
Lanc camera control, halfduplex UART (slow), continous data stream while operating
-
camera lens mount, halfduplex SPI (fast!), continous data stream while operating
-
"Due Core" (Arduino Due clone, http://www.inhaos.com), all pins of Atmel SAM3X8E are accessible
2) State of affairs
I thought connecting the standard SPI components to the hardware SPI port would be the best choice, as I can make use of the 4 hardware CS pins:
3x motor driver, motion sensor <-> hardware SPI + 4 CS pins
The motor driver only needs some setup (and maybe some adjustments every now and then), while data is continously streamed from the motion sensor (after initial setup) and processed by the CPU. Thanks to the hardware CS pins there is automatic switching between devices and no need for extra code.
On the display shield is an extra memory modul, where all the processed motion data will be stored. Also, the display has to be continously updated:
display/memory <-> UART(RX1/TX1) in SPI mode
The RF modul is receiving and transmitting data (packages) at all times, that have to be processed by the CPU, but it can't do SPI:
RF modul <-> UART(RX0/TX0)
This way I can offload most of the data streaming to the DMA controllers and free up CPU time.
Being on a tight serial port budged (as RX3/TX3 is not supported by the Arduino IDE), the Lanc interface only running at 9600baud and halfeduplex mode on one wire, it seems a good idea to do some software serial here:
Lanc camera controll <-> bitbanging (halfduplex) serial
Last, but not least...of a problem: directly controlling FourThirds and Micro-FourThirds lenses
The FourThirds mount utilises halfduplex SPI consisting of Clock (500kHz, always send by the camera), Data, 2 signal lines (lens>body, body>lens). Data are always send by the device which pulls its signal line LOW first, but not before the other device answers by pulling its signal line LOW too.
As this connection runs at 500kHz and the CPU has lots of other (time critical) tasks to do, I would like to use one of the hardware ports here (so no bitbanging). And as using those two CS lines is not really standard SPI, I see no advantage in using the hardware SPI port over UART in SPI mode (which additionally is buffered).
lens control <-> UART(RX2/TX2) in SPI mode
3) Does that make any sense?
Is this the optimal assignment of components to serial ports? Or did I miss something?
Or is there any benefit, by e.g. exchanging the hardware SPI port with one of the UART in SPI mode ports? (see also 4) )
Any suggestions?
4) Halfduplex-SPI elektronics
The camera lens transmits and receives data over one line, therefore MOSI/TX and MISO/RX have to be connected to this line. (This is not the same as one-wire-SPI!)
I have found two possible circuitrys:
A) MOSI via resistor connected to the data line, MISO directly connected.
B) MOSI and MISO connected via an analog switch to the data line, controlling the switch by an extra I/O pin.
Which possibility is here preferable?
Is there any electrical/electronical difference between the hardware SPI and the UART in SPI mode ports, that would be of interest using one of those circuits?