Jump to content

Mtd001

Members
  • Posts

    29
  • Joined

  • Last visited

Mtd001's Achievements

Member

Member (2/4)

0

Reputation

  1. 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.
  2. I’m just running your code. The output that I posted was just your code. I can package my code and send you mine but in general both code will not activate the trigger
  3. So I know that it’s receiving the pattern. It’s not triggering though
  4. 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.
  5. 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.
  6. 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 ?
  7. 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,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,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,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,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, If I comment out the Thread.Sleep(20) I get the following. 0,0,0,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,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,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 ?
  8. 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 ?
  9. 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
  10. 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.
  11. The following is your code that I modified to invert the mask and pattern. Additionally my current wiring is connected to P0d0 and GND. Still doesn't work for me. using System; using MccDaq; //added to project references namespace DigitalOutput { class Program { public const string DEVICE = "DIO32HS"; //identify the board using string name public const int SAMPLES = 100; public const ushort PATTERN = 0x6dbd; public static MccDaq.MccBoard Discover(string dev) { //this ignores devices listed in InstaCal utility MccDaq.DaqDeviceManager.IgnoreInstaCal(); //get inventory of MCC USB devices MccDaq.DaqDeviceDescriptor[] inventory = MccDaq.DaqDeviceManager.GetDaqDeviceInventory(MccDaq.DaqDeviceInterface.Usb); int numDevDiscovered = inventory.Length; if (numDevDiscovered > 0) { //loop through inventory looking for device for (int boardNum = 0; boardNum < numDevDiscovered; boardNum++) { try { if (inventory[boardNum].DevString.Contains(dev)) { MccDaq.MccBoard daqBoard = MccDaq.DaqDeviceManager.CreateDaqDevice(boardNum, inventory[boardNum]); return daqBoard; } } catch (ULException ule) { Console.WriteLine("Error occured: " + ule.Message); } } } return null; } static void Main(string[] args) { MccDaq.ErrorInfo RetVal; MccBoard daq = Discover(DEVICE); if (daq == null) { Console.WriteLine("Board not detected!\n"); WaitForKey(); } else { try { RetVal = daq.DConfigBit(DigitalPortType.AuxPort0, 0, DigitalPortDirection.DigitalIn); RetVal = daq.BoardConfig.SetPatternTrigPort(1); if (RetVal.Value != 0) Console.WriteLine("SetPatternTrigPort error {0}", RetVal.Value); RetVal = daq.SetTrigger(TriggerType.TrigPatternEQ, 0xFFFF,PATTERN); if (RetVal.Value != 0) Console.WriteLine("SetTrigger error {0}", RetVal.Value); int rate = 1000; IntPtr buffer = MccService.WinBufAllocEx(SAMPLES); RetVal = daq.DInScan(DigitalPortType.AuxPort0, SAMPLES, ref rate, buffer, ScanOptions.ExtTrigger | ScanOptions.Background); if (RetVal.Value != 0) Console.WriteLine("DInScan error {0}", RetVal.Value); short status = 0; int curCount = 0; int curIndex = 0; RetVal = daq.GetStatus(out status, out curCount, out curIndex, FunctionType.DiFunction); while (curCount < 10) { RetVal = daq.GetStatus(out status, out curCount, out curIndex, FunctionType.DiFunction); System.Threading.Thread.Sleep(20); if (Console.KeyAvailable) break; } ushort[] UserBuffer = new ushort[SAMPLES]; MccService.WinBufToArray(buffer, UserBuffer, 0, SAMPLES); for (int i = 0; i < 10; i++) Console.WriteLine("Buffer[{0}] = {1}H", i, (PATTERN & UserBuffer[0]).ToString("X")); Console.ReadKey(); WaitForKey(); //stop background operation daq.StopBackground(FunctionType.DiFunction); //free up memory MccService.WinBufFreeEx(buffer); MccDaq.DaqDeviceManager.ReleaseDaqDevice(daq); } catch (ULException ule) { Console.WriteLine("Error occured: " + ule.Message); } } } /*////////////////////////////////////////////////////////////////////////////////////*/ public static void WaitForKey() { Console.WriteLine("\nPress any key to continue..."); do { System.Threading.Thread.Sleep(20); } while (!Console.KeyAvailable); ConsoleKeyInfo cki = Console.ReadKey(); } } }
  12. Running your code didn't work for me either with mask and pattern in either order
  13. my code private void Init() { MccDaq.DaqDeviceManager.IgnoreInstaCal(); this.BoardNum = this.GetBoardNumber(); this.daqBoard = new MccBoard(this.BoardNum); this.ret = this.daqBoard.DConfigBit(DigitalPortType.AuxPort0, 0,DigitalPortDirection.DigitalIn); this.ret = this.daqBoard.BoardConfig.SetPatternTrigPort(1); } private void Listen(ContentData model) { this.rate = model.Rate; this.size = model.Size; this.BoardNum = 0; this.messageList = new List<ushort[]>(); this.SetTrigger(); MccService.WinBufFreeEx(this.memHandle); this.memHandle = MccService.WinBufAllocEx(200); ret = this.daqBoard.DInScan(DigitalPortType.AuxPort0, 200, ref this.rate, memHandle, ScanOptions.ExtTrigger|ScanOptions.Background); short dataValue; short status; int currentCount = 0; int currentIndex = 0; int eventCount; do { ret = this.daqBoard.GetStatus(out status, out currentCount, out currentIndex, FunctionType.DiFunction); } while (currentCount < 200); var message = new ushort[200]; ret = MccService.WinBufToArray(memHandle, message, 0, 200); } public void SetTrigger() { ret = this.daqBoard.BoardConfig.SetPatternTrigPort(1); ret = this.daqBoard.DConfigBit(DigitalPortType.AuxPort0, 0, DigitalPortDirection.DigitalIn); short low = Convert.ToInt16(Communication.listenString, 2); ret = this.daqBoard.SetTrigger(TriggerType.TrigPatternEQ, 0xffff, 0x6dbd); } what am I missing. Also I'm wiring input to P0D0 and GND.
×
×
  • Create New...