Embedded programming

1. Weekly Brief Summary

This week, I embedded the programing in the board I created in week06.
Since the board I created was using “ATtiny44”, I checked the datasheet before writing the programing.
As for the group assignment, I used “microbit” to compare the development environment.


2. Weekly Assignment Requirement

Group Assignment

  • Compare the performance and development workflows for different microcontroller families
  • Document your work (in a group or individually)

Individual Assignments

  • Read the datasheet for the microcontroller you are programming
  • Program the board you have made to do something, with as many different programming languages and programming environments as possible.

Learning outcomes

  • Identify relevant information in a microcontroller datasheet.
  • Implement programming protocols.

Have you

  • Linked to the group assignment page
  • Documented what you learned from reading a microcontroller datasheet.
  • Programmed your board
  • Described the programming process/es you used
  • Included your source codeshot’ photos of final object
  • Included a short ‘hero video’ of your board

Kamakura Group Assignment Week08


4. Assignment Work Planning

  • Group Assignment
    Comparison of Programming with Different Microcontrollers
    (a)ESP8266・・・Yuki Oka
    (b)microbit・・・Toshiki Tsuchiyama
    (c)Raspberry Pi・・・Hideo Oguri

  • Individual Assignments
    (a)Read the Datasheet
    (b)Programing


5. Description of Assignment Work

① Decipher the Datasheet

I used ATtiny44 for the board I made in week06, so I read that datasheet out.
This time I checked the Summary data sheet.

First, I checked the pin configuration of ATty44.
There are 14 pins in total, and 1 and 14 are used in the power supply.
Other pins also have roles, and I checked which part I was using on which pins.
After that, I checked the relation of pinout since I’m programming with Arduino.

  • ATtiny44 Pinout

  • Arudiono Pinout - Arduino

Next, I checked the block diagram of ATtiny44. The ATtiny44 has eight analog pins and four digital pins.
Since the converter is an “ADC”, you can see that the analog signal is converted into a digital signal.
I also checked the many features of ATtiny44 and realized that there is an “ISP INTERFACE”.

  • Port A = Analog

  • Port B = Digital

I was also surprised that ATtiny44 works in an environment of -40°C.
It can be used even in the winter of Hokkaido!

Finally, I checked the drawing of ATtiny44.
I understand that L in the drawing is the length of the soldering terminal to the board.
At the time of soldering, it was written that “the measurement value should not exceed the maximum value when the measurement value is 0.36 mm (0.014 inches) or more on the seating surface”, so it was a reference for the next time or later.

② Ardino Programming

(1) Select Settings

・Boards ー ATtiny24/44/84
・Processor ー ATtiny44
・Clock ー External 20 MHz
・Port ー cu.usbserial-FTAS0HLH(※select a proper option depending on your device)
・Programmer ー USBTinyISP

(2) Sample Programming

First of all, I decided to try the sample program for Arduino.
I read the [Button] programming from [File] - [Example] - [02. Digital].


I needed to match the Arduino settings with the USB-connected boards from the “Tool”.

I changed the sample program pinboard to the pin number I was using and installed it.

I was able to successfully make the write board switch function.

(3) FTDI Cable Does not Recognize

I tried other programming, but the “Port ー cu.usbserial-FTAS0HLH” shown earlier disappeared.
I installed a driver to detect the FTDI cable in Mac OS from this site, but it didn’t work.

So I decided to use “USB serial cable made by QinHeng Electronics” instead of FTDI cable.
“QinHeng Electronics USB serial cable” is a product that plays the same role as an FTDI (USB-Serial conversion) cable.

Check the pins on the USB serial side and the pins on the board side and connect them.
Connect TX on the USB serial side to RX on the board side and RX on the USB serial side to the TX pin on the board side.

I checked the “Port” after connecting the board and the PC as shown in the image.
Then, I firmly recognized “/dev/cu.usbserial-14340” and was able to write the program normally.

(4) Creating another program

I created a program separate from the programming I just wrote.
This is a program that repeats the lighting of the LED three times every second when the button is pressed.

/*
  Button

  Turns on and off a light emitting diode(LED) connected to digital pin 13,
  when pressing a pushbutton attached to pin 2.

  The circuit:
  - LED attached from pin 13 to ground
  - pushbutton attached to pin 2 from +5V
  - 10K resistor attached to pin 2 from ground

  - Note: on most Arduinos there is already an LED on the board
    attached to pin 13.

  created 2005
  by DojoDave <http://www.0j0.org>
  modified 30 Aug 2011
  by Tom Igoe

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/Button
*/

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 3;     // the number of the pushbutton pin
const int ledPin =  7;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == LOW) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
    delay(1000);
    digitalWrite(ledPin, LOW);
    delay(1000);
    digitalWrite(ledPin, HIGH);
    delay(1000);
    digitalWrite(ledPin, LOW);
    delay(1000);
    digitalWrite(ledPin, HIGH);
    delay(1000);

  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

A view of the program being written


6. Description of Important Weekly Learning Outcome

This time, I tried programming for the first time, but it was quite difficult.
I’m not good at programming, so it was especially difficult to understand what the characters mean and what they meant.
Microbits can be programmed in blocks, so I thought I could understand them intuitively.
It turns out that the problem with the FTDI cable does not resolve when the MacOS is Catalina and downloading the driver tool.
However, if I used a USB serial cable, it was recognized normally and I could write the program.
If you are having trouble with similar problems, we recommend you to use USB serial cable.


  • Button Programming [ino]
  • Button 3times Lighting Programming [ino]

8. Appendix