Jump to content
  • 0

usb-dio32hs trigger pattern


Mtd001

Question

I'm working with the usb-dio32hs using the universal library for windows.  I've connected my sensor to PD01 and GND and set my trigger using the following code which is c# and I've set my pattern to be the listenString.

DConfigPort(DigitalPortType.AuxPort, DigitalPortDirection.DigitalIn);

this.daqBoard.BoardConfig.SetPatternTrigPort(1);

short low = Convert.ToInt16(listenString, 2);

SetTrigger(TriggerType.TrigPatternEQ, low, short.MaxValue);

message = new ushort[this.contentSize];
MccService.WinBufFreeEx(this.memHandle);
memHandle = MccService.WinBufAllocEx(this.contentSize);
ret = DInScan(DigitalPortType.AuxPort, contentSize, ref rate, memHandle, ScanOptions.ExtTrigger);

The pattern never seems to get detected because it never seems to progress past the DInScan method call.  I've confirmed that the pattern has been generated correctly.  What am I doing wrong.

 

Update to this post, so I changed 

ret = DInScan(DigitalPortType.AuxPort, contentSize, ref rate, memHandle, ScanOptions.ExtTrigger);

to 

 

ret = DInScan(DigitalPortType.AuxPort, contentSize, ref rate, memHandle, ScanOptions.Default);

so it would accept anything and not look at a pattern but turns out that the problem is not that its not seeing the pattern, its not reading any data at all.  When I dump the buffer to an array.  All I see are zeroes.  Its a different problem than what I thought it was.

Edited by Mtd001
Link to comment
Share on other sites

Recommended Posts

  • 0

I re ran your code and like before the only time I was able to get trigger to occur was when 

RetVal = daq.SetTrigger(TriggerType.TrigPatternNE, 0xFFFF,PATTERN);

and

RetVal = daq.SetTrigger(TriggerType.TrigPatternBelow, 0xFFFF,PATTERN);

nothing else would cause the trigger to occur.

Link to comment
Share on other sites

  • 0

To rule out the code that sent the signal I've included it below.

 

            MccDaq.DaqDeviceManager.IgnoreInstaCal();
            this.BoardNum = this.GetBoardNumber();
            this.daqBoard = new MccBoard(this.BoardNum);
            ret = this.daqBoard.DConfigPort(DigitalPortType.AuxPort1, MccDaq.DigitalPortDirection.DigitalOut);

            this.memHandle = MccService.WinBufAllocEx(sizeContent.Length);
            ret = MccService.WinArrayToBuf(sizeContent, this.memHandle, 0, sizeContent.Length);
            this.ret = this.daqBoard.DOutScan(DigitalPortType.AuxPort1, sizeContent.Length, ref rate, memHandle, ScanOptions.Default);

 

this code runs on a computer connected to a separate usb-dio32hs

Link to comment
Share on other sites

  • 0

At this time, I'm not able to reproduce the problem. My test program triggers correctly with 0x6DBD applied to AuxPort0. I've tested other combinations too. I suspect one of your wires is not making good contact with the screw terminal. 

In the while, you can just read the current value while waiting for it to trigger. For example:

short digVal = 0;

   while (curCount < 10)
    {

          RetVal = daq.GetStatus(out status, out curCount, out curIndex, FunctionType.DiFunction);

          System.Threading.Thread.Sleep(20);

          if (Console.KeyAvailable) break;

          daq.DIn(DigitalPortType.AuxPort0, out digVal);

          Console.Write("{0},", digValue.ToString("X");
    }

 

Link to comment
Share on other sites

  • 0

I am still unable to trigger via a pattern.  Just to clarify that you are putting the pattern in the high threshold and mask in the low threshold ?

I was able to get a work around for this problem by wiring up the trig pin then using

ret = this.daqBoard.SetTrigger(TriggerType.TrigRising, 0xffff,0x6dbd ); 

then using         ret = this.daqBoard.DInScan(DigitalPortType.AuxPort0, this.size, ref this.rate, memHandle, ScanOptions.ExtTrigger);  Not ideal but it seems to work until I can get the pattern code to work.

However, I'm running into a second problem that I was hoping you can help.  I initiate a read using the above code, then in a separate thread attempt to write by using 

            ret = MccService.WinBufFreeEx(this.memHandle);
            this.memHandle = MccService.WinBufAllocEx(sizeContent.Length);
            ret = MccService.WinArrayToBuf(sizeContent, this.memHandle, 0, sizeContent.Length);
            this.ret = this.daqBoard.DOutScan(DigitalPortType.AuxPort1, sizeContent.Length, ref rate, memHandle, ScanOptions.Default);
 

The call the DOutScan would not execute until AFTER the DInScan finish.  Should I be able to do both DInScan and DOutScan at the same time ?

Link to comment
Share on other sites

  • 0

Ran  your code and got the following when I sent 0x6DBD followed by 0x6DBD

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

I'm reasonably sure I'm sending the signal correctly because If I send a "1"  followed by 0x6dbd (the 1 is if I set trigger to TrigRising)  I am able to read everything correctly.

 

 

 

Also, can you answer the following question ?

The call the DOutScan would not execute until AFTER the DInScan finish.  Should I be able to do both DInScan and DOutScan at the same time ?

 

Link to comment
Share on other sites

  • 0

Its actually a solar panel.  I'm hitting the solar panel with a light that is turned on/off with another usb-dio32hs.  A ground loop ?  I'm connecting the solar panel to port 0 and on port 1 I'm connecting the a light source.  I'll start removing stuff and re-connecting and see what happens.

 

Also 

 I'm running into a second problem that I was hoping you can help.  I initiate a read using the above code, then in a separate thread attempt to write by using 

            ret = MccService.WinBufFreeEx(this.memHandle);
            this.memHandle = MccService.WinBufAllocEx(sizeContent.Length);
            ret = MccService.WinArrayToBuf(sizeContent, this.memHandle, 0, sizeContent.Length);
            this.ret = this.daqBoard.DOutScan(DigitalPortType.AuxPort1, sizeContent.Length, ref rate, memHandle, ScanOptions.Default);
 

The call the DOutScan would not execute until AFTER the DInScan finish.  Should I be able to do both DInScan and DOutScan at the same time ?

 

 

Link to comment
Share on other sites

  • 0

ScanOption.Default makes the function wait until it's finished doing its business. To run both scans simultaneously, include the BACKGROUND scan option like  BACKGROUND | EXTTRIGGER.  It instructs the function to return immediately. Use the GetStatus function to determine when it starts and finishes. 

To ensure your setup is working, could you use our DAQami program to test your setup? I want to ensure you can output values and see correct responses.

 

Link to comment
Share on other sites

  • 0

Eureka, I found the problem.  I re-ran your code again and played around with the rate and got the following output.

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,2,2,0,2,2,0,2,2,2,2,0,2

If I got rid of the commas

0220220220222202

The reason the pattern was not detected was because it was expecting

0110110110111101

The question now becomes.  Why am I getting 2's instead of 1's and how can I get 1's instead.  The pattern was there just 2s instead of 1s.

Link to comment
Share on other sites

  • 0

ok, so I connected the positive input to p0d0 instead of p0d1 and got the following

0,0,0,0,0,1,1,0,1,1,0,1,1,0,1,1,1,1,0,1

get rid of the commas

0110110110111101 

which is my pattern 0x6DBD but running your program does not activate the trigger.

Link to comment
Share on other sites

  • 0

I don't know why it's not triggering because it works for me. Can you send me your program code?

Also, I've modified my program to test using DOutScan and DInScan simultaneously. In doing so, I found a bug in the program I provided. I used DConfigBit for AuxPort0 instead of DConfigPort. It's a minor bug because the default configuration is input.

RetVal = daq.DConfigBit(DigitalPortType.AuxPort0, 0, DigitalPortDirection.DigitalIn);

RetVal = daq.DConfigPort(DigitalPortType.AuxPort1, DigitalPortDirection.DigitalOut);

Please look at the attached program to see how to use DInScan and DOutScan simultaneously. If you would like to test your USB-DIO32HS, you can connect AuxPort0 to AuxPort1. - P0D0 to P1D0, P0D1 to P1D1, etc.
                         

Program.cs

Link to comment
Share on other sites

  • 0

We need to make sure it is defective. Can you connect AuxPort0 to AuxPort1 and then use the DAQami program to test each bit?

We usually don't replace items because too many result from customer misuse. If it's broken and your purchase was less than a year ago, there's no charge for the repair. 

Link to comment
Share on other sites

  • 0

Trust me I don't want to have to deal with returning the units (I have 2 of them)  and I don't have time to wait for replacement.  One odd thing to note is that Both of my usb-dio32hs are doing the same thing.  I ran your code and both units are outputting the correct 0110110110111101 when writing out DIN but fail to trigger.  However, I don't know what else to try.  You tell me that your code on your unit is activating the trigger.   I run the same code and although I see the pattern getting written via the DIn method call (that proves that its seeing the pattern but not recognizing it).  This also validates that the wiring is correct and also validates that the correct signal is being sent to the unit.  I don't know what else to try.  If worse comes to worse then I can set trigger using TrigRising and wire to the Trig port and send a trigger bit.  This seems to work but not ideal.  

Link to comment
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
×
×
  • Create New...