• Content Count

  • Joined

  • Last visited

About Lesiastas

  • Rank
    Frequent Visitor

Recent Profile Visitors

168 profile views
  1. Hi @attila Thanks for the clarification and sorry for the confusion. What I meant by 'enable DIOs' is this: Does changing the FDwfDigitalInSampleFormatSet affect how many DIO pins can be used in receiving data? For example, if I set the FDwfDigitalInSampleFormatSet to 8 (Byte) bits, will I only be receiving data from DIOs 0 to 7 of Analog Discovery 2? I also did the changes you advised for 8 (Byte) bit data. ...... Function decodeUart(ByRef rgData() As Byte,... ...... FDwfDigitalInSampleFormatSet(hdwf, 8) ...... Dim rgData(cSamples) As Byte FDwfDigitalInStatusData(hdwf, rgData, rgData.Length) 'FDwfDigitalInStatusDataUShort uses rgData as UShort Transmitted data was ASCII "vU" and the bit sequence was captured: (DIO #0 & 1 was used that's why 3 bits was received) But when I step at the rg0 line, the result that I get is blank: Any advice regarding this error? Best Regards, Lesiastas
  2. Hi @attila Thank you for all the help so far! Its been a huge boost overall. I tweaked around the code you gave me and I got the results that I wanted. I don't know how to explain it, but I changed the following declarations: The results that I got are: Orange = represents start & stop bits. Green = represents bit sequence of ASCII “v”. Yellow = represents bit sequence of ASCII “U”. The decodeUart was used and the hex value that it produced was: (pin = 0 for DIO #0) I was wondering if I can increase cSamples to 4096 since its the Default value in the WF Logic Analyzer app because I keep getting some errors when I change cSamples. Correct me if I'm wrong but, if I set The FDwfDigitalInStatusData to return an array of raw samples of 8 (Byte) bits, will it only enable DIOs #0 to 8? Best Regards, Lesiastas
  3. Hi @attila Your advice really helped and I now understand the setting that needs to be used for each Logic Analyzer API. I'm trying to implement the decodeUart to our own version of here: UART_for_Reception.rar ASCII characters "vU" were transmitted to test the code. The expected result was: Hex: 0x76 and 0x55 UART: "vU" The actual result that was being received are: Orange = represents start & stop bits. Green = represents bit sequence of ASCII “v”. Yellow = represents bit sequence of ASCII “U”. The decodeUart was used but the hex value that it produced was: (pin = 0 for DIO #0) I don't understand why this happens. Can you please check the code provided above? Thanks in advance! Best Regards, Lesiastas
  4. Hi @attila Thanks for the snippet of code! I appreciate it and it made me understand a lot of things. I was just wondering: 1. Is the UART API in the WF Protocol app different from the UART mentioned in the WF Logic Analyzer app? Because the Add UART setting looks very familiar with the WF Protocol app's settings. Correct me if I'm wrong, but looking at the DecodeUART script, I think the values set there are used in the DecodeUART script to enable different DIOs right? Thanks again for all the support! Regards, Lesiastas
  5. Hi @attila Thanks for clearing things about the Custom Logic Analyzer Script example. I'm beginning to understand what I need to do now. Just to make things clear: 1. I think the SampleMode should be 8, 16, or 32. Correct me if I'm wrong, but this is applied to the FDwfDigitalInSampleFormatSet right? 2. Base from my understanding, if I tweak the FDwfDigitalInStatusData to return an array of raw samples of 16 (UShort) bits, it will enable DIOs 0 to 15. What changes can I make to the dwf declaration given below so that it can be compatible with the UShort format? 3. I don't think I'll be using the 32 (UInteger) bits format because the device I'm using is Analog Discovery 2, which only have DIOs 0 to 15. 4. Base from my understanding, I can use the java script example in the Logic Analyzer Custom to decode the raw samples from FDwfDigitalInStatusData right? The language that I'm mostly using right now is in VB6 and I don't really understand java script. Can you please provide a VB6 script version of that Logic Analyzer Custom Script? Thanks in advance! Regards, Lesiastas
  6. Hi @attila A follow up question: How is it that the UART setting in the Protocol GUI can only handle 1 Rx at a time, but the UART setting in the Logic Analyzer can be used for multiple channels? Can you please help me in understanding the above setting? Can I do the same with the code that I'm working on? Regards, Lesiastas
  7. Hi @attila Thanks for answering the several settings of the code I'm working on. I'll apply just that and see the results that I'm getting. I transmitted the ASCII characters "Dog" to the Logic Analyzer. As I observed in the WaveForms Logic Analyzer GUI, the bit sequence was displayed and it was decoded into its ASCII equivalent because of the UART setting. This is what I want to replicate but I'm having a hard time understanding how it works. Sorry but I'm having a hard time in finding out how I can pass the FDwfDigitalInStatusData raw samples of 16 (UShort) to the FDwfDigitalUartRx. Do you have a sample code where the FDwfDigitalInStatusData data is passed to the FDwfDigitalUartRx for it to be decoded into ASCII format like what is done in the Logic Analyzer GUI? Thanks in advance! Regards, Lesiastas
  8. Greetings, Is there a way to receive 0/1 values for the captured samples using FDwfDigitalInStatusData? I tried transmitting ASCII "a" but the result for each channel is different. I expected and wanted a result of Binary (1000 0110) using ASCII "a", but the actual result that I got was different for each DIO channels. Actual result using DIO #0 = (1)000 0(1)(1)0 Actual result using DIO #1 = (2)000 0(2)(2)0 Actual result using DIO #2 = (4)000 0(4)(4)0 Actual result using DIO #7 = (128)000 0(128)(128)0 I want the result from DIO #1, 2, and 7 to display 0/1 values, but I haven't had any breakthroughs so far. I'm aware that I asked this question sometime ago, but I decided to start a new thread because the other one is too long already. The previous advice that was given to me is from this link: The problem is, I did not fully understand how to apply it to the code I'm working on given below: Dim idxDevice As Integer : idxDevice = -1 Dim handle As Integer 'LA Parameters Dim phzFreq As Double Dim acqMode As Integer : acqMode = 0 Dim trigSrc As Byte : trigSrc = 3 'trigsrcDetectorDigitalIn As Byte = 3 'Set Trigger Bits for Channels to be used Dim LowStateTrigger As UInteger : LowStateTrigger = 0 Dim HighStateTrigger As UInteger : HighStateTrigger = 0 Dim RisingEdgeTrigger As UInteger : RisingEdgeTrigger = 0 Dim FallingEdgeTrigger As UInteger : FallingEdgeTrigger = &HFFFF Dim BaudRate As Double : BaudRate = 9600 Dim nBits As Integer : nBits = 16 Dim SampleMode As Integer : SampleMode = 0 'DwfDigitalInSampleModeSimple As Byte = 0 '4096 for 8bit, 2048 for 16 bit, 1024 for 32bit Dim cSamples As Integer : cSamples = 2048 Dim cSamplesAfterTrigger As Integer : cSamplesAfterTrigger = cSamples - 1 Dim fReconfigure As Integer : fReconfigure = 0 Dim fStart As Integer : fStart = 1 Dim fReadData As Integer : fReadData = 1 Dim sts As Byte Dim rgwData(cSamples) As UInt16 Dim countOfDataBytes As Integer : countOfDataBytes = 2 * cSamples 'Opening Device Call AD2_FDwfDeviceOpen(idxDevice, handle) 'DigitalIn Parameters Call AD2_FDwfDigitalInInternalClockInfo(handle, phzFreq) Call AD2_FDwfDigitalInAcquisitionModeSet(handle, acqMode) Call AD2_FDwfDigitalInTriggerSourceSet(handle, trigSrc) Call AD2_FDwfDigitalInTriggerSet(handle, LowStateTrigger, HighStateTrigger, RisingEdgeTrigger, FallingEdgeTrigger) Call AD2_FDwfDigitalInTriggerAutoTimeoutSet(handle, 10.0) Call AD2_FDwfDigitalInDividerSet(handle, (phzFreq / BaudRate)) Call AD2_FDwfDigitalInSampleFormatSet(handle, nBits) Call AD2_FDwfDigitalInSampleModeSet(handle, SampleMode) Call AD2_FDwfDigitalInBufferSizeSet(handle, cSamples) Call AD2_FDwfDigitalInTriggerPositionSet(handle, cSamplesAfterTrigger) 'Configure for Reception Call AD2_FDwfDigitalInConfigure(handle, fReconfigure, fStart) 'Start Reception Call AD2_FDwfDigitalInStatus(handle, fReadData, sts) 'Retrieves Captured Samples Call AD2_FDwfDigitalInStatusData(handle, rgwData, countOfDataBytes) 'Closing Device Call AD2_FDwfDigitalInReset(handle) Call AD2_FDwfDeviceClose(handle) Any advice would really help a lot. Thanks in advance Regards, Lesiastas
  9. Greetings, I am creating a VBA Macro Script to enable the Pattern Generator function of Analog Discovery 2 for parallel transmission of data. I've already created a VB6 Wrapper (Pattern_Generator) containing these two files: 1). Pattern Generator Wrapper.txt(Calls APIs from dwf.vb) 2). dwf.vb I've referenced it to a VBA Script to call those functions using this snippet of codes: Public TxWrapper As Pattern_Generator.ComClass1 Public Function PatGenForTx() Set TxWrapper = New Pattern_Generator.ComClass1 'PatGen Parameters Dim rgBits1 As String: rgBits1 = "UART" Dim n As Long: n = Len(rgBits1) + 1 Dim idxDevice As Long: idxDevice = -1 Dim handle As Long Dim phzFreq As Double Dim idxChannel1 As Long: idxChannel1 = 0 Dim fEnable As Long: fEnable = 1 Dim secRun1 As Double: secRun1 = (n * 8) * (1 / 9600) Dim cRepeat As Long: cRepeat = 1 Dim t As Long: t = 1 ''DwfDigitalOutTypeCustom As Byte = 1 Dim i As Long: i = 2 ''DwfDigitalOutIdleHigh As Byte = 2 Dim countOfBits1 As Long: countOfBits1 = n * 8 Dim fStart As Long: fStart = 1 'Initializing Device PatGen = TxWrapper.AD2_FDwfDeviceOpen(idxDevice, handle) 'Setting for enabling 1st Channel PatGen = TxWrapper.AD2_FDwfDigitalOutInternalClockInfo(handle, phzFreq) PatGen = TxWrapper.AD2_FDwfDigitalOutEnableSet(handle, idxChannel1, fEnable) PatGen = TxWrapper.AD2_FDwfDigitalOutRunSet(handle, secRun1) PatGen = TxWrapper.AD2_FDwfDigitalOutRepeatSet(handle, cRepeat) PatGen = TxWrapper.AD2_FDwfDigitalOutTypeSet(handle, idxChannel1, t) PatGen = TxWrapper.AD2_FDwfDigitalOutIdleSet(handle, idxChannel1, i) PatGen = TxWrapper.AD2_FDwfDigitalOutDividerSet(handle, idxChannel1, (phzFreq / 9600)) PatGen = TxWrapper.AD2_FDwfDigitalOutDataSet(handle, idxChannel1, rgBits1, countOfBits1) 'Start Site 1 Transmission PatGen = TxWrapper.AD2_FDwfDigitalOutConfigure(handle, fStart) 'Closing Device PatGen = TxWrapper.AD2_FDwfDigitalOutReset(handle) PatGen = TxWrapper.AD2_FDwfDeviceCloseAll() End Function But I am encountering this error at the FDwfDigitalOutDataSet: Any advice? Regards, Lesiastas
  10. Greetings, I would like to replicate the result being captured by the Logic Analyzer GUI here: Is it possible to combine the Digital_UART and DigitalIn Functions to create a VB6 wrapper that will display results like in the GUI? I'm not sure if my hunch is correct or possible, but since the UART is a setting in the Logic Analyzer GUI: I suspect that we can implement the Digital_UART function into one of the DigitalIn APIs available in order to create a VB6 program to receive data that is composed of both: 1. Captured Bit Sequence of character sent (Like in the Data Line of the WaveForms GUI) , and 2. Its equivalent ASCII format (Like in the UART Line of the WaveForms GUI). Any advice? Regards, Lesiastas
  11. Hi @attila Is it possible to immediately store String values instead of Byte in the FDwfDigitalUartRx API? I created another set of code to be applied in VBA. Here's the code I'm working on: Public Function AD2_FDwfDigitalUartRx(ByVal hdwf As Integer, ByRef szRx() As String, ByVal cRx As Integer, ByRef pcRx As Integer, ByRef pParity As Integer) As Integer Dim rgRx = System.Text.Encoding.ASCII.GetString(szRx, 0, cRx) Call FDwfDigitalUartRx(hdwf, rgRx, cRx, pcRx, pParity) End Function But an error of: always occurs. So my main question is this: How can I post process the FDwfDigitalUartRx to display String data after reception? Regards, Lesiastas
  12. Greetings, I am creating a VBA program which uses the DigitalOut Functions in the dwf.vb file to replicate the capability of the AD2's Pattern Generator. I'm having trouble of declaring the FDwfDigitalOutDataSet API in VBA. I always encounter this error: I am aware that this is because of some data types in VB6 that are not supported in VBA. I've encountered similar errors in the FDwfDigitalOutRepeatSet and the FDwfDigitalOutDividerSet API. What I did was change the UInteger data type to Integer, since its the data type supported supported in VBA. Function FDwfDigitalOutRepeatSet(ByVal hdwf As Integer, ByVal cRepeat As Integer) As Integer End Function Function FDwfDigitalOutDividerSet(ByVal hdwf As Integer, ByVal idxChannel As Integer, ByVal v As Integer) As Integer End Function I already changed countOfBits in FDwfDigitalOutDataSet from UInteger to Integer, but the error is still present. I think the error is because of the <MarshalAs(UnmanagedType.LPArray)> used in the FDwfDigitalOutDataSet. What changes could I do to FDwfDigitalOutDataSet in order to agree with VBA? Function FDwfDigitalOutDataSet(ByVal hdwf As Integer, ByVal idxChannel As Integer, <MarshalAs(UnmanagedType.LPArray)> rgBits() As Byte, ByVal countOfBits As Integer) As Integer End Function Sorry in advance, but I could be wrong since I'm a complete novice in coding, especially across different programming platforms. Any advice on how to work around this? Regards, Lesiastas
  13. Hi @attila The UART project for serial reception is now working. Thank you so much for all of your help. I just added some APIs that I need to replicate what was being done in the WaveForms GUI. Here's the VB6 code made with your guidance: Dim handle As Long 'Dim szTx = "Try lang" 'Dim rgTx = System.Text.Encoding.ASCII.GetBytes(szTx) Dim rgRx(512) As Byte Dim fParity As Integer Dim cRx As Integer 'Opening Device Call AD2_FDwfDeviceOpen(-1, Handle) 'Initializing UART Call AD2_FDwfDigitalUartRateSet(handle, 9600) '9.6kHz 'Call AD2_FDwfDigitalUartTxSet(handle, 1) Call AD2_FDwfDigitalUartRxSet(handle, 0) Call AD2_FDwfDigitalUartBitsSet(handle, 8) '8 bits Call AD2_FDwfDigitalUartParitySet(handle, 0) '0 none, 1 odd, 2 even Call AD2_FDwfDigitalUartStopSet(handle, 1) ' 1 bit stop length 'Call AD2_FDwfDigitalUartTx(handle, Nothing, 0) ' initialize TX Call AD2_FDwfDigitalUartRx(handle, Nothing, 0, Nothing, Nothing) ' initialize RX 'Capturing Samples 'Call AD2_FDwfDigitalUartTx(handle, rgTx, rgTx.Length) Call AD2_FDwfDigitalUartRx(handle, rgRx, rgRx.Length, cRx, fParity) Dim szRx = System.Text.Encoding.ASCII.GetString(rgRx, 0, cRx) 'System.Console.WriteLine(szRx) 'Done Call AD2_FDwfDigitalUartReset(handle) Call AD2_FDwfDeviceCloseAll() Here's the result we came up when we connected the UART Controller to transmit ASCII characters: Thanks for everything! More power to you and Digilent! Regards, Lesiastas
  14. Hi @attila Thank you so much for that sample codes. I'll study it well to see how I can apply the Digital_Uart to be used only to Receive ASCII characters. Regards, Lesiastas
  15. Hi @attila Sorry to be a bother, but can you help me understand how to declare this in VB6 format? rgRX = create_string_buffer(101) dwf.FDwfDigitalUartRx(hdwf, rgRX, c_int(sizeof(rgRX)-1), byref(cRX), byref(fParity)) Regards, Lesiastas