8/11/2022

Analog Discovery 2 와 Python

1. Analog Discovery 2 와 Python 연결 
 

Analog Discovery 2  기본테스트 및 Wavforms 설치확인 

Analog Discovery 2 와 Python 연결 

  • WaveForms의 Sample
  1. Windows 32-bit: C:\Program Files\Digilent\WaveFormsSDK\samples
  2. Windows 64-bit: C:\Program Files (x86)\Digilent\WaveFormsSDK\samples
  3. Linux: /usr/share/digilent/waveforms/samples
  4. macOS: /Applications/WaveForms.app/Contents/Resources/SDK/samples

현재 C++ 과 Python 기반으로 제공해주는 것으로 보인다. 


$ sudo apt install python3-pip   //python3 pip 설치 
$ sudo ln -s /usr/bin/python3 /usr/bin/python  // python setup 
$ pip install numpy matplotlib   

  • Python Waveforms

$ pip install waveforms   // 이것은 필요 없어보이며 괜히 설치 했다.          
$ sudo apt install  git
$ git clone https://github.com/feihoo87/waveforms.git


$ pip install pydwf      

$ python -m pydwf list -c                    //  연결상태 확인 
Device information for device #0 (1 device found)
=================================================

  device ........... : 3
  version .......... : 3
  open ............. : True
  user_name ........ : 'Discovery2'
  device_name ...... : 'Analog Discovery 2'
  serial ........... : 'xxxxxxx'                  //Seril Number 삭제 

  Configuration:                 0         1         2         3         4         5         6         7
  ----------------------  --------  --------  --------  --------  --------  --------  --------  --------
  TooltipText (length)       (319)     (263)     (211)     (311)     (352)     (404)     (313)     (295)
  OtherInfoText                  .         .         .         .       [0]     Power       [0]         .
  AnalogInChannelCount           2         2         2         2         2         2         2         2
  AnalogOutChannelCount          2         2         2         2         2         4         2         2
  AnalogIOChannelCount           2         2         2         2         2         2         2         2
  DigitalInChannelCount         16        16         0        16        16        16        16        16
  DigitalOutChannelCount        16         0         0        16        16         8        16        16
  DigitalIOChannelCount         16        16        16        16        16        16        16        16
  AnalogInBufferSize          8192     16384      2048       512      8192      8192       512      8192
  AnalogOutBufferSize         4096      1024     16384       256      4096      4096       256      1024
  DigitalInBufferSize         4096      1024         0     16384      4096      2048     16384     16384
  DigitalOutBufferSize        1024         0         0     16384      1024       256     16384       256

  Strings referenced in the preceding table (with newlines replaced by '•'):

  [0]  '1V8_Digital_Input'
$ python -m pydwf extract-examples  // Sampe example 가져오기 
$ cd pydwf-examples

$ python AnalogInSimple.py   // 각 동작 확인 
....
analog input channel 0:   -0.01111883895232168573 [V], channel 1:    0.00848256450475493029 [V]
analog input channel 0:   -0.00008158292222348873 [V], channel 1:   -0.01756863060662183784 [V]
analog input channel 0:   -0.01479792429568771439 [V], channel 1:    0.00103936590150444097 [V]
analog input channel 0:   -0.01111883895232168573 [V], channel 1:    0.00476096520312963012 [V]
analog input channel 0:   -0.01479792429568771439 [V], channel 1:    0.00476096520312963012 [V]
analog input channel 0:   -0.02215609498241988273 [V], channel 1:    0.00848256450475493029 [V]
analog input channel 0:   -0.00376066826558951739 [V], channel 1:    0.01592576310800541961 [V]
analog input channel 0:   -0.01111883895232168573 [V], channel 1:    0.00848256450475493029 [V]
analog input channel 0:   -0.01111883895232168573 [V], channel 1:    0.00476096520312963012 [V]
analog input channel 0:    0.00359750242114253993 [V], channel 1:    0.01964736240963060876 [V]
analog input channel 0:   -0.02583518032578591139 [V], channel 1:    0.00848256450475493029 [V]
analog input channel 0:   -0.00376066826558951739 [V], channel 1:   -0.00640383270174615937 [V]
analog input channel 0:   -0.02583518032578591139 [V], channel 1:   -0.02129022990824713801 [V]
analog input channel 0:   -0.00008158292222348873 [V], channel 1:    0.02709056101288109808 [V]
analog input channel 0:   -0.02215609498241988273 [V], channel 1:   -0.01012543200337134852 [V]
analog input channel 0:   -0.02583518032578591139 [V], channel 1:    0.00103936590150444097 [V]


$ cd /usr/share/digilent/waveforms/samples/py  // WaveForm Sample Python 이동 , 예제가 너무 많음 

$ python Device_Info.py
DWF Version: b'3.18.1'
Number of Devices: 1
------------------------------
Device 1 : 
	b'Analog Discovery 2'
	b'SN:xxxxxxxx'   // Serial Number 삭제 

AnalogIn channels: 2
Buffer size: 8192
ADC bits: 14
Range from 5.0 to 50.0 in 2.0 steps
Offset from -25.0 to 25.0 in 16384.0 steps

AnalogOut channels: 2
Channel 1
Node: Carrier
Buffer size: 4096
Amplitude from 0.01 to 5.0
Offset from -5.0 to 5.0
Frequency from 1e-06 to 100000000.0
.....



좀 더 다양한 예제를 가지고 테스트를 해보면 될 꺼 같으며, 추후 시간이 되면 Audio를 직접 넣어 테스트 하고 관련부분 수정하면서 테스트 해도 될꺼 같다. 


2. Raspberry Pi4 

추후 원격으로 사용할 일 있다면, 아래와 같이 구성한 후 사용하도록 하자 

Raspberry Pi 4 에 WaveForm 을 설치한 후, VNC로 연결하여 사용