S.Kagawa Posted November 8, 2019 Share Posted November 8, 2019 Hello. I am developing a system with Analog Discovery 2 and SDK (C++). It uses 1 channel DA output, 2 channels AD input, and 1 channel DIO output. I use "FDwfAnalogInStatus" command to detect the end of AD input. (Refer to the sample program.) Normally, returned status should be "DwfStateDone" (2) or "DwfStateRunning" (3). But sometimes it returns "DwfStateReady" (0) and never return "DwfStateDone". I wonder if AD was not triggered to start for some reason at that time. It seems that it occurs frequently when input voltage was high at previous measurement. I wonder if there were some errors in previous measurement. (Over range or something?) If it become that situation, it cannot recover until closing and opening the device again. It cannot recover if "FDwfAnalogOutReset" and "FDwfAnalogInReset" commands were sent and setting parameters from the first. I want to know how to detect the error status of the device that AD cannot start, and how to recover that situatuion. Link to comment Share on other sites More sharing options...
S.Kagawa Posted January 30, 2020 Author Share Posted January 30, 2020 Thank you for reply. I sum up the current situation. Specifications of the power of USB isolator : USB-029H2-RP : Work by bus power or external AC adapter. +5V is supplied to target USB connector. USB-029L2 : Work by only bus power. No power is supplied to target USB connector. (Temporaly) Results : 1. USB-029H2-RP + bus power : Good. No error occurred yet. 2. USB-029H2-RP + AC Adapter : Bad. Error occurred very often. 3. USB-029L2( + bus power) : Not good. Rarely error occurred. In case of USB-029H2-RP, the power of AD2 is supplied by both external AC adapter and bus power. On the other hand, in case of USB-029L2, the power of AD2 is supplied only by external AC adapter, no bus power. The result of 3.USB-029L2 was not so bad, but not good because rarely error occurred. (The worst was 2.) One difference between USB-029H2-RP and USB-029L2 is power supply to target USB. Is it OK if only external power was supplied, no bus power? (Of cource there are other differences between USB-029H2-RP and USB-029L2. Only USB-029H2-RP has "repeat function" to receive and remake signal. But it is not sure if this function was effective or not.) Link to comment Share on other sites More sharing options...
attila Posted February 19, 2020 Share Posted February 19, 2020 Hi @S.Kagawa I could not reproduce the issue so far. The configured waveform is stretched/shrunk to the 4096 sample device buffer. You could optimize your code by configuring 4096 samples, like 2048+2048. The plus 1 is not necessary since by default in idle the initial value is output.FDwfAnalogOutIdleSet(hdwf, idxChannel, DwfAnalogOutIdleInitial) Link to comment Share on other sites More sharing options...
S.Kagawa Posted February 19, 2020 Author Share Posted February 19, 2020 Thank you. m_dFreq==5000 and m_iNumVoltRising + m_iNumVoltKeeping + 1 == 5001 (2500+2500+1). Wave data is increasing 2500 points from 0 to 1(MAX), keeping MAX at 2500 points, and down to 0 at last one point. Link to comment Share on other sites More sharing options...
attila Posted February 18, 2020 Share Posted February 18, 2020 Hi @S.Kagawa The code looks good to me. Do you know what values are you using for "m_iNumVoltRising + m_iNumVoltKeeping + 1" and "m_dFreq" ? Link to comment Share on other sites More sharing options...
S.Kagawa Posted February 18, 2020 Author Share Posted February 18, 2020 Thank you. TAttached file is the essence of the source. "OnBnClicked" is the main sequence. At firs, "DeviceOpen" is executed. "OnBnClicked" will be executed when clicking the button. There are setting commands and run commands. Setting commands will be executed only once after "DeviceOpen". ("m_FirstTime") Run commands will be executed everytime clicking the button. Run Analog-out ch.0 and Analog-in ch.0 and ch.1. After analog-in status ws done (FDwfAnalogInStatus), data will be saved to array. source.txt Link to comment Share on other sites More sharing options...
attila Posted February 18, 2020 Share Posted February 18, 2020 Hi @S.Kagawa Could you share or send me the code you are using to control the device? Link to comment Share on other sites More sharing options...
S.Kagawa Posted February 8, 2020 Author Share Posted February 8, 2020 Thank you. I checked FDwfGetLastErrorMsg after FDwfDeviceOpen, but found that the string was empty when offset value changed. There are 3 patterns of offset, 0V, -200mV and +200mV. +200mV occurred vely rarely, but the phenomenon is a little different from othe 2 patterns. Please take notice light blue waves. They are output voltage of DA converter. "Zero.png" is pattern "0V" or "-200mV". "Plus.png" is pattern "+200mV". The voltage is rising from 0V to 4V by 2500 steps. But "Plus.png" seems like stairs. Is it somethig to get hints? Link to comment Share on other sites More sharing options...
attila Posted February 5, 2020 Share Posted February 5, 2020 Calibration parameters for all AD, DA... Scope, Wavegen, Supplies These are stored in an eeprom and read on device opening. When device opening succeeds, the last error could could return warnings. Link to comment Share on other sites More sharing options...
S.Kagawa Posted February 5, 2020 Author Share Posted February 5, 2020 Thank you for reply. Does "calibration" mean voltage calibration for DA output? I wonder if the reference (standard) voltage for DA output is initialized when system started (device open or reset), but rarely it failed to set correct value. And can "FDwfGetLastErrorMsg" get message string in any case if the returned value of previous function was "TRUE"? I have implemented to get error message by "FDwfGetLastErrorMsg" after functions concerned with USB communication, but only the case if returned value of the function was "FALSE". Link to comment Share on other sites More sharing options...
attila Posted February 5, 2020 Share Posted February 5, 2020 Hi @S.Kagawa If the output would have only 2 steps, like 0 and +0.2 I would guess the calibration reading failure but with 3 steps I have no idea. To catch such issues you could add FDwfGetLastErrorMsg right after FDwfDeviceOpen, like: dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) szerr = create_string_buffer(512) dwf.FDwfGetLastErrorMsg(szerr) print(szerr.value) Link to comment Share on other sites More sharing options...
S.Kagawa Posted February 4, 2020 Author Share Posted February 4, 2020 Thank you for information. By the way, I have another problem. This system uses 1-ch AD converter, generating voltage wave by custom mode. The voltage of output is 0-4V because amplitude is set 4 by "FDwfAnalogOutNodeAmplitudeSet". The problem is that the output voltage sometimes (very rarely) include certain offset value. There are 3 steps of offset values, usualy 0V, but rarely about +200mV or -200mV . Of course the output offset is set 0 by "FDwfAnalogOutNodeOffsetSet". But rarely the real output voltage shifted about 200mV in plus or minus. It seems to change offset values after un-plugged and plugged USB connector and opening device again. What dou you think the cause? Link to comment Share on other sites More sharing options...
attila Posted February 3, 2020 Share Posted February 3, 2020 Hi @S.Kagawa When the reconnect is not working probably the PC disabled the port due to its power surge detection. The errors are not too meaningful in this case. const ERC ercTransferCancelled = 2; // The transfer was cancelled or timeout occurred const ERC ercDataSndLess = 7; // Data send failed or peripheral did not received all the sent data const ERC ercDataSndLessRcvLess = 10; // Two errors: ercDataSndLess and ercDataRcvLess Link to comment Share on other sites More sharing options...
S.Kagawa Posted February 3, 2020 Author Share Posted February 3, 2020 When "FDwAnalogInStatus" returns FALSE, the last error code would be "0" and the last error message would be "DptiIO failed ERC:0x2" or "0xA". It is able to restart from opening device by "FDWfDeviceOpen" function. But sometimes the last error message would be changed from "0x2" or "0xA" to "ERC:0x7". In case of "ERC:0x7", it is not able to restart. The returned value of "FDWfDeviceOpen". would be FALSE, and the last error code would be "1", the last error message would be "The device is being used by other application. Device programing failed." It is not able to open device until the PC (Windows) restarted. What is the situation of "ERC:0x7" ? Link to comment Share on other sites More sharing options...
S.Kagawa Posted February 3, 2020 Author Share Posted February 3, 2020 I'm testing other environment (PC), and found that it was OK if using isolator USB-o20H2-RP by bus power with some PCs, but not good with some other PCs. Returned value of "FDwAnalogInStatus" would be FALSE with some other PCs, too. But the last error message was sometimes different. Sometimes "DptiIO failed ERC:0xA" was returned. What is the meaning of "ERC:0xA" and the difference between "ERC:0x2" ? Link to comment Share on other sites More sharing options...
attila Posted January 30, 2020 Share Posted January 30, 2020 Hi @S.Kagawa Thank you for posting the results, it may help others. In the AD2 the USB controller is only powered from USB, < 100mA The rest of the board is supplied either from USB or AUX 5V. Link to comment Share on other sites More sharing options...
attila Posted January 30, 2020 Share Posted January 30, 2020 Hi @S.Kagawa This is the first time I hear of such USB EMI problem. Here in the last post mentions that the issue is solved by using floating/battery power laptop and USB optical link:https://electronics.stackexchange.com/questions/31417/how-can-i-improve-usb-emi-insensitivity I'm using laptop and didn't notice any signal quality difference when using isolator. Probably noisy PC supplies and ground loops could affect the signals. Link to comment Share on other sites More sharing options...
S.Kagawa Posted January 29, 2020 Author Share Posted January 29, 2020 Thank you for reply. I have already tested cheaper FS isolator (ADUM4160) at first, because I did not notice the speed at that time. But I found the speed was slow compared with direct connection (no isolator). Then I changed to HS isolator. In case of FS isolator, the rate of error occurrence seemed low, but also occurred sometimes. By the way I 'm testing other isolator, USB-029H2-RP (HUMANDATA). It has external power input and AC power adapter, able to use bus power or external AC power. (USB-029L2, the original one can use only bus power.) I found the error occurred very often (worse than USB-029L2) if using AC power adapter, but if using bus power, it changed seem stable. Also I tested lap-top PC for host. Error occurred very often(worse than original desk-top PC) if using AC adapter (not for isolator but PC), but if using battery, it changed seem stable. Behavior changed if using AC power adapter or not in above mentioned 2 cases. Is it common case? Link to comment Share on other sites More sharing options...
attila Posted January 28, 2020 Share Posted January 28, 2020 Hi @S.Kagawa The FDwfDeviceOpen, FDwfAnalog/Digital-In/Out-Status, -Config (and -Set with the default AutoConfigure option) functions communicate with the device. The -StatusData (-Status...) returns the fetched data with the last -Status call. The -Get returns the last configured/set parameters. The FTDI driver/device uses USB control and bulk data transfers. The crc/ack/resend should be handled by the low level system/device. Since you have noticed the problem is when using the USB HS isolator, you could try using a cheaper USB FS isolator like an ADUM3160 based one. With the FS communication you will have lower transfer rate (2MBps vs 20-40MBps), lower capture rate, but this is suffice for normal usage of the device. The speed difference is noticeable when using streaming modes, Wavegen/AnalogOut Play or Scope/AnalogIn Record. Link to comment Share on other sites More sharing options...
S.Kagawa Posted January 28, 2020 Author Share Posted January 28, 2020 Thank you for reply. I found that the error of USB communication almost occurred in "FDwfAnalogInStatus" function. Sorry, I don't know the details of USB interface, but I heard that there are some protocols of USB transfer. Some protocols have auto re-send function if there were some errors, but others not. I wonder if "FDwfAnalogInStatus" function was a latter one? Link to comment Share on other sites More sharing options...
attila Posted January 27, 2020 Share Posted January 27, 2020 Hi @S.Kagawa The erc 2 indicates timeout on waiting for the device to reply. const ERC ercTransferCancelled = 2; // The transfer was cancelled or timeout occurred Link to comment Share on other sites More sharing options...
S.Kagawa Posted January 27, 2020 Author Share Posted January 27, 2020 I have tried item 1. (short ferrite FB 19), but the result seemed not changed. By the way, I confirmed the last error code and last error message by "FDwfGetLastError" and "FDwfGetLastErrorMsg" when this error (return value of function was FALSE) occurred. The error code was 0 and the error message was "DptiIO failed ERC:0x2". If USB cable was unplugged, the error code was 0 and the error message was "DptiIO failed ERC:0x7". The phenomenon was similar but the error message was a little different. What is the meaning of "DptiIO failed ERC:0x2"? Link to comment Share on other sites More sharing options...
S.Kagawa Posted January 21, 2020 Author Share Posted January 21, 2020 Thank you for reply. I'll try 1. I have already tried 2. (without USB isolator). Communication error was not occurred if USB was connected directly, but USB isolator is necessary in this system to reduce analog input noise from the PC (equipment). Shielding isolator also tried, input in a metal box. But it was not so effective. Link to comment Share on other sites More sharing options...
attila Posted January 20, 2020 Share Posted January 20, 2020 Hi @S.Kagawa 1. It could be a grounding issue. You could try to connect the device/your circuit ground to the isolator device gnd or to short the ferrite (FB19) on the device under the USB connector. See the pictures below. 2. The isolator could be also influenced by the EMI. Try shielding this too or try without isolator and use a 'disposable'/old laptop. Link to comment Share on other sites More sharing options...
S.Kagawa Posted January 16, 2020 Author Share Posted January 16, 2020 Thank you for reply. This system is for embedded in an equipment. BNC / x10 scope is not used because it is connected to the analog circuit directly through 2x15P connector. Attache PDF is the circuit. J1 (2x15P connector) is connected to Analog Discovery 2. "W1"(P5) is for DA 0-ch, wave data output. 0-4V voltage will be amplified to 0-250V by an amplifier. "+1"(P1) is for AD 0-ch, voltage measurement. 0-250V voltage is changed to 0--2V by voltage-dividing circuit and input in "+1". "+2"(P2) is for AD 1-ch, current measurement. 0-10mA current is changed to 0--10V voltage by current-shunting circuit and input in "+2". AD2 and PC are connected USB-cable through USB-Isolater ("USB-029L2" by HUMANDATA Co,Ltd). The GND of PC and AD2 are isolated by it. We heva tried to reinforce shield, inserting ferrite core with USB-cable, putting AD2 in a metalic box, connecting the GND of AD2 to the GND of PC through capacitor (3000Pf). But the situation would not be improved. spark check.pdf Link to comment Share on other sites More sharing options...
attila Posted January 13, 2020 Share Posted January 13, 2020 Hi @S.Kagawa We have not tested the device in such extreme conditions. 'Faraday' shielding of the device should protect it from EMI. Are you using shielded USB cable Could you provide details about the scope input connection? are you using BNC/ 10x scope? Link to comment Share on other sites More sharing options...
Question
S.Kagawa
Hello.
I am developing a system with Analog Discovery 2 and SDK (C++).
It uses 1 channel DA output, 2 channels AD input, and 1 channel DIO output.
I use "FDwfAnalogInStatus" command to detect the end of AD input. (Refer to the sample program.)
Normally, returned status should be "DwfStateDone" (2) or "DwfStateRunning" (3).
But sometimes it returns "DwfStateReady" (0) and never return "DwfStateDone".
I wonder if AD was not triggered to start for some reason at that time.
It seems that it occurs frequently when input voltage was high at previous measurement.
I wonder if there were some errors in previous measurement. (Over range or something?)
If it become that situation, it cannot recover until closing and opening the device again.
It cannot recover if "FDwfAnalogOutReset" and "FDwfAnalogInReset" commands were sent and setting parameters from the first.
I want to know how to detect the error status of the device that AD cannot start, and how to recover that situatuion.
Link to comment
Share on other sites
29 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.