Schlabonski / evalcontrol

A minimalistic python library to control the AD9959 DDS Evaluation Board.
3 stars 8 forks source link

question: how to use the evalcontrol app under Ubuntu 16.04 #3

Closed satfan52 closed 6 years ago

satfan52 commented 6 years ago

Hello,

I have installed your application under Ubuntu 16.04 and I think I meet all the dependencies( PyUSB, libsub), but I do not have much success using it so far. I just want to set the frequency and phase of each of the 4 port, not much more for the time being. I am running the latest version of Ubuntu 16.04.

I am trying to use your application with an AD9958/9959 control board sold on ebay (see link below) and that works fine with the evaluation board software under Windows 10 ( I have tested it ok on a dedicated native windows 10 PC )

https://www.ebay.com/itm/4-channel-AD9959-DDS-Generator-Module-USB2-0-control-board/152605192513?hash=item2387fa7141:g:8-IAAOSwbopZVUiV

Here is the error that I get:

root@abc:~/evalcontrol# ./set_frequency_example.py import: unable to open image evalcontrol': Is a directory @ error/blob.c/OpenBlob/2712. ./set_frequency_example.py: line 3: syntax error near unexpected token(' ./set_frequency_example.py: line 3: `evaluation_board = evalcontrol.AD9959()'

If instead I use ;

root@abc:~/evalcontrol# python3 ./set_frequency_example.py Traceback (most recent call last): File "./set_frequency_example.py", line 3, in evaluation_board = evalcontrol.AD9959() File "/home/peter/evalcontrol/evalcontrol/ad9959.py", line 43, in init assert len(devs) > 0, dev_mess AssertionError: No devices with matching vID/pID 1110/60965 found! Exception ignored in: <bound method AD9959.del of <evalcontrol.ad9959.AD9959 object at 0x7f20aaa26438>> Traceback (most recent call last): File "/home/peter/evalcontrol/evalcontrol/ad9959.py", line 83, in del usb.util.dispose_resources(self.dev) AttributeError: 'AD9959' object has no attribute 'dev'

Please provide me some guidance on on how to use your app. I really would like to try to avoid using my windows 7 PC, not my favourite os ;-)

Thanks Peter

Schlabonski commented 6 years ago

Hi Peter,

first of all, I'm happy that you found this little library and will try to help you get it running on your system! It looks like the AD9959 is not detected properly on your system as indicated by

No devices with matching vID/pID 1110/60965 found!

Could you post the output of lsusb? I fear that the error is caused by a fundamental issue I have not gotten hold of yet: the boards' USB controller needs to be initialized by a windows machine that has the AD9959 driver installed (i.e. plug it into your windows PC and wait until the status LED CR2 flashes). When this is done, you can use evalcontrol to communicate with your device as long as the board remains powered up. In our lab we sometimes operate the boards for months without connecting them to a windows PC.

Cheers Fabian

P.S.: The second method is the correct one to launch the script.

satfan52 commented 6 years ago

Hi Fabian,

Thank you for your answer. Please find below the output of lsusb. As you can read the output returned for the analogue device seems to me quite strange, it seems to me inverted !

root@abc:~/Desktop/quisk-4.1.12# lsusb Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 002: ID 058f:9520 Alcor Micro Corp. EMV Certified Smart Card Reader Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 004: ID 058f:6362 Alcor Micro Corp. Flash Card Reader/Writer Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 003 Device 005: ID 062a:3286 Creative Labs Nano Receiver [Sandstrom Laser Mouse SMWLL11] Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 008 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 007 Device 015: ID 0456:ee24 Analog Devices, Inc. Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Please note that the led on my board does not flashes as the board that I am using is not the original model from Analogue Device but some Chinese implementation (there is only one led and it stays red all the time).

I can use this board successfully on my Windows 10 PC (yes 10 not 7, I made an error in the initial post, which is now corrected ); the detection of the board is immediate and the official evaluation control software of Analogue Device works as it should. The board also works as it should, I have tested it ok in this environment.

Maybe it will also help you to know that I was unable to use the board using Virtualbox and Windows 7 (using Ubuntu 16.04 as the host). The USB is detected ok by virtualbox and I can flash the board with the official firmware download application without any problem, but the official evaluation board software will not detect the board in this set-up (though it detects the driver). I have checked with the seller on ebay, and it seems a known issue for which no one has found a solution yet.

Please also note that I only have one USB plug on this board, there does seems to be any easy way of powering the board via an independent power supply so I can easily disconnect the USB plug and move it (without interrupting the power supply) from my windows 10 PC to my Ubuntu 16.04 PC. However I guess I could walk around that problem easily if needed by finding a way to power up the board separately of the USB plug.

Thanks again for your help Fabian! Have a great week!

Peter

Schlabonski commented 6 years ago

Hi Peter,

it looks to me like the board has not been initialized yet. In this case it is shown with the product ID ee24, whereas when initialized it has ee25.

In order to get the board working with evalcontrol you will have to find a way to power it externally. Then the following procedure should work:

  1. Power up the board.
  2. Connect it to a Windows machine and check that it has been initialized e.g. by setting a frequency.
  3. Do not disconnect the board from power.
  4. Connect the board to your linux machine.

lsusb should now show the product ID ee25 and evalcontrol should detect your board. Note that this operation needs to be conducted every time the board was disconnected from power. I have not yet found a way to initialize the board under linux.

Cheers

Fabian

satfan52 commented 6 years ago

Hi Fabian,

Great explanation ! It allowed me to find a work around ! In my virtual box Windows environment I have set the filters to acquire USB devices automatically based on IDs ee24 and ee25. The official windows driver then dialogues with the firmware of the board that dynamically updates the USB ID from ee24 to ee25. Next step is just to power down the virtual machine, the USB ID of the board is still remains ee25 under Linux as long as I do not remove the USB connector from my Linux PC !

Please note I do not have to launch the official application ! It is the official Windows driver that actually dialogues with the firmware of the board to order the firmware to change of the UDB ID from ee24 to ee25 !! I do not have to fire up the official Analogue Device evaluation board application at all !!! . This is a nice work around because I do not have to find a way of powering up the board independently of the USB device.

I am also wondering why I can not get the official evaluation app work in my virtual environment as the windows driver seems to work just fine. So strange.

Of course, it would be fantastic if you could emulate the windows driver with your program so you instruct the firmware to change the USB ID to ee25, but I guess I will have to wait a little for that ;-)

Thanks Regards Peter

Here is the info I get after powering down the virtual machine :grinning:

lsusb: Bus 007 Device 017: ID 0456:ee25 Analog Devices, Inc.

root@abc:~/evalcontrol# python3 ./set_frequency_example.py System clock exceeds 255MHz, VCO gain bit was set to True! System clock exceeds 255MHz, VCO gain bit was set to True! Setting frequency of channel [0, 1]:0 to closest possible value 20.000000023283064MHz

Thanks again Regards Peter

satfan52 commented 6 years ago

Hello again Fabian,

The library seems to be running fine but I measure no RF output on the board !!! This the script I am using is indicated below. It seems to me that in that script I miss an instruction to set the frequency of the board clock to 25 Mhz, right ? Or is it set by default to 25 Mhz ? and only setting the multiplier is required ? Where can I find all the instructions that I can use in such as script ?

Thanks Peter

import evalcontrol evaluation_board = evalcontrol.AD9959() evaluation_board.set_clock_multiplier(20) evaluation_board.set_frequency(50000000, channel=[0]) evaluation_board.set_frequency(50010000, channel=[1]) evaluation_board.set_frequency(10000000, channel=[2]) evaluation_board.set_frequency(10010000, channel=[3]) evaluation_board.set_phase(90, channel=[0,1,2,3])

Schlabonski commented 6 years ago

Hi Peter,

good to hear that this workaround is working. The clock multiplier can be set by using the rfclk keyword in the initialization of the AD9959 instance, e.g.

evaluation_board = evalcontrol.AD9959(rfclk=25)

would set the reference clock frequency to 25 MHz. I use MHz as a standard unit, so in the same way

evaluation_board.set_frequency(50, channel=[0])

would set the output of channel 0 to 50 MHz. You can find the documentation of this and other methods (e.g. channel modulation or frequency sweep) in the docstrings of this file. However, much of the functionality of the chip is not implemented in evalcontrol, only the part of it we needed in the lab so far. If you need a specific function, you can open another issue and I see what I can do. :)

Cheers

Fabian

P.S.: I discovered that in fact, the rfclk was inconsistently set in Hz and fixed this in commit 4041272dd982eb2ca563ccaf29c5766c2b84b5af . You can pull and use the corrected version or set the rfclk variable in units of Hertz.

satfan52 commented 6 years ago

Hello Fabian,

Unfortunately, it does not solve the problem, still no signal...there is no error reported by your program though....

I tried without success: evaluation_board = evalcontrol.AD9959(rfclk=25000000, clkmtp=20) and :
evaluation_board = evalcontrol.AD9959(rfclk=25000000) evaluation_board.set_clock_multiplier(20)

With the official software on my windows 10 PC, the parameters are set to 25 Mhz for the reference and 20 for the multiplier (to get to 500 Mhz). There is no modulation (single tone).

I have attached the working set_up for the configuration that works successfully on my windows 10 PC.

two tone test.stp.zip

When I look at my spectrum analyser after running evalcontrol, I just see the usual spurs and it is seems to me obvious that the only reason there is no signal on the output is because something is wrong with the clocking. The clone that I use has an onboard 25 Mhz clock, I have no input for an external reference clock (in case that makes a difference for your software).

The unsuccessful evalcontrol script is the following:

import evalcontrol evaluation_board = evalcontrol.AD9959(rfclk=25000000, clkmtp=20) evaluation_board.set_frequency(10000000, channel=[0]) evaluation_board.set_frequency(20000000, channel=[1]) evaluation_board.set_frequency(30000000, channel=[2]) evaluation_board.set_frequency(40000000, channel=[3]) evaluation_board.set_phase(90, channel=[0,1,2,3])

Result of the run:

root@abc:~/evalcontrol# python3 ./set_frequency_example.py System clock exceeds 255MHz, VCO gain bit was set to True! Setting frequency of channel [0]:0 to closest possible value 10.000000011641532MHz Setting frequency of channel [1]:0 to closest possible value 20.000000023283064MHz Setting frequency of channel [2]:0 to closest possible value 30.000000034924597MHz Setting frequency of channel [3]:0 to closest possible value 40.00000004656613MHz

Important: My understanding is that the version I am using (before you made the change) requires to enter the frequency of the different channels in Hz and not in Mhz as entering the data in Mhz instead of Hz leads to undesired values (see below)

System clock exceeds 255MHz, VCO gain bit was set to True! Setting frequency of channel [0]:0 to closest possible value 1.0011717679447429e-05MHz Setting frequency of channel [1]:0 to closest possible value 2.0023435358894857e-05MHz Setting frequency of channel [2]:0 to closest possible value 3.0035153038342286e-05MHz Setting frequency of channel [3]:0 to closest possible value 4.0046870717789715e-05MHz

Thanks Regards Peter PS/ By the way, I have also downloaded the latest version after you implemented 4041272 and it is still required to enter the frequency of channels in HZ not MHZ

Schlabonski commented 6 years ago

Hi Peter,

I'm sorry for the inconvenience, I realized I actually did use SI units throughout the driver. I reverted 4041272dd982eb2ca563ccaf29c5766c2b84b5af. Could you pull and install the version that includes the revert, give the board a fresh restart, initialize it and then run

import evalcontrol
evaluation_board = evalcontrol.AD9959(rfclk=25e6, clkmtp=20)
evaluation_board.set_frequency(10e6, channel=[0])
evaluation_board.set_frequency(20e6, channel=[1])
evaluation_board.set_frequency(30e6, channel=[2])
evaluation_board.set_frequency(40e6, channel=[3])

print(evaluation_board._read_from_register(0x04, 32)

and check the output of board/terminal?

Cheers

Fabian

satfan52 commented 6 years ago

Hello Fabian,

I hope you had a nice weekend. Unfortunately it does not work. See below the result of the run:

root@abc:/usr/src/evalcontrol# python3 ./test.py File "./test.py", line 10

^

SyntaxError: unexpected EOF while parsing root@abc:/usr/src/evalcontrol#

In fact, line 10 is the print() function.

Have a nice evening Peter

Schlabonski commented 6 years ago

Argh sorry, a ) is missing on the end of the last line. Could you try the corrected version?

import evalcontrol
evaluation_board = evalcontrol.AD9959(rfclk=25e6, clkmtp=20)
evaluation_board.set_frequency(10e6, channel=[0])
evaluation_board.set_frequency(20e6, channel=[1])
evaluation_board.set_frequency(30e6, channel=[2])
evaluation_board.set_frequency(40e6, channel=[3])

print(evaluation_board._read_from_register(0x04, 32)
satfan52 commented 6 years ago

Hello Fabian, Here is the result: System clock exceeds 255MHz, VCO gain bit was set to True! Setting frequency of channel [0]:0 to closest possible value 10.000000011641532MHz Setting frequency of channel [1]:0 to closest possible value 20.000000023283064MHz Setting frequency of channel [2]:0 to closest possible value 30.000000034924597MHz Setting frequency of channel [3]:0 to closest possible value 40.00000004656613MHz array('B', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

Schlabonski commented 6 years ago

Hi Peter,

I'm not sure whether the USB microcontroler is initialized properly by your virtual machine. It has the proper product/vendor ID, but communication with the DDS chip seems to fail. Can you find a way to provide the board with external power and initialize it on your windows machine?

Cheers

Fabian

satfan52 commented 6 years ago

Success !!!

It works !! See below:

System clock exceeds 255MHz, VCO gain bit was set to True! Setting frequency of channel [0]:0 to closest possible value 10.000000011641532MHz Setting frequency of channel [1]:0 to closest possible value 20.000000023283064MHz Setting frequency of channel [2]:0 to closest possible value 30.000000034924597MHz Setting frequency of channel [3]:0 to closest possible value 40.00000004656613MHz array('B', [0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0])

and Indeed I can see the 4 signals on the 4 outputs !!!

What I have done is to customize a USB2 cable to provide the power supply externally instead of via the windows PC. The official application must be started on the windows PC before the cable is moved to the Linux PC otherwise your script/library does not work. No need to set any parameters on the official app in Windows before moving the cable through, just opening the official application is sufficient for this trick to work.

I now understand why I could not initialize the board using my windows 7 environment in Virtualbox; the official app does not detect the board so the initialization of the board is not completed !!!

Many Thanks for your Help Fabian ! I will resume my test sequence now !
Have a lovely weekend ! Peter