A Microcontroller Operated SWR Meter

Aus DL8RDS Wiki
Version vom 7. November 2009, 02:09 Uhr von Dl8rds (Diskussion | Beiträge) (Controlling digital Output)
Wechseln zu: Navigation, Suche

1 Project description

This project is related to the SVXLink project. Since I intend to use T7F transceivers for this project, it is highly interesting to detect troublesome antenna and SWR conditions and to be able to shut off the transmitter. The only way to do that is to read out the SWR digitally. And this can be done using an Analog Digital Converter, either directly on a microcontroller board or over an I2C BUS.

BTW, I want to measure some more values:

  • PA temperature
  • Transmitter power consumption / input current
  • Total system input current

And I want to switch some things, too:

  • Be able to switch the transceiver OFF

But very basically this project can also be seen in an isolated perspective: I want to learn how to use a microcontroller and set up a project that's useful for other OMs as well. Notably interesting will be to use the Sparkfun Low Current readout boards and feed this voltage into the ADC that's contained on the Arduino board. so that I possibly don't even need the I2C BUS for this isolated scenario.

The LCD display is a ANAG Vision AV2020YFBF-SJ

2 Other People's work

3 Shops where to buy the components

4 Project Plan

  • Purchase stuff
  • Get familiar with the Arduino board. See how to read out values and to control actuators.
  • Build a directional coupler. Role model: http://www.dj4uf.de/projekt/swr/swr.htm
  • Make sure the readouts of the forward voltages are within a reasonable range. identify peak voltages.
  • Then take the BeagleBoard and be successful measuring voltages through a Analog Digital Converter (ADC).
  • Then connect the coupler to the ADC and see if it's possible to measure the voltages.
  • Then connect an LCD display to an Arduino board.
  • Then successfully control the LCD display and devise a reasonable display readout
  • Then read the I2C bus from the Arduino board
  • Then calculate the SWR based on the readings from the I2C bus and send them to the LCD display
  • Finally build a nice case
  • Write an article and post it in some fancy electronics magazine :-)

5 Progress

5.1 Purchase Stuff

  • 2009-09-04 The BeagleBoard has an I2C header in the expansion port. So it is just a wonderful idea to use it and read out some things. The only problem: It's operated with 1,8V. So I need a bidirectional voltage translator.
  • 2009-09-05 I decided to get the one from Gravitech.
  • 2009-09-10 My ADC arrived. I'm still waiting to receive the voltage translator. And I have bought some books on Arduino programming. Still need to buy the Arduino board and an LCD display.
  • ToDo: Go shopping

There are some guides on how to connect LCD dislays and Arduinos:

5.2 First Steps on Arduino

My first steps on the Arduino platform are successful! Since I have been working on a Ubuntu Hardy platform, I noticed that I would not be able to compile my programs properly because there are some bugs here and there. Anyway, so I decided to upgrade to the most modern Ubuntu Jaunty distribution and now it works fine: I can start the Arduino development environment without problems. Trying out the first little program, the famous "Blink" program which blinks a LED, compiled perfectly. So I started over and plugged the LED into digital output pin 13 and GND and uploaded the code and there it went. The Arduino went blinking!!!

5.2.1 Controlling digital Output with the Arduino

5.2.2 Controlling Serial Output

My next experiment was to send stuff to the serial console back to the computer. Here I tried out some code from the book "Manuel Odendahl, Julian Finn & Alex Wenger. Arduino. Pysical Computing für Bastler, Designer & geeks. O'Reilly, 2009.", page 132 ff.

void setup() 
{
  Serial.begin(9600);
}
void loop()
{
  Serial.println("Hallo");
  Serial.println("--------");
  delay(1000);
}

5.2.3 Evaluate an analog value through the ADC

And after making a connection to /dev/ttyUSB0 with 9600 bit/s and handshake off, I was able to read the Hello by every second. So also the serial connection is damn simple. The next bit was even a bit harder: I want to read out the setting of a poti and send the value to the serial console. That's my first attempt to make a bridge from the real world into the digital world. Here's the setup:

Arduino mit poti.jpg

The poti is a 1 kOhm.

And here's the code:

int potiPin = 0;
int potiVal = 0;

void setup() {
  Serial.begin(9600);
  int potiPin = 0;
}

void loop() {
  int zahl = 10;
  int potiVal = analogRead(potiPin);
  Serial.println("Poti-Wert:");
  Serial.println(potiVal);
  Serial.println("-------------");
  delay(1000);
}

And now when I take a screwdriver and twist around the poti, I am getting different values in my minicom!!!

Poti-Wert:
541
-------------
Poti-Wert:
561
-------------
Poti-Wert:
653
-------------
Poti-Wert:
804
-------------
Poti-Wert:
857
-------------
Poti-Wert:
1018
-------------
Poti-Wert:
1023
-------------
Poti-Wert:
1019

Most remarkable is that the values range from 0 to 1023. So that's just a perfect basis to do further calculations.

5.2.4 Evaluate an analog value through the ADC on the Arduino Nano

5.2.5 Controlling the Arduino over the serial connection

5.2.6 Controlling an LCD display with the Arduino

5.2.7 Writing stuff to the LCD display with an Arduino

5.2.8 Reading a value from the I2C port with an Arduino

5.2.9 Talking to the network with an Arduino

5.2.10 Controlling a PWM over I2C

5.2.11 A I2C controlled, LCD enabled Thermometer

5.2.12 Reading Input from an I2C ADC

5.3 The Directional Coupler

I'm just about organizing the hardware.

6 What's next?

  • Come back and see in a few weeks / months...