Week 08: Embeded Programming

Group Assignment: Compare the performance and development workflows for other architectures

In lecture, Neil already discussed these basic architectures Harvard and Von-Neumann. Here i will start by comparing them and we will then move forward.
Von Neumann architecture is a very basic architecture as it uses the same memory for storing data and instructions, where as Harvard is relatively advanced architecture. Best thing about harvard architecture is that it uses two different memories, one for data and one for instructions. Hence processing speed is improved. Thanks to google below we can see detailed comparison of both these architectures.
Von-Neumann Architecture Harvard Architecture
Single memory to be shared by both code and data. Separate memories for code and data.
Processor takes code/instructions in a separate clock cycle and data in another clock cycle. So it requires two clock cycles. Single clock cycle does the job, as separate buses are used to access code and data.
Higher speed, hence less time consuming. Slower in speed, hence more time-consuming.
Simple in design. Complex in design.


Next i would like to discuss other architectures as CISC and RISC. Below shown table will help us understand these two architectures.
CISC RISC
Easy to program larger set of instructions. Difficult to program even smaller set of Instructions.
Simpler design of compiler, considering larger set of instructions. Complex design of compiler.
Many addressing modes causing complex instruction formats. Few addressing modes, fix instruction format.
Instruction length is variable. Instruction length varies.
Higher clock cycles per second. Low clock cycle per second.
Emphasis is on hardware. Emphasis is on software.
Control unit implements large instruction set using micro-program unit. Each instruction is to be executed by hardware.
Slower execution, as instructions are to be read from memory and decoded by the decoder unit. Faster execution, as each instruction is to be executed by hardware.
Pipelining is not possible. Pipelining of instructions is possible, considering single clock cycle.
There are many more architectures to discuss but let's just leave it here and start programming our board.

Individual Assignment: Read a microcontroller data sheet, program your board from electronic design week to do something, with as many different programming languages and programming environments as possible

For this week i thought of making a general purpose board that can be used now and also for future assigments. Hence i chose and made atmega32u4 board. It is always good to know what are you dealing with or what are you working on.. Hence reading a datasheet is as important as results of a project. Because if you don't choose correct equipment for your task/project you definitely won't get the desired results. So let's start with reading a ATMEGA32U4 datasheet.. I won't go in depth yet will just tell you about the key features.

Hence below shown is the pinout of ATMEGA32U4

I actually downloaded schematic and board files from my local instructor's page and reworked board file, as it had some traces shorted no voltage regulator. Whereas in my board i added a voltage regulator to get 12V and 5V from the board and shuffeled a few traces that were overlapping after milling. Below is shown the schematic..

And this was the final board after the changes i made.

Next i did mill the board with SRM20 by first generating rml files and then operating the machine. You can find the detailed process in electronics design week. This is how it looked in the end..

Soldered it..

As by now our board is ready

Hence let's go and program it. To do so.. Open/Download and install arduino. Arduino is one the most widely used programming enviroment. Open arduino and connect your board physically on the serial port.

Now go to tools > select your board as arduino leonardo and check if it has been recognized by your device manager. If yes click burn the bootloader and wait.

Next is nothing but programming your board as your board is ready.. if the bootloader has burnt succssfully!

Click on file(top left corner) go to examples > basic > fade.

Open fade program and click on upload button.

Hence by now your program has been uploaded so below is the output.. LED fading in and out as programmed. Tan Tara!

Now i used another programming enviroment to program my board and that was python. Oh yes! I actually programmed my board using this famous package/library called pyfirmita from python. Firmata is a generic protocol for communicating with microcontrollers from software on a host computer. It is intended to work with any host computer software package. It is sort of an interface for microontrollers, and PYFIRMITA is interface for python to program hardware.
First open arduino click on files > go to examples > go to Firmita > click on/open StandardFirmita

Now following window pops-up with different liberaries and stuff needed for the purpose.

Upload the program to your board as earlier we did and that is it our leonardo is ready communicate with python. Now download and install python. I already have worked with python so i have it installed on my PC with editor of my choice(pycharm). You can find alot of help on youtube in this regard so go and install python and come back. Note: To run anything with python different packages are needed like in our case we will need pyfirmita one of the python packages. It is very difficult sometimes to import packages using command line, but i must tell you this- with pycharm installed on your desktop its no big deal. Let's see how.. In pycharm open it as i hope you have installed it by now..

go to files > settings

go to project interpreter which shows you, your installed packages. click on this plus(+) sign which pops-up a window of packages you can install. writepyFirmita here in search bar and you will get the package just by clicking install at the bottom of this window.



If all goes well you will have it installed, and that is it..

Now we have our program following video that demostrates the working, In this program computer/board asks user to define how many time he/she wants led to blink? And as user enters the value, led blinks specified number of times and that is it.
Click here to get design files.. Happy programming!


Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

Copyright © 2019 Azmat Hussain