Difference between revisions of "CON:Simar"

From .:: Wiki-Sirius ::.
Jump to: navigation, search
(Select modules)
(Select modules)
Line 83: Line 83:
 
! style="text-align: center; font-weight: bold; width: 400px;" | Modules Addressing
 
! style="text-align: center; font-weight: bold; width: 400px;" | Modules Addressing
 
|-
 
|-
| style="text-align: center;" | 00
+
| style="text-align: center;" | 000
 
| style="text-align: center;" | Enable the EEPROM memory
 
| style="text-align: center;" | Enable the EEPROM memory
 
|-  
 
|-  
| style="text-align: center;" | 01
+
| style="text-align: center;" | 001
 
| style="text-align: center;" | Enable SIPO register for writing digital data  
 
| style="text-align: center;" | Enable SIPO register for writing digital data  
 
|-
 
|-
| style="text-align: center;" | 10
+
| style="text-align: center;" | 010
 
| style="text-align: center;" | Load digital data on PISO register
 
| style="text-align: center;" | Load digital data on PISO register
 
|-
 
|-
| style="text-align: center;" | 11
+
| style="text-align: center;" | 011
 
| style="text-align: center;" | Enable PISO register for reading digital data
 
| style="text-align: center;" | Enable PISO register for reading digital data
 +
|-
 +
| style="text-align: center;" | 100
 +
| style="text-align: center;" | Configure the potentiometer counter
 +
|-
 +
| style="text-align: center;" | 101
 +
| style="text-align: center;" | Enable digital potentiometer
 
|}
 
|}
  

Revision as of 17:02, 1 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 02: Circuit regulator to 7V.
Figure 03: Circuit regulator to 3.3V.

Three voltages values are generate on base board, 12V, 7V, 3.3V, beyond two standards values voltages, 5V provide by an external power supply and 1.8V by the BeagleBone Black. As a external voltage source is of 5 Vcc, some converters are necessary, to generate 3.3V, 7V and 12Vcc, and their are the MEV1D0512DC and LT3080.

The MEV1D0512DC is a DC-DC Isolate converter and ins used to converter 5 Vcc in 12 Vcc. Its circuit is shown on figure 01.

The LT3080 is a linear adjustable voltage regulator, where its output is defined by configuration resistors. This regulator is used to obtain the voltages values of 7V and 3.3V, from the voltages 5V and 12V, respectively. The circuits of each regulators are showed on figures 02 and 03.

An output load was connected to each converter, as a minimum output current is required to operate them efficiently and reliably. For MEV1D0512DC a minimum required load is 10% of its capacity, 10mW, in the other converters, the minimum load current is guaranteed by a led connected to its output. If the actual load is less than the specified minimum load, the output ripple may increase sharply while its efficiency and reliability will reduce greatly.

Communication Bus

All protocols communication, already said, are disposable in just one connector.

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. Five 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 five bits on dip switch and the output of XORs gates (mod_0 ⊕ mod_1 ⊕ mod_2 ⊕ mod_3 ⊕ mod_4) 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) (5 bits: Board Addressing) (2 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)(01010)(01)
spi.writebytes([message])
time.sleep(1)
GPIO.output(DS, GPIO.HIGH)
#---------------------------------

In this example, it's selected the SIPO

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] [5 bits: Board Addressing] [ 1 1 ](LSB) (Load read register)
2) Send: (MSB)[1 bit: Even Parity] [5 bits: Board Addressing] [ 0 0 ](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] [5 bits: Board Addressing] [ 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