// mbed C++ sketch for the ChipDesign SDR antenna // // The ChipDesign SDR antenna can be connected to 5 V Arduino shield compatible // mbed micro-controller boards, such as the Seeeduino Arch (Pro) and the u-blox C027. // The SDR antenna can be powered and interfaced over USB using any programming language // supported by the mbed platform. The varactors are connected to the low-pass filtered // PWM ouput pins 3, 5, and 6 of the Arduino platform. Using the PwmOut interface, the // reverse bias voltage of the varactors can be set between 0 V and 5 V. // // 3.3 V mbed micro-controller boards will require 3.3 V to 5 V level shifters to be // inserted to bias the varactors up to 5 V and cover the entire tunable frequency range // of the SDR antenna. // // The firmware code is provided as is. #include "mbed.h" #define FREQ_CMD_LENGTH 5 #define CMD_LENGTH 8 Serial pc(USBTX, USBRX); PwmOut varactorLeft(p24); PwmOut varactorTop(p25); PwmOut varactorRight(p26); static void runFreqCommand(char* freqCommand); int main() { int i = 0; char command[] = "!!!!!!!!!!"; while(1) { int c = pc.getc(); pc.putc(c); if (i < CMD_LENGTH && c != 0xD) command[i++] = (char) c; else { if (i>=FREQ_CMD_LENGTH && strncmp(command,"FREQ:",FREQ_CMD_LENGTH) == 0) { pc.printf("Freq Command Received %x\n",strcmp(command,"freq")); runFreqCommand(command+FREQ_CMD_LENGTH); } else pc.printf("Unknown command\n"); i = 0; memset(command,0,sizeof(char)*CMD_LENGTH); pc.printf(">> "); } } } static void runFreqCommand(char* freqCommand) { char *strPtr; int freq = strtol(freqCommand,&strPtr,10); pc.printf("Frequency Parsed: %d\n",freq); switch (freq) { case 700: varactorLeft = 0.1; varactorTop = 0.1; varactorRight = 0.1; break; default: pc.printf("Unknown frequency\n",freq); } }