Python GUI for Arduino controlled AD9959 DDS board
You want to determine the Serial Number column in the current_settings.csv
.
Win+R
>devmgmt.msc
to open Device Manager (or type the name in the search bar).- In
Ports (COM & LPT)
a list of of COM ports are found. - Unplug/re-plug the Arduino to determine which port is of interest and double click that entry.
- Go to
Details
>Property
>Device instance path
, the string in red box is what to put in the Serial Number column.
You want to tune for the PDH signal, the EOM and LO signals coming by two channels of DDS board.
Since in a PDH set-up, only the phase difference between EOM drive and LO matters, we can change the phase of LO while keeping that of EOM drive fixed. Assume LO on channel 3 and EOM drive on channel 0, this is achieved below.
# Assume the name of Arduino is 'local', LO on channel 3 and EOM drive on channel 0
DDSSingleChannelBack(DDSSingleChannelWriter('local', 3, [0]))
This scenario is what initiated the project, so most capabilities of the program focus on the ease of this process.
The DDSSingleChannelWriter
object expects 3 arguments as its input. Parameters are:
DDSSingleChannelWriter(name, channel, shared_channels)
name
: The "Name" column fromcurrent_settings.csv
;channel
: The channel that phase change applies to;shared_channels
: The channels, apart from that specified inchannel
, that frequency change applies to.
In a PDH tuning scenario, channel
and shared_channels
refers to either LO/EOM drive.
After launching the program, you want to know what the buttons, textbox, slider, etc. do.
After running the script, a window would pop up. This is the playground of all tuning. An anatomy is as follows.
A typical PDH tuning procedure is as follows:
- The EOM frequency is measured from spectrum analyzer and is around
$58.78,\mathrm{MHz}$ . So the filecurrent_settings.csv
is edited with parameter saved. - The script is run and the resonance peak is found by minimizing EOM reflection. A few clicks on the up/down button shows a trend and a minimum is found quickly. The script outputs tuning history to terminal.
- The PDH signal can be seen, but the phase is not correct. So the slider is dragged until most symmetric pattern is found.
- The parameters are deemed optimal so they should be stored in Arduino's EEPROM, which can be achieve by just clicking
Upload
.
- You want to make sure the upload is successful so click
Download
.
- The tuning is finished so the window is closed and you're prompted to decided whether or not to upload the parameter to EEPROM. Since they're just uploaded, this time
No
is clicked.
- Finally, you're prompted to edit the entry
current_settings.csv
, such that it records the latest parameters stored in EEPROM.
You want to make DDS board serve as a four-channel sine-wave generator.
Just create four UIs, one for each channel, as follows:
# Assume the name of Arduino is 'local'
for ch in range(4):
DDSSingleChannelBack(DDSSingleChannelWriter('local', ch))
In this situation, upload feature needs to be used with care. The logic of uploading(updating) is this: for each instance of DDSSingleChannelWriter
the frequency & phase of only channel
and shared_channels
are uploaded to EEPROM (updated to AD9959 chip). In our case, channel=ch
and shared_channels=[]
, so when Upload
button is clicked, only one channel is updated to EEPROM.
Note that although there's no restriction preventing you write something like:
# Channel 0, 1, 2 shares the same frequency;
# and the phase/frequency of channel 1 and channel needs to be tuned simultaneously
DDSSingleChannelBack(DDSSingleChannelWriter('local', 1, [0, 1, 2]))
DDSSingleChannelBack(DDSSingleChannelWriter('local', 2, [0, 1, 2]))
It should be understood that updating frequency from one window does not affect the frequency in the other.
Also note that if you have two boards named local1
and local2
, and you want to use them simultaneously, then two Python script can be created each controlling one board.