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
Question
Lesiastas
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
Link to comment
Share on other sites
21 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.