36

BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

  • Upload
    others

  • View
    14

  • Download
    0

Embed Size (px)

Citation preview

Page 1: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,
Page 2: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

BASIC Arduino

Part I

Page 3: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 4: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Components• Arduino UNO single

board micro-computer

• Breadboard, wires

• LED, 220R

• LCD, Rotary Encoder

• Si5351 module

• Connecting wires (male to male)

Page 5: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Arduino UNO

Page 6: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 7: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 8: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Set-up IDE• Create a folder/

directory: Documents/Arduino

• Start Arduino IDE

• Go to Preferences, select Arduino Sketchbook location

Re-start Arduino IDE

Page 9: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Plug in your UNO• Connect your UNO to your

PC by the USB Cable

• Start Arduino IDE > Tools

• Chose Board, Port (COMx)

Page 10: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Coding

Page 11: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 12: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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”);

Page 13: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 14: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Take a look at the Arduino Library

arduino.cc > Learning > Reference

Page 15: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Part IILet’s continue our activities

LiquidCrystal_I2C corruption problem has been solved

Page 16: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

New USB Stick1st: Delete all stuff in Documents/Arduino/

2nd: Copy new USB stick to Documents/Arduino/

Result?Documents/Arduino/

Page 17: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 18: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Your hardwareand it’s interface

LCD, Rotary Encoder Synthesiser

Page 19: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 20: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 21: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 22: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 23: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 24: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 25: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

The I2C bus

Page 26: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 27: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Using your LCD

Page 28: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Build a display

UploadPress Reset to run again

• Connect upSCL = A5 SDA = A4 VCC = 5V GND = GND

• Open My_LCD_Test-Basic

Page 29: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Using your Si5351

Page 30: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 31: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Upload

Set 9600Set Newline

Enter Frequency in Hz

Check output on a Radio

Open Monitor1

2

3

My_VFO_KB-Basic

Page 32: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Build a 1-60MHz VFO

Can extend to 10kHz to 200MHz (maybe higher)

Page 33: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,
Page 34: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

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

Page 35: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,

Have fun.

RememberSi5351 - Mixers, SDRs, digital apps

AD9850 - Antenna analysers, low harmonic apps

Try transmitting My_HELL_S/MT_5x7

and My_WSPR

Page 36: BASIC Arduino - Banbury Amateur Radio Society Home Page VFO.pdfPart I. Objectives. •Introduction to Arduino. •Build a 1-60MHz DDS VFO prototype, breadboard and write Sketches,