THE ARDUINO MICROCONTROLLERS
Presented by: Forest Shick, WA2MZG
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-
Presented by: Forest Shick, WA2MZG
Buyer Beware
$0.95 Is it worth it?
Did you ever wonder Why is this person presenting? I do!!
Single Board Computers
Beagleboard.org Raspberrypi.org Asus.com/us/single-board- computer/tinker-board
Other Microcomputer Modules
Teensy 3.2 Teensy 3.6 Teensy 4.0 Pjrc.com/teensy/ 3.2 – 72MHz Cortex M4 3.6 – 180MHz Cortex-M4F 4.0 – 600 MHz ARM Cortex M7 NANO – 16MHz 8 bit Arduino NANO
Other Arduino Modules
Arduino Shields
Simon?
Raspberry Pi and other more powerful devices
Prototyping
Projects – Direct Conversion Receiver
NANO controls the LCD and the DDS chip – the VFO in this direct conversion receiver
Projects
First steps in an SSB transceiver. This uses an UNO.
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
Let’s Get Started
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
ATmega328 ATmega2560
There are 294 pages in this data “book” At some level of project complexity many of these pages will be important to your project BUT Arduino has done a great job of getting you started without having to depend
The Arduino web site has much to offer if you have the time to look through it. TAKE THE TIME NOTE: I have not found a hardware description – it could be there somewhere!
NANO / ATmega328 Features
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.
Arduino UNO Schematic
Arduino MEGA Schematic
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
Powering the NANO
the USB port on your computer, the board is powered from the USB port – shown by the blue circles
board and accessories
the 5V pin to power the board and accessories
power output not to exceed 50ma.
NANO Pin Functions
Arduino NANO Conclusion
Initial Conditions
condition of the pins
Digital IO – Chapter 13
port output
the port input
port input may not be the same 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
Digital IO
Registers
pinMode(8, OUTPUT); // Make D8 an output In C DDRB = (1<< DDB0); // Set DDRB0 to 1 (output) digitalWrite(8, 1); // set D8 to 1 In C PORTB = (1 << PB0); // set PORTB0 to 1
Digital IO Examples
Turn a LED on and off Read a push button switch Drive and read a 4 x 4 keypad pinMode(8, OUTPUT); digitalWrite(8, 1); pinMode(5, INPUT_PULLUP); sw = digitalRead(5);
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;
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
alternate functionality: I2C: A4 (SDA) and A5 (SCL). Support I2C (TWI) communication Analog Input Resistance: 100M ohms Reference Input Resistance: 23k ohms
A/D Converter
analogReference(DEFAULT); // optional . . int value; . . // Measure the voltage on ADC1 value = analogRead(A1);
A/D Converter
Reading a potentiometer Reading a temperature sensor int val; val = analogRead(A0); int val; analogReference(EXTERNAL); val = analogRead(A6);
Alternate Port Functions
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
Interrupt triggering on comparator
Uses
Communications
USART – Chap 19
SPI – Serial Peripheral Interface – Chap 18
TWI – 2 wire Serial Interface – Chap 21
8 Bit Timer / Counter – Chap 14 & 17
OUTPUT COMPARE
a port pin will change state PULSE WIDTH MODULATOR
duty cycle set by an 8 bit word
16 Bit Timer / Counter – Chap 15
Interrupts – Chap 11
There are 26 sources of interrupts What is an interrupt?
program.
process that requires attention
completed and control jumps to a special interrupt routine
instruction, in the main program, is executed
RESET
External Interrupts – Chap 12
microcontroller
addressed using the IDE functions
NOT handle : PCINT0 to PCINT23 (No PCINT15)
Internal Interrupts
The internal interrupts are triggered by actions of the internal peripherals – although external stimulus may be involved – receiving data on the TWI – the interrupt occurs because 8 data bits were transferred on the TWI lines There are 20 internal interrupts Beyond the scope of our discussion today They are extremely useful but require studying the appropriate sections of the manual.
Timer / Counter and Pin Change Interrupt Example
down and up – triggering a timer for dot and dash length
rotation of the rotary encoder and direction
pushbutton action
detect and decode incoming Morse code
the LCD
Card
Resources