LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling Light intensity Using LDR

I am doing a project using LabVIEW 8.5, N6221 DAQ card. The project deals with switching on and off LED lights using LDR as a sensor. When there is light available the Led should be off but at night it should be on.  Im trying to in-cooperate some more sub vi’s to control the intensity of the LED light with different lighting level. For example if the voltage across the resistor is 4V then the program should send 0V via DAQ card to LED, for Voltage of 2v the program should send 4V to the LED. Infact the lesser the ambient light falling on thr LDR the brighter the LEDS get. Attached please find the VI Im currently using and the circuit diagram. Any help will be very much appreciated. 

Download All
0 Kudos
Message 1 of 18
(11,879 Views)

Hi kasamaneka,

 

so you decided to open a new thread instead of continuing your original one. What's the reason for that decision?

 


Infact the lesser the ambient light falling on thr LDR the brighter the LEDS get.


 

So you have an analog input and you need an analog output. You connect both by simple math, in the beginning something like "AO = 5 - AI" should do the trick. Instead of using ExpressVIs you should use simple DAQmx functions as demonstrated in all those example VIs coming with LabVIEW...

 

You should keep in mind you cannot connect a LED directly to a voltage source. You should also keep in mind the current limits of the AO pins of your DAQ card, they are given in the manual/spec sheet. That's pretty basic electronics knowledge, you should have learned that in school by now...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 18
(11,877 Views)

The circuit diagram has a 1k ohm resistor attached to the LED.

 

I am new to this software and for this simple Vi idid a lot of research and finally i managed to only switch on and off Led light, but now i need to change its intensity with varying ambient light. I tried DAQ max but made a big blunder and nothing was running well. How can I modify my program?

0 Kudos
Message 3 of 18
(11,870 Views)

Any example VI would be very helpful.

0 Kudos
Message 4 of 18
(11,839 Views)

Hi kasamaneka,

 

for getting examples you simply need to open the example finder (in LabVIEW's help menu) and look at all those DAQmx examples...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 18
(11,830 Views)

Tried whole day to match one of the example vi's could not find. Thought someone from this powerful forum might help me modifying my current project.

0 Kudos
Message 6 of 18
(11,806 Views)

Hi kasamaneka,

 

so you're not able to learn from example VIs like "PID Control-Single Channel", that uses one analog input to control one analog output? Come on!

 

You will find that in the DAQmx section of the example finder...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 18
(11,799 Views)

I think its kind of complicated thing to do of what you have suggested. Attached please find of what i was expecting as help. Thanks for couple of tips you gave.

0 Kudos
Message 8 of 18
(11,722 Views)

Hi kasamaneka,

 

so it took you two weeks to create a VI with a race condition? You don't need a property node in there:

check.png

The point is:

That basically is the same as the example VI i mentioned earlier: you used DAQ-Assistent expressVIs instead of the plain DAQmx functions shown in the example. If you would have used that example you only needed to change the "PID"-control VI to use your simple control algorithm with all those comparisons and add functions...

 

But well: "learning by doing" is acceptable! 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 18
(11,714 Views)

Do you mind sending me the VI, you modified. I think it looks better than mine. But I am using Labview version 8.5.

0 Kudos
Message 10 of 18
(11,693 Views)