ASSIGNMENTS

Week 4

Embedded Programming

Group Assignment

Compare the performance and development workflows for other architectures.

Microcontrollers

For this assignment we compared build and performance of three microcontrollers:

  1. Atmega 328
  2. ESP32
  3. ATTiny412

Basic Specs Comparison

Atmega 383

ESP32

ATTiny 412

CPU

8-bit AVR

32-bit

8-bit AVR

Max Clock

20MHz

2.4GHz

20MHz

Flash

32Kb

4Mb

4Kb

SRAM

2Kb

400Kb

256b

EEPROM

1Kb

384Kb

128b

UART/USART Capability

Yes

Yes

Yes

I2C Capability

Yes

Yes

Yes

SPI Capability

Yes

Yes

Yes

Wifi Capability

No

Yes

No

Bluetooth Capability

No

Yes

No

Atmega 328 (Via Arduino Uno)

The ATmega328, is an 8-bit AVR microcontroller which provides a relatively modest computing capability with a maximum clock speed of 20 MHz. It offers 32 KB of flash memory for program storage and 2 KB of SRAM for data manipulation. While it includes 1 KB of EEPROM for non-volatile data storage, it supports only one UART and offers basic SPI capabilities. Notably, it lacks Wi-Fi and Bluetooth capability, making it unsuitable for IoT applications that require wireless connectivity.

ESP32 (Via XIAO ESP32C3)

While the ESP32 (Via XIAO ESP32C3) is a powerhouse with a dual-core 32-bit Tensilica LX6 microcontroller running at speeds of up to 2.4 GHz. It provides ample resources, typically boasting 4 MB of flash memory and 400 KB or more of SRAM. It supports multiple UARTs and SPI interfaces, making it versatile for various communication tasks. Additionally, the ESP32 includes built-in Bluetooth and Wi-Fi capabilities, making it an excellent choice for IoT projects requiring wireless connectivity.

ATTiny 412 (Via Inhouse Development Board)

Lastly the ATtiny412, while still an 8-bit AVR microcontroller like the ATmega328, is more compact in terms of resources. It features 4 KB of flash memory, 256 b of SRAM, and 128 b of EEPROM, making it suitable for simple, low-power applications. It offers a single USART and basic SPI capabilities but lacks Wi-Fi and Bluetooth support. Its strengths lie in power efficiency and cost-effectiveness for projects with minimal memory and processing requirements.

Speedtest

We covered the basic functionalities and capabilities of the three microprocessors, but we needed to see how well they process and respond. To accomplish this, we did a simple speedtest to check their response time. The speedtest incorporates a simple program being sent to each microprocessor that will check the time it will take to switch from a Low signal to High signal and back to a Low signal. The time taken will be recorded in milli seconds and sent to the Serial Monitor.


            unsigned long start, Total ;
            #define test_pin 4    //assigns pin   
            void setup() {
              Serial.begin(9600); // starts serial
              pinMode(test_pin, OUTPUT); //declares pin as output
            }
            void loop() {
              start = millis();  //starts reading the microprocessors internal timer from 0
              for (int i = 0; i < 10000; i++) {  //constant time readings function
                digitalWrite(test_pin, HIGH);   // sets the pin to output High signal
                digitalWrite(test_pin, LOW);    // sets the pin to output Low signal
              }
              Total = millis() - start ;   //time reading after previous reading
              Serial.print("Switching Time : "); 
              Serial.println(Total);  // displays results on serial monitor
            }
        

The program was first uploaded to the Arduino Uno using the pin 3. The switching time read between 89 and 90 ms.

The program was then uploaded to te XIAO ESP32C3. The test pin was assigned to pin D8 and the switching time read at 10ms.

The program was uploaded to the ATTiny 412 development board. The test pin was assigned to digital pin 4 and the switching time was read at 28 and 27ms.

In summary, the choice among these microcontrollers depends on the specific project needs, with the ATmega328 and ATtiny412 suitable for less resource-intensive tasks, while the ESP32 excels in performance and connectivity for more demanding applications, especially those involving Wi-Fi and IoT functionalities. Although similar architecture, The ATTiny412 responds much faster than ATmega328 on the Arduino Uno board.