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

Data acquisition


  • Please log in to reply
1 reply to this topic

#1 tee-banks

tee-banks
  • Members
  • 2 posts

Posted 21 July 2014 - 02:14 PM

Hi

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. Now 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 output 0.0v. Can i get any help on this

 

Thanks



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 21 July 2014 - 03:58 PM

You can get the IO0 and IO1 states with two EDigitalIn or one DigitalIO calls:

 

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

http://labjack.com/s...sers-guide/4.17

 

The digitalIO.m and easyFunctions.m MATLAB examples demonstrate these calls' usage. With the states you can use if conditions to set the analog outputs as you like. For example using EDigitalIn (add error checking in your code):

readD = 0 %Use IO lines

%Get state of IO0 (switch 1)
io0State = 0
[errorCode, idnum, io0State] = lj.LabJack.EDigitalIn(idnum, demo, 0, readD, io0State);

%Get state of IO1 (switch 2)
io1State = 0
[errorCode, idnum, io1State] = lj.LabJack.EDigitalIn(idnum, demo, 1, readD, io1State);

if (io0State >= 1) && (io1State == 0)
    %Set both AOs to 5.0 V
    [errorCode, idnum] = lj.LabJack.EAnalogOut(idnum, demo, 5.0, 5.0)
end

if (io0State == 0) && (io1State >= 1)
    %Set both AOs to 0.0 V
    [errorCode, idnum] = lj.LabJack.EAnalogOut(idnum, demo, 0.0, 0.0)
end



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users