Added a waveform generator

This commit is contained in:
Kai Lauterbach 2024-02-11 12:50:31 +01:00
parent 48f034f0a4
commit 2964460a87
21 changed files with 2732 additions and 469 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

1
.gitconfig Normal file
View file

@ -0,0 +1 @@
core.autocrlf true

View file

@ -1,6 +1,6 @@
This project is reengineered out of the TenaTester build by ZL1CVD. This project is reengineered out of the TenaTester build by ZL1CVD.
The firmware is completely written by myself, the wheatstone bridge was mostly drawn as seen in the TenaTesta demo videos by ZL1CVD on youtube. The electrical component values were modified by myself to fit my personal requirements. The si5351 prt in the schematics was replaced by an adafruit breakout board. The firmware is completely written by myself, the wheatstone bridge was mostly drawn as seen in the TenaTesta demo videos by ZL1CVD on youtube. The electrical component values were modified by myself to fit my personal requirements. The si5351 in the schematics was replaced by an adafruit breakout board.
Ressources: Ressources:
* https://learn.adafruit.com/adafruit-si5351-clock-generator-breakout/wiring-and-test * https://learn.adafruit.com/adafruit-si5351-clock-generator-breakout/wiring-and-test

BIN
Si5351Arduino/.DS_Store vendored Normal file

Binary file not shown.

BIN
firmware/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -226,9 +226,17 @@ void cc_startMeasurement()
uint32_t a1_sum = 0; uint32_t a1_sum = 0;
uint16_t i = 0; uint16_t i = 0;
si5351.set_freq((uint64_t)freq * 100, SI5351_PLL_FIXED, SI5351_CLK0); if (freq < 8000)
si5351.output_enable(SI5351_CLK0, 1); // enable clock output 0 {
delay(1); setWaveformFrequency((int)freq);
enableWaveformOutput();
si5351.output_enable(SI5351_CLK0, 0); // disable clock output 0
} else {
disableWaveformOutput();
si5351.set_freq((uint64_t)freq * 100, SI5351_PLL_FIXED, SI5351_CLK0);
si5351.output_enable(SI5351_CLK0, 1); // enable clock output 0
delay(1);
}
for (i = 0; i < intervall; i++) for (i = 0; i < intervall; i++)
{ {
@ -295,12 +303,21 @@ void cc_enableClk(void)
sendSOM(); sendSOM();
if (cc_read_data[0] == SI5351_CLK0) if (cc_read_data[0] == SI5351_CLK0)
{ {
si5351.set_freq((uint64_t)start_freq * 100, SI5351_PLL_FIXED, SI5351_CLK0); if (start_freq < 8000)
si5351.output_enable(SI5351_CLK0, 1); // enable clock output 0 {
setWaveformFrequency((int)start_freq);
enableWaveformOutput();
si5351.output_enable(SI5351_CLK0, 0);
} else {
disableWaveformOutput();
si5351.set_freq((uint64_t)start_freq * 100, SI5351_PLL_FIXED, SI5351_CLK0);
si5351.output_enable(SI5351_CLK0, 1); // enable clock output 0
}
Serial.write(MSG_TYPE_ANSWER_OK); Serial.write(MSG_TYPE_ANSWER_OK);
} }
else if (cc_read_data[0] == SI5351_CLK1) else if (cc_read_data[0] == SI5351_CLK1)
{ {
si5351.set_freq((uint64_t)start_freq * 100, SI5351_PLL_FIXED, SI5351_CLK1); si5351.set_freq((uint64_t)start_freq * 100, SI5351_PLL_FIXED, SI5351_CLK1);
si5351.output_enable(SI5351_CLK1, 1); // enable clock output 1 si5351.output_enable(SI5351_CLK1, 1); // enable clock output 1
Serial.write(MSG_TYPE_ANSWER_OK); Serial.write(MSG_TYPE_ANSWER_OK);
@ -323,6 +340,7 @@ void cc_disableClk(void)
sendSOM(); sendSOM();
if (cc_read_data[0] == SI5351_CLK0) if (cc_read_data[0] == SI5351_CLK0)
{ {
disableWaveformOutput();
si5351.output_enable(SI5351_CLK0, 0); // disable clock output 0 si5351.output_enable(SI5351_CLK0, 0); // disable clock output 0
Serial.write(MSG_TYPE_ANSWER_OK); Serial.write(MSG_TYPE_ANSWER_OK);
} }
@ -527,4 +545,3 @@ void send16BitValue(uint16_t value)
} }
/*****************************************************************************/ /*****************************************************************************/

View file

@ -59,6 +59,8 @@ void setup()
analogReference(DEFAULT); // 5V reference analogReference(DEFAULT); // 5V reference
initWaveformGenerator();
readEEPValues(); readEEPValues();
} }
@ -90,6 +92,8 @@ void loop()
cc_processData(c); cc_processData(c);
} }
pollWaveformGenerator();
//delay(100); //delay(100);
delay(10); delay(10);
} }
@ -186,4 +190,3 @@ uint32_t keepFreqRange(uint32_t freq)
} }
/*****************************************************************************/ /*****************************************************************************/

View file

@ -0,0 +1,63 @@
#include "Waveforms.h"
#define PWM_BIT_WIDTH 10
#define PWM_PIN 5 // PWM-Pin für DAC0 auf dem Arduino Nano 328
int wf_wave0 = 0;
int wf_pos = 0;
int wf_sample;
bool wf_outputEnabled = true; // Variable to control waveform output state
void initWaveformGenerator()
{
setWaveform(WAVEFORM_SINUS);
// Call the function to set default frequency, here you might want to specify a default frequency
setWaveformFrequency(WAVEFORM_DEFAULT_FREQ_HZ);
}
void setWaveform(int waveform0)
{
if (waveform0 >= 0 and waveform0 < WAVEFORM_MAXWAVEFORM_NUM)
{
// Set default waveforms
wf_wave0 = waveform0;
}
}
void setWaveformFrequency(int frequency)
{
if (frequency >= 1 and frequency < 8000)
{
wf_sample = map(frequency, 0, (2^PWM_BIT_WIDTH)-1, 0, WAVEFORM_ONE_HZ_SAMPLE);
wf_sample = constrain(wf_sample, 0, WAVEFORM_ONE_HZ_SAMPLE);
} else {
wf_sample = map(WAVEFORM_DEFAULT_FREQ_HZ, 0, (2^PWM_BIT_WIDTH)-1, 0, WAVEFORM_ONE_HZ_SAMPLE);
wf_sample = constrain(wf_sample, 0, WAVEFORM_ONE_HZ_SAMPLE);
}
}
void enableWaveformOutput()
{
wf_outputEnabled = true;
}
void disableWaveformOutput()
{
wf_outputEnabled = false;
}
void pollWaveformGenerator()
{
if (wf_outputEnabled)
{
analogWrite(PWM_PIN, waveformsTable[wf_wave0][wf_pos]); // write the selected waveform on DAC0
wf_pos++;
if (wf_pos == WAVEFORM_MAX_SAMPLES_NUM) // Reset the counter to repeat the wave
wf_pos = 0;
delayMicroseconds(wf_sample); // Hold the sample value for the sample time
}
}

84
firmware/waveforms.h Normal file
View file

@ -0,0 +1,84 @@
#ifndef _Waveforms_h_
#define _Waveforms_h_
#define WAVEFORM_MAXWAVEFORM_NUM 4
#define WAVEFORM_MAX_SAMPLES_NUM 120
#define WAVEFORM_ONE_HZ_SAMPLE (1000000/WAVEFORM_MAX_SAMPLES_NUM) // sample for the 1Hz signal expressed in microseconds
#define WAVEFORM_DEFAULT_FREQ_HZ 1
#define WAVEFORM_SINUS 0
#define WAVEFORM_TRIANGULAR 1
#define WAVEFORM_SAWTOOTH 2
static int waveformsTable[WAVEFORM_MAXWAVEFORM_NUM][WAVEFORM_MAX_SAMPLES_NUM] = {
// Sin wave
{
0x7ff, 0x86a, 0x8d5, 0x93f, 0x9a9, 0xa11, 0xa78, 0xadd, 0xb40, 0xba1,
0xbff, 0xc5a, 0xcb2, 0xd08, 0xd59, 0xda7, 0xdf1, 0xe36, 0xe77, 0xeb4,
0xeec, 0xf1f, 0xf4d, 0xf77, 0xf9a, 0xfb9, 0xfd2, 0xfe5, 0xff3, 0xffc,
0xfff, 0xffc, 0xff3, 0xfe5, 0xfd2, 0xfb9, 0xf9a, 0xf77, 0xf4d, 0xf1f,
0xeec, 0xeb4, 0xe77, 0xe36, 0xdf1, 0xda7, 0xd59, 0xd08, 0xcb2, 0xc5a,
0xbff, 0xba1, 0xb40, 0xadd, 0xa78, 0xa11, 0x9a9, 0x93f, 0x8d5, 0x86a,
0x7ff, 0x794, 0x729, 0x6bf, 0x655, 0x5ed, 0x586, 0x521, 0x4be, 0x45d,
0x3ff, 0x3a4, 0x34c, 0x2f6, 0x2a5, 0x257, 0x20d, 0x1c8, 0x187, 0x14a,
0x112, 0xdf, 0xb1, 0x87, 0x64, 0x45, 0x2c, 0x19, 0xb, 0x2,
0x0, 0x2, 0xb, 0x19, 0x2c, 0x45, 0x64, 0x87, 0xb1, 0xdf,
0x112, 0x14a, 0x187, 0x1c8, 0x20d, 0x257, 0x2a5, 0x2f6, 0x34c, 0x3a4,
0x3ff, 0x45d, 0x4be, 0x521, 0x586, 0x5ed, 0x655, 0x6bf, 0x729, 0x794
}
,
// Triangular wave
{
0x44, 0x88, 0xcc, 0x110, 0x154, 0x198, 0x1dc, 0x220, 0x264, 0x2a8,
0x2ec, 0x330, 0x374, 0x3b8, 0x3fc, 0x440, 0x484, 0x4c8, 0x50c, 0x550,
0x594, 0x5d8, 0x61c, 0x660, 0x6a4, 0x6e8, 0x72c, 0x770, 0x7b4, 0x7f8,
0x83c, 0x880, 0x8c4, 0x908, 0x94c, 0x990, 0x9d4, 0xa18, 0xa5c, 0xaa0,
0xae4, 0xb28, 0xb6c, 0xbb0, 0xbf4, 0xc38, 0xc7c, 0xcc0, 0xd04, 0xd48,
0xd8c, 0xdd0, 0xe14, 0xe58, 0xe9c, 0xee0, 0xf24, 0xf68, 0xfac, 0xff0,
0xfac, 0xf68, 0xf24, 0xee0, 0xe9c, 0xe58, 0xe14, 0xdd0, 0xd8c, 0xd48,
0xd04, 0xcc0, 0xc7c, 0xc38, 0xbf4, 0xbb0, 0xb6c, 0xb28, 0xae4, 0xaa0,
0xa5c, 0xa18, 0x9d4, 0x990, 0x94c, 0x908, 0x8c4, 0x880, 0x83c, 0x7f8,
0x7b4, 0x770, 0x72c, 0x6e8, 0x6a4, 0x660, 0x61c, 0x5d8, 0x594, 0x550,
0x50c, 0x4c8, 0x484, 0x440, 0x3fc, 0x3b8, 0x374, 0x330, 0x2ec, 0x2a8,
0x264, 0x220, 0x1dc, 0x198, 0x154, 0x110, 0xcc, 0x88, 0x44, 0x0
}
,
// Sawtooth wave
{
0x22, 0x44, 0x66, 0x88, 0xaa, 0xcc, 0xee, 0x110, 0x132, 0x154,
0x176, 0x198, 0x1ba, 0x1dc, 0x1fe, 0x220, 0x242, 0x264, 0x286, 0x2a8,
0x2ca, 0x2ec, 0x30e, 0x330, 0x352, 0x374, 0x396, 0x3b8, 0x3da, 0x3fc,
0x41e, 0x440, 0x462, 0x484, 0x4a6, 0x4c8, 0x4ea, 0x50c, 0x52e, 0x550,
0x572, 0x594, 0x5b6, 0x5d8, 0x5fa, 0x61c, 0x63e, 0x660, 0x682, 0x6a4,
0x6c6, 0x6e8, 0x70a, 0x72c, 0x74e, 0x770, 0x792, 0x7b4, 0x7d6, 0x7f8,
0x81a, 0x83c, 0x85e, 0x880, 0x8a2, 0x8c4, 0x8e6, 0x908, 0x92a, 0x94c,
0x96e, 0x990, 0x9b2, 0x9d4, 0x9f6, 0xa18, 0xa3a, 0xa5c, 0xa7e, 0xaa0,
0xac2, 0xae4, 0xb06, 0xb28, 0xb4a, 0xb6c, 0xb8e, 0xbb0, 0xbd2, 0xbf4,
0xc16, 0xc38, 0xc5a, 0xc7c, 0xc9e, 0xcc0, 0xce2, 0xd04, 0xd26, 0xd48,
0xd6a, 0xd8c, 0xdae, 0xdd0, 0xdf2, 0xe14, 0xe36, 0xe58, 0xe7a, 0xe9c,
0xebe, 0xee0, 0xf02, 0xf24, 0xf46, 0xf68, 0xf8a, 0xfac, 0xfce, 0xff0
}
,
// Square wave
{
0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff,
0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff,
0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff,
0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff,
0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff,
0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
}
};
#endif

View file

@ -0,0 +1,265 @@
EESchema-LIBRARY Version 2.4
#encoding utf-8
#
# +5V
#
DEF +5V #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -150 50 H I C CNN
F1 "+5V" 0 140 50 H V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
DRAW
P 2 0 1 0 -30 50 0 100 N
P 2 0 1 0 0 0 0 100 N
P 2 0 1 0 0 100 30 50 N
X +5V 1 0 0 0 U 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# BNC
#
DEF BNC P 0 40 Y N 1 F N
F0 "P" 10 120 50 H V C CNN
F1 "BNC" 110 -60 50 V V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
BNC_*
bnc
bnc-*
$ENDFPLIST
DRAW
C 0 0 20 0 1 8 N
C 0 0 70 0 1 12 N
X In 1 -150 0 130 R 40 40 1 1 P
X Ext 2 0 -200 130 U 40 40 1 1 P
ENDDRAW
ENDDEF
#
# C
#
DEF C C 0 10 N Y 1 F N
F0 "C" 25 100 50 H V L CNN
F1 "C" 25 -100 50 H V L CNN
F2 "" 38 -150 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
C?
C_????_*
C_????
SMD*_c
Capacitor*
$ENDFPLIST
DRAW
P 2 0 1 20 -80 -30 80 -30 N
P 2 0 1 20 -80 30 80 30 N
X ~ 1 0 150 110 D 40 40 1 1 P
X ~ 2 0 -150 110 U 40 40 1 1 P
ENDDRAW
ENDDEF
#
# CONN_01X07
#
DEF CONN_01X07 P 0 40 Y N 1 F N
F0 "P" 0 400 50 H V C CNN
F1 "CONN_01X07" 100 0 50 V V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
Pin_Header_Straight_1X07
Pin_Header_Angled_1X07
Socket_Strip_Straight_1X07
Socket_Strip_Angled_1X07
$ENDFPLIST
DRAW
S -50 -350 50 350 0 1 0 N
S -50 -295 10 -305 0 1 0 N
S -50 -195 10 -205 0 1 0 N
S -50 -95 10 -105 0 1 0 N
S -50 5 10 -5 0 1 0 N
S -50 105 10 95 0 1 0 N
S -50 205 10 195 0 1 0 N
S -50 305 10 295 0 1 0 N
X P1 1 -200 300 150 R 50 50 1 1 P
X P2 2 -200 200 150 R 50 50 1 1 P
X P3 3 -200 100 150 R 50 50 1 1 P
X P4 4 -200 0 150 R 50 50 1 1 P
X P5 5 -200 -100 150 R 50 50 1 1 P
X P6 6 -200 -200 150 R 50 50 1 1 P
X P7 7 -200 -300 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# CONN_01X09
#
DEF CONN_01X09 P 0 40 Y N 1 F N
F0 "P" 0 500 50 H V C CNN
F1 "CONN_01X09" 100 0 50 V V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
Pin_Header_Straight_1X09
Pin_Header_Angled_1X09
Socket_Strip_Straight_1X09
Socket_Strip_Angled_1X09
$ENDFPLIST
DRAW
S -50 -395 10 -405 0 1 0 N
S -50 -295 10 -305 0 1 0 N
S -50 -195 10 -205 0 1 0 N
S -50 -95 10 -105 0 1 0 N
S -50 5 10 -5 0 1 0 N
S -50 105 10 95 0 1 0 N
S -50 205 10 195 0 1 0 N
S -50 305 10 295 0 1 0 N
S -50 405 10 395 0 1 0 N
S -50 450 50 -450 0 1 0 N
X P1 1 -200 400 150 R 50 50 1 1 P
X P2 2 -200 300 150 R 50 50 1 1 P
X P3 3 -200 200 150 R 50 50 1 1 P
X P4 4 -200 100 150 R 50 50 1 1 P
X P5 5 -200 0 150 R 50 50 1 1 P
X P6 6 -200 -100 150 R 50 50 1 1 P
X P7 7 -200 -200 150 R 50 50 1 1 P
X P8 8 -200 -300 150 R 50 50 1 1 P
X P9 9 -200 -400 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# CONN_01X15
#
DEF CONN_01X15 P 0 40 Y N 1 F N
F0 "P" 0 800 50 H V C CNN
F1 "CONN_01X15" 100 0 50 V V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
Pin_Header_Straight_1X15
Pin_Header_Angled_1X15
Socket_Strip_Straight_1X15
Socket_Strip_Angled_1X15
$ENDFPLIST
DRAW
S -50 -695 10 -705 0 1 0 N
S -50 -595 10 -605 0 1 0 N
S -50 -495 10 -505 0 1 0 N
S -50 -395 10 -405 0 1 0 N
S -50 -295 10 -305 0 1 0 N
S -50 -195 10 -205 0 1 0 N
S -50 -95 10 -105 0 1 0 N
S -50 5 10 -5 0 1 0 N
S -50 105 10 95 0 1 0 N
S -50 205 10 195 0 1 0 N
S -50 305 10 295 0 1 0 N
S -50 405 10 395 0 1 0 N
S -50 505 10 495 0 1 0 N
S -50 605 10 595 0 1 0 N
S -50 705 10 695 0 1 0 N
S -50 750 50 -750 0 1 0 N
X P1 1 -200 700 150 R 50 50 1 1 P
X P10 10 -200 -200 150 R 50 50 1 1 P
X P11 11 -200 -300 150 R 50 50 1 1 P
X P12 12 -200 -400 150 R 50 50 1 1 P
X P13 13 -200 -500 150 R 50 50 1 1 P
X P14 14 -200 -600 150 R 50 50 1 1 P
X P15 15 -200 -700 150 R 50 50 1 1 P
X P2 2 -200 600 150 R 50 50 1 1 P
X P3 3 -200 500 150 R 50 50 1 1 P
X P4 4 -200 400 150 R 50 50 1 1 P
X P5 5 -200 300 150 R 50 50 1 1 P
X P6 6 -200 200 150 R 50 50 1 1 P
X P7 7 -200 100 150 R 50 50 1 1 P
X P8 8 -200 0 150 R 50 50 1 1 P
X P9 9 -200 -100 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# D
#
DEF D D 0 40 N N 1 F N
F0 "D" 0 100 50 H V C CNN
F1 "D" 0 -100 50 H V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
Diode_*
D-Pak_TO252AA
*SingleDiode
*_Diode_*
*SingleDiode*
$ENDFPLIST
DRAW
P 2 0 1 6 -50 50 -50 -50 N
P 3 0 1 0 50 50 -50 0 50 -50 F
X K 1 -150 0 100 R 50 50 1 1 P
X A 2 150 0 100 L 50 50 1 1 P
ENDDRAW
ENDDEF
#
# GND
#
DEF GND #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -250 50 H I C CNN
F1 "GND" 0 -150 50 H V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
DRAW
P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N
X GND 1 0 0 0 D 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# MCP6002
#
DEF MCP6002 U 0 10 Y Y 2 F N
F0 "U" 0 150 50 H V L CNN
F1 "MCP6002" 0 -150 50 H V L CNN
F2 "" -100 50 50 H V C CNN
F3 "" 0 150 50 H V C CNN
DRAW
P 4 0 1 6 -200 200 200 0 -200 -200 -200 200 f
X V- 4 -100 -300 150 U 50 50 0 1 W
X V+ 8 -100 300 150 D 50 50 0 1 W
X ~ 1 300 0 100 L 50 50 1 1 O
X - 2 -300 -100 100 R 50 50 1 1 I
X + 3 -300 100 100 R 50 50 1 1 I
X + 5 -300 100 100 R 50 50 2 1 I
X - 6 -300 -100 100 R 50 50 2 1 I
X ~ 7 300 0 100 L 50 50 2 1 O
ENDDRAW
ENDDEF
#
# R
#
DEF R R 0 0 N Y 1 F N
F0 "R" 80 0 50 V V C CNN
F1 "R" 0 0 50 V V C CNN
F2 "" -70 0 50 V V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
R_*
Resistor_*
$ENDFPLIST
DRAW
S -40 -100 40 100 0 1 10 N
X ~ 1 0 150 50 D 50 50 1 1 P
X ~ 2 0 -150 50 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# SW_PUSH
#
DEF SW_PUSH SW 0 40 N N 1 F N
F0 "SW" 150 110 50 H V C CNN
F1 "SW_PUSH" 0 -80 50 H V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
DRAW
S -170 50 170 60 0 1 0 N
P 4 0 1 0 -40 60 -30 90 30 90 40 60 N
X 1 1 -300 0 200 R 50 50 0 1 P I
X 2 2 300 0 200 L 50 50 0 1 P I
ENDDRAW
ENDDEF
#
#End Library

View file

@ -0,0 +1,75 @@
{
"board": {
"active_layer": 0,
"active_layer_preset": "",
"auto_track_width": true,
"hidden_nets": [],
"high_contrast_mode": 0,
"net_color_mode": 1,
"opacity": {
"pads": 1.0,
"tracks": 1.0,
"vias": 1.0,
"zones": 0.6
},
"ratsnest_display_mode": 0,
"selection_filter": {
"dimensions": true,
"footprints": true,
"graphics": true,
"keepouts": true,
"lockedItems": true,
"otherItems": true,
"pads": true,
"text": true,
"tracks": true,
"vias": true,
"zones": true
},
"visible_items": [
0,
1,
2,
3,
4,
5,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
32,
33,
34,
35,
36
],
"visible_layers": "fffffff_ffffffff",
"zone_display_mode": 0
},
"meta": {
"filename": "TenaTesta_ZL1CVD.kicad_prl",
"version": 3
},
"project": {
"files": []
}
}

View file

@ -0,0 +1,320 @@
{
"board": {
"design_settings": {
"defaults": {
"board_outline_line_width": 0.1,
"copper_line_width": 0.2,
"copper_text_size_h": 1.5,
"copper_text_size_v": 1.5,
"copper_text_thickness": 0.3,
"other_line_width": 0.15,
"silk_line_width": 0.15,
"silk_text_size_h": 1.0,
"silk_text_size_v": 1.0,
"silk_text_thickness": 0.15
},
"diff_pair_dimensions": [],
"drc_exclusions": [],
"rules": {
"solder_mask_clearance": 0.0,
"solder_mask_min_width": 0.0
},
"track_widths": [],
"via_dimensions": []
},
"layer_presets": []
},
"boards": [],
"cvpcb": {
"equivalence_files": []
},
"erc": {
"erc_exclusions": [],
"meta": {
"version": 0
},
"pin_map": [
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
2,
0,
1,
0,
0,
1,
0,
2,
2,
2,
2
],
[
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
1,
2
],
[
0,
1,
0,
0,
0,
0,
1,
1,
2,
1,
1,
2
],
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2
],
[
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
2
],
[
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
2,
1,
2,
0,
0,
1,
0,
2,
2,
2,
2
],
[
0,
2,
0,
1,
0,
0,
1,
0,
2,
0,
0,
2
],
[
0,
2,
1,
1,
0,
0,
1,
0,
2,
0,
0,
2
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
],
"rule_severities": {
"bus_definition_conflict": "error",
"bus_entry_needed": "error",
"bus_label_syntax": "error",
"bus_to_bus_conflict": "error",
"bus_to_net_conflict": "error",
"different_unit_footprint": "error",
"different_unit_net": "error",
"duplicate_reference": "error",
"duplicate_sheet_names": "error",
"extra_units": "error",
"global_label_dangling": "warning",
"hier_label_mismatch": "error",
"label_dangling": "error",
"lib_symbol_issues": "warning",
"multiple_net_names": "warning",
"net_not_bus_member": "warning",
"no_connect_connected": "warning",
"no_connect_dangling": "warning",
"pin_not_connected": "error",
"pin_not_driven": "error",
"pin_to_pin": "warning",
"power_pin_not_driven": "error",
"similar_labels": "warning",
"unannotated": "error",
"unit_value_mismatch": "error",
"unresolved_variable": "error",
"wire_dangling": "error"
}
},
"libraries": {
"pinned_footprint_libs": [],
"pinned_symbol_libs": []
},
"meta": {
"filename": "TenaTesta_ZL1CVD.kicad_pro",
"version": 1
},
"net_settings": {
"classes": [
{
"bus_width": 12.0,
"clearance": 0.2,
"diff_pair_gap": 0.25,
"diff_pair_via_gap": 0.25,
"diff_pair_width": 0.2,
"line_style": 0,
"microvia_diameter": 0.3,
"microvia_drill": 0.1,
"name": "Default",
"pcb_color": "rgba(0, 0, 0, 0.000)",
"schematic_color": "rgba(0, 0, 0, 0.000)",
"track_width": 0.25,
"via_diameter": 0.8,
"via_drill": 0.4,
"wire_width": 6.0
}
],
"meta": {
"version": 2
},
"net_colors": null
},
"pcbnew": {
"last_paths": {
"gencad": "",
"idf": "",
"netlist": "",
"specctra_dsn": "",
"step": "",
"vrml": ""
},
"page_layout_descr_file": ""
},
"schematic": {
"annotate_start_num": 0,
"drawing": {
"default_line_thickness": 6.0,
"default_text_size": 50.0,
"field_names": [],
"intersheets_ref_own_page": false,
"intersheets_ref_prefix": "",
"intersheets_ref_short": false,
"intersheets_ref_show": false,
"intersheets_ref_suffix": "",
"junction_size_choice": 3,
"label_size_ratio": 0.25,
"pin_symbol_size": 0.0,
"text_offset_ratio": 0.08
},
"legacy_lib_dir": "",
"legacy_lib_list": [],
"meta": {
"version": 1
},
"net_format_name": "",
"ngspice": {
"fix_include_paths": true,
"fix_passive_vals": false,
"meta": {
"version": 0
},
"model_mode": 0,
"workbook_filename": ""
},
"page_layout_descr_file": "",
"plot_directory": "",
"spice_adjust_passive_values": false,
"spice_external_command": "spice \"%I\"",
"subpart_first_id": 65,
"subpart_id_separator": 0
},
"sheets": [],
"text_variables": {}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,266 @@
EESchema-LIBRARY Version 2.3
#encoding utf-8
#
# +5V
#
DEF +5V #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -150 50 H I C CNN
F1 "+5V" 0 140 50 H V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
DRAW
P 2 0 1 0 -30 50 0 100 N
P 2 0 1 0 0 0 0 100 N
P 2 0 1 0 0 100 30 50 N
X +5V 1 0 0 0 U 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# BNC
#
DEF BNC P 0 40 Y N 1 F N
F0 "P" 10 120 50 H V C CNN
F1 "BNC" 110 -60 50 V V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
BNC_*
bnc
bnc-*
$ENDFPLIST
DRAW
C 0 0 20 0 1 8 N
C 0 0 70 0 1 12 N
X In 1 -150 0 130 R 40 40 1 1 P
X Ext 2 0 -200 130 U 40 40 1 1 P
ENDDRAW
ENDDEF
#
# C
#
DEF C C 0 10 N Y 1 F N
F0 "C" 25 100 50 H V L CNN
F1 "C" 25 -100 50 H V L CNN
F2 "" 38 -150 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
C?
C_????_*
C_????
SMD*_c
Capacitor*
$ENDFPLIST
DRAW
P 2 0 1 20 -80 -30 80 -30 N
P 2 0 1 20 -80 30 80 30 N
X ~ 1 0 150 110 D 40 40 1 1 P
X ~ 2 0 -150 110 U 40 40 1 1 P
ENDDRAW
ENDDEF
#
# CONN_01X07
#
DEF CONN_01X07 P 0 40 Y N 1 F N
F0 "P" 0 400 50 H V C CNN
F1 "CONN_01X07" 100 0 50 V V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
Pin_Header_Straight_1X07
Pin_Header_Angled_1X07
Socket_Strip_Straight_1X07
Socket_Strip_Angled_1X07
$ENDFPLIST
DRAW
S -50 -350 50 350 0 1 0 N
S -50 -295 10 -305 0 1 0 N
S -50 -195 10 -205 0 1 0 N
S -50 -95 10 -105 0 1 0 N
S -50 5 10 -5 0 1 0 N
S -50 105 10 95 0 1 0 N
S -50 205 10 195 0 1 0 N
S -50 305 10 295 0 1 0 N
X P1 1 -200 300 150 R 50 50 1 1 P
X P2 2 -200 200 150 R 50 50 1 1 P
X P3 3 -200 100 150 R 50 50 1 1 P
X P4 4 -200 0 150 R 50 50 1 1 P
X P5 5 -200 -100 150 R 50 50 1 1 P
X P6 6 -200 -200 150 R 50 50 1 1 P
X P7 7 -200 -300 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# CONN_01X09
#
DEF CONN_01X09 P 0 40 Y N 1 F N
F0 "P" 0 500 50 H V C CNN
F1 "CONN_01X09" 100 0 50 V V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
Pin_Header_Straight_1X09
Pin_Header_Angled_1X09
Socket_Strip_Straight_1X09
Socket_Strip_Angled_1X09
$ENDFPLIST
DRAW
S -50 -395 10 -405 0 1 0 N
S -50 -295 10 -305 0 1 0 N
S -50 -195 10 -205 0 1 0 N
S -50 -95 10 -105 0 1 0 N
S -50 5 10 -5 0 1 0 N
S -50 105 10 95 0 1 0 N
S -50 205 10 195 0 1 0 N
S -50 305 10 295 0 1 0 N
S -50 405 10 395 0 1 0 N
S -50 450 50 -450 0 1 0 N
X P1 1 -200 400 150 R 50 50 1 1 P
X P2 2 -200 300 150 R 50 50 1 1 P
X P3 3 -200 200 150 R 50 50 1 1 P
X P4 4 -200 100 150 R 50 50 1 1 P
X P5 5 -200 0 150 R 50 50 1 1 P
X P6 6 -200 -100 150 R 50 50 1 1 P
X P7 7 -200 -200 150 R 50 50 1 1 P
X P8 8 -200 -300 150 R 50 50 1 1 P
X P9 9 -200 -400 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# CONN_01X15
#
DEF CONN_01X15 P 0 40 Y N 1 F N
F0 "P" 0 800 50 H V C CNN
F1 "CONN_01X15" 100 0 50 V V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
Pin_Header_Straight_1X15
Pin_Header_Angled_1X15
Socket_Strip_Straight_1X15
Socket_Strip_Angled_1X15
$ENDFPLIST
DRAW
S -50 -695 10 -705 0 1 0 N
S -50 -595 10 -605 0 1 0 N
S -50 -495 10 -505 0 1 0 N
S -50 -395 10 -405 0 1 0 N
S -50 -295 10 -305 0 1 0 N
S -50 -195 10 -205 0 1 0 N
S -50 -95 10 -105 0 1 0 N
S -50 5 10 -5 0 1 0 N
S -50 105 10 95 0 1 0 N
S -50 205 10 195 0 1 0 N
S -50 305 10 295 0 1 0 N
S -50 405 10 395 0 1 0 N
S -50 505 10 495 0 1 0 N
S -50 605 10 595 0 1 0 N
S -50 705 10 695 0 1 0 N
S -50 750 50 -750 0 1 0 N
X P1 1 -200 700 150 R 50 50 1 1 P
X P2 2 -200 600 150 R 50 50 1 1 P
X P3 3 -200 500 150 R 50 50 1 1 P
X P4 4 -200 400 150 R 50 50 1 1 P
X P5 5 -200 300 150 R 50 50 1 1 P
X P6 6 -200 200 150 R 50 50 1 1 P
X P7 7 -200 100 150 R 50 50 1 1 P
X P8 8 -200 0 150 R 50 50 1 1 P
X P9 9 -200 -100 150 R 50 50 1 1 P
X P10 10 -200 -200 150 R 50 50 1 1 P
X P11 11 -200 -300 150 R 50 50 1 1 P
X P12 12 -200 -400 150 R 50 50 1 1 P
X P13 13 -200 -500 150 R 50 50 1 1 P
X P14 14 -200 -600 150 R 50 50 1 1 P
X P15 15 -200 -700 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# D
#
DEF D D 0 40 N N 1 F N
F0 "D" 0 100 50 H V C CNN
F1 "D" 0 -100 50 H V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
Diode_*
D-Pak_TO252AA
*SingleDiode
*_Diode_*
*SingleDiode*
$ENDFPLIST
DRAW
P 2 0 1 6 -50 50 -50 -50 N
P 3 0 1 0 50 50 -50 0 50 -50 F
X K 1 -150 0 100 R 50 50 1 1 P
X A 2 150 0 100 L 50 50 1 1 P
ENDDRAW
ENDDEF
#
# GND
#
DEF GND #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -250 50 H I C CNN
F1 "GND" 0 -150 50 H V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
DRAW
P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N
X GND 1 0 0 0 D 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# OP275
#
DEF OP275 U 0 10 Y Y 2 F N
F0 "U" 0 150 50 H V L CNN
F1 "OP275" 0 -150 50 H V L CNN
F2 "" -100 50 50 H V C CNN
F3 "" 0 150 50 H V C CNN
ALIAS ADA4075 MCP6002 LM7332
DRAW
P 4 0 1 6 -200 200 200 0 -200 -200 -200 200 f
X V- 4 -100 -300 150 U 50 50 0 1 W
X V+ 8 -100 300 150 D 50 50 0 1 W
X ~ 1 300 0 100 L 50 50 1 1 O
X - 2 -300 -100 100 R 50 50 1 1 I
X + 3 -300 100 100 R 50 50 1 1 I
X + 5 -300 100 100 R 50 50 2 1 I
X - 6 -300 -100 100 R 50 50 2 1 I
X ~ 7 300 0 100 L 50 50 2 1 O
ENDDRAW
ENDDEF
#
# R
#
DEF R R 0 0 N Y 1 F N
F0 "R" 80 0 50 V V C CNN
F1 "R" 0 0 50 V V C CNN
F2 "" -70 0 50 V V C CNN
F3 "" 0 0 50 H V C CNN
$FPLIST
R_*
Resistor_*
$ENDFPLIST
DRAW
S -40 -100 40 100 0 1 10 N
X ~ 1 0 150 50 D 50 50 1 1 P
X ~ 2 0 -150 50 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# SW_PUSH
#
DEF SW_PUSH SW 0 40 N N 1 F N
F0 "SW" 150 110 50 H V C CNN
F1 "SW_PUSH" 0 -80 50 H V C CNN
F2 "" 0 0 50 H V C CNN
F3 "" 0 0 50 H V C CNN
DRAW
S -170 50 170 60 0 1 0 N
P 4 0 1 0 -40 60 -30 90 30 90 40 60 N
X 1 1 -300 0 200 R 50 50 0 1 P I
X 2 2 300 0 200 L 50 50 0 1 P I
ENDDRAW
ENDDEF
#
#End Library

3
pcb/sym-lib-table Normal file
View file

@ -0,0 +1,3 @@
(sym_lib_table
(lib (name "TenaTesta_ZL1CVD-rescue")(type "Legacy")(uri "${KIPRJMOD}/TenaTesta_ZL1CVD-rescue.lib")(options "")(descr ""))
)

View file

@ -202,11 +202,11 @@ def cc_dataReceiverThread():
bytesToRead = ser.inWaiting() bytesToRead = ser.inWaiting()
if bytesToRead > 0: if bytesToRead > 0:
incoming = list(ser.read(64)) incoming = list(ser.read(64))
#print(incoming)
# 2. process the received data # 2. process the received data
for c in incoming: for c in incoming:
c = int(binascii.hexlify(c), 16) #print(c)
# call the cc_state specific function to process the currently received byte # call the cc_state specific function to process the currently received byte
cc_state_fn[cc_state](c) cc_state_fn[cc_state](c)
@ -340,7 +340,7 @@ def openSerialDevice(d):
ser = serial.Serial(d) ser = serial.Serial(d)
except: except:
print "ERROR (1): Can't open the serial device " + d print("ERROR (1): Can't open the serial device " + d)
exit(1) exit(1)
# Toggle DTR to reset Arduino # Toggle DTR to reset Arduino
@ -363,7 +363,7 @@ def openSerialDevice(d):
rtscts=0,\ rtscts=0,\
timeout=0) timeout=0)
except: except:
print "ERROR (2): Can't open the serial device " + d print("ERROR (2): Can't open the serial device " + d)
exit(2) exit(2)
##### #####
@ -471,9 +471,18 @@ def calc_data():
old = 1000 old = 1000
for r in sorted(meas_vswr_f.items(), key=operator.itemgetter(1)): for r in sorted(meas_vswr_f.items(), key=operator.itemgetter(1)):
vswr_marker.append(meas_freq.index(r[0])) vswr_marker.append(meas_freq.index(r[0]))
if r > old:
'''
print("\ntype(r) = " + str(type(r)) + " = " + str(r))
print("type(old) = " + str(type(old)) + " = " + str(old))
type(r) = <class 'tuple'> = (50, 1.1784989858012171)
type(old) = <class 'int'> = 1000
'''
if r[1] > old:
i += 1 i += 1
old = r old = r[1]
if i == 5: if i == 5:
break break
@ -543,7 +552,7 @@ if __name__ == "__main__":
if args.device != None: if args.device != None:
device = args.device device = args.device
print "SWR meter measurement software v0.1 by Kai Lauterbach (me@klaute.de)\n---\n" print("SWR meter measurement software v0.1 by Kai Lauterbach (me@klaute.de)\n---\n")
openSerialDevice(device) openSerialDevice(device)
@ -554,7 +563,7 @@ if __name__ == "__main__":
# 3. get and process the commandline arguments/parameter # 3. get and process the commandline arguments/parameter
if args.start_freq != None: if args.start_freq != None:
print "Set start frequency to: " + user_friendly_freq(args.start_freq) print("Set start frequency to: " + user_friendly_freq(args.start_freq))
sendSerialData([CC_CMD_SET_START_FREQ, sendSerialData([CC_CMD_SET_START_FREQ,
(args.start_freq & 0xff000000) >> 24, (args.start_freq & 0xff000000) >> 24,
(args.start_freq & 0x00ff0000) >> 16, (args.start_freq & 0x00ff0000) >> 16,
@ -563,7 +572,7 @@ if __name__ == "__main__":
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.end_freq != None: if args.end_freq != None:
print "Set the end frequency to: " + user_friendly_freq(args.end_freq) print("Set the end frequency to: " + user_friendly_freq(args.end_freq))
sendSerialData([CC_CMD_SET_END_FREQ, sendSerialData([CC_CMD_SET_END_FREQ,
(args.end_freq & 0xff000000) >> 24, (args.end_freq & 0xff000000) >> 24,
(args.end_freq & 0x00ff0000) >> 16, (args.end_freq & 0x00ff0000) >> 16,
@ -572,7 +581,7 @@ if __name__ == "__main__":
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.step_freq != None: if args.step_freq != None:
print "Set the frequency step size to: " + user_friendly_freq(args.step_freq) print("Set the frequency step size to: " + user_friendly_freq(args.step_freq))
sendSerialData([CC_CMD_SET_FREQ_STEP, sendSerialData([CC_CMD_SET_FREQ_STEP,
(args.step_freq & 0xff000000) >> 24, (args.step_freq & 0xff000000) >> 24,
(args.step_freq & 0x00ff0000) >> 16, (args.step_freq & 0x00ff0000) >> 16,
@ -581,44 +590,44 @@ if __name__ == "__main__":
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.intervall != None: if args.intervall != None:
print "Set the time intervall to %d milliseconds" % (args.intervall) print("Set the time intervall to %d milliseconds" % (args.intervall))
sendSerialData([CC_CMD_SET_INTERVALL, sendSerialData([CC_CMD_SET_INTERVALL,
(args.intervall & 0x0000ff00) >> 8, (args.intervall & 0x0000ff00) >> 8,
(args.intervall & 0x000000ff)]) (args.intervall & 0x000000ff)])
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.drive_str != None: if args.drive_str != None:
print "Set the output drive strength to %d mA" % ((args.drive_str + 1) * 2) print("Set the output drive strength to %d mA" % ((args.drive_str + 1) * 2))
sendSerialData([CC_CMD_SET_DRIVE_STRENGTH, sendSerialData([CC_CMD_SET_DRIVE_STRENGTH,
args.drive_str]) args.drive_str])
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.start_meas == True: if args.start_meas == True:
print "\nStarting the measurement process..." print("\nStarting the measurement process...")
sendSerialData([CC_CMD_START_MEASUREMENT]) sendSerialData([CC_CMD_START_MEASUREMENT])
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.get_config == True and args.start_meas == False: if args.get_config == True and args.start_meas == False:
print "Read configuration values..." print("Read configuration values...")
sendSerialData([CC_CMD_GET_CONFIG]) sendSerialData([CC_CMD_GET_CONFIG])
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.enable_clk != None: if args.enable_clk != None:
if args.enable_clk < 0 or args.enable_clk > 2: if args.enable_clk < 0 or args.enable_clk > 2:
args.enable_clk = 0 args.enable_clk = 0
print "Enabling clock output channel: %d" % (args.enable_clk) print("Enabling clock output channel: %d" % (args.enable_clk))
sendSerialData([CC_CMD_EN_CLK, args.enable_clk]) sendSerialData([CC_CMD_EN_CLK, args.enable_clk])
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.disable_clk != None and args.enable_clk == None: if args.disable_clk != None and args.enable_clk == None:
if args.disable_clk < 0 or args.disable_clk > 2: if args.disable_clk < 0 or args.disable_clk > 2:
args.disable_clk = 0 args.disable_clk = 0
print "Disabling clock output channel: %d" % (args.disable_clk) print("Disabling clock output channel: %d" % (args.disable_clk))
sendSerialData([CC_CMD_DIS_CLK, args.disable_clk]) sendSerialData([CC_CMD_DIS_CLK, args.disable_clk])
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.save_config == True: if args.save_config == True:
print "Save default configuration values..." print("Save default configuration values...")
sendSerialData([CC_CMD_SAV_DFLT]) sendSerialData([CC_CMD_SAV_DFLT])
dataSend = dataSend + 1 dataSend = dataSend + 1
@ -626,7 +635,7 @@ if __name__ == "__main__":
plt.ion() plt.ion()
fig1, axarr = plt.subplots(3, sharex=True) fig1, axarr = plt.subplots(3, sharex=True)
fig1.canvas.set_window_title("SWR meter measurement results") fig1.suptitle("SWR meter measurement results")
update_graph() update_graph()
@ -647,7 +656,7 @@ if __name__ == "__main__":
pass pass
elif e[1] == MSG_TYPE_ANSWER_NOK: elif e[1] == MSG_TYPE_ANSWER_NOK:
print "recv: NOT OK on %d" % (dataSend) print("recv: NOT OK on %d" % (dataSend))
elif e[1] == MSG_TYPE_MEAS_FREQ_INFO: elif e[1] == MSG_TYPE_MEAS_FREQ_INFO:
#print "recv: FREQ INFO" #print "recv: FREQ INFO"
@ -675,9 +684,9 @@ if __name__ == "__main__":
elif e[1] == MSG_TYPE_CONFIG: elif e[1] == MSG_TYPE_CONFIG:
#print "recv: CONFIG" #print "recv: CONFIG"
if args.start_meas == True: if args.start_meas == True:
print "\nConfiguration used for measurement:" print("\nConfiguration used for measurement:")
else: else:
print "\nConfiguration:" print("\nConfiguration:")
start_freq = e[3][0] << 24 start_freq = e[3][0] << 24
start_freq += e[3][1] << 16 start_freq += e[3][1] << 16
start_freq += e[3][2] << 8 start_freq += e[3][2] << 8
@ -694,12 +703,12 @@ if __name__ == "__main__":
intervall += e[3][13] intervall += e[3][13]
drive_str = e[3][14] drive_str = e[3][14]
print "start_freq = " + user_friendly_freq(start_freq) print("start_freq = " + user_friendly_freq(start_freq))
print "end_freq = " + user_friendly_freq(end_freq) print("end_freq = " + user_friendly_freq(end_freq))
print "step_freq = " + user_friendly_freq(step_freq) print("step_freq = " + user_friendly_freq(step_freq))
print "intervall = " + str(intervall) + " ms" print("intervall = " + str(intervall) + " ms")
print "drive_str = " + str((drive_str + 1) * 2) + " mA" print("drive_str = " + str((drive_str + 1) * 2) + " mA")
print "" print("")
if args.start_meas == True and config_read == False: if args.start_meas == True and config_read == False:
dataSend = dataSend + 1 + ((end_freq - start_freq) / step_freq) dataSend = dataSend + 1 + ((end_freq - start_freq) / step_freq)
@ -708,7 +717,7 @@ if __name__ == "__main__":
elif e[1] == MSG_TYPE_MEAS_END_INFO: elif e[1] == MSG_TYPE_MEAS_END_INFO:
#print "recv: END INFO" #print "recv: END INFO"
sys.stdout.write("\r100.00 % done \n") sys.stdout.write("\r100.00 % done \n")
print "" print("")
#if (args.output_file != None or args.show_graph == True) and args.start_meas == True: #if (args.output_file != None or args.show_graph == True) and args.start_meas == True:
#calc_data() #calc_data()
@ -724,19 +733,19 @@ if __name__ == "__main__":
FILE.write("%f;%f;%f;%f;%d;%d\n" % (meas_freq[j], m, meas_imp[j], i, meas_data[j][1], meas_data[j][2])) FILE.write("%f;%f;%f;%f;%d;%d\n" % (meas_freq[j], m, meas_imp[j], i, meas_data[j][1], meas_data[j][2]))
j = j + 1 j = j + 1
FILE.close() FILE.close()
print "Output file " + args.output_file + " written." print("Output file " + args.output_file + " written.")
print "First minimum VSWR %0.6f found at freqency %s" % (min_vswr[0], user_friendly_freq(min_vswr[1])) print("First minimum VSWR %0.6f found at freqency %s" % (min_vswr[0], user_friendly_freq(min_vswr[1])))
##### show the graph ##### show the graph
if args.show_graph == True and args.start_meas == True: if args.show_graph == True and args.start_meas == True:
# TODO wait for close # TODO wait for close
update_graph() update_graph()
print "Please close the window to exit the program." print("Please close the window to exit the program.")
plt.show(block=True) plt.show(block=True)
else: else:
print "err: unknown type 0x%02x" % (e[1]) print("err: unknown type 0x%02x" % (e[1]))
break break
thread_lock.acquire() thread_lock.acquire()
@ -753,7 +762,7 @@ if __name__ == "__main__":
timeout = timeout + 1 timeout = timeout + 1
if timeout >= TIMEOUT_CNT_MAX: if timeout >= TIMEOUT_CNT_MAX:
print "Timeout happened" print("Timeout happened")
# 5. stop data processing thread # 5. stop data processing thread
cc_stopReceiverThread() cc_stopReceiverThread()