Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

U3 Single Pulse Output on multiple pins


  • Please log in to reply
13 replies to this topic

#1 MAH2681

MAH2681
  • Members
  • 9 posts

Posted 06 May 2012 - 12:04 PM

Hello, I am using the U3 Single Pulse Output (no-timer) vi to create a pulse (about 250 ms) on a particular pin (say FIO3). That works fine and produces a pulse as I want it to with no issues. I would like to create an additional pulse on a separate pin (say FIO4), and the have the pulses active together at the same time. I had previously did something similar on the LabJack U12 quite easily with no issues, however with the U3, I am running into a problem. I can't seem to add the additional pin, I only seem to produce a signal on one pin, and it isn't correct (when adding a second pulse to a pin). I was hoping someone could point me in the right direction as to what I am missing (a command or something of the like) that has to be added to make this work. I assume this is possible, but it may not be with one vi. I tried running two separate vi's (one for each pin), but the pulses were shifted. I'd like to reproduce what worked so well on the U12 with the U3 (U3-LV version). If an example with the additional pin pulsing could be posted, that would be helpful. I'm running Windows 7 and Labview 2010 SP1. Thanks in advance...

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 07 May 2012 - 08:39 AM

If you look at the VI's diagram it is putting together a list of operations for the LabJack to perform. First set an IO, then wait a while, then set an IO again. To achieve two simultaneous pulses you need to: Set an IO Set the other IO Wait the shorter pulse's duration Set the IO with the shorter pulse Wait the time difference between the two pulses Set the other IO

#3 MAH2681

MAH2681
  • Members
  • 9 posts

Posted 18 May 2012 - 10:10 AM

Thanks for the reply. I have been super busy with some other work, but finally got around to trying this out after reading the reply several times. It looks like I have both pulses going right now. However, the second appears to be shifted slightly. I'd like them both to be 250 microseconds and exactly the same. Is there something I'm missing? I have attached my vi (saved in Labview 2010). Any other advice would be appreciated.

Attached Files



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 18 May 2012 - 11:23 AM

Because the commands are executed in order there will always be a slight timer difference between edges when using bit operations. To get the edges to transition at the exact same time you need to use port functions and set the pins and mask both pins to get a concurrent transition. On the U3 HV and LV here are the pin groups within which you can expect IO to transition without any delay between them: FIO 0-3 FIO 4-5 FIO 6-7 EIO 0-3 EIO 4-5 EIO 6-7 CIO 0-3

#5 MAH2681

MAH2681
  • Members
  • 9 posts

Posted 18 May 2012 - 01:17 PM

Can you post an example of this or direct me to an existing example that shows how to do this, making use of these commands?

#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 18 May 2012 - 02:05 PM

Start with "U3 Single Pulse Output (no-timer).vi", but rather than using LJ_ioPUT_DIGITAL_BIT use LJ_ioPUT_DIGITAL_PORT. You can read more about that IOType in Section 4.3.5:

http://labjack.com/s...ers-guide/4.3.5

Try it, and if you have trouble post a screenshot of your code (we can't open anything newer than LabVIEW 7.1).

#7 MAH2681

MAH2681
  • Members
  • 9 posts

Posted 18 July 2012 - 07:53 AM

I've been away on travel and have been trying to work on this before leaving again, but still no luck. I've read the portion of the users guide specified, but I'm still confused. I've attached a capture of my original code that use the "PUT_DIGITAL_BIT" parameter and has the pulses slightly shifted. I'm confused as to how to implement the parameter you suggested and overall with the newer parameters of the U3. The dual pulsing was much easier in my view with the previous U12 model, at least as far as getting it to work in Labview. If there is anyway you can post a screen capture of what I should be doing or an example code that demonstrates the dual pulsing, I'd appreciate it. I'll keep plugging away on this, but I need some direction as to what I am doing wrong and where exactly and how these new commands should be implemented.

Attached Thumbnails

  • U3_DualPulseOutput_001.PNG


#8 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 18 July 2012 - 08:40 AM

The original "U3 Single Pulse Output (no-timer).vi" is almost what you want, so start with that rather than your modified VI. It does 3 requests in order:

IOType, Channel, Value:

LJ_ioPUT_DIGITAL_BIT, 4, 1
LJ_ioPUT_WAIT, 0, 100000
LJ_ioPUT_DIGITAL_BIT, 4, 0

You want to use the port iotype to control multiple bits in the same request. Besides changing iotype, you need to change Channel and Value and add x1. This comes from Section 4.3.5 which says that with the port iotype Channel is the starting bit and x1 is the number of bits. Value then is the binary encoded value for whatever bits you are doing:

http://labjack.com/s...ers-guide/4.3.5

Say you want to set FIO4 & FIO5 high at the same, then wait, then set both low. Binary b11 is decimal 3, so in decimal you do:

IOType, Channel, Value, x1:

LJ_ioPUT_DIGITAL_PORT, 4, 3, 2
LJ_ioPUT_WAIT, 0, 100000
LJ_ioPUT_DIGITAL_PORT, 4, 0, 2

Try that and if you have trouble post a screenshot.

#9 MAH2681

MAH2681
  • Members
  • 9 posts

Posted 18 July 2012 - 09:15 AM

After reading your explanation I'm still a little confused. How would what you have described translate into the Labview example? I don't understand where the 3 and 2 you mentioned would go. Which values are placed in the x1 control and how many? Again, if you can post a screen capture of a code that is setup to what you described, that would help me understand all of this better. My screenshot posted previously was built off of the standard example. I thought i had understood that enough to modify it to get dual pulses generating. I had both pulses showing up, the second one was shifted slightly. I thought it was an easy fix to switch the commands. It may be, but I'm just not quite following with how to get it done.

#10 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 18 July 2012 - 09:28 AM

You want matching (same length) arrays for IOTypes, Channels, Values, and x1. See attached.

Attached Files



#11 MAH2681

MAH2681
  • Members
  • 9 posts

Posted 18 July 2012 - 10:16 AM

Thank you very much for the example and your help, that is a big help. While the example you provided does the job, I do have another related question, which you may have answered previously, but I want to follow up on. Can the dual pulsing happen on say channels 0 and 4, without the shift I saw previously? I was trying to modify the newest example to do this, but I wasn't seeing any pulsing on the second channel, in this case 4. I may have been doing something wrong as far as not providing a value somewhere else to compensate. Or will the dual pulsing without any shift only take place in groups of channels, i.e. FIO0-FIO1, FI02-FIO3, etc? If the latter is the case, that's not a huge deal, we'll modify are wiring and software accordingly, I just want to check to see if it can be done and what I might be doing wrong software wise. Thank you again for your help (and patience).

#12 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 18 July 2012 - 10:45 AM

The port iotypes just specify starting channel and number of bits, so you have to use sequential channels. You could do 0 through 4, but not just 0 and 4.

#13 lakelander

lakelander
  • Members
  • 2 posts

Posted 01 May 2014 - 04:28 AM

HI

I'm trying to use a U3 to produce a single pulse output with the matlab driver based on this advice

 

The original "U3 Single Pulse Output (no-timer).vi" is almost what you want, so start with that rather than your modified VI. It does 3 requests in order:

IOType, Channel, Value:

LJ_ioPUT_DIGITAL_BIT, 4, 1
LJ_ioPUT_WAIT, 0, 100000
LJ_ioPUT_DIGITAL_BIT, 4, 0

 

 

here is my example code

 

ljud_AddRequest(ljHandle, LJ_ioPUT_DIGITAL_BIT, 4, 1,0,0)
ljud_AddRequest(ljHandle, LJ_ioPUT_WAIT, 0, 100000,0,0)
ljud_AddRequest(ljHandle, LJ_ioPUT_DIGITAL_BIT, 4, 0,0,0)

tic
ljud_GoOne(ljHandle)
toc
 

the tic/toc latency depends on the value of the LJ_ioPUT_WAIT command - for 100000 it is 0.05 s and for 1000000 it is 0.5s.

 

I thought using this strategy the command sequence would be passed to the U3 where the WAIT is performed and matlab would not be paused.

 

What am I missing?



#14 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 06 May 2014 - 03:46 PM

HI

I'm trying to use a U3 to produce a single pulse output with the matlab driver based on this advice

 

The original "U3 Single Pulse Output (no-timer).vi" is almost what you want, so start with that rather than your modified VI. It does 3 requests in order:

IOType, Channel, Value:

LJ_ioPUT_DIGITAL_BIT, 4, 1
LJ_ioPUT_WAIT, 0, 100000
LJ_ioPUT_DIGITAL_BIT, 4, 0

 

 

here is my example code

 

ljud_AddRequest(ljHandle, LJ_ioPUT_DIGITAL_BIT, 4, 1,0,0)
ljud_AddRequest(ljHandle, LJ_ioPUT_WAIT, 0, 100000,0,0)
ljud_AddRequest(ljHandle, LJ_ioPUT_DIGITAL_BIT, 4, 0,0,0)

tic
ljud_GoOne(ljHandle)
toc
 

the tic/toc latency depends on the value of the LJ_ioPUT_WAIT command - for 100000 it is 0.05 s and for 1000000 it is 0.5s.

 

I thought using this strategy the command sequence would be passed to the U3 where the WAIT is performed and matlab would not be paused.

 

What am I missing?

 

The LJ_ioPUT_WAIT command is sending the wait to the U3.  The LabJackUD library will wait until the U3 finishes processing the whole command before returning from the function.  Thus, if you have a wait of 0.5s, that function will take 0.5s to return, as it is waiting for the response from the U3.

This is just the way things are designed.  The library/driver must always wait for communication to finish so it knows if there was an error or not.  When you add a delay (In the form of a wait) to the communication, it must wait that long.

 

If you wanted to wait 0.5s without Matlab pausing you could use the ePut() function with LJ_ioPUT_DIGITAL_BIT to set the i/o line high, then wait using a function in matlab (such as the Sleep() function Matlab supports), then the ePut() function again to set the line low.  This timing won't be as accurate as doing it with the LJ_ioPUT_WAIT method, but won't have to spend that time waiting in the library for the function to return.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users