4.2 - EAnalogOut [U12 Datasheet] | LabJack

# 4.2 - EAnalogOut [U12 Datasheet]

Easy function. This is a simplified version of AOUpdate. Sets the voltage of both analog outputs.

Execution time for this function is 20 milliseconds or less (typically 16 milliseconds in Windows).

If either passed voltage is less than zero, the DLL uses the last set voltage. This provides a way to update 1 output without changing the other. Note that when the DLL is first loaded, it does not know if the analog outputs have been set, and assumes they are both the default of 0.0 volts. Similarly, there are situations where the LabJack could reset without the knowledge of the DLL, and thus the DLL could think the analog outputs are set to a non-zero voltage when in fact they have been reinitialized to 0.0 volts.

Declaration:

long EAnalogOut (    long *idnum,
long demo,
float analogOut0,
float analogOut1 )

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.
• analogOut0 – Voltage from 0.0 to 5.0 for AO0.
• analogOut1 – Voltage from 0.0 to 5.0 for AO1.

Outputs:

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

## LabJackPython Example

>>> import u12
>>> d = u12.U12()
>>> d.eAnalogOut(analogOut0=2.0, analogOut1=2.0)
{'idnum': 12}

### I wanted to know what happens

I wanted to know what happens in the end of this example: will the tension remains set to 2V, or does it falls back to 0?

### The voltage will stay at the

The voltage will stay at the commanded 2.0 volts, until told to go to some other voltage.

### Is there a way to set the

Is there a way to set the voltage for a specified time?

eg (psuedo code):

time = 0

while time < 10

d.eAnalogOut(4.5, 0)

d.eAnalogOut(0,0)

or is the way I have written above suffice?

### The only way to control the

The only way to control the analog outputs is calling a function (e.g. EAnalogOut) that simply sets the AO to a new voltage.  So to have it change to a new voltage at some later time, you need to call the function again from software.  That means software timing is the only option.

You can create a 5/0 volt pulse with specified time on a digital output using the PulseOut functions.  Or you could use such a digital output pulse to control some sort of switch that is controlling the analog output signals.

### i want to send out 5v from

i want to send out 5v from the labjack u12 and after 3 seconds, send 0v. Want it repeated, i.e a while loop, please how do i go about this.

Thanks

### To alternate a voltage you

To alternate a voltage you would use a loop as you suggest. The host program would have to set 5V, wait for X milliseconds, set 0V, wait again etc.

If you need examples for a specific language start here: http://labjack.com/support/u12/examples

And shoot us an email if you don't find what you are looking for.

Also, The T7 can toggle an output without the need of a host computer by using script or stream out.

### If i do want to send the 5v

If i do want to send the 5v from the labjack into a circuit, do i just connect wire from the AO0 or AO1 and GND to the circuit or is there other ways,

Thanks

### You can also use +5V and GND,

You can also use +5V and GND, but you cannot turn off +5V on the U12, so it will always be on.

### Thanks for the previous

Thanks for the previous response about sending 5v from labjack... this is the program i have now

idnum = -1;  %Using first found U12
demo = 0;  %Normal operations

analogOut0 = 5.0;

[errorCode, idnum] = lj.LabJack.EAnalogOut(idnum, demo, analogOut0)

so how can i include the timing and the alternate voltage of 0v after the time elaspse..

cheers

### It would look something like

It would look something like this in MATLAB:

analogOut0 = 5.0
analogOut1 = 5.0
[errorCode, idnum] = lj.LabJack.EAnalogOut(idnum, demo, analogOut0, analogOut1) %Set both AO0 and AO1 to 5 V

pause(3.0) %wait for 3 seconds

analogOut0 = 0.0
analogOut1 = 0.0
[errorCode, idnum] = lj.LabJack.EAnalogOut(idnum, demo, analogOut0, analogOut1) %Set both AO0 and AO1 to 0 V

You need to set both analog outputs with the EAnalogOut call, so for the above example's case both are set the same.

The pause function documentation is here:

http://www.mathworks.com/help/matlab/ref/pause.html

### I really appreciate the

I really appreciate the support. . You the best. One more question i have a circuit which I want to power by send 5v from the u12 labjack, should I connect from the AO0 or AO1 and GND to the circuit or from the +5 and GND

Cheers

### You can supply more power

You can supply more power with the +5V and GND terminals than with AO0 and AO1, so +5V is better to power external sensors and circuits.

### Hi to get +5v from labjack

Hi to get +5v from labjack u12 analogOut, I connected my external circuit to AO0 and GNDso I can alternate btw +5v and 0v using matlab program, is my connection correct.

### Yes, that sounds correct for

Yes, that sounds correct for most situations.

### Hi thanks for all your

Hi thanks for all your support, you guys rock.....

i have written this program on matlab

analogOut0 = 5.0
analogOut1 = 5.0
[errorCode, idnum] = lj.LabJack.EAnalogOut(idnum, demo, analogOut0, analogOut1) %Set both AO0 and AO1 to 5 V

pause(3.0) %wait for 3 seconds

analogOut0 = 0.0
analogOut1 = 0.0
[errorCode, idnum] = lj.LabJack.EAnalogOut(idnum, demo, analogOut0, analogOut1) %Set both AO0 and AO1 to 0 V

now i am trying to modify it using two switches, which i have connected to my labjack u12 IO0 and IO1. Instead of the 3 seconds delay to change the output, i want if switch one is high and switch two is low, i will get analogOut 5.0v and if switch one is low and switch two is high, i will get 0.0v. I tried to modify this program, but i keep getting error. Can i get any help on this

Thanks

### I tried your chunk of code

I tried your chunk of code and it runs without problems. I added your code to the end of the analog.m example for testing.

In your script make sure your NET.addAssembly call is pointing to LJDotNet.dll in the location on your system.

Make sure the idnum is correct for your U12 (-1 for first found, local ID or serial number) and demo is 0.

If using 64-bit MATLAB make sure you install the 64-bit U12 driver (download is in the "Windows U12 Installer" details):

http://labjack.com/support/u12

If that doesn't help, what error are you getting from MATLAB or what error code are you getting from the EAnalogOut call?

### I am trying to use two

I am trying to use two switches, which i have connected to my labjack u12 IO0 and IO1. I want if switch one is high and switch two is low, i will get analogOut 5.0v and if switch one is low and switch two is high, i will get 0.0v. How can I achieve this code

### First make 2 calls to

First make 2 calls to EDigitalIn to read IO0 and IO1.  The you want a couple If statements such is "If IO0 & !IO1, Then EAnalogOut=5.0".  I suggest you try it in whatever language you are using, and then for further help and details post on our forum.