Page 1 of 1

Dark Adaptometer

Posted: Sun Jul 28, 2013 6:28 pm
by pottertongold
Hello everyone!


For a university project I am planning on building a medical device known as a dark adaptometer, which measures the rate at which a person's eyes become adapted to the dark.

What this device does is present a fast pulsating light source (often of particular wavelengths ie a particular wavelength of green or red) which can be gradually dimmed until it is completely off.

To measure a patient's dark adaptation involves a patient being sat in a completely dark room. First the patient's eyes are bleached; which means the patient looks at a very bright light source for a few seconds and then they are instructed to look at a dark adaptometer, at which point a timer is also started. The time at which the patient is first able to see the pulsating light of the device is recorded and the light is made incrementally dimmer and for a period of time until the patient's eyes adapt they will be unable to see the light again and when they do the time is again recorded and this process continues until the light is so dim that the patient is unable to see it after any period of time of adaptation.

My main question is: with the Raspberry Pi would it be possible to create a device which via pulse width modulation controls some LEDs which pulsate and can be gradually made brighter and dimmer. At the same time I would like Raspberry Pi to record all of the timing- so if possible I would like the patient to have a remote button which they press every time the light source becomes visible and for the time at which this happens to be recorded and for the raspberry pi to automatically make the light source incrementally dimmer.

Would I be better off using an Arduino for this project?

I don't have any experience with the raspberry pi but I'm willing to put the work in (I can do some programming up to A level standard in Delphi).

Thanks for taking the time to read this, it is very much appreciated.
Btw I hope this post makes sense! If it doesn't please quiz me and I'll try to make it clearer.

Re: Dark Adaptometer

Posted: Sun Jul 28, 2013 7:48 pm
by joan
Your project should be viable on a Pi.

Do you use special LEDs? The sort of LEDs I use don't seem to have a particularly fine grained control over light output, e.g. assuming PWM of 0 to 255, there is not much difference between PWM 128 and 255.

Re: Dark Adaptometer

Posted: Mon Jul 29, 2013 11:42 am
by pottertongold
joan wrote:Your project should be viable on a Pi.

Do you use special LEDs? The sort of LEDs I use don't seem to have a particularly fine grained control over light output, e.g. assuming PWM of 0 to 255, there is not much difference between PWM 128 and 255.
Thanks for your reply Joan. Tbh I'm not really sure and I hadn't even thought about it so thanks for bringing it up. If I had at least 12 equally spaced "levels" of brightness, I would be able to make do although the finer the control I have the better.

Do you have any suggestions on where I should start on this whole project? (well I suppose I should order a Raspberry Pi!)

Will I need to buy more hardware to connect to the Raspberry Pi in order to PWM control LEDs? or Can I connect directly to the Raspberry Pi itself? I'm thinking I'll probably have 6 LEDs in total; 3 green and 3 red and only one colour would ever be on at a time.

Thanks again.

Re: Dark Adaptometer

Posted: Mon Jul 29, 2013 11:56 am
by joan
It should be fine on the Pi. It might be worth checking how much current the LEDs need. If it's only a few milliamps there shouldn't be a problem. If it's dozens of milliamps (unlikely) then you might need additional circuitry. Do you plan to use the same LEDs to dazzle as well?

Re: Dark Adaptometer

Posted: Mon Jul 29, 2013 8:01 pm
by pottertongold
joan wrote:It should be fine on the Pi. It might be worth checking how much current the LEDs need. If it's only a few milliamps there shouldn't be a problem. If it's dozens of milliamps (unlikely) then you might need additional circuitry. Do you plan to use the same LEDs to dazzle as well?
Thanks again for your reply Joan!

I haven't yet chosen the LEDs but from having a quick nosey on rapidonline.com, I was thinking of using something like these pretty standard LEDs and put three of each colour behind a plastic diffuser to give an even light output: http://www.rapidonline.com/Electronic-C ... -LED-64864

I would like to include some sort of system in the device to dazzle the patient, this would be useful as the Raspberry Pi could control the timing of the dazzling and the brightness in patients with special cases. The dazzling has to be done with white light so I will have to include a third system of white LEDs or perhaps a light bulb would be suited to the task better.

If I require more than a few milliamps are there other options available?

Re: Dark Adaptometer

Posted: Mon Jul 29, 2013 8:26 pm
by joan
pottertongold wrote:...
If I require more than a few milliamps are there other options available?
Plenty of options, you just drive the LEDs through transistors. I don't think it's going to be an issue, especially given that apart from the dazzle you want pretty subdued LEDs.

Re: Dark Adaptometer

Posted: Tue Jul 30, 2013 1:56 am
by Jim Manley
You can turn the LEDs on and off very rapidly at a large variety of pulse-width modulated PWM duty cycles (ratio of time LEDs are on vs. off) to achieve the perceived brightnesses you need. Typical low-cost red/green LEDs draw upwards of 20 ma each at full brightness, and white LEDs can draw as much as 60 ~ 85 ma each. You can choose current-limiting resistor values that limit the current below the maximum, but brightness drops off rapidly with a change of only a few ma. As noted by others, since each GPIO pin can only provide 2 ~ 16 ma each (and the total limit for all GPIO pins is 16 ma), you're going to need to control the LEDs via a transistor, especially if more than one LED is going to be on at one time.

The challenge is going to be calibrating the system to know exactly what the LED brightness level is at any given threshold of visibility. You would need some kind of photometer that's accurate for measuring the light intensity of LEDs at the various specific wavelengths of the LEDs used. You can determine relative brightness based on duty cycle, since you can control the duty cycle via software control of GPIO pin on/off states. See https://code.google.com/p/raspberry-gpi ... n/wiki/PWM for an example of how to use the RPi.GPIO Python library to control the brightness of an LED connected to a GPIO pin via duty cycle modulation (aka PWM).

I would also be very careful about projecting white LEDs directly into people's eyes, as they actually emit ultraviolet light that is then mostly down-shifted to visible light by absorption in a fluorescing layer inside the LED lens that reemits photons in the visible spectra (with a distinct bluish hue). Both the visible and UV energy might be high enough to cause damage to the retina and/or cornea if intensity and duration are sufficient, and the intensity of white LEDs can be quite high, certainly enough to cause pain, if not permanent blindness.

Re: Dark Adaptometer

Posted: Tue Jul 30, 2013 7:37 pm
by pottertongold
joan wrote:
pottertongold wrote:...
If I require more than a few milliamps are there other options available?
Plenty of options, you just drive the LEDs through transistors. I don't think it's going to be an issue, especially given that apart from the dazzle you want pretty subdued LEDs.
Thanks again Joan, you've been great,

Ah okay that's brill- my knowledge of electronics is rusty and has many gaps so I've got plenty of homework to do. The Raspeberry Pi, a breadboard and some components will be ordered this evening, so I can start playing with stuff before I make a proper start.

Re: Dark Adaptometer

Posted: Tue Jul 30, 2013 11:02 pm
by pottertongold
Jim Manley wrote:You can turn the LEDs on and off very rapidly at a large variety of pulse-width modulated PWM duty cycles (ratio of time LEDs are on vs. off) to achieve the perceived brightnesses you need. Typical low-cost red/green LEDs draw upwards of 20 ma each at full brightness, and white LEDs can draw as much as 60 ~ 85 ma each. You can choose current-limiting resistor values that limit the current below the maximum, but brightness drops off rapidly with a change of only a few ma. As noted by others, since each GPIO pin can only provide 2 ~ 16 ma each (and the total limit for all GPIO pins is 16 ma), you're going to need to control the LEDs via a transistor, especially if more than one LED is going to be on at one time.

The challenge is going to be calibrating the system to know exactly what the LED brightness level is at any given threshold of visibility. You would need some kind of photometer that's accurate for measuring the light intensity of LEDs at the various specific wavelengths of the LEDs used. You can determine relative brightness based on duty cycle, since you can control the duty cycle via software control of GPIO pin on/off states. See https://code.google.com/p/raspberry-gpi ... n/wiki/PWM for an example of how to use the RPi.GPIO Python library to control the brightness of an LED connected to a GPIO pin via duty cycle modulation (aka PWM).

I would also be very careful about projecting white LEDs directly into people's eyes, as they actually emit ultraviolet light that is then mostly down-shifted to visible light by absorption in a fluorescing layer inside the LED lens that reemits photons in the visible spectra (with a distinct bluish hue). Both the visible and UV energy might be high enough to cause damage to the retina and/or cornea if intensity and duration are sufficient, and the intensity of white LEDs can be quite high, certainly enough to cause pain, if not permanent blindness.
Thanks for your reply Jim,

Time to start doing home work on transistors, if you have a spare moment would you mind linking me to some transistors which you think might be suitable? (your suggestion might point me in the right direction).

Yeah the thoughts about calibration crossed into my own mind earlier today to; I should be able to gain access to some of the lab equipment available in my university department and will be able to calibrate the system so I know the exact luminance of the LEDs at the relevant duty cycles.

I also need to do some more in-depth research and find out which particular wavelengths of red and green would be best and how best to produce these with LEDs.

Cheers for the warning, I was planning on having a filter in place to minimise UV and infra-red wavelengths but I'll look more into it. It might be better for me to use a bulb to perform the bleaching of the photoreceptors; in all of the ophthalmic equipment I've used so far which involve shining lights into the eye use xenon or halogen bulbs and I'm assuming there's probably a reason for this. And I'd make sure the brightness and duration were in safe limits.


Thanks again! :D