CON:Simar

From .:: Wiki-Sirius ::.
Revision as of 13:48, 4 March 2021 by Robert.polli (Talk | contribs) (Select modules)

Jump to: navigation, search

Introduction

The Internet of things Group has developing a general communication board, with the focus of making it a modular system which will serve as a basis for new group projects. The base board of Simar project has been developed with the ability to communicate with others modules though one of its four communication protocol, that are:

  • Onewire;
  • Inter-Integrated Circuit - I2C;
  • Serial Peripheral Interface - SPI;
  • Universal Asynchronous receiver-transmitter - UART;

Hardware Overview

Base board

The base board is responsible to work as master on communication's bus, generate the necessaries power voltages to each integrate circuit and controlling a general bus though the Processing Real Time Unit - PRU. The master controlling chosen was BeagleBone Black and its PRU0 and PRU1 are used to real time data processing.

Board Power Circuits

Figure 01: Circuit regulator to 3.3V.

There are three voltages values available on base board, 5Vdc, 3.3Vdc and 1.8Vdc. The 5V level voltage is obtained by an external power supply, which is then regulated to other voltages. The 1.8V level is provided by BeagleBone Black, using its internal voltage converter and 3.3V is generate using the integrated circuit LT3080.

The LT3080 is a linear adjustable voltage regulator, where its output is defined by configuration resistors, according to the equation below. To converter operates with efficiently and reliably, a minimum output current is required, that must to be higher than 0,5 mA and it is performed putting a LED on circuit output. The circuit is showed on figure 01.

Vout = Rset . 10uA

Communication Bus

All protocols communication are disposable in a db9 connector, see figure 02.

Digital/Analog board

The first shield board of SIMAR is a general in/out digital data and read analogical data. It is divided on six blocks: board enable, module selector, read digital data, write digital data, memory and read analogical values.

First of all, a SIPO register 74HC595 is used to receive one byte of data by spi protocol, that will determined which module will be enable. four bit from data received are connected on XOR logic gates (74HC86), that has the aim to determinate the parity of them ("0" if even, "1" furthermore).

The Board enable block is compound by a magnitude comparator (74LS688) and a dip switch of five positions. It will compared the four bits on dip switch and the output of XORs gates (mod_0 ⊕ mod_1 ⊕ mod_2 ⊕ mod_3) with the addressing and the bit parity, sent by spi.

Protocol

In order to write or read any value on the board, it is necessary to send at least two bytes. As the board has three modules for selection, the first data byte must choose one of them, after, the others bytes can be sent according the selected module.

To send the first byte, it's necessary set the pin "P9_14" to low, and generate a rising edge on it after all the data has been sent, now setting it high. Once a module is selected, it is not necessary to do it again, if more then one byte is read or written.

Two initial settings must be made, related with spi, the mode set to three and the most significant bit sent first. This setting are showed below:

from Adafruit_BBIO.SPI import SPI
# /dev/spidev0.0
spi = SPI(0, 0)
spi.mode = 3             # CPHA = 1 ; CPOL = 1
spi.lsbfirst = false  
spi.bpw = 8
spi.msh = 10000000       # Testar qual a máxima taxa


Note: In all examples, the parity is only related to the board's address.


Select modules

[w: 1 byte]

To select the interested module, its necessary send 1 byte of data serially. The sent data sequence must be:

1) Set the BeagleBone Black pin "P9_14" to low;
2) Send one byte data by spi;
3) Set the BeagleBone Black pin "P9_14" to high.

The data byte is divided on:

(MSB)(1 bit: Even Parity) (4 bits: Board Addressing) (3 bits: Module Addressing)(LSB)

The table below shows the addresses to each module present on board:


Modules Address
Address Modules Addressing
000 Enable the EEPROM memory
001 Enable SIPO register for writing digital data
010 Load digital data on PISO register
011 Enable PISO register for reading digital data
100 Configure the potentiometer counter
101 Enable digital potentiometer

E.g.:

import time
import Adafruit_BBIO.SPI as SPI
import Adafruit_BBIO.GPIO as GPIO
DS = "P9_14"
#---------- Set Pinouts ----------
GPIO.setup(DS, GPIO.OUT) #Set DS
GPIO.output(DS, GPIO.LOW)
#---------------------------------
#------------ Set SPI ------------
spi = SPI.SPI(0, 0) # set which SPI will be used
spi.bpw = 8
spi.lsbfirst = False
spi.mode = 3
spi.msh = 10000000
#---------------------------------
#-------- Select Module ----------
GPIO.output(DS, GPIO.LOW)
message = [41]             #(0)(0101) (001)
spi.writebytes([message])
time.sleep(1)
GPIO.output(DS, GPIO.HIGH)
#---------------------------------

In this example, it's selected the SIPO register.


Read digital data

[w: 2 bytes (1 + 1)] [r: 1 byte]

To read the values of the digital data, it is necessary to first load the read register, after, enable the read register and then, read one byte data by mode 3 serial spi. It isn't necessary to select the register again, or load it, if you want read the same value, just read the data by spi.

Then, the sequence to read the digital data will be:

1) Send: (MSB)[1 bit: Even Parity] [4 bits: Board Addressing] [ 0 1 0 ](LSB) (Load read register)
2) Send: (MSB)[1 bit: Even Parity] [4 bits: Board Addressing] [ 0 1 1 ](LSB) (Enable register)
3) Read one byte through spi.

Write digital data

[w: n bytes (1 + (1+1+...+1))] [r: none]

To write on digital bus, first select the SIPO register and, then, send one byte of data. It's not necessary to select again the module if you want write others data bytes on bus.

The sequence will be:

1) Send: (MSB)[1 bit: Even Parity] [4 bits: Board Addressing] [ 0 0 1 ](LSB) (Enable register)
2) Send: [8 bits: digital data] (Writes data)
3) Send: [8 bits: digital data] (Writes data)
4) Send: [8 bits: digital data] (Writes data)
...

Read/Write memory

SPIxxSWI

Protocol

Software Overview

Protocol