buyer beware
play

Buyer Beware $0.95 Is it worth it? Qualifications Did you ever - PowerPoint PPT Presentation

T HE A RDUINO M ICROCONTROLLERS Presented by: Forest Shick, WA2MZG Buyer Beware $0.95 Is it worth it? Qualifications Did you ever wonder Why is this person presenting? I do!! Single Board Computers Asus.com/us/single-board-


  1. T HE A RDUINO M ICROCONTROLLERS Presented by: Forest Shick, WA2MZG

  2. Buyer Beware $0.95 Is it worth it?

  3. Qualifications Did you ever wonder Why is this person presenting? I do!!

  4. Single Board Computers Asus.com/us/single-board- Beagleboard.org Raspberrypi.org computer/tinker-board

  5. Other Microcomputer Modules Pjrc.com/teensy/ 3.2 – 72MHz Cortex M4 3.6 – 180MHz Cortex-M4F 4.0 – 600 MHz ARM Cortex M7 NANO – 16MHz 8 bit Teensy 3.2 Teensy 4.0 Arduino NANO Teensy 3.6

  6. What is an Arduino?

  7. Other Arduino Modules

  8. Arduino Shields

  9. What is an Arduino good for? • Weather station • Station control / accessories • Keyer • Rotor controller • Home automation • Station 24 Hr Clock • Use your imagination • Robot • Steppingstone to the • Light Controller Raspberry Pi and other more • Simple Security System powerful devices • Having fun • Homebrew test equipment • Saying – “ I DID THAT ”!! • Game design – remember Simon?

  10. Prototyping

  11. Projects – Direct Conversion Receiver NANO controls the LCD and the DDS chip – the VFO in this direct conversion receiver

  12. Projects First steps in an SSB transceiver. This uses an UNO.

  13. Projects – Morse Code Tool The Arduino MEGA was used because the SD card required a lot of memory space – program and RAM Details are in a previous issue of the RAG

  14. Let’s Get Started • To be fair – there is more relevant material than we can cover in 1 hour • We will start with an overview of the NANO • We will investigate the more common / easy to use features first • Initialization • Digital IO • Analog Conversion • As time permits, we will do a 10,000 ft view of as many features as possible

  15. Comparison UNO NANO MEGA Microcontroller ATmega328P ATmega328 ATmega2560 Digital IO 14 22 54 Analog IO 6 8 16 PWM 6 6 15 UART 1 1 4 Flash 32K 32K 256K RAM 2K 2K 8K EEPROM 1K 1K 4K Clock 16MHz 16MHz 16MHZ LED_BUILTIN 13 13 13 Pins 28 32 100

  16. Microcontroller Block Diagram ATmega328 ATmega2560

  17. ATmega328 Data Sheet BUT Arduino has done a great job of getting you started There are 294 pages in without having to depend this data “book” on this book. At some level of The Arduino web site has project complexity much to offer if you have many of these pages the time to look through it. will be important to your project TAKE THE TIME NOTE: I have not found a hardware description – it could be there somewhere!

  18. AVR CPU Core and Sample of Instruction Set

  19. NANO / ATmega328 Features • 32K bytes of Flash memory • 8 channel, 10 bit A/D • Internal temperature measurement • 1K bytes of EEPROM • USART (UART) • 2K bytes of RAM • SPI • Two 8 bit Timer / Counter • I2C / IIC / TWI • Prescaler • Output Compare • Watchdog timer and oscillator • One 16 bit Timer / Counter • Analog Comparator • Prescaler • Interrupt • Input Capture • Pin Change Interrupts • Output Compare • 23 Programmable IO lines • Real time counter and oscillator • Six Pulse Width Modulator channels

  20. Shared Pin Functionality As you can see there are only 32 pins, 7 of which are power and ground. Leaving only 25 for all the SHARED hardware functions See the multiple functions for each pin.

  21. Arduino UNO Schematic

  22. Arduino MEGA Schematic

  23. NANO Schematic

  24. NANO Pin Out Notice the multiple functions assigned to each pin POWER - red GND - black Discussed on the next slide Be aware of the multiple numbering systems. The VIOLET numbers are the names of the digital IO. The GREEN letter number combination are the analog inputs. The GRAY numbers are the pin number of the microcontroller.

  25. Powering the NANO For development, when you connect the NANO to • the USB port on your computer, the board is powered from the USB port – shown by the blue circles External power may be applied to the Vin pin, red • circle. It is then regulated to 5V to power the board and accessories 5 volt power, violet circle , may also be applied to • the 5V pin to power the board and accessories The 3.3V pin, light blue is NOT power input. It is • power output not to exceed 50ma.

  26. NANO Pin Functions

  27. Arduino NANO Conclusion

  28. Initial Conditions Most pins are tri-state during reset • Many registers provide the initial • condition of the pins Properly terminate unused pins • DDR – 0 = Input and 1 = Output • WHY? •

  29. Digital IO – Chapter 13 Each of the 14 digital pins on the Nano can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In addition, some pins have specialized functions Circles • RED – pull up resistor • BLUE – output • GREEN - input • Squares • RED – Pull up disable signal • BLUE – reads the state of the • port output GREEN – reads the state of • the port input NOTE – the port output and • port input may not be the same

  30. Digital IO pinMode(8, OUTPUT); // Make D8 an output pinMode(pin, mode) • pin 0 – 22 (D0 - D22) • In C mode: INPUT, OUTPUT, INPUT_PULLUP • DDRB = (1<< DDB0); // Set DDRB0 to 1 (output) digitalRead(pin) • Returns the state of the pin digitalWrite(8, 1); // set D8 to 1 • digitalWrite(pin, value) • Value – write a 0 or 1 to the pin In C • PORTB = (1 << PB0); // set PORTB0 to 1 Registers DDxn – Data Direction, Port x, Bit n • PORTxn – Data output port • PINxn – Data input port •

  31. Digital IO Examples Turn a LED on and off Read a push button switch Drive and read a 4 x 4 keypad pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, INPUT_PULLUP); pinMode(9, INPUT_PULLUP); pinMode(10, INPUT_PULLUP); pinMode(11, INPUT_PULLUP); PORTD = 0xf0; val = PINB & 0x0f; pinMode(8, OUTPUT); pinMode(5, INPUT_PULLUP); digitalWrite(8, 1); sw = digitalRead(5);

  32. A/D Converter Inputs – Chap 23 The Nano has 8 analog inputs, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though it is possible to change the upper end of their range using the analogReference() function. Analog pins 6 and 7 cannot be used as digital pins. Additionally, some pins have specialized, alternate functionality: I2C: A4 (SDA) and A5 (SCL). Support I2C (TWI) communication Analog Input Resistance: 100M ohms Reference Input Resistance: 23k ohms

  33. A/D Converter analogReference(type) • DEFAULT – 5V power • INTERNAL – 1.1V • EXTERNAL – voltage on the AREF pin • analogRead(pin) • A0 – A7 (ADC0 – ADC7) • analogReference(DEFAULT); // optional . . int value; . . // Measure the voltage on ADC1 value = analogRead(A1);

  34. A/D Converter Reading a potentiometer Reading a temperature sensor int val; analogReference(EXTERNAL); int val; val = analogRead(A0); val = analogRead(A6);

  35. Alternate Port Functions Clock oscillator • Timer Oscillator • Pin change interrupt • SPI • Output Compare • Input capture • Reset • A/D Converter • IIC / I2C / TWI • Analog Comparator • USART • External clock • External Interrupt •

  36. Analog Comparator – Chap 22 The Analog Comparator compares the input values on the positive pin AIN0 and negative pin AIN1. When the voltage on the positive pin AIN0 is higher than the voltage on the negative pin AIN1, the Analog Comparator output, ACO, is set. The comparator’s output can be set to trigger the Timer/Counter1 Input Capture function. In addition, the comparator can trigger a separate interrupt, exclusive to the Analog Uses Comparator. The user can select Period / frequency measurement • Interrupt triggering on comparator Voltage threshold • output rise, fall or toggle. Phase measurement •

  37. Communications USART – Chap 19 SPI – Serial Peripheral Interface – Chap 18 Full duplex Full duplex • • Baud rate generator Master or slave • • 5 – 9 data bit and 1 or 2 stop bits 7 programmable bit rates • • More MISO – D12 – Master in / Slave out • • MOSI – D11 – Master Out / Slave in • The NANO and UNO only have 1 SCK – D13 – Serial Clock • • It is assigned to the USB comms SS – D10 – Slave Select • • D0 – RX Use the SPI library • • D1 - TX • TWI – 2 wire Serial Interface – Chap 21 Also known as IIC & I2C • SCL – A5 • SDA – A4 • Use the Wire library •

  38. 8 Bit Timer / Counter – Chap 14 & 17 • There are 2, 8 bit timer / counters • Output Compare • PWM • Frequency Generation OUTPUT COMPARE A value can be set in the OC register • When the counter reaches that value • a port pin will change state PULSE WIDTH MODULATOR Creates a repetitive waveform with a • duty cycle set by an 8 bit word

  39. 16 Bit Timer / Counter – Chap 15 One 16 bit timer counters • Output Compare • Input Capture • PWM • Frequency generation • Event counting •

Recommend


More recommend