Upload
others
View
14
Download
0
Embed Size (px)
Citation preview
BASIC Arduino
Part I
Objectives• Introduction to Arduino
• Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches, with Buffer amps to be designed, and PCB Using your own laptop
• Go on to build other useful stuff - RF Meter, Digital mode transmitters, QRP Transceiver, SWR Meter….
• Revise your knowledge
• Or start at the beginning
• Hands-on Amateur Radio
Components• Arduino UNO single
board micro-computer
• Breadboard, wires
• LED, 220R
• LCD, Rotary Encoder
• Si5351 module
• Connecting wires (male to male)
Arduino UNO
Setup your PC• Club Wifi: BARS_AP
• Password: 1234567890
• Download and install Arduino IDE from arduino.cc > Downloads
• If you have already installed, update to 1.8.1
Copy the USB Stick• Quit/Exit Arduino IDE
• Make a folder and copy the contents of the stick to Documents/Arduino
• Contains libraries and a various sketches
Pass it round
Set-up IDE• Create a folder/
directory: Documents/Arduino
• Start Arduino IDE
• Go to Preferences, select Arduino Sketchbook location
Re-start Arduino IDE
Plug in your UNO• Connect your UNO to your
PC by the USB Cable
• Start Arduino IDE > Tools
• Chose Board, Port (COMx)
Coding
C++• A problem can always be divided into bits, called
functions. Some already exists in libraries
• C++ language is based on libraries and functions
• We have lots already written for us
• Arduino IDE has a set of functions in its own libraries
• User libraries of functions have examples of how to use them
Library example• Use library:#include “LiquidCrystal_I2C.h”
• Create an LCD object for your display, which has an I2C address of 0x3F, 16 columns and 2 rowsLiquidCrystal_I2C lcd(0x3F, 16, 2);
• Use the objectlcd.init(); lcd.print(“Hello World”);
Look at some real code// include libraries for LCD#include "LiquidCrystal_I2C.h"
// LCD I2C address, cols, rows#define LCDADDR 0x27//#define LCDADDR 0x3F#define LCDCOLS 16#define LCDROWS 2
// create an LCD object "lcd"LiquidCrystal_I2C lcd(LCDADDR, LCDCOLS, LCDROWS);
// setup runs once on uploadvoid setup() { // initialise the LCD & switch the backlight on lcd.begin(); // move the cursor to col, row and output text lcd.setCursor(3, 0); lcd.print(" BASIC “);
pinMode(10, OUTPUT); digitalWrite(10, HIGH);
Use library
Create lcd object
Use lcd functions
Use Arduino functions
Part IILet’s continue our activities
LiquidCrystal_I2C corruption problem has been solved
New USB Stick1st: Delete all stuff in Documents/Arduino/
2nd: Copy new USB stick to Documents/Arduino/
Result?Documents/Arduino/
Test sketch• Plug in your Arduino UNO using the USB cable
• Open File > Sketchbook > My_Blink
// My_Blink// flashes a LED on pin 13
// pin number#define LED 13
// the setup routine runs once void setup() { // initialise the digital pin 13 as an output pinMode(LED, OUTPUT);}
// the loop runs over and over again, forevervoid loop() { digitalWrite(LED, HIGH); // turn the LED on (HIGH voltage level) delay(1000); // wait for 1 second (1000ms) digitalWrite(LED, LOW); // turn the LED off (LOW voltage level) delay(1000); // wait for 1 second}
Upload
Your hardwareand it’s interface
LCD, Rotary Encoder Synthesiser
Two kinds of Synthesiser• There are two kinds
• Digital output, Si5351 Good for mixers, SDR
• Analog output, AD9850 Needed for pure output
• Analog output generates a sine wave using a D/A convertor
Wewill start
withthis one
Si5351 Synthesiser• Si5351 has 3 outputs each
programmable
• The outputs are 3.3V, can drive 8mA = 4dBm into 50R
• It has an I2C bus input SDA & SCL (address 0x60)
• Frequency 10kHz to > 200MHz
• 0.01Hz min tuning steps
• Arduino library
AD9850 Synthesiser• AD9850 has sine wave and
digital outputs
• 5V operation
• Dedicated serial bus (not I2C)
• > 30MHz output, LPF
• 0.0291Hz min thing steps
• Arduino library
LCD• The display is 16
characters by 2 lines
• It has an address on the I2C bus (0x3F or 0x27)
• It has a data line (SDA) and a clock line (SCL)
• Data is sent serially
GND - groundVCC - +5VSDA - DataSCL - Clock
I2C Bus
Rotary Encoder• The Rotary Encoder has a
two outputs
• From the phase of the outputs you know the direction
• Outputs A & B go to digital input pins 2 & 3
• The shaft is a push button switch, connected to pin 4
A (CLK)B (DT)SW+5VGND
Serial I2C bus
Arduino is a “Master” Devices are “Slaves”
Every slave has an address (0x60, 0x3F…)
A4A5
Arduino talks to some hardware on a serial bus
The I2C bus
Arduino Pinout• A plan for pin usage • Interfaces for
• SIG/FWD, REV • RETURN LOSS • RFMETER • I2C • RX/TX SEQ • AD9850 BUS • BAND SELN • PTT • ENCODER
Using your LCD
Build a display
UploadPress Reset to run again
• Connect upSCL = A5 SDA = A4 VCC = 5V GND = GND
• Open My_LCD_Test-Basic
Using your Si5351
Build a VFO• Connect upSCL = A5 SDA = A4 VCC = 5V GND = GND
• Open My_VFO_KB-Basic
• We will set the VFO frequency from your PC keyboard
Use a four wire cable
Upload
Set 9600Set Newline
Enter Frequency in Hz
Check output on a Radio
Open Monitor1
2
3
My_VFO_KB-Basic
Build a 1-60MHz VFO
Can extend to 10kHz to 200MHz (maybe higher)
VFO 1-60MHz
OpenMy_VFO_Basic
Wire encoder:CLK = D3DT = D2SW = D4GND - GND+ - 3.3V
(+ can go to 5V or 3.3V)
Upload
Use a five wire cable
Use a four wire cable
Wire LCD:GND - GNDVCC - +5VSDA - A4SCL - A5
I2C Bus
Have fun.
RememberSi5351 - Mixers, SDRs, digital apps
AD9850 - Antenna analysers, low harmonic apps
Try transmitting My_HELL_S/MT_5x7
and My_WSPR