• 0
Lesiastas

Enabling DigitalOut Functions in VBA using Analog Discovery 2's Pattern Generator Function

Question

Posted (edited)

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:
image.png.694a441f244254074096946a9a840350.png
image.png.407253a404fa90ed954dd97464b8b10a.png
 

Any advice? 

Regards,

Lesiastas

Edited by Lesiastas
Updated Codes

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

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