Download presentation
Presentation is loading. Please wait.
1
Arduino and the Radio Amateur
Gary Sutcliffe, W9XT This presentation will cover a lot of topics quickly. There will be a lot of terms thrown out. For those who have a background in computers this talk will help identify what is unique about Arduino For those that this is all new: Don’t worry about the details. Just try to get a general flavor for what is being discussed A red ! In upper corner means this is an important concept Last Revision – May, 2012 Copyright © 2012 Gary C. Sutcliffe 1
2
What is Arduino? Microcontroller Development System Low cost - ~$30
Free development software USB connection to Arduino Runs under Windows, Mac, Linux Easily expand hardware with stackable “Shields” Huge user community Software Designs Tutorials Forums Arduino is taking the world by storm. There are probably 500,000 or more Arduino or Arduino compatible systems out there. Arduino makes it easier to develop microcontroller based projects. 2
3
What is a microcontroller?
Microprocessor Microcontroller Multipurpose PC MAC Memory is external Extra circuitry to outside world Usually has OS (Windows) Single purpose Microwave Oven TV remote Memory inside chip Peripherals to outside world built in Usually does not have OS A PC has a microcomputer chip, but it does not contain the memory, I/O, etc. These are all on the mother board or plug in boards. A microcontroller has these built in. Different microcontrollers offer different mixes of memory and peripherals. Some of the lines are blurred. The chip in a smart phone may use external memory and use an OS, but have built in peripherals. Program memory holds program if power lost. Sort of like the hard drive on a PC. Peripherals used to interact with outside world. Microcontrollers come in different sizes – 8, 16, or 32 bit, amount of memory, different peripherals, amount of I/O. Low end ones cost less than $1 in single quantity. A microcontroller is generally programmed to run just one application – Keyer, repeater controller, rotor control, etc. 3
4
Microcontroller Peripherals
Communications Serial (RS-232) SPI I2C USB Ethernet CAN Bus LIN Bus Timing Timers Counters PWM Analog A/D Converter Many classes of peripherals Not every microcontroller has all of these peripherals Don’t worry if you don’t know what all of these are. Digital I/O Ports LCD control 4
5
Arduino UNO Processor The IC is an Atmel AVR microcontroller with 32K memory. The silver box in the upper right is the USB connector for programming. The thin black connectors on the top and bottom of the picture allow stacking of daughter boards called shields to expand the hardware. There are a number of Arduino models and Arduino clones. The UNO is the current standard model. It costs about $9. 5
6
Expand I/O with “shields”
Stackable shields expand I/O lists nearly 300 available shields Motor control WiFi LCD Displays Ethernet Sensors Bluetooth Memory LED matrix Relay GPS Prototype/development Many, many more! The Unified Microsystems ATS-1 shield adds LCD, push buttons, programmable LED & buzzer. This boards only use two of the Arduino I/O lines leaving the rest available for your project. The daughter boards are called shields because they “shield” you from the hardware. A lot of projects need a user interface. There are a lot of designs on the web showing how to connect the Arduino to an LCD display with buttons, LEDs, etc. The problem is they used almost all of the I/O lines and left very few left for the application. To solve this problem, I designed the ATS-1to use the serial lines so it only uses two lines to add all these functions. This leaves the rest of the I/O lines for sensors, output control lines, etc. 6
7
Free Development Software
The development software is a free download. The system lets you write the software, compile it and down load to the Arduino board. Compile: Computers only understand very simple instructions: Add two numbers, compare two numbers, etc. Very tedious for humans High level languages have instructions like print a line of text, open a text file, etc. Compilers translate high level instructions to instructions computers can understand. A high level instruction can be just a few machine instructions or maybe thousands. Some similar systems use “interpreters” instead of compilers. These are much slower since the microcontroller has to decode each program instruction then execute them each time. 7
8
Arduino Programming Language
“Wiring Language” - C/C++ Based, simplified Fast - compiled, not interpreted Built in functions make it easy to use peripherals Digital Input/Output Analog/Digital Converters Serial Ports I2C & SPI interface Thousands of programs & examples on web Don’t worry if you don’t understand what all these mean. What is important is: Designed to be easy to learn and use A lot of the low level complex work is done for you Lot of programs, programming tutorials, & examples on the web The built in peripheral control functions really make it easy for beginners. It often takes “pros” hours to do things on other systems a beginner can do in minutes on an Arduino. 8
9
Computer Programs Made up of a series of instructions
Make a calculation Control the output pins Check state of input pins Configure & control the microcontroller peripherals Make decisions and control program direction Important thing is that a program is a set of instructions done in order. 9
10
! Lather Rinse Repeat Simple Computer Program Important concept slide!
Similar to computer program Set of simple instructions Computers programs are always a big loop. A computer is (almost) always executing instructions. Loop over and over- with computer you don’t run out of shampoo 10
11
! Variables Name X Switch_State Dave 3.1415 ON (1, HIGH)
RAM memory locations you can put information into and check later Dave 3.1415 ON (1, HIGH) Important concept slide! Think of a variable as a box to store things. We can put something in one and later come back and see what it is or replace its contents with something else. There are different types of variables to hold different types of data We can change the value of a variable any time we want. When the power is removed, all the boxes are emptied. Name X Switch_State You need to define what type of data goes into variables Contents of RAM are lost when power is lost! 11
12
! Digital Input/Output Signals ON OFF
Arduino has 14 digital lines that can be configured to be inputs or outputs. Digital signals can have only 2 states ON “1” True High 5V at I/O pin OFF “0” False Low 0V at I/O pin Important to understand this slide! Microcontrollers have pins dedicated for digital input and outputs. A pin can be set to be an input or an output – it can’t be both at the same time. An output pin will put either 5V or 0 V to the pin. It is used to control something outside the microcontroller. An input pin expects to see either 5V or 0V applied to the pin. It is used to check the state of something outside the microcontroller. 12
13
! Digital Output Programming
Think of a digital output line as a switch. Setting it HIGH is like turning the switch ON. Setting it LOW is like turning the switch OFF. digitalWrite(5, HIGH); //Set Output #5 High Output will put 5V at the pin which can drive a relay, LED, transistor or other external device digitalWrite(7, LOW); //Set Output #7 Low Output pin will be 0V, turning off external device Important concept slide! Don’t try to remember the exact details of the code. Just get an idea of the types of things that are done in a program. The digitalWrite() function sets the selected output pin high or low. The ‘//’ means that what follows are comments or notes to describe what the code is doing. 13
14
! Digital Input Programming
An external switch, sensor or other device can be connected to an input pin. The program can make decisions based on the value in X X= digitalRead(12); // Reads Input #12 and set X to: “1” if Input pin #12 is HIGH (5V) “0” if Input pin #12 is LOW (0V) The digitalRead() functions check what voltage is present on the input pin and stores the value in a variable. What do you get if 2.5V is applied? – Can’t tell. Voltages around ½ the supply voltage give unpredictable results What do you get if 10V is applied? – You open the smoke output port 14
15
Simple I/O Circuits Input: Read State of Switch Output: Turn LED On/Off A simple circuit with Switch input on I/O 11. High if switch open, low if switch closed LED on I/O 10. If high, LED will be on. If low, LED is off. 15
16
A Simple Arduino Program
//Turn on LED when switch closed int sw; // variable to hold state of switch void setup() //do this 1 time when power is applied { pinMode(10, OUTPUT); //set pin to output to drive LED pinMode(11, INPUT); //set pin to input to read switch digitalWrite(11,HIGH); //Turns on internal pull up resistor } void loop() //loop runs forever (or at least until we turn it off) sw = digitalRead(11); if(sw == 0) digitalWrite(10,HIGH); //turn on LED else digitalWrite(10,LOW); //turn LED off } /*** end of loop() ***/ Don’t worry about details. Just try to understand the general reason for the steps. Setup() is required and where you normally put the instructions to configure the Arduino hardware. It is executed once at start up. Loop () is required and where the main body of the program is put. The statements inside loop() will execute one by one forever. The {} curly brackets break up sections of code that go together. This simple program turns an Arduino with about ½ million transistors into a wire! Have to walk before we can run…. 16
17
TNC Beacons QRSS APRS Voice keyer Rotor control Antenna Switching
Ham Radio Arduino Projects Google Ham Radio + Arduino gets 1,500,000 hits APRS Repeater Control Voice keyer TNC Satellite Tracking CW Keyers Beacons Rotor control Most Arduino users are not hams. There are thousands of non-ham projects Antenna Switching QRSS 17
18
Let’s Make a CW Keyer! Morse is made of dits and dahs (dots and dashes) The basic unit of time is the dit. Dahs are 3 times as long as a dit. The space between dits & dahs in a character is one dit. 18
19
A Simple CW Keyer Shield
Only needs 3 resistors, two connectors and a transistor. A CW paddle is connected to I/O pins 3 & 4 which are configured as inputs. Resistors R2 and R3 connect to +5V. This puts = +5V on the two input pints. If the paddle is not pressed, the dit and dah inputs will see 5V, a logical 1. If a paddle is pressed, a connection is made shorting the resistor to ground. The I/O pin will see 0V, or a logical 0. I/O pin 5 is configured as an output. To effect a key down state, a logical 1 is put on the input. This drives 5V into the transistor which acts as a switch to key the transmitter. For key up state, a logic 0 (0V) is put on I/O pin 6. This turns off the transistor. The transistor is used because the microcontroller pin can’t handle voltage and currents of the typical transmitter CW input. 19
20
Simple Keyer Program – Part 1
// W9XT Simple Arduino Keyer // Give pins names – easier to remember what they are for: const int Dit = 3; // Pin for Dit input const int Dah = 4; // Pin for Dah input const int KeyOut = 5; //Pin for keyer output // variables will change: int ditTime = 120; // Dit time in msec for 10 WPM int padState; //holds state of paddle contact void setup() { //do this once at power up // initialize the pins as inputs and outputs pinMode(Dit, INPUT); pinMode(Dah, INPUT); pinMode(KeyOut, OUTPUT); digitalWrite(KeyOut,LOW); //Make sure we start out key up } We assign names Dit, Dah, KeyOut to the pins because it is easier to remember than a bunch of pin numbers. Create a variable ditTime that will hold the number of msec that will be used for the period of time for a dit. Finally we set up the pins to be used as inputs and outputs. Note that we initially set the KeyOut output low so it won’t power up keying the transmitter. The above code executes once when power is applied or the Arduino is reset. 20
21
Simple Keyer Program – Part 2
void loop(){ padState = digitalRead(Dit); // Check for the dit paddle pushed if(padState == 0){ //pin low if paddle pressed. If low do this: digitalWrite(KeyOut,HIGH); //set Key down state delay(ditTime); //stay that way for 1 dit time digitalWrite(KeyOut,LOW); // now have to be key up for 1 dit time delay(ditTime); } padState = digitalRead(Dah); //now check for the dah paddle pushed if(padState == 0){ //pin low if paddle pressed. If low, do this: delay(ditTime* 3); //stay that way for 3 dit times } // end of loop() This is the main loop. Ultimately all computer programs are a continuous loop that will continue to execute as long as the computer is powered up. The first part determines if the dit paddle is pressed. If it is, it generates a key down period for the dit, followed by a one dit key up period to act as a space between the next dit or dah. The second part looks for a dah press. It is the same as the dit code except that the key down period is 3 times as long. The program endlessly keeps checking for dit and dah presses and generating the proper key up and key down periods. 21
22
Adding Speed Control with A/D
The Arduino has Analog to Digital converter inputs An A/D converter is like a digital voltmeter 10 bit A/D – gives a value between With 5V reference, actual voltage = returned value * .0049V We will use a potentiometer as a voltage divider to vary the voltage at an A/D pin. The voltage will determine the CW speed. No one wants a keyer that only works at 10 WPM, so lets add a speed control. 22
23
Voltage Divider Speed Control
Morse Timing – Dit Period Tmsec = 1200/WPM 5 WPM: T = 240msec 40 WPM: T = 30msec AD 0V = 0 AD 5V = 1023 Equation to cover ~5 to ~40 WPM T = AD/5 +30 Note: Fastest speed is at 0V, slowest at 5V We want keyer to handle 5WPM to 40 WPM. This circuit is added to the keyer shield 23
24
Keyer Program with Speed Control
void loop(){ //do forever int rawAnalog; //holds A/D reading //update the CW speed – new!! rawAnalog = analogRead(analogPin); //measure the voltage ditTime = (rawAnalog/5) +30; //Calculate the new dit time // Check for the dit paddle pushed padState = digitalRead(Dit); if(padState == 0) //pin low if paddle pressed { digitalWrite(KeyOut,HIGH); //set Key down state delay(ditTime); //stay that way for 1 dit time digitalWrite(KeyOut,LOW); // now have to be key up for 1 dit time delay(ditTime); } //now check for the dah paddle pushed – code not shown for clarity } //end of loop This builds on the old code. The dit and dah handling routines are unchanged. Some of the old code is not shown for clarity. We configured analog pin 0 as an analog channel in setup code – Not shown Declared a new variable rawAnalog to hold the raw A/D value for use in calculating the length of a dit. We added a line of code to read the voltage provided by our voltage divider pot and store it in the variable rawAnalog. Then we calculate a new ditTime. This is used for the timing control next time we get a dit or dah paddle press. 24
25
Possible Keyer Improvements
The speed control is not very good. Not much resolution at high speed. Could fix with software Could add weight control – change dit/dah ratio Add “Mode B” operation Could add stored messages Could add ability to swap dit/dah inputs for lefties Add just about anything you can think of... This keyer is pretty crude but is a good example of a simple ham radio application. Mode A and Mode B have different timing of when they recognize key closures. If you learn on one type of keyer it is hard to use the other kind. The amount of features you could add are only limited by your imagination! 25
26
Advantages of Arduino Arduino Development Programming knowledge
Historical Development Programming knowledge Electronics knowledge Computer architecture knowledge Expensive development software & equipment Arduino Development Very little experience to start – hard work done Low cost hardware ~$30 Free Software Concentrate on learning one area at a time Lots of resources on web I have been working with micros since the mid 1970’s as my main professional specialization. I have done hundreds of microcontroller apps from simple to very complex. There was a huge learning curve just to get to the point where you could do simple things. Even though I have a lot of knowledge and equipment, I often use the Arduino for simple one off projects. In one project I figured it would take about 3-4 hours to wire up the circuit and program it. With the Arduino I wrote the software in about 5 minutes and wired up the external electronics in about 15 minutes. This was great since I only needed it for a couple of days. Member of WCARC got an Arduino for Christmas. With no programming experience and average ham knowledge of electronics made a system to control stepper motors for controlling some equipment at work. This was done in a week doing it at night. 26
27
What neat Arduino project will you come up with?
Arduino Summary Great for beginners Inexpensive Much of the hard work is already done Lots of learning resources on the web Start simple and grow as you learn What neat Arduino project will you come up with? Although designed for students, the Arduino is great for pros for single, one off projects. 27
28
Arduino Resources www.arduino.cc - Main Arduino site
– list of available shields Arduino sources Radio Shack – LCD Shield – micro interfacing tutorial This program will be available on The main Arduino sites has information on hardware, development software down load, forums, tutorials and more. I am developing additional shields that may be available. Check the Unified Microsystems web site. I have a series of tutorials on how to connect external electronics to microcontrollers like the Arduino. They are written for people with only very basic experience with electronics. 28
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.