Amateur Radio / Arduino

Amateur Radio / Arduino

While You're Resting...

Remember the 1980s?

Not those 1980's

I Meant the Apple II

The Apple II

Arduino

Arduino

Arduino Peripherals

Arduino Peripherals

Arduino Peripherals

Arduino Peripherals

Arduino Peripherals

Arduino Peripherals

Arduino Peripherals

Arduino Advantages: Community

Arduino Advantages: Community

Arduino Advantages: Books

Arduino Advantages: Books

Arduino Advantages: Books

Arduino Advantages: Books

Arduino Advantages: Books

Arduino Advantages: High-level Programming

Arduino Advantages: High-level Programming

Arduino Advantages: High-level Programming

Arduino Disadvantages

Diavolino and Arduino

Diavolino

Today's Project

Today's Project

Today's Project

Today's Project

Today's Project

Today's Project

Today's Project

Today's Project

Today's Project

QRSS Receivers

Grabber Screenshot

Project Overview

Pulse Width Modulation

PWM Space

PWM Mark

PWM Voltage

Parts selection

Design Choice: 3.999 MHz and 28.322 Mhz

Schematic

3.999 MHz 3.3v

Modes

Arduino sketch

Setup

Set PWM word in the range 128-255 to achieve 3150mV for mark, and 2850mV for space

#define VCC_MV 4675   // Vcc measured

void setup() {
  ...
  mark = calibrate(128, 255, 3150);
  space = calibrate(128, 255, 2850);
  ...
}

Similar setup for 5V part

Loop

void loop()
  analogWrite(PWM, (mark+space)/2);
  delay(1000); 
  tri(); tri(); tri();
  analogWrite(PWM, (mark+space)/2);
  delay(1000); 
  qrss_cw(MESSAGE);
}

QRSS

void qrss_dit() {
  analogWrite(PWM, mark);
  delay(QRSS_DIT_SPEED);
  analogWrite(PWM, space);
  delay(QRSS_DIT_SPEED);
}

void qrss_dah() {
  analogWrite(PWM, mark);
  delay(QRSS_DIT_SPEED * 3);
  analogWrite(PWM, space);
  delay(QRSS_DIT_SPEED);
}

void qrss_space() {
  analogWrite(PWM, space);
  delay(QRSS_DIT_SPEED * 2);
}

Tri

void tri() {
  for (int i = space; i < mark; i++) {
    analogWrite(PWM, i);
    delay(TRI_DELAY);
  }
  for (int i = mark; i >= space; i--) {
    analogWrite(PWM, i);
    delay(TRI_DELAY);
  }
}

Calibrate

// Use Analog Input A0 for voltmeter

int calibrate(byte min_pwm, byte max_pwm, int desired_mv) {
  Serial.print("Calibration for ");
  Serial.print(desired_mv);
  Serial.print("mv = ");
  read_voltage(128);
  delay(1000);
  int m = calibrate_b(min_pwm, max_pwm, desired_mv);
  Serial.println(m);
  return m;
}

calibrate_b

int calibrate_b(byte min_pwm, byte max_pwm, int desired_mv) {
  int m;
  while(min_pwm<=max_pwm) {
    m=(min_pwm+max_pwm)/2;
    int mv = read_voltage(m);
    if (desired_mv==mv) {
      break;
    } else if(desired_mv<mv) {
      max_pwm=m-1;
    } else {
      min_pwm=m+1;
    }
  }
  return m;
}

read_voltage

// start with initial voltage and delay(1500)
// when used to read a slowly-changing voltage per-step delay(250) is ok.
// with sudden jumps from previous call, use delay(1500)
unsigned int read_voltage(byte pwm) {
  analogWrite(PWM, pwm);
  delay(250);
  long avg = 0;
  analogRead(DVM);
  for (byte i = 0; i < 10; i++) {
    avg += analogRead(DVM);
  }
  return (avg*(VCC_MV/10))/1024L;
}

Thanks to...

Photo Credits

Licenses