8. Embedded programming¶
General Info¶
Nueval¶
- https://nueval.fabacademy.org/#/login
- Login with fablabs.io
- Student’s checklist
- check all(weekly) -> local evaluation
- 2-3 weekly completed local eval -> global eval(later)
Machine building¶
- class: Mar 24: mechanical design, machine design
- local session Sat Mar 27
- break: Mar 31
- local session Sat Apr 03
- review (few minuets presentation): Apr 07
What to make¶
- Group assignment -> one machine/team (per lab, between labs, collaborate with someone)
-
two weeks project
-
Mechanical Design
- design a machine that includes mechanism+actuation+automation
- build the mechanical parts and operate it manually
- document the group project and your individual contribution
-
Machine Design
- actuate and automate your machine
- document the group project and your individual contribution
-
documentation
- the group project -> lab site (Machine building)
- video (1 min)
- slide
- your individual contribution -> your site (weekly page)
- the group project -> lab site (Machine building)
-
board and software…
- existing commercial boards
- existing software
-
parts
- find and buy (amazon, monotaro, misumi)
- 3D print
- laser
Assignment¶
Individual assignment:¶
Note
read a microcontroller data sheet
program your board to do something,
with as many different programming languages
and programming environments as possible
Group assignment:¶
Note
compare the performance and development workflows for other architectures
TODO: Individual assignment¶
read a microcontroller data sheet
- Datasheet(Digikey)
-
AVR 1-series
- 412
- 4KB-flash
- 1-series
- 2(8pins)
- pin-count: 2(8pins), 4(14pins), 6(20pins), 7(24pins)
- 412
- package
- 8-SOIC
- Small Outline Integrated Circuit
- pin pitch 1.27 mm (50 mil)
- 16-SSOP(FT230XS)
- Shrink SOP
- 0.025 in= 25 mil = 0.635 mm
- 8-SOIC
-
pinout
- ATtiny1614
- 4.Pinout (page14)
- ref. here
- ATtiny1614
-
Pin name
- 5.1 Multiplexed Signals(page18)
- Pin names are of type Pxn, with x being the PORT instance (A, B) and n the pin number. The notation for signals is PORTx_PINn. All pins can be used as event input.
- PA0
- PORT A
- pin number 0
- 5.1 Multiplexed Signals(page18)
-
Data Direction Register
- 16.5.1 Data Direction
- DDRA
- PORT A
- 0: input
- 1: output
- DDRA
- 16.5.1 Data Direction
-
Port
-
Registor
- 1 byte = 8 bits = [7:0]
- binary
- 2進数(0,1)
- 0b00001111
- B00001111
- hexadecimal
- 16進数(0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)
- 0xFF
- $FF
- decimal
- 10進数(0,1,2,3,4,5,6,7,8,9)
- 0d255
- 255
- ref. 2進数、8進数、10進数、16進数相互変換ツール
1 2 3 4 5 6 7 8 9 |
|
AVR
1 2 3 4 5 6 7 8 9 |
|
AVR 1-series
1 2 3 4 5 6 7 8 9 |
|
ref. Arduinoで入出力を高速化する方法
Hint
// コメント
a = 0; //初期値 代入
b = a + 1; //代入
a = a + 1; //加算代入
a += a; //加算代入
DDRB = 0b000000; //初期値
DDRB = DDRB | 0b00000001; //OR
DDRB |= 0b00000001; //OR
OR
1 2 3 4 |
|
NOT
1 2 3 |
|
AND
1 2 3 4 |
|
ref. Arduino Language Reference
Bitwise Operators (bit演算子)
機能 | 演算子 | 使用例 |
---|---|---|
OR | | |
指定bitのセット |
AND | & | 指定bitの取り出し, NOTと併用した指定bitのクリア |
XOR | ^ | bit反転 |
NOT | ~ | bit反転, bitクリア |
ビットシフト(右) | >> | ビットシフト |
ビットシフト(左) | << | ビットシフト |
program your board to do something,
with as many different programming languages and programming environments as possible
Software design¶
Arduino¶
- echo.ino
- class page
- blink.ino
- class page
- ArduinoIDE File -> example
- button
- ArduinoIDE File -> example
C language¶
- echo.c
- class page
- blink.c
- class page
- Write C language program to AVR-1 serries
- Programming - C language(t1614.simpleblink.c), FA2020
programming environments¶
- Arduino IDE (megaTinycore2.2.9)
- pyupdi
TODO: Group assignment¶
compare the performance and development workflows for other architectures
Assessment¶
- Is it enough for the group assignment if we compare different microcontrollers in theory?
- Answer: No, You need to program at least two different family MCU’s.
- How do I prove I’ve read the Datasheet?
- Answer: Point out things in your code and board design that you learnt from the Datasheet. Also point to other weeks when you used information from the Datasheet.