Difference between revisions of "CON:Simar"

From .:: Wiki-Sirius ::.
Jump to: navigation, search
(Bus and Communication Circuits)
(Bus and Communication Circuits)
Line 63: Line 63:
 
! style="text-align: center; font-weight: bold; width: 400px;" | Data traffic lines
 
! style="text-align: center; font-weight: bold; width: 400px;" | Data traffic lines
 
! style="text-align: center; font-weight: bold; width: 400px;" | BBB pins
 
! style="text-align: center; font-weight: bold; width: 400px;" | BBB pins
|-
 
| style="text-align: center;" | I2C
 
| style="text-align: center;" | SDA
 
| style="text-align: center;" | P9.20
 
|-
 
| style="text-align: center;" | I2C
 
| style="text-align: center;" | SCLK
 
| style="text-align: center;" | P9.22
 
 
|-
 
|-
 
| style="text-align: center;" | I2C
 
| style="text-align: center;" | I2C
Line 79: Line 71:
 
| style="text-align: center;" | ADDR 1
 
| style="text-align: center;" | ADDR 1
 
| style="text-align: center;" | P9.16
 
| style="text-align: center;" | P9.16
 +
|-
 +
| style="text-align: center;" | I2C
 +
| style="text-align: center;" | SDA
 +
| style="text-align: center;" | P9.20
 +
|-
 +
| style="text-align: center;" | I2C
 +
| style="text-align: center;" | SCLK
 +
| style="text-align: center;" | P9.22
 
|-
 
|-
 
| style="text-align: center;" | SPI 0
 
| style="text-align: center;" | SPI 0

Revision as of 14:19, 12 March 2021

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

Bus and Communication Circuits

All protocols communication are disposable in a db9 connector, see figure 02. Two of them are directly connected to the BeagleBone pins, the One Wire and Uart protocols, according to the table below:

Protocol Data traffic lines BBB pins
UART0 Tx0 P4 - Cosole BBB
UART0 Rx0 P5 - Cosole BBB
UART4 Rx4 P9.11
UART4 Tx4 P9.13
One Wire 1-wire P9.12


The serial SPI communication is, before the bus, burrefed by a 74HC245 buffer circuit in order to isolated the primary board from the other boards and, in addition, the integrated circuit changes the digital voltage level, from 3.3V to 5V.

Furthermore, the bus possibilities data traffic of up to four dispositives though the I2C protocol, using for it a dual 4-channel analog demultiplexer, the HEF4052 B circuit, which switches SDA and SCLK signs between the secundary boards. So, for the I2C communication, the base board needs send two more data signals, addr 0 and addr 1, to select the demultiplexer channel.

The BeagleBones pins used to SPI and I2C communication are described below:


Protocol Data traffic lines BBB pins
I2C ADDR 0 P9.15
I2C ADDR 1 P9.16
I2C SDA P9.20
I2C SCLK P9.22
SPI 0 DS P9.14
SPI 0 CS P9.17
SPI 0 MOSI P9.18
SPI 0 MISO P9.21
SPI 0 CLK P9.22

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:


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


Set potentiometer

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

The digital potentiometer has its resistance value changed using the spi clock sign. For each pulse, an increment of

SPIxxSWI

Protocol

Software Overview

Protocol