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 Pass it round Make a folder and copy the contents of the stick to Documents/Arduino Contains libraries and a various sketches
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 rows LiquidCrystal_I2C lcd(0x3f, 16, 2); Use the object lcd.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 Use library Create lcd object // create an LCD object "lcd" LiquidCrystal_I2C lcd(lcdaddr, LCDCOLS, LCDROWS); // setup runs once on upload void setup() { // initialise the LCD & switch the backlight on lcd.begin(); Use lcd functions // move the cursor to col, row and output text lcd.setcursor(3, 0); lcd.print(" BASIC ); pinmode(10, OUTPUT); digitalwrite(10, HIGH); Use Arduino functions
Take a look at the Arduino Library arduino.cc > Learning > Reference
Part II Let s continue our activities LiquidCrystal_I2C corruption problem has been solved
New USB Stick 1st: 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, forever void 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 hardware and it s interface LCD, Rotary Encoder Synthesiser
Two kinds of Synthesiser There are two kinds Digital output, Si5351 Good for mixers, SDR We will start with this one Analog output, AD9850 Needed for pure output Analog output generates a sine wave using a D/A convertor
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) I2C Bus It has a data line (SDA) and a clock line (SCL) Data is sent serially GND - ground VCC - +5V SDA - Data SCL - Clock
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 A (CLK) B (DT) SW +5V GND The shaft is a push button switch, connected to pin 4
Serial I2C bus Arduino talks to some hardware on a serial bus A4 A5 Arduino is a Master Devices are Slaves Every slave has an address (0x60, 0x3F )
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 Connect up SCL = A5 SDA = A4 VCC = 5V GND = GND Open My_LCD_Test-Basic Upload Press Reset to run again
Using your Si5351
Build a VFO Connect up SCL = A5 SDA = A4 VCC = 5V GND = GND Open My_VFO_KB-Basic Use a four wire cable We will set the VFO frequency from your PC keyboard
Upload 1 Open Monitor My_VFO_KB-Basic 3 Enter Frequency in Hz Check output on a Radio 2 Set Newline Set 9600
Build a 1-60MHz VFO Can extend to 10kHz to 200MHz (maybe higher)
VFO 1-60MHz Wire encoder: CLK = D3 DT = D2 SW = D4 GND - GND + - 3.3V Use a five wire cable (+ can go to 5V or 3.3V) Wire LCD: GND - GND VCC - +5V SDA - A4 SCL - A5 Open My_VFO_Basic Upload Use a four wire cable I2C Bus
Have fun. Try transmitting My_HELL_S/MT_5x7 and My_WSPR Remember Si5351 - Mixers, SDRs, digital apps AD9850 - Antenna analysers, low harmonic apps