• 0
Lesiastas

Receiving ASCII bits from a UART Controller by using Logic Analyzer APIs

Question

Greetings! I'm working on a project involving the use of the Analog Discovery 2's Logic Analyzer feature and I've been tasked to recreate its function through the use of a VB6 Wrapper. I'm having a hard time finding the correct APIs to use. The Python sample codes in the WaveForms SDK folder isn't working when I tried to use it in receiving ASCII bits from a UART controller. For people like me that aren't good in coding, it would be great if it would at least contain more examples showing the different uses of the settings present in the Logic Analyzer GUI. So I just set some additional APIs that could help my code and here's the code that I've made so far:

image.png.f97c985f5fe1a1018080fb3df8063bdb.png

The main showstopper that I've encountered right now is the highlighted API in the picture above. It's suppose to retrieve the acquired data samples from the instrument, but it still cannot receive the bits of the ASCII character that I'm sending. This is the result that I'm trying to replicate using the Logic Analyzer APIs:

image.png.97656181c031c4f5c0373793fdd40106.png

I used a UART Controller as the Tx to the VB6 Wrapper while I was doing breakpoint debug in it to see the received bits. These are the results that I got:

image.thumb.png.82af994684f5d703def490e6a5bc4d92.png

It received a "1" and "0" bits unlike the one in the Logic Analyzer GUI. I could be wrong, but I think the problem is I still haven't set the Trigger and Trigger Detector APIs for the Logic Analyzer properly.

Any advice guys?

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Hi @attila 

Is it not possible to replicate the function of the Logic Analyzer GUI without using the FDwfDigitalUart functions? Because I was advised to see if I can get the Signal Bus functions of the Logic Analyzer GUI to work in the API first. Only then we'll proceed with using the UART Bus present in the Logic Analyzer GUI. Sorry if its a bit confusing, but I'll also try your advice :) 

 


 

image.png

Share this post


Link to post
Share on other sites
  • 0

Hi @attila

A follow-up question: What is the API function to set the Trigger Mode settings? (The highlighted settings in the picture below)
I've checked the APIs available in the reference manual but there is no TriggerMode API in there.
image.png.f416ba902f528d12eb4ed3c6647a846c.png
 

Sincerely yours,

Lesiastas

 


 

Share this post


Link to post
Share on other sites
  • 0

Hi @Lesiastas

WaveForms application trigger options are similar to the following SDK settings:
None     = FDwfDigitalInTriggerSourceSet(hdwf, trigsrcNone)
Auto      = FDwfDigitalInTriggerSourceSet(hdwf, other than trigsrcNone) FDwfDigitalInTriggerAutoTimeoutSet(hdwf, not zero
Normal = FDwfDigitalInTriggerSourceSet(hdwf, other than trigsrcNone) FDwfDigitalInTriggerAutoTimeoutSet(hdwf, zero

Share this post


Link to post
Share on other sites
  • 0

Hi @attila

I found a thread which seems very similar to what I'm working on.

The main difference is I want to use a UART Controller to send an ASCII character and have the FDwfDigitalInStatusData API display the bits of the ASCII character.
Here's the VB6 code that I've come up with the help of the thread that I read.

Imports UART_Single_Acquisition.ComClass1
Imports System.Windows.Forms
Imports System.Text
Imports System.Text.RegularExpressions
Public Class Form1
    Private Sub UartButton1(ByVal sender As System.Object, ByVal e As EventArgs) Handles Button1.Click

        Dim UART As New UART_Single_Acquisition.ComClass1
        Dim handle As Integer
        Dim sts As Byte
        Dim phzFreq As Double
        Dim hzDI As Double
        Dim hzData As Double : hzData = 9600
        Dim idxChannel As Integer : idxChannel = 0
        Dim cSamples As Integer : cSamples = 2 * 8
        Dim rgwData(cSamples) As UInt16
        'Dim pfAuto As Integer

        'Opening Device
        Call AD2_FDwfDeviceOpen(-1, handle)
        Call AD2_FDwfDigitalOutReset(handle)
        Call AD2_FDwfDigitalInReset(handle)
        'DigitalOut APIs
        Call AD2_FDwfDigitalOutInternalClockInfo(handle, phzFreq)
        Call AD2_FDwfDigitalOutEnableSet(handle, idxChannel, 1)
        Call AD2_FDwfDigitalOutIdleSet(handle, idxChannel, 2) 'DwfDigitalOutIdleHigh As Byte = 2
        Call AD2_FDwfDigitalOutDividerSet(handle, idxChannel, (phzFreq / hzData))
        'Call AD2_FDwfDigitalOutCounterSet(handle, idxChannel, 1, 1)
        Call AD2_FDwfDigitalOutRunSet(handle, (cSamples / phzFreq))
        Call AD2_FDwfDigitalOutRepeatSet(handle, 1)
        
        'DigitalIn Parameters
        Call AD2_FDwfDigitalInInternalClockInfo(handle, hzDI)
        Call AD2_FDwfDigitalInTriggerSourceSet(handle, 3) 'trigsrcDetectorDigitalIn As Byte = 3
        Call AD2_FDwfDigitalInTriggerAutoTimeoutSet(handle, 10.0)
        Call AD2_FDwfDigitalInSampleModeSet(handle, 1) 'DwfDigitalInSampleModeSimple As Byte = 0
        Call AD2_FDwfDigitalInDividerSet(handle, (hzDI / hzData))
        'Use 8 for 8bit, 16 for 16bit and 32 for 32bit samples
        Call AD2_FDwfDigitalInSampleFormatSet(handle, (16))
        Call AD2_FDwfDigitalInBufferSizeSet(handle, cSamples)
        Call AD2_FDwfDigitalInTriggerPositionSet(handle, (cSamples - 1))
        Call AD2_FDwfDigitalInTriggerSlopeSet(handle, 1) 'DwfTriggerSlopeFall As Byte = 1
        'Call AD2_FDwfDigitalInTriggerSet(handle,0,0,&HFFFF,&HFFFF)

        'DigitalIn Enable
        Call AD2_FDwfDigitalInConfigure(handle, 0, 1)
        'DigitalOut Enable
        Call AD2_FDwfDigitalOutConfigure(handle, 1)

        'Acquisition State
        Call AD2_FDwfDigitalInStatus(handle, 1, sts)
        '1* for 8bit, 2* for 16bit, 4* for 32bit samples
        Call AD2_FDwfDigitalInStatusData(handle, rgwData, (2 * cSamples))

        'Done
        Call AD2_FDwfDeviceClose(handle)

    End Sub
End Class

Sincerely yours,
Lesiastas

Share this post


Link to post
Share on other sites
  • 0

Hi @attila

Thanks for the advice 😆 I'll try just that.
Sorry for more questions but:


1. What values should I set to the FDwfDigitalInAcquisitionModeSet, FDwfDigitalInDividerSet, FDwfDigitalInSampleModeSet, FDwfDigitalInTriggerPositionSet, and FDwfDigitalInTriggerSet for Repeated Acquisition Mode in Analog Discovery 2? 

2. And lastly, what values should I set to the FDwfDigitalInTriggerSet in order for it to trigger on Falling Edges using DIO Channel 0?

Yours truly,
Lesiastas

Share this post


Link to post
Share on other sites
  • 0

Hi @Lesiastas

For FDwfDigitalUart functions you don't have to configure the digital-in or -out. The uart functions will do this.

1. For repeated capture use FDwfDigitalInAcquisitionModeSet acqmodeSingle 0 . The other options depend on your reqirements.

2. Please take a look at the manual and examples in WF SDK

image.png

image.png.20e36a37e47784204e83be386b3a4918.png

DigitalIn_Trigger.py:
dwf.FDwfDigitalInTriggerSet(hdwf, c_int(0), c_int(0), c_int(0), c_int(1<<7)) # DIO7 falling edge

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now