# 6. Electronics design ## nueval - Startd - April 13: break, midterm - first half in nueval - final project plan reviewed and site started ## daylight savings time Global - March 13 US daylight savings time - Mar 09 computer-controlled machining - 23:00JST - Mar 14 recitation: programming - 22:00JST Asian Review - 21:00JST (no change) ## Preparation for next week > **Computer-Controlled Machining** > *group assignment* > do your lab's safety training > test runout, alignment, speeds, feeds, materials, and toolpaths for your machine > > *individual assignment* > make (design+mill+assemble) something big (~meter-scale) > extra credit: don't use fasteners or glue > extra credit: include curved surfaces ### Hamamatsu {width=400} - message me when on board - Rendezvous point: Tokaido line platform - Ms.Takemura will wait us at Takatsuka Sta. of North entrance ### Preparation - Read [Assessment](https://fabacademy.org/2022/nueval/computer-controlled_machining.html) > **How big is big?** >Answer: Life size, big enough to show you understand many of the possibilities of CNC machining - drill, pocket, dogbones, nesting, etc. > Neil: "at least one dimension should be larger than 1m"!? - material - 910x1820mm x2 (Group x1, Individual x1) - [shop stock 2017](https://docs.google.com/document/d/1JuWOrUpjlp4soWDLRY14wLR42nnkVJtF4mHKIAQKY-E/edit) - Read Tips - [dog bone in Fusion360](./tips/dogbone.md) - [How to use Hamamatsu CNC](http://academany.fabcloud.io/fabacademy/2021/labs/kannai/site/instruction/tips/cut2d_mach3/) - Finish Parametric Design in Fusion360 - Material Thicness - is not exact number in written - may sold out - may change your mind in store - Dogbone - Online Local session - Thursday or Friday - You should have - Gloves (you and some from lab and 5F) - Eye protection (from Lab) - Caliper (from my home) - Sander (from 5F) - for packaging to home - Lunch ## Mystery of Bootloader Arduino [Bootloader](https://docs.arduino.cc/hacking/software/Bootloader) > **What's a Bootloader?** > > Microcontrollers are usually programmed through a programmer unless you have a piece of firmware in your microcontroller that allows installing new firmware without the need of an external programmer. > This is called a bootloader. From Instructor and Staff group >both SAMD and AVR can work without bootloader. For SAMDs, the role of the bootloader is to accept firmware uploads through serial over USB, without any additional hardware. Hence you only need a programmer connected to it the first time you flash the bootloader. But if you wish, you can also keep using the programmer and edbg every time you upload, it's simply a lot less convenient. Arduino stores its binary in a hidden folder before uploading, so you could simply find it and upload it with edbg instead. > For the AVR, uploading through UPDI requires some USB-serial programmer connected to it, because the AVR itself doesn't support USB. Optiboot is an optional bootloader that can take uploads through a regular serial port of the AVR instead of the UPDI port. But you will still need a USB-serial adapter next to your AVR. This is similar to how Arduinos (ATmega type) work too, they have a serial USB adapter onto the board, connected to one of the serial ports of the ATmega, and take firmware uploads through there. Family</br>MCU |Interface |upload program</br>without bootloader|upload program</br>after burned bootloader -- |--- |---|-- Original AVR</br>ATmega328P|ISP |Via programmer</br>(fab ISP)|serial over USB </br> with external Serial-USB board AVR-1</br>3216 |UPDI |Via programmer</br>(USB-Serial board & Serial-UPDI board)|serial over USB </br> with external Serial-USB board ARM</br>SAMD11C |SWD/JTAG |Via programmer</br>(freeDAP board)|serial over USB </br> with **internal** Serial-USB function ---- ## Group Assignment > use the test equipment in your lab to observe the operation > of a microcontroller circuit board [Assesment](https://fabacademy.org/2022/nueval/electronics_design.html) ### test equipment #### Oscilloscope - TektronixTBS1052B - [user manual](https://www.allaboutcircuits.com/test-measurement/oscilloscopes/tbs1000b-series-tbs1052b/manual/) - [user manual_JP](https://download.tek.com/manual/TBS1000B-and-TBS1000B-EDU-Oscilloscope-User-Manual-JA-JA.pdf) - [Tips](http://yuichitamiya.fabcloud.io/fabacademy2020/projects/Oscilloscope/) {width=400} !!! note **Screenshot(Setup the button)** Insert USB memory Utility > Options > Printer Setup Ink Saver On > Off Save/Recall(on Front panel button) Action > Save Image > Select Save option !!! note **Screenshot** Save/Recall (on Front panel button) > Action Save All > Print button > Saves Image to File - Mini DSO DS213 - [user manual_JP](./images/week06/rest_equipment/DS213_manual) {width=300} #### Multimeter - [TDX-200](http://www.ohm-direct.com/shopdetail/002012000014/) - no beep - [PM3](https://www.sanwa-meter.co.jp/japan/products/digital_multimeters/pm3.html) - 電流測定不可 ### ToDo {width=300} {width=300} - [Kannai Inventry](https://docs.google.com/spreadsheets/d/16No34EYWp9jkpQH5ESc-zzDbUVTjdCI8g1H436G6a8c/edit#gid=426488364) #### Multimeter - Measure Voltage between IC2 IN and GND - USB 5V - Measure Voltage between IC2 OUT and GND - IC2: 3.3 Regulator - [IC REG LINEAR 3.3V 100MA SOT23-3](https://www.digikey.jp/ja/products/detail/LM3480IM3-3.3%2fNOPB/LM3480IM3-3.3%2fNOPBCT-ND/270750?itemSeq=279756902) - [SAMD11C](https://www.digikey.jp/ja/products/detail/microchip-technology/ATSAMD11C14A-SSUT/5226488) - Check Connection - soldered (Connected) - short (should not be connected, but connected) #### Oscilloscope - Read [Oscilloscope](http://yuichitamiya.fabcloud.io/fabacademy2020/projects/Oscilloscope/) - upload echo program to 3216 breakout board - Probe TX, RX line (and GND) - TX(Transmitter): USB-Serial-D11C(3.3V) -> t3216(5V) - RX(Receiver): t3126(5V) ->(R3_4.99k)-> USB-Serial-D11C(3.3V) - Open Serial Monitor in Arduino IDE and send Character (1-9. A-Z, a-z… ) - Data bits Will be send from LSB (least significant bit) - [ASCII](http://www12.plala.or.jp/mz80k2/electronics/ascii/ascii.html) - Probe RX line - between **before** 4.99k register (t3216 side) and GND - between **after** 4.99k register (D11C side) and GND - Probe RX_t3216_side line and RX_D11C_side line - may see voltage drop 1.7V(= 5-3.3V) !!! note Ref. [Quentin_2020](https://fabacademy.org/2020/labs/ulb/students/quentin-bolsee/projects/samd11c_uart-updi/) The UART connector is directly wired to the RX and TX of the serial 0 on the D11C. On the RX pin, the 1.2 kΩ resistor offers some protection in case the other device is talking in 5V serial. The internal protection of the D11C saturates inputs to VDD+0.6V, but can only accept a small injection current. According to the datasheet, we should be safe in this case. Let’s compute the current when RX is at 5V: {width=300} which is below the reported limit. When enabling the UPDI mode with the jumper, the RX and TX pins are simple shorted together, along with a 4.7 kΩresistor. This resistor limits the current to the TX pin, which is low impedance as it is configured as an output on the D11C. The value of this resistor is not critical, you can also use 5 kΩ. !!! note **Level Shift 5V to 3.3V** {width=300} {width=300} Ref. [How to Level Shift 5V to 3.3V](https://randomnerdtutorials.com/how-to-level-shift-5v-to-3-3v/) Echo.ino ``` void setup() { Serial.begin(115200); } void loop() { if(Serial.available() > 0){ Serial.write(Serial.read()); } } ``` Ref. [Arduino – A Simple Serial Echo](https://open4tech.com/arduino-simple-serial-echo/) Result of last year {width=400} ## Individual Assignment > redraw an echo hello-world board, > add (at least) a button and LED (with current-limiting resistor) > check the design rules, make it, and test that it can communicate > extra credit: simulate its operation ### components Button / Tactile switch [{width=300}](https://fujiwaram.hateblo.jp/entry/2019/05/28/220841) > ちなみに、タクトスイッチには4つ足がついていますが、足が向かい合っているところは元からつながっています。 >こんな単純な仕組みなのに、たまに「どっちだっけ?」って思ってしまうのが人間というものです。 >なので私は、確実に導電していない斜め向かいに線を繋げるようにしています。頭いいな〜。 - normally open - open may mean parts missing - normally close LED - polarized - anode(+) - cathode(-): cathode line - cathode(en) - Kathode(de) - [datasheet](https://www.digikey.jp/ja/products/detail/LTST-C150GKT/160-1169-1-ND/269241?itemSeq=279757180) - Voltage - Forward (Typ) VF = 2.1V - Current - Test = 10mA !!! Attention **Ohm's law** V=IR R=V/I Resistor - [size](https://eepower.com/resistor-guide/resistor-standards-and-codes/resistor-sizes-and-packages/#) - 1206 - 0.12" x 0.06" - 3216(Metric) - 3.2mm x 1.6mm - value - 4991 = 499 x 10^1 = 4990 = 5k[ohm] - 4990 = 499 x 10^0 = 499 = 500[ohm] - color code - APP - current-limiting resistor - Ref. [LED Basic_JP](https://www.marutsu.co.jp/pc/static/large_order/led) - R = (E -VF)/IF = ( 5[V]-2.1[V] )/10m[A] = 2.9[V]/10m[A] = 290[Ohm] - E: electromotive force - Pull up / Pull down resistor - Ref. [here_JP](https://voltechno.com/blog/pullup-pulldown/) ``` pinMode(2, INPUT); pinMode(3, INPUT_PULLUP); ``` IC - AVR-1 - 412 - 4: 4KB Flash memory - 1: AVR-1 - 2: 8 pins - 1614 - 4: 14 pins - 3216 - 6: 20 pins - Ref. [3216 datasheet](https://www.mouser.com/datasheet/2/268/ATtiny3216_ATtiny1616_data_sheet_40001997-1374799.pdf) Figure 1-1. - pinout - [AVR-1](http://yuichitamiya.fabcloud.io/fabacademy2020/projects/updi_programme/) ### Todo #### Eagle - download [site](https://www.autodesk.com/products/eagle/free-download) - Library - [eagle/fab.lbr](https://gitlab.cba.mit.edu/pub/libraries/-/tree/master/) - [new parts](http://academany.fabcloud.io/fabacademy/2021/labs/kannai/site/instruction/tips_list/) - tips - [Eagle hole making](http://yuichitamiya.fabcloud.io/fabacademy2020/projects/eagle_holes/) - [Eagle_holes_making_shortcut](http://academany.fabcloud.io/fabacademy/2021/labs/kannai/site/instruction/tips/Eagle_Holes_making_shortcut/) - Design roule - Eagle: DRC - 16mil = 16 milli-inch = 0.4064 mm #### Test - echo - class page - Flash sound - [Flash sound](http://academany.fabcloud.io/fabacademy/2021/labs/kannai/site/instruction/tips/flash_sound/) - buzzer - [ATtiny1614 hello buzzer board](http://tatsuro.homma.fabcloud.io/fabacademy/tips/electronics_design/ATtiny1614_hello_buzzer/) - Step Response / CapacitiveSensor - [Step Response / CapacitiveSensor](http://academany.fabcloud.io/fabacademy/2021/labs/kannai/site/instruction/tips/step_response/)