LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LED as a light sensor w/ arduino

Hello All,


   <insert obligatory "I'm New To Labview" Here>, Well, new to programming in Labview, but have programming off and on for years, nothing professional... Still getting a grip on the formatting...  I also hope I'm putting this in the correct forum.

 


I'm using Labview 2012, Arduino Uno, and LVIFA, and have been surprised at how easy it is to do many tasks. However, some things still confuse me, but getting there.

 

For my project, I would like to monitor and record the quality of the light in specific wavelengths over time. I've found many places saying you can use an LeD to acquire a specific frequency, and several Arduino sketches to do just that, however my Google-fu has failed me, and I have not found a Labview VI example  that I can play with to toy with. I believe it is going to be simple enough, but I don't yet have the skills to program this from scratch. Can anyone point me to an example ?

 

Second Question. For my project, I'm feeling a bit retro, and would love to set up my front panel to look like a 1960's era Rack mount panel display. (most notably, The large plastic selector knobs, dials, and buttons) I have seen a couple suggestions that there should be a place for user created custom controls so that we don't keep remaking the wheel, has this happened yet? Does anyone have a "set" of old style knobs and buttons already built, or am I doomed to have to try and make these things myself later?

 


I'm sure there are many more questions, but it is late, and my mind is going blank, so enough for tonight, and thank you in advance for your replies,

-Chris

 

0 Kudos
Message 1 of 12
(5,283 Views)

Chris,

 

Welcome to LabVIEW and to the Forums!

 

LEDs, at least monochromatic ones, can be used as wavelength selective sensors. They are sensitive to approximately the same wavelengths they emit.  White LEDs are not suitable.  They are basically blue LEDs coated with phosphors to produce a broader spectrum.  I have never tried one as a sensor, but the physics suggests that they would be rather poor blue sensors and not responsive to the longer wavelengths.

 

As sensors they will act like any other photodiode. So you can use the any of the thousands of circuits available for photodiodes.  It sounds like you want to use the Arduino for the data acquisition and then communicate the results to LV, right? I have not used this approach.  I think it uses a USB connection configured as a virtual RS-232 port.  If that is the case, you can use the basic serial communication example VIs to get started.

 

I cannot help with the knobs.

 

Lynn

Message 2 of 12
(5,261 Views)

I wish to than you for your response, and apologize for not being clearer in what I was looking for. I really should avoid posting anything when tired, I tend to end up leaving important details out when I do so. 

 

  So to back things up a little bit, I've long been looking for a cheap (or reasonably priced) way to monitor the decay of light quality in the bulbs for my salt water fish tank. Corals can be fussy about the quality of their light, and currently, the only way to make sure they are happy is to replace very expensive bulbs on a calendar schedule and I'm not always sure if they truly need replacing. 

 

  A couple weeks ago ( before buying Labview or Arduino) I stumbled across the "Led's can be used as a light sensor" information, and was happy (as I have a wide selection of Led's from IR to UV) and started looking into this more. After much digging I found there are two basic ways that can be used to make a Led into sensor. 1st on, and pretty easily done (and I've tried it, and it does work) is to connect the Led to a analog input pin and measure the voltage generated. However this doesn't seem to be the preferred method, and given it's ease, I have to wonder why. The 2nd method is a little more complicated, yet appears to be the preferred method. It involves connecting the Anode of the diode to Digital P2, and the Cathode to Digital P3, Applying voltage to P2 while keeping P3 low (for about 1 ms, thus charging the parasitic capacitor ) the measuring the time it takes for the voltage to leak at P3. I'm writing this from memory so a few details may be wrong, but basically reverse bias a led, measure the leakage.

 

  I found ways to play with the analog input method, but I want to compare the digital input method. It doesn't seem like the code would be all that difficult to write, However as it took me the better part of a 8 hr day to figure out how to writethe following in Labview:

 

sub loop1;

  If X=20 then (do things; X=0)

   else X = X+1;

goto loop1;

 

 

I expect it will take me a bit more before I get that other code.

 

 

0 Kudos
Message 3 of 12
(5,210 Views)

Chris,

 

I would not use either of those methods to monitor the LED photodiode.

 

The output voltage is not a very good indicator of the light intensity.  The current is much more relevant.  The second method is very dependent on the capacitance and leakage currents, both of the diode and of the Digital lines. The diode capacitance is a function of temperature and voltage and leakage currents are quite temperature dependent.  The method I prefer requires a bit more circuitry but is much more robust. Connect the diode to an op amp with a resistor for feedback.  The resistor and op amp convert the diode current (which is proportional to light) to a voltage which is easy to measure with an analog input.

 

Since you do not need rapid response, you could use a single op amp with multiple LEDs, using open drain FET switches driven by Digital Lines to select the particular diode you want to measure at any given time.

 

Here is a simple LV loop which implements what I think you were trying to do with the pseudo-code. Have you looked at the on-line tutorials for Getting Started with LabVIEW.  Going through those first would probably have not taken any longer to get your VI working and you would have learned a lot about LV.

 

Lynn

0 Kudos
Message 4 of 12
(5,195 Views)

@johnsold wrote:

Chris,

 

I would not use either of those methods to monitor the LED photodiode.

 

The output voltage is not a very good indicator of the light intensity.  The current is much more relevant.  The second method is very dependent on the capacitance and leakage currents, both of the diode and of the Digital lines. The diode capacitance is a function of temperature and voltage and leakage currents are quite temperature dependent.  The method I prefer requires a bit more circuitry but is much more robust. Connect the diode to an op amp with a resistor for feedback.  The resistor and op amp convert the diode current (which is proportional to light) to a voltage which is easy to measure with an analog input.

 

Since you do not need rapid response, you could use a single op amp with multiple LEDs, using open drain FET switches driven by Digital Lines to select the particular diode you want to measure at any given time.

 

Here is a simple LV loop which implements what I think you were trying to do with the pseudo-code. Have you looked at the on-line tutorials for Getting Started with LabVIEW.  Going through those first would probably have not taken any longer to get your VI working and you would have learned a lot about LV.

 

Lynn


Lynn, i like your circuit idea of output voltage base on the light emmitted from the tank, but to use labview to monitor that voltage over a period of time would be over kill....use the same circuit you had mentioned and connect the output voltage to a voltage comparator and once the low voltage is reached the output can turn an LED indicator to signal bulb change. why use computer resources and labview to continually monitor a fish tank lamp? just my humble opinion...

0 Kudos
Message 5 of 12
(5,188 Views)

Check it once a week?  I agree that continuous monitoring is probably not needed.

 

Lynn

0 Kudos
Message 6 of 12
(5,175 Views)

I'll answer that one. This is only one small piece of a larger project that is in the works. Over all, the plan is to control multiple valves to re-direct water currents both during the day and night, monitor temperature, check PH, control water lever and an automatic top off, specific gravity, If I can figure out how, monitor several other chemical levels such as ammonia, phosphates, nitrates, KH,  as well as adding other things in the future. I first considered just hardwiring much of this, or using assembly to write a simple code, but I decided I liked the idea of being able to adjust flow and flow rates by simply changing a few settings vs spending time with a soldering iron.

 

  As for being overkill... Salt water fish can be very expensive. The average price of the corals in my tank are $50.00, and some easily reach $100 - $150. While I don't have any expensive fish, the ones I like average $50.00, and can reach $250.00. When dealing with these kind of prices, a little overkill isn't that much and since a old computer is just sitting there,collecting dust and Arduino board costs $35.00 (and more importantly, it's a way to force me to learn Labview, which will make me more valuable to my employer).  

0 Kudos
Message 7 of 12
(5,172 Views)

@cdemeritt wrote:

I'll answer that one. This is only one small piece of a larger project that is in the works. Over all, the plan is to control multiple valves to re-direct water currents both during the day and night, monitor temperature, check PH, control water lever and an automatic top off, specific gravity, If I can figure out how, monitor several other chemical levels such as ammonia, phosphates, nitrates, KH,  as well as adding other things in the future. I first considered just hardwiring much of this, or using assembly to write a simple code, but I decided I liked the idea of being able to adjust flow and flow rates by simply changing a few settings vs spending time with a soldering iron.

 

  As for being overkill... Salt water fish can be very expensive. The average price of the corals in my tank are $50.00, and some easily reach $100 - $150. While I don't have any expensive fish, the ones I like average $50.00, and can reach $250.00. When dealing with these kind of prices, a little overkill isn't that much and since a old computer is just sitting there,collecting dust and Arduino board costs $35.00 (and more importantly, it's a way to force me to learn Labview, which will make me more valuable to my employer).  



then...there ya go. labview would be very capable to do that job....I did not realizing the whole scope of the project. Have you joined the Arduino forum yet? There are many useful information concerning Arduino. I myself have a board and controlled digital pots using SPI communication. I've read that the UNO has 1 ADC onboard , therefore you will have to control a multiplexer to get the various voltage readings from your sensors. I would probably use a USB 600x....good luck!

0 Kudos
Message 8 of 12
(5,162 Views)

I would love a 6009, but it's a little steep for my budget at the moment. Arduino has 6 analog inputs and 11 (13 total, but 2 are dedicated to other things) Digial I/O pins. with 6 of those being PWM output capable. Some inital playing, I can read Temp, Light Level (using a CdS cell) and the analog reading of a led at the same time in my test code. (which is a horrible frankenstien of a monster, but it's trial at the moment) I'm also using a GGE909 HID compatible game controller I had lying around for additional inputs (feedback to confirm that the vavles I turn on/off actually turns on/off, scavanging... what a wonderful skill.)  Yes this project has been in the back of my head for some time. Most things will be passive infrequent checks, the valve controls are the big deal. Yes, lots of circuitry is still to be figured out, and  multiplexers/shift registers (as well as opto-isolators, I so prefer them to relays) are in my future. 

0 Kudos
Message 9 of 12
(5,156 Views)

Sounds like an interesting project.  Keep posting as you have more questions.

 

Lynn

0 Kudos
Message 10 of 12
(5,153 Views)