week_14
Networking and Communications
Embedded electronics are created by interconnecting circuits (processors or other integrated circuits) to create symbiotic systems. In order for these individual circuits to exchange their information, they must share a common communication protocol. Hundreds of communication protocols have been defined for this data exchange, and generally each can be divided into two categories: parallel or serial.
"Serial communication is the process of sending data one bit at a time, sequentially, over a communication channel or computer bus. This is in contrast to parallel communication, where several bits are sent as a whole, on a link with several parallel channels. Many communication systems were generally designed to connect two integrated circuits on the same printed circuit board, connected by signal traces on that board (rather than external cables)."Some low-cost serial buses include SPI, I2C, DC-BUS, UNI/O, and 1-Wire.
SPI mode usually has one master device and one or more slave devices, requiring at least 4 wires, and in fact 3 wires can be used (for one-way transmission).Also common to all SPI based devices are MISO (primary device data input), MOSI (primary device data output), SCLK (clock), CS (chip selection).
(1) MISO -- Master Input Slave Output, data Input from the Master device and data Output from the Slave device;
(2) MOSI -- Master Output Slave Input, data Output of the Master device and data Input from the Slave device;
(3) SCLK -- Serial Clock, Clock signal, generated by the main device;
(4) CS -- Chip Select, enabling signal from the slave device, controlled by the master device.
I2C bus is a simple, two - way two - line synchronous serial bus developed by Philips. It requires only two wires to transmit information between devices connected to the bus. The I2C protocol involves using two lines to send and receive data: a serial clock pin (SCL) that the master board pulses at regular interval, and a serial data pin (SDA) over which data is sent between the two devices.
In my group assignment, I am planning that to connect my ultrasonic sensor input driver which made in week 09 and RGB output driver which made in week 11.
First, I referred the schematic diagrams for the ultrasonic sensor input driver.
Here is the board of the ultrasonic sensor input driver.
Then I used the Arduino IDE to program. Then I program the codes like this:
This part of the program is connected to the ultrasonic sensor interface. It is the premise that simply initializes the ultrasonic sensor, takes readings, and outputs the data in serial. At each read, a "#" is inserted to mark the end of one read and the beginning of the next.
I also read the schematic diagram of RGB board.
Here is the RGB board.
The program codes like this
This part of the program is for RGB LED panel, which accepts serial data from another panel. The data is received by character the '#' is found, reset the values. if a sequence decimal is found, it’s converted to a number. This number, if less than 10 the RED led in the RGB led is lit up with the appropriate brightness. If more than 10 and less than 20, RED is lit with full brightness and GRENN with the brightness corresponding to the distance, similarly for the distance between 20 and 30. For more than 30 all are lit with full brightness. But it didn’t work. I don’t know why.
(1) Eagle
This week I only designed the master board because I would use boards created previously on week_06. The designed in Eagel and the necessary components for producing the board are shown below.
(2) PCB Production
I used the Roland SRM-20 milling machine, controlled with mods to mill the board, following the same process as in Electronics Design week.
(3) Programing
I used Arduino IDE to program I2C communication codes. In my case, the master device was connected to one slave device, the board for a LED and a button created previously on week_06.
① Master device
② Slave code
Setting the environment
In this case, there has a problem when I first I tried to use “Wire.h” for the slave board using ATtiny44, which is the library could not be used.
So I search the problem in the fablab, I found the page that shows how to execute Wire.h in Attiny44. From this web page, additional board manager library file was required. All files and tutorial are shown here.
A. File->Preferences on a PC, or Arduino->Preferences on a Mac, enter the above URL in "Additional Boards Manager URLs.
B. Tools -> Boards -> Boards Manager... *If using 1.6.6, close boards manager and re-open it (see below)
C. Select "ATTinyCore by Spence Konde" and click "Install".
After I completed to install new board manager library file, I could compile the code for the slave device.
④ Wiring
Actual wiring is shown below.
Pull-up registers were already included in Master board, so just wiring power, GND, SDA, and SCL was enough to prepare I2C communication.