Difference between revisions of "BG7TBL"
(→Spectrum analyzer: + code sample & ref.) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 37: | Line 37: | ||
=== Query firmware === | === Query firmware === | ||
* Send | * Send 0x8f+"v" | ||
The answer should be in hex: | The answer should be in hex: | ||
* | * 77 | ||
Where the | Where the returned byte is the firmware version, 0x77 = 119 = 'w'. | ||
<pre> | |||
#!/usr/bin/python | |||
import serial | |||
ser = serial.Serial('/dev/ttyUSB0', 57600, timeout=1) # Linux first FTDI | |||
ser.write("\x8f" + "v") | |||
print("version is " + ser.read()) | |||
</pre> | |||
=== Signal generator === | === Signal generator === | ||
Line 55: | Line 64: | ||
* 400 000 000 / 10 | * 400 000 000 / 10 | ||
* f040000000 | * f040000000 | ||
<pre> | |||
#!/usr/bin/python | |||
import sys, serial | |||
ser = serial.Serial('/dev/ttyUSB0', 57600, timeout=1) # Linux first FTDI | |||
# sys.argv[1] is frequency in Herz | |||
cmd = "\x8f" + "f" + '{:09d}'.format(int(sys.argv[1])/10) | |||
ser.write(cmd) | |||
</pre> | |||
=== Spectrum analyzer === | === Spectrum analyzer === | ||
Line 61: | Line 79: | ||
https://github.com/DoYouKnow/BG7TBL_Reader | https://github.com/DoYouKnow/BG7TBL_Reader | ||
Here is a minimal code for an 'x' sweep <small>(the protocol is described in chapter 6 of http://www.dl4jal.eu/LinNWT_doc_en.pdf )</small>. The device sends back the expected number of bytes but it seems I have to divide the frequency by 10... (?). | |||
<pre> | |||
#!/usr/bin/python | |||
import sys, serial, struct | |||
start_frequency = 100000000 # FM band | |||
increment = 20000 | |||
steps = 2000 | |||
# | |||
# 'x' sweep (writing the command returns (4 * steps) bytes (what is it, I don't know) | |||
# | |||
cmd = "\x8f" + "x" + '{:09d}{:08d}{:04d}'.format(start_frequency/10, increment, steps) | |||
ser = serial.Serial('/dev/ttyUSB0', 57600, timeout=100) # Linux first FTDI | |||
ser.write(cmd) | |||
rsp = ser.read(4 * steps) | |||
if len(rsp) < (4 * steps): | |||
sys.stderr.write("Warning : Did not read enough measures! Try increasing the timeout\n") | |||
steps = len(rsp)/4 # adapt to the number of measures read | |||
val_tab = struct.unpack_from("<" + "h"*2*steps, rsp) # 2 * steps 'little endian shorts' | |||
for i in range(0, steps): | |||
print(val_tab[2*i]) # channel A (A and B are interleaved) | |||
</pre> |
Latest revision as of 13:13, 21 May 2018
Status | planned |
---|---|
Frequency (user) | 138MHz-4.4GHz |
Waveforms | sine (fixed) |
Amplitude | ? V |
Connectivity | USB |
The BG7TBL USB RF Signal Generator is a PC-based function generator. It has no external controls, requiring a USB connection to a computer.
Software to run this hardware can be found here http://www.dl4jal.eu/.
This device can be bought on ebay for ca $65. Search for "138MHz-4.4GHz". There is a version with the ADF4351 instead that will give you more range (35MHz-4.4GHz).
Hardware
- Microcontroller: Atmel Atmega 8L
- Wideband Synthesizer: ADF4350
- USB to Serial: FTDI FT232RL
- Logarithmic Amplifier AD8307
- Mixer: IAM 81008
- LDO: AMS1117
Photos
Protocol
Baud 57600, 8n1
The protocol is binary serial based.
Query firmware
- Send 0x8f+"v"
The answer should be in hex:
- 77
Where the returned byte is the firmware version, 0x77 = 119 = 'w'.
#!/usr/bin/python import serial ser = serial.Serial('/dev/ttyUSB0', 57600, timeout=1) # Linux first FTDI ser.write("\x8f" + "v") print("version is " + ser.read())
Signal generator
Setting frequency
To set a frequency send:
- 0x8f
Then f and then the frequency divided by 10 with leading zeroes. For example this is the payload for 400MHz.
- 400 000 000 / 10
- f040000000
#!/usr/bin/python import sys, serial ser = serial.Serial('/dev/ttyUSB0', 57600, timeout=1) # Linux first FTDI # sys.argv[1] is frequency in Herz cmd = "\x8f" + "f" + '{:09d}'.format(int(sys.argv[1])/10) ser.write(cmd)
Spectrum analyzer
The protocol is briefly described in the source code here:
https://github.com/DoYouKnow/BG7TBL_Reader
Here is a minimal code for an 'x' sweep (the protocol is described in chapter 6 of http://www.dl4jal.eu/LinNWT_doc_en.pdf ). The device sends back the expected number of bytes but it seems I have to divide the frequency by 10... (?).
#!/usr/bin/python import sys, serial, struct start_frequency = 100000000 # FM band increment = 20000 steps = 2000 # # 'x' sweep (writing the command returns (4 * steps) bytes (what is it, I don't know) # cmd = "\x8f" + "x" + '{:09d}{:08d}{:04d}'.format(start_frequency/10, increment, steps) ser = serial.Serial('/dev/ttyUSB0', 57600, timeout=100) # Linux first FTDI ser.write(cmd) rsp = ser.read(4 * steps) if len(rsp) < (4 * steps): sys.stderr.write("Warning : Did not read enough measures! Try increasing the timeout\n") steps = len(rsp)/4 # adapt to the number of measures read val_tab = struct.unpack_from("<" + "h"*2*steps, rsp) # 2 * steps 'little endian shorts' for i in range(0, steps): print(val_tab[2*i]) # channel A (A and B are interleaved)