Difference between revisions of "Led sensor"
(→How does it work ?) |
|||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | According to [http://www.merl.com/reports/docs/TR2003-35.pdf this] | + | According to [http://www.merl.com/reports/docs/TR2003-35.pdf this paper], a simple LED can be a light sensor if used in reverse mode. In fact if LED is used in invert, it becomes a variable capacitance. |
+ | To test this phenomena, I have used a pin of the FPGA, and design a little component/IP that provides the discharging time in a register. | ||
+ | |||
+ | |||
+ | = How does it work ? = | ||
+ | |||
+ | Ledsensor ip formed by by four entities : | ||
+ | |||
+ | [[Image:structledtouch.png|500px|center]] | ||
+ | |||
+ | |||
+ | * '''cnt''' : like «counter» this entity provide counter to measure ledcapacitor discharge, it also provide charge period timing. | ||
+ | * '''led''' : This entity is used to drive the led. It has four signal, one to load capacitor «charge», one to read led value and two others to branch led (cathode and anode). | ||
+ | * '''wbread''' : This entity is Wishbone 16-data bits bus manager. | ||
+ | * '''fsm''' : This is the main component of the IP, this state machine drive the component. The working of the fsm is describe below : | ||
− | |||
[[Image:ledtouchschema.png|300px|center]] | [[Image:ledtouchschema.png|300px|center]] | ||
+ | |||
+ | On read from ''wishbone16'', the '''fsm''' will reset the counter and load the | ||
+ | led during a ''charge_period''. | ||
+ | |||
+ | When led is charged, fsm disconnect ''cathode'' and count until the ''value'' | ||
+ | reach 0. The result of count is available on 16bits read register (named | ||
+ | counter). Counter can be convert in time with formula : | ||
+ | |||
+ | divisor x clock_period x counter = led_disharge_period | ||
+ | |||
+ | By default, divisor is equal to 10. It's possible to change the divisor writing on the same register (named divisor). | ||
+ | |||
+ | [[Image:ledtouchgraph.png|500px|center]] | ||
+ | |||
+ | = Code = | ||
+ | |||
+ | [http://fabienmarteau.free.fr/images/synthesis.tar.gz here] | ||
+ | |||
+ | |||
+ | |||
+ | = Results = | ||
+ | |||
+ | With a green standard led, that gives : | ||
+ | |||
+ | [[Image:greenplot.png|300px|center]] |
Latest revision as of 20:33, 25 September 2008
According to this paper, a simple LED can be a light sensor if used in reverse mode. In fact if LED is used in invert, it becomes a variable capacitance.
To test this phenomena, I have used a pin of the FPGA, and design a little component/IP that provides the discharging time in a register.
How does it work ?
Ledsensor ip formed by by four entities :
- cnt : like «counter» this entity provide counter to measure ledcapacitor discharge, it also provide charge period timing.
- led : This entity is used to drive the led. It has four signal, one to load capacitor «charge», one to read led value and two others to branch led (cathode and anode).
- wbread : This entity is Wishbone 16-data bits bus manager.
- fsm : This is the main component of the IP, this state machine drive the component. The working of the fsm is describe below :
On read from wishbone16, the fsm will reset the counter and load the led during a charge_period.
When led is charged, fsm disconnect cathode and count until the value reach 0. The result of count is available on 16bits read register (named counter). Counter can be convert in time with formula :
divisor x clock_period x counter = led_disharge_period
By default, divisor is equal to 10. It's possible to change the divisor writing on the same register (named divisor).
Code
Results
With a green standard led, that gives :