Latest Posts

Friday, November 21, 2014

Serial Communication Protocol between Boards

Purpose

The purpose of this post is to outline the choices we have regarding communication between multiple microcontrollers. Our current prototyped design requires 14 PWM I/O ports, an SPI port, and 4 ADC ports. This makes the use of the PIC32 a less feasible option for controlling our robot’s low- level operations. Therefore, we decided to use a second microcontroller to collect feedback data from the sensors and provide the data through to the main system board.

Choice of Microcontroller

We were only provided one board for the robot, so a second development board would have had to be purchased. In our case, our software lead had an Arduino Due that he was willing to part with.
The Due has 3 high resolution DAC Outputs that I was interested in using as a possible means of communication between the two boards.

P.Memory (Kbytes)
2048 Flash
P.Memory (KWords)
512
Self-Write Flash
Yes
RAM (Bytes)
512K
Auxiliary/Boot Flash
160
Emu. Flash
Yes
Dual Boot Flash Write
Yes
I/O Pins
120
Max CPU Speed
200 MHz (330 MIPS)
Internal OSC
8 MHz, 32 kHz
System Mgmt Features
8-DMAC, BOR, LVD, POR, WDT, RTCC, Osc <=1% accuracy
Analog Peripherals
2-Comparators, Bandgap - Yes; 1A/D, 48x ADC Mode-1 10-bit @ 500ksps; ADC Mode-2 0-bit @ 0ksps
Digital Comm. Peripherals
6-UART w/IrDA®, 6-SPI™, 5-I2C™, 6-I2S™, AC97, I2S
Connectivity
1-HS Device/Host/OTG-, 10/100 Base-TX Mac, LIN, IrDA
Digital Peripherals
9-Output Comp. PWM , 32-bit PWM, 9-Input Capture, PPS

Communication Options

Our choices of serial communication options were, at first, limited by the availability of certain I/O ports on either the PIC32 or the Arduino Due. After we had the opportunity to research more interfaces – we attempted a few of the more common communication protocols (I2C and SPI), but ran in to issues with the arduino spamming the input buffer of the PIC32.
We didn’t have a lot of time to find out why the SPI interface was not working, but we tried the sample code available on the microchip website and I tried probing  on the oscilloscope successfully, but I couldn’t configure the device in master mode properly.

Final Decision

We decided on creating our own communication system, because the options available on the Due (mainly UART and I2C, SPI, and CANBUS) did not match the simplicity of a hardcoded interface that we could create for this particular purpose. Also, both MCU’s have the same operating voltage, so we could communicate direct pinouts without any issues.


From Arduino to Pic32

  • 3 digital pins as input from the Pic32 for commands being sent (3 bit unsigned). 
  • 3 analog pins (up to 12 bit DAC) are used to send data from the arduino to the PIC32 upon request. 
  • voltage reference pin (labeled VREF onboard) is also wired to the 3.3V out of the PIC32
  • common Ground pin  

From Pic32 to Arduino

  • 3 ADC pins (Delta-Sigma, precise up to 10 bits)
  • 3 digital pins are used to send data to the Arduino from the PIC32 (treated as a 3-bit unsigned value)
  • voltage reference pin (3.3V works as well)
  • common Ground pin 

 Diagram of Serial Connections Required



No comments:

Post a Comment