Arduino/C3/Digital-Logic-Design-with-Arduino/English-timed

From Script | Spoken-Tutorial
Revision as of 14:49, 26 October 2018 by Sandhya.np14 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Time Narration
00:01 Welcome to the Spoken Tutorial on Digital Logic Design with Arduino.
00:07 In this tutorial, we will learn to: implement and verify the AND, OR and XOR operations in assembly,
00:17 implement and verify simple Combinational Logic.
00:21 To follow this tutorial, you should have basic knowledge of electronics and Assembly language.
00:31 To record this tutorial, I am using: Arduino UNO Board
00:38 and Ubuntu Linux operating system version 14.04.
00:44 We also require some external devices such as:

Breadboard,

00:51 Arduino UNO Board,
00:54 Seven Segment Display,
00:57 220-ohm Resistor,
01:00 Decoder (7447 IC) and

Jumper Wires.

01:07 We will use the same circuit setup as we did for the decoder, in the earlier tutorial.
01:14 Let us see the live connection setup.
01:17 Now, we will write an assembly program to verify the logical AND operations.
01:24 Open any text editor and type the following program.
01:29 m328Pdef.inc file and the source code are available in the code files link of this tutorial.
01:38 You can download and use it.
01:41 The highlighted code configures pins 2, 3, 4 and 5 of the Arduino as output pins.
01:49 We are considering only the first bit of r16 and r17 for our boolean operations. Here, both are 1.
02:00 This line performs bitwise AND operation on the bits of r16 and r17. The result is stored in r16.
02:12 The rest of the program takes care of displaying this output.
02:17 The LSB of r16 has our result. This has to be shifted by two positions to the left.
02:26 This line of code calls the loop named loopw.
02:31 This loop takes care of shifting the LSB of r16 twice.
02:38 The value in r16 is sent to PORTD. This displays either 0 or 1 on the Seven segment display.
02:48 Here, contents of r16 are left shifted once. Then the value of r20 is decremented by 1.
02:58 If the value of r20 is not equal to zero, the loop is repeated again.
03:05 I’ll save the code as boolean.asm in the home slash spoken slash Assembly folder.
03:15 Switch to the terminal.
03:18 Go to the folder where boolean.asm file is saved. Type: avra space boolean.asm and press Enter.
03:29 This will assemble the code and create a file boolean.hex.
03:34 Let us clear the screen.
03:36 Next, we need to upload the code to the Arduino.
03:41 For this, type: avrdude space hyphen p space atmega328p space hyphen c space arduino space hyphen b space 115200 space hyphen capital P space forward slash dev forward slash ttyACM0 space hyphen capital U space flash colon w colon boolean dot hex

and press Enter.

04:17 Now, you can see that the digit one on the seven segment display is glowing.
04:23 Pause the tutorial and do the below assignment.
04:27 Modify the values of r16 and r17 to verify the rest of the truth table of AND.
04:35 Replace the keyword and in the program with or to perform logical OR operation.
04:42 Replace the keyword and in the program with xor to perform logical XOR operation.
04:49 Next, we will implement and verify few simple combinational logics.
04:55 Let us see the live connection setup. It will be the same as the previous setup.
05:02 We are going to implement these equations in our program and verify their truth table.
05:09 This is the truth table for the equations shown above.
05:14 Here W, X, Y and Z are the inputs.
05:19 A, B, C and D are the outputs. Let us consider the first row of the truth table. Thus, all the inputs will be zeros.
05:31 As per the truth table, we can expect the output as 1.
05:36 We will display the output on the seven segment display.
05:40 Let us write an assembly program to implement and verify these equations.
05:46 Open any text editor and type the following program.
05:50 Let me explain the program.
05:53 This line configures pins 2,3,4 and 5 of the Arduino as output pins.
06:00 r30 is a dummy variable for storing the output.
06:05 The values of input variables W, X, Y and Z are stored in registers r17, r18, r19 and r20 respectively.
06:16 The values of r17, r18, r19 and r20 are stored in the dummy variables r0, r1, r2 and r3.
06:27 These values are used to restore the original registers after performing operations.
06:35 The 'comp' subroutine is used to find the complement of a variable.
06:41 The complement of W, X, Y and Z are calculated and stored in r21, r22, r23 and r24 respectively.
06:52 The values of r21, r22, r23 and r24 are stored in the dummy variables r4, r5, r6 and r7.
07:04 Note that A is nothing but the complement of W.

Now, we have implemented the first equation.

07:12 Next, we perform two left shift operations and store the value in r30.

Thus, the third bit of the r30 has the value of A.

07:24 The 'reload' subroutine reloads the values r0, r1, r2, r3, r4, r5, r6 and r7 from its copies.
07:36 They might have changed during previous operations.
07:41 The logic for B is implemented and the result is stored in r0.
07:47 The value in r0 is left shifted thrice and stored in r30.
07:54 Now, the fourth bit of r30 holds the result of B.
08:00 The logic for C is implemented and the result is stored in r0.
08:06 The value in r0 is left shifted four times and stored in r30.
08:13 Now, the fifth bit of r30 holds the result of C.
08:19 The logic for D is implemented and the result is stored in r0.
08:25 The value in r0 is left shifted five times and stored in r30.
08:32 Now, the sixth bit of r30 holds the result of D.
08:38 Finally, the value stored in r30 is sent to PORTD to be displayed.
08:46 Save the code as combination.asm in the home slash spoken slash Assembly folder.
08:55 Switch to the terminal.
08:58 Type: avra space combination.asm and press Enter.
09:05 This will assemble the code and create a file combination.hex.

Let us clear the terminal.

09:14 To upload, press the up arrow to get the previous command.
09:19 Now change the filename as shown and press Enter.
09:26 Now you can verify the truth table with the output shown on the seven-segment display.
09:34 Pause the tutorial and do the below assignment.
09:38 Change the values of W, X, Y and Z and verify different rows of the truth table.
09:46 This brings us to the end of this tutorial. Let us summarize.
09:52 In this tutorial, we learnt to: implement and verify the AND, OR and XOR operations in assembly,
10:01 implement and verify simple Combinational Logic.
10:05 The video at the following link summarizes the Spoken Tutorial project.

Please download and watch it.

10:13 The Spoken Tutorial Project team conducts workshops and gives certificates.

For more details, please write to us.

10:23 Please post your timed queries in this forum.
10:27 Spoken Tutorial project is funded by NMEICT, MHRD, Government of India.

More information on this mission is available at this link.

10:38 This tutorial has been contributed by FOSSEE' and Spoken Tutorial Project, IIT Bombay'.

This is Priya from IIT Bombay, signing off. Thanks for watching.

Contributors and Content Editors

PoojaMoolya, Sandhya.np14