What are the steps necessary to get
Device 1. MSP430 ez430-rf2500 to communicate over Serial Peripheral Interface (SPI) with
Device 2. MSP430 5528 and MPU 6000 gyroscope?
Goal to get Device #2 to send inertial position data over SPI to Device #1. Device #1 will analyze received position data and send a control signal over SPI back to Device #2(attempting to achieve a stable hover). As the position of Device #2 changes this process repeats.
I have come up with an outline of what I think is the right answer to solve a problem like this, however I was hoping the community can help with modifying incorrect/inaccurate information, adding useful information, or removing unnecessary information from my outline.
I have included 3 figures below that I will refer to in my outline:
Figure #0 (F0) – Device #2 MSP 430 F5528 Processor which is on connected to Inertial Sensor (Figure #1)
Figure #1 (F1) – Device #2 Inertial Sensor Schematic containing MPU-6000 Gyro chip
Figure #2 (F2) – pg. 47 on page Device #1 ez430-rf2500 SPI Configuration
Outline
-
Figure out which (Device #1 or Device #2) is "Master" or"Slave".
1.1 The master is considered to be the microcontroller that initiates communication. Since the Device #2 – Inertial Sensor (Figure 1) is the one that generates position data Device #2 should be the master.1.2 The slave is considered to be the microcontroller that responds to initial communication. Since Device #1 ez430-rf2500 will need to figure out how to stabilize Device #2 shown in Figure 1 and send it a control signal Device #1 should be the slave.
-
Figure out where to store and how to send position data on the Device #2 Inertial Sensor
2.1 Determine where the output buffer that will store position data is located on Device #2 (perhaps somewhere in Figure # 0)
2.2 Determine how to initiate transfer of output buffer data to Device #1 over SPI from Device #2
-
Write code to receive position data over SPI from Device #2 on Device #1
3.1 Determine where the input buffer is located on Device #1 that will store incoming position data.
3.2 Determine how to copy input buffer into registers on Device #1
-
Write code Device #1 will execute to generate a control message to be sent to Device #2
-
Copy control data into Device #1's output buffer and send it to Device #2's Processor (Figure #0)
5.1 Determine where the output buffer is located on the Device #1
5.2 Determine how to send control data from Device #1's output buffer over SPI to Device #2's input buffer.
-
Determine how to copy control signal from Device #2's input buffer and send it from Device #2's processor to Device #2's motor/servos to execute (i.e. creating a new position and triggering a repeat of steps 1-6 above)
Best Answer
In the scenario you gave, Device 1 performs the calculation and asks Device 2 to move accordingly. Therefore Device 1 runs the control algorithm; it is the controller. That suggests Device 1 should be the SPI master, requesting gyroscope data, and commanding moves.
Also presumably, the RF2500 is receiving commands from a transmitter somewhere - another data point suggesting it is the (onboard) controller.
I suspect you can make either approach work, but that's not really the point - starting from the cleanest design makes the job easier.