Two new functions added to set and get the clock correction factor to the si5351 chip. Also replaced the a0 a1 labels with fwd and ref text.
This commit is contained in:
parent
9ab691f081
commit
21d5fb58dc
4 changed files with 61 additions and 15 deletions
|
@ -31,6 +31,8 @@ void cc_getConfig(void);
|
|||
void cc_enableClk(void);
|
||||
void cc_disableClk(void);
|
||||
void cc_saveDefaults(void);
|
||||
void cc_setClkCorrection(void);
|
||||
void cc_getClkCorrection(void);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
@ -51,6 +53,8 @@ uint8_t cc_commands[] = {
|
|||
CC_CMD_EN_CLK,
|
||||
CC_CMD_DIS_CLK,
|
||||
CC_CMD_SAV_DFLT,
|
||||
CC_CMD_SET_CLK_CORR,
|
||||
CC_CMD_GET_CLK_CORR,
|
||||
};
|
||||
|
||||
void (*cc_cmd_functions[])() = {
|
||||
|
@ -64,6 +68,8 @@ void (*cc_cmd_functions[])() = {
|
|||
CC_CMD_EN_CLK_FUNC,
|
||||
CC_CMD_DIS_CLK_FUNC,
|
||||
CC_CMD_SAV_DFLT_FUNC,
|
||||
CC_CMD_SET_CLK_CORR_FUNC,
|
||||
CC_CMD_GET_CLK_CORR_FUNC,
|
||||
};
|
||||
|
||||
uint8_t cc_cmd_data_to_read[] = {
|
||||
|
@ -77,6 +83,8 @@ uint8_t cc_cmd_data_to_read[] = {
|
|||
CC_CMD_EN_CLK_DATA_TO_READ,
|
||||
CC_CMD_DIS_CLK_DATA_TO_READ,
|
||||
CC_CMD_SAV_DFLT_DATA_TO_READ,
|
||||
CC_CMD_SET_CLK_CORR_DATA_TO_READ,
|
||||
CC_CMD_GET_CLK_CORR_DATA_TO_READ,
|
||||
};
|
||||
|
||||
uint8_t cc_read_data[CC_READ_DATA_MAX];
|
||||
|
@ -397,6 +405,38 @@ void cc_saveDefaults(void)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
void cc_setClkCorrection(void)
|
||||
{
|
||||
uint32_t tmp_corr = (uint32_t)cc_read_data[0] << 24;
|
||||
tmp_corr += (uint32_t)cc_read_data[1] << 16;
|
||||
tmp_corr += (uint32_t)cc_read_data[2] << 8;
|
||||
tmp_corr += (uint32_t)cc_read_data[3];
|
||||
|
||||
si5351.set_correction(tmp_corr);
|
||||
|
||||
Serial.write(MSG_SOM1);
|
||||
Serial.write(MSG_SOM2);
|
||||
Serial.write(MSG_TYPE_ANSWER_OK);
|
||||
Serial.write(MSG_EOM1);
|
||||
Serial.write(MSG_EOM2);
|
||||
}
|
||||
|
||||
void cc_getClkCorrection(void)
|
||||
{
|
||||
uint32_t tmp_corr = si5351.get_correction();
|
||||
|
||||
Serial.write(MSG_SOM1);
|
||||
Serial.write(MSG_SOM2);
|
||||
Serial.write((uint8_t)((tmp_corr & 0xff000000) >> 24));
|
||||
Serial.write((uint8_t)((tmp_corr & 0x00ff0000) >> 16));
|
||||
Serial.write((uint8_t)((tmp_corr & 0x0000ff00) >> 8));
|
||||
Serial.write((uint8_t) (tmp_corr & 0x000000ff));
|
||||
Serial.write(MSG_EOM1);
|
||||
Serial.write(MSG_EOM2);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void cc_init()
|
||||
{
|
||||
cc_state = CC_STATE_READ_SOM1;
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
#define CC_CMD_EN_CLK 0x20
|
||||
#define CC_CMD_DIS_CLK 0x21
|
||||
#define CC_CMD_SAV_DFLT 0x22
|
||||
#define CC_CMD_SET_CLK_CORR 0x23
|
||||
#define CC_CMD_GET_CLK_CORR 0x24
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
@ -58,6 +60,8 @@
|
|||
#define CC_CMD_EN_CLK_FUNC &cc_enableClk
|
||||
#define CC_CMD_DIS_CLK_FUNC &cc_disableClk
|
||||
#define CC_CMD_SAV_DFLT_FUNC &cc_saveDefaults
|
||||
#define CC_CMD_SET_CLK_CORR_FUNC &cc_setClkCorrection
|
||||
#define CC_CMD_GET_CLK_CORR_FUNC &cc_getClkCorrection
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
@ -71,10 +75,12 @@
|
|||
#define CC_CMD_EN_CLK_DATA_TO_READ 1
|
||||
#define CC_CMD_DIS_CLK_DATA_TO_READ 1
|
||||
#define CC_CMD_SAV_DFLT_DATA_TO_READ 0
|
||||
#define CC_CMD_SET_CLK_CORR_DATA_TO_READ 4
|
||||
#define CC_CMD_GET_CLK_CORR_DATA_TO_READ 0
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define CC_READ_DATA_MAX 64
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo 160m
|
||||
python meas.py -o 160m.csv -s 1810000 -e 2000000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
|
||||
python meas.py -o 160m.csv -s 1810000 -e 2000000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
|
||||
echo 80m
|
||||
python meas.py -o 80m.csv -s 3500000 -e 3800000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
|
||||
python meas.py -o 80m.csv -s 3500000 -e 3800000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
|
||||
echo 40m
|
||||
python meas.py -o 40m.csv -s 7000000 -e 7200000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
|
||||
python meas.py -o 40m.csv -s 7000000 -e 7200000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
|
||||
echo 30m
|
||||
python meas.py -o 30m.csv -s 10100000 -e 10150000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
|
||||
python meas.py -o 30m.csv -s 10100000 -e 10150000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
|
||||
echo 20m
|
||||
python meas.py -o 20m.csv -s 14000000 -e 14350000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
|
||||
python meas.py -o 20m.csv -s 14000000 -e 14350000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
|
||||
echo 17m
|
||||
python meas.py -o 17m.csv -s 18068000 -e 18168000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
|
||||
python meas.py -o 17m.csv -s 18068000 -e 18168000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
|
||||
echo 15m
|
||||
python meas.py -o 15m.csv -s 21000000 -e 21450000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
|
||||
python meas.py -o 15m.csv -s 21000000 -e 21450000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
|
||||
echo 12m
|
||||
python meas.py -o 12m.csv -s 24890000 -e 24990000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
|
||||
python meas.py -o 12m.csv -s 24890000 -e 24990000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
|
||||
echo 10m
|
||||
python meas.py -o 10m.csv -s 28000000 -e 29700000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
|
||||
python meas.py -o 10m.csv -s 28000000 -e 29700000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
|
||||
echo 6m
|
||||
python meas.py -o 6m.csv -s 50080000 -e 51000000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
|
||||
python meas.py -o 6m.csv -s 50080000 -e 51000000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
|
||||
echo 2m
|
||||
python meas.py -o 2m.csv -s 144000000 -e 146000000 -i 1 -p 1000 -d /dev/ttyUSB0 -m
|
||||
python meas.py -o 2m.csv -s 144000000 -e 146000000 -i 1 -p 1000 -d /dev/ttyUSB0 -m -g
|
||||
|
||||
echo 70cm and up is not supported
|
||||
|
||||
|
|
|
@ -500,8 +500,8 @@ def update_graph():
|
|||
x = arange(start_freq, end_freq, step_freq)
|
||||
lvswr, = axarr[0].plot(x[0], [1], label='VSWR', markevery=[vswr_marker[0]], markersize=4, marker="o", markerfacecolor="r")
|
||||
limp, = axarr[1].plot(x[0], [50], label='impedance', markevery=[vswr_marker[0]], markersize=4, marker="o", markerfacecolor="r")
|
||||
la0, = axarr[2].plot(x[0], [512], label='a0')
|
||||
la1, = axarr[2].plot(x[0], [512], label='a1')
|
||||
la0, = axarr[2].plot(x[0], [512], label='fwd')
|
||||
la1, = axarr[2].plot(x[0], [512], label='ref')
|
||||
|
||||
axarr[0].legend(handles=[lvswr])
|
||||
axarr[0].set_xlim([start_freq, end_freq])
|
||||
|
@ -716,7 +716,7 @@ if __name__ == "__main__":
|
|||
##### generate the output CSV file
|
||||
if args.output_file != None and args.start_meas == True:
|
||||
FILE = open(args.output_file, "w")
|
||||
FILE.write("freqency;ratio;impedance;drive;a0;a1\n")
|
||||
FILE.write("freqency;ratio;impedance;drive;fwd;ref\n")
|
||||
j = 0
|
||||
i = ((drive_str + 1) * 2.0) / 1000.0
|
||||
|
||||
|
|
Loading…
Reference in a new issue