4.25 - PulseOut [U12 Datasheet] | LabJack

# 4.25 - PulseOut [U12 Datasheet]

Requires firmware V1.1 or higher. This command creates pulses on any/all of D0-D7. The desired D lines must be set to output using another function (DigitalIO or AOUpdate). All selected lines are pulsed at the same time, at the same rate, for the same number of pulses.

Execution time for this function is about 20 milliseconds plus pulse output time.

This function commands the time for the first half cycle of each pulse, and the second half cycle of each pulse. Each time is specified by sending a value B & C, where the time is:

1st half-cycle microseconds = ~17 + 0.83C + 20.17BC
2nd half-cycle microseconds = ~12 + 0.83C + 20.17BC

... both of which can be approximated as:

microseconds = 20BC

So, if lowFirst is 0 (false), then 20B1C1 is the high time and 20B2C2 is the low time.  If B1=C1=B2=C2=10, that would mean the low time is 2ms and the high time is 2ms, which means the period is 4ms, the frequency is 250Hz, and the duty-cycle is 50%.

For best accuracy when using the approximation, minimize C. B and C must be between 1 and 255, so each half cycle can vary from about 38/33 microseconds to just over 1.3 seconds.

If you have enabled the LabJack Watchdog function, make sure it's timeout is longer than the time it takes to output all pulses.

The timeout of this function, in milliseconds, is set to: 5000+numPulses((B1C1*0.02)+(B2C2*0.02))

PWM Output:

Wanting to output PWM?  Other LabJacks are much better at PWM, but you can use these PulseOut functions on the U12 to create PWM.  To simplify things we will use the 20BC approximation and will set C1=C2, so we can just call it C.  That means:

Period = 20B1C + 20B2C = 20C * (B1 + B2)

First, get the frequency you want.  Say you want 200 Hz, which is a period of 5000us.  That means:

5000 = 20C * (B1 + B2)

B1 + B2 = 250/C

We want to choose C such that it is as small as possible to help with the accuracy of the approximation, but we want to keep B1 + B2 <= 255 so we can get the full range of duty cycle.  We will choose C=1 for this example, so:

B1 + B2 = 250

Now we know that with C1=C2=1, and B1 + B2 = 250, we will get a frequency of about 200Hz.  If lowFirst is 0, then 20B1C2 is the high time and thus the duty cycle is:

DutyCycle = B1 / (B1 + B2) = B1 / 250

So, if B1=50, B2=200, C1=C2=1, we get a frequency of about 200 Hz and duty cycle of about 20%.

Declaration:

``````long PulseOut (    long *idnum,
long demo,
long lowFirst,
long bitSelect,
long numPulses,
long timeB1,
long timeC1,
long timeB2,
long timeC2)
``````

Parameter Description:

Returns: LabJack errorcodes or 0 for no error.

Inputs:

• *idnum – Local ID, serial number, or -1 for first found.
• demo – Send 0 for normal operation, >0 for demo mode. Demo mode allows this function to be called without a LabJack.
• lowFirst – If >0, each line is set low then high, otherwise the lines are set high then low.
• bitSelect – Set bits 0 to 7 to enable pulsing on each of D0-D7 (0-255).
• numPulses – Number of pulses for all lines (1-32767).
• timeB1 – B value for first half cycle (1-255).
• timeC1 – C value for first half cycle (1-255).
• timeB2 – B value for second half cycle (1-255).
• timeC2 – C value for second half cycle (1-255).

Outputs:

• *idnum – Returns the local ID or –1 if no LabJack is found.

### i just started using labjack

i just started using labjack and labview and i have run into some trouble:

1) when using labview how does one assign the B1,C1,B2,C2 values to the pusleout?

2)if given a desired pulse duration(cycle length), how do you find B1,C1,B2, and C2, and what is the equation for each?

I would really appreciate any help

Thanks

### 1.  I am not sure what you

1.  I am not sure what you are asking.  You pass the desired values in to those parameters of PulseOut or PulseOutStart.  For LabVIEW help, go to the LabVIEW Examples (U12) page and forum topic #84.

2.  I don't understand this question either.  The equations are given above.  For example, using the simplified approximate equation, say you want to create a 10Hz square wave.  That means the period of the square wave is 100ms, and each half cycle is 50ms.  So using the equation us=20*B*C, you could use B1=C1=B2=C2=50.  You can also use the PulseOutCalc function to help.

### Hi, I'am using the function

Hi,

I'am using the function "pulse out" and I am trying to create a module where I can modify  frequency and duty cycle :

so I am to solve the system :

1) Fr = 1/ (first half cycle + scd half cycle)

2) Dc = first half cycle / (first half cycle + scd half cycle)

If I define c1=c2=1

So B1 < 0

Is it normal ? are my equations good ?

Thanks,

Ronan