Embedded programming 2.0

individual asiignment

Read a microcontroller datasheet and program your board to do something

group assignment

compare the performances and developemnet of diferent workflows

you can go here to see what i did on this week group assignment

Disclaimer

i've pushed a test on the final board programmed

Test on the morse code

Disclaimer

Fabacademy 2020 and 2021 efforts

also all of the links can be found under "links and references"

this assignment has various steps

Disclaimer

I use a Windows 10 based system the (flashing commands and general workflow of installation may vary for another OS)

for more info about the instalation of edbg and openOCD for to

  1. Read a datasheet of an MCU
  2. i choose to do my very own version of the samdino made by adrian torres from fablab leon.

    altough he made a terrifyc job i´d like to make use of the THT components i have at my disposal at fablab queretaro.

    i talk more about this design on electronics design week tough.

    So i'm up with the task to design and fabricate another homade "arduino" bootleg

    i choose adrian's samdino version because of his documentation it's very clear and straight fordward.

    so the first on the list was to download the datasheet and try to understand it.

    HERE you can download the same datasheet

    the first thing i noticed is that has 14 pins

    then it has 16KB of flash memory

    and unlike the atmega328p i used before this MCU runs on 3.3v.

    mcu pinout from the datasheet

    mcu pinout from adrian's samdino page

    it has spi,I2C USART comunications protocols compatibility built in

  3. Design a board.
  4. HERE you can check the assignment on electronics design i did

    also HERE you can download the EAGlE files on this board

    also HERE you can download the EAGlE files on this board

  5. Flash the board
  6. take out the board from the cnc

    weed it,clean it and probe it with the multimeter

    Stuff it and probe it once again with the multimeter

    I choose to use an adapter in order to flash the memory out of the samd11c, because i have to do this step once and then the traces on the board become useless.

    this is the adapter i used to flashe the board

    HERE you can check the specs

    HERE you can download the eagle footprint to use it on your own designs

    this is how i conected the swd programmer

    this is my setup

    on a fresh windows CMD terminal navigate to the file were the edbg and openocd is stored check electronics production to see how to

    download the binary for a generic SAMD11C chip from HERE and place it on the same directory as the edbg,openocd and free-dap binary file

    and then type edbg-windows-r24.exe -ebpv -t samd11 -f sam_ba_SAMD11C14A.bin

    on Windows 10 when you first conect the board pops up a meesage like this installing the proper driver for the device

  7. Install the samd11c board on arduino IDE
  8. https://www.mattairtech.com/software/arduino/package_MattairTech_index.json

    you need to copy this URL and paste it on the arduino IDE

    You can do it under file/preferences

    Only then you'll be able to install the MattairTech core boards

    you can do it under tools/board/board manager

  9. Upload a sketch
  10. open the blink example and use it to turn on/off the led on digital pin 2

    HERE you can download my sketch

    Select you com port before you upload the sketch

    on the lower half of the IDE GUI you should get a message like this one

    Also i did a button testing on this week

    this is the code i use

    HEREas always you can get the file .ino from here or in the "links and reference" section

    this is a simple counter and push button and a LED just to test the board

    an this is the video

    Morse code test

    as my global instructor said the blinking of a led is too simple you need to code a little more complex

    so i decided to do a morse code translator because i think it's simple enough to be using the power supply on the usb of a laptop and not burning it.

    The principle of the morse code is really simple each letter of the alphabet get translated into discrete pulses of light or sound divided by silences or time lapses where not light or sound is emited by the source.

    below it's a scheme of this letters translated into dots and dashes separated by blank spaces of silence.


    this picture i took it from a tutorial HERE

    so i went into the internet for some ideas and found this excelent tutorial on how to use an MCU as a morse code translator using the serial monitor terminal

    the article does not authors a person but an "editorial team"

    device plus

    so this is an excelent resource to find diferent code examples and well explained.

    for a noob like myself.

    i'll try my best to explain how it works on the comments of the .txt and .ino files

    so this is a sketch to translate serial monitor into morse code using a buzzer


    setup

    just 3 wires 5v, gnd and signal comming from pin 2 on my board


    code

    for this code i use one pin as output(specifically pin 2 on my board).

    i use a variable to set the default tone of the buzzer (1000)

    a default time unit that will be used to muliply or divide wether if it is a dot (2 times the time unit),dash (4 times the time unit) letter pause (3 times the time unit) or a word pause (7 times the time unit)

    because i'm only using nested IF statements and functions. i do not need to call for any library

    if (input == 'a' || input == 'A') if the variable holds the char "a" or "A" then calls the function 1A()

    and so on

    then the function 1A() it's called later outside the void loop

    within void 1A() and it calls specific function in a specific order to make the letter

    for the example of the caracter A or a

    it is dot followed by a dash and then a letter pause

    so the dot function is

    arduino function called tone whch need to be specified the pin of the output,the note will be emiting and the time will be emiting it

    tone(buzzer,note,timeUnit);

    then after the tone the delay of the time unit that represent the letter pause

    then the dash function gets called and do it's job and then the letter pause function gets called and do it's job.

    this is just for the letter A

    also all of the lines are commented on the text file below.

    everything that follows after // is a comment and is just for debugging purpouses

    this is the code on this test

    *ino File


    Back to index

    Conclusions

    comparing this board with the old attiny gen 44/84/45/85 and so. This workflow is a lot more simpler and straight fordward.

    i would never have done it with out adrian's documentation.

    Links and references

    Adrian's Samdino page

    samd11c14a datasheet

    luisino eagle files

    luisino SRM-20 files

    samd11c bootloader

    blink file for the luisino

    Button INO file