Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Need help making a simple flashing LED device

  1. Feb 23, 2010 #1

    ABN

    User Avatar

    I'm sure this is very simple for everyone here.

    I need to make a device that will allow an LED to flash at very specific rates (for example 4 times/sec).
    I assume I need to use an I/O system that will allow me to program it via computer connected by USB.
    If this is even the best way to go about this, my question is what kind of controller do I need or what should I be looking for to control the voltage?
     
  2. jcsd
  3. Feb 23, 2010 #2

    berkeman

    User Avatar

    Staff: Mentor

    Welcome to the PF. There are many ways to do this, depending on what your overall goal and requirements are. You can make a simple stand-alone circuit adjusted by a potentiometer, or you can program a simple microcontroller (uC) board to flash one of its LEDs, or you can make something controlled by a PC like you mention.

    What is your overall goal? What are the adjustment and accuracy requirements of the flash rate?
     
  4. Feb 23, 2010 #3

    ABN

    User Avatar

    Thank you berkeman

    The device is to be used in a biology laboratory working with zebrafish. Basically, I need to expose the fish to light at a very specific rate, ideally controlling both the duration that the light is on as well as when it is off. The rate of flashes will often be tweaked as the experiments progress.

    Precision is my main concern. And the other is ease of use.
    I realize there are many routes to create this device but frankly I don't know what the pros and cons of each would be. Could you lay this out for me and recommend specific chips or modules I should be looking at?
     
  5. Feb 23, 2010 #4
    use labview. its very simple. however you need to connect the output from the computer to the LED. I am working on a similar project but way way harder. its about microsecond delays and it has to be damn exact, and not just one led but 100 of them. What class grade are you attending?
     
  6. Feb 23, 2010 #5

    berkeman

    User Avatar

    Staff: Mentor

    That's very helpful. For biological response times, a USB (or other) controlled interfaced from Windows will be fine. For really precise real-time control, you need to consider other OSs, but for people and fish response times, Windows based program control is generally fine.

    Look at the National Instruments interfaces for USB and any other interfaces you might have available on your PC. I prefer to program in CVI, but you can use LabView if that works better for you. Omega Instruments also has hardware to get you from the PC out to digital/analog IO.
     
  7. Feb 23, 2010 #6

    ABN

    User Avatar

    Last edited: Feb 24, 2010
  8. Feb 24, 2010 #7
    if you choose the NI version it would work with labview. You can download a trial version and do your application and from there, convert it to exe file, so that when trial license expires , you can still have your working program. Labview can do it. If you choose the Pic, you need to create a routin for 1 sec delay and than have in the option to selec t for how long it would be on and off. You can find sample code online for sure. It all depends on budget and how comfortable are you with pic. You can even get free samples of pic, make your own device to connect the chip to computer and write your own code. or you can buy ready made from NI or omega. Good luck
     
  9. Feb 24, 2010 #8

    vk6kro

    User Avatar
    Science Advisor

    With old versions of Windows, this used to be easy. You could just write to the printer port and directly control the pins.
    Windows XP is very protective and you have to use special drivers to turn off this protection.

    However, a free program called Liberty Basic lets you control the printer port after you transfer a couple of small files to the Windows directory of your computer.

    I just tried this and got a LED flashing from the parallel port. This port is not used on my computer.

    Here is the program I used:

    [start]

    out 888,255
    for j= 1 to 166000:next
    out 888, 0
    for j= 1 to 166000:next

    goto [start]

    Simple stuff. Liberty Basic is pretty powerful, so there are probably better ways of doing this. The delays in the above example program give a flash rate close to 1 Hz.
    888 is the address of the parallel port (378 Hex)
    for j= 1 to 166000:next .............this gives a delay of 500 milliseconds

    You could vary these delays to give whatever flash rate you like.
    ---------------------------------------------------------------------

    If you could use a free-standing device (with no connection to a computer) one way would be with a Picaxe chip.
    You would use a program very similar to the one above , but the delay would be done with a "pause" command.
    This is powerful and accurate. For example, "pause 423" means pause for 423 milliseconds before doing anything else.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook