Arduino Intro
Arduino Intro
THINGS:
ARDUINO
AND C
PROGRAMMI
NG
ARDUINO ENVIRONMENT
THE ARDUINO BOARD, ITS SOFTWARE COMPONENT AND OTHER ADD-ON HARDWARE
ARDUINO DEVELOPMENT
BOARD
• Eight bit microcontroller – brain of the board
• USB Port – to communicate with the desktop/laptop
• USB controller chip – manages USB transferred data
• IO pins – board’s connection to the outside world
• Quartz oscillator – board’s time keeper
• Reset button – taking the board back to its initial state
• External power jack – power from dedicated source
Co-axial jack, but USB can also be used
INPUT/OUTPUT PINS (I/O
PINS)
Top and bottom rows of the board
Holes in the board which we can stick wires in
Holes are connected to the chips through traces on-board
14 Digital I/O pins on top [0-13]
Highs – 5 volts Lows – 0 volts Max Current -
40 mA
6 Analog input pins on the bottom [A0 – A5]
Power output pins on the bottom [ 5v , 3.3 v ]
Reset pin to reset the board to initial state
MICROCONTROLL
ERS
Two microcontrollers on the board
Main ATmega328 – 8 bit microcontroller
User programmable, runs user-written application code
Carries firmware, like bootloader
ATmega16U2
Handles the communication with the USB interface, not
directly accessible
STORAGE &
MEMORY
Non-volatile flash memory for storage
32 kilobytes in size
Static Random Access Memory (SRAM) for memory (volatile)
3 kilobytes in size
CLOC
K 16 MHz clock speed ~ 16 million operations per second
Helps synchronize all components together
Keeping track of occurrence of events
PROGRAMMING
FIRMWARE
The ISCP headers can be used to program the firmware on
the board
ICSP1 for the main ATmega328 microcontroller
ICSP2 for the ATmega16U2 microcontroller
Special equipment are required in order to re-program the
firmware through these headers
SOFTWARE
ENVIRONMENT
ARDUINO TOOLCHAIN
Steps taken post code authoring
Source code(sketch) is compiled to an executable format
Executable file is linked with libraries and interpreted into a
hex file
Hex file is uploaded to board
Starts executing right away
CROSS
COMPILATION
Compile on one machine, but the target is another machine.
E.g.: compiling it on an Intel processor, compiling it for an AVR processor
avr-gcc – C compiler for AVR targets, gives a *.o file
avr-lnk – links library object files, results in a *.elf file
avr-objcopy – change the *.elf file into Arduino compatible *.hex file
DEBUGGING AND
TROUBLESHOOTING
REMOVING ERRORS AND TAKING CARE OF REPAIR AND MAINTENANCE
DEBUGGI
NG
• Finding reasons of erroneous execution or failure of execution
• Software problems
• Require ‘controllability’ and ‘observability’
• Controllability: the ability to control sources of data that are used by the system
Allows to do testing to test certain circumstances that might be causing a bug or triggering a bug at
any rate
• Observability: the ability to observe intermediate and final results
An oscilloscope, multi-meter, or the serial monitor could be used
REAL TIME
MONITORING