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

Setting DAC0 output with MATLAB


  • Please log in to reply
1 reply to this topic

#1 bongewj

bongewj
  • Members
  • 3 posts

Posted 29 July 2014 - 09:05 AM

Hi, 

 

I'm very new with the Labjack and have no had much experience interfacing with DACs in general. I am trying to get the DAC to output 2.5V when one of the input goes below a certain voltage. I am able to read the inputs and store them in MATLAB using the examples posted, but I'm not sure how to implement an if else statement for the output. I greatly appreciate any help.

 

Thanks!



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 29 July 2014 - 12:00 PM

It could look something like this (untested code):

 

%Specify the ainChannel to read the analog input from and the dacChannel to set the voltage of in your code

%Get our analog input's voltage
[ljError, voltage] = ljudObj.eGet(ljhandle, LabJack.LabJackUD.IO.GET_AIN, ainChannel, 0, 0);
if voltage < maxVoltage
    %Our analog input is below the maxVoltage we want. Setting the DAC to 2.5 V
    ljudObj.ePut(ljhandle, LabJack.LabJackUD.IO.PUT_DAC, dacChannel, 2.5, 0);
end

 

For general UD driver usage, take a look at the pseudocode section of the User's Guide:

 

http://labjack.com/s...users-guide/4.3

 

For help on MATLAB usage and syntax, look at the MATLAB examples.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users