Week 11: Communication

Group Assignment: send a message between two projects

Individual Assignment: design, build, and connect wired or wireless node(s) with network or bus addresses and local input &/or output device(s)


Communication Methods

UART / Asynchronous

UART stands for Universal Asynchronous Receiver Transmitter. It is a wired method of communication, a key point is it is Asynchronous which means the data sent is not monitored or coordinated by a clock. Instead, there is a pre-existing agreement about the 1) data length, 2) start/stop bits, and 3) speed of transmission. This allows for the data to be transferred with precision.

For communicating between multiple devices using UART we can employ "hop-counting" or "broad-hopping". Basically these are methods to count the devices in the network, give them addresses, as well as communicate with them. Here is a screenshot of the concept from Dr. Neil's previous lecture illustrating the concept.

Its a little difficult to understand precisely how it is all working, but important to try. Anyway, this section is about Asynchronous communication which again means that it is not coordinated by a clock. Instead the line is held on high, and at any time a device in the network may start transmitting.


I2C / Synchronous

In contrast, I2C and other types of synchronous communication use time when transmitting. For I2C in particular, there are 2 lines, namely SDA (Serial Data) and SCL (Serial Clock), and they work in conjunction.



SPI - Serial Peripheral Interface

SPI is another major communication protocol. It uses 4 pins to communicate with another device, and then usually requires an additional pin for each additional device connected. However it is fast and in some aspects easier, because it has a dedicated line for both sending and receiving between the master and slave.



Communication!

Set-Up:

We have to make more NEMA boards since in this week we need to communicate to multiple devices. Here's 2:

The task this week is to communicate. Saheen explains one possibility is through supplemental connector boards. The plan is to communicate with UART, so this additional mini-board will have the RX TX pins. We will also be able to program through the programmer via this board.

We cut the mini-boards using the X-Tool laser machine. It was good practice to review that.

Also it was weirdly enjoyable to clean these boards with the toothbrush.

Connected the two motor boards with wires to the mother-board:



Programmming:

Now its all about programming. Actually 2 programs, as we'll need a program both for the RP2040 Master and the two motor controllers driven by ATtiny1614. What we'll do is adapt programs from the previous weeks.

Master Program: in week 8, "Electronics Production", we created a simple board with a button and some LEDs controled by the RP2040. This is our master board, and what follows is the main part of the program. Our task is to control both the selection of external motors (Motor 'A' / Motor 'B'), as well as the status of those motors. We can control all of this from a single button by differentiating between short and long presses. The long press will toggle between motors, and the short press will toggle between modes on the selected motor. Hence in the main loop we are detection button press, button release, as well as measuring the time between these events.

Slave Program(s): the slave program is developed from our communications program from week 10. Actually relatively few changes are needed here. Please refer to week 10 for more information.

Now please watch the video. Note that the controls for the attached second motor only work when the second motor is activated, indicated by the blue LED. Hence the long press does indeed allow us to toggle between and select the motors, and the subsequent small pushes control the motor activity.



Files: