Pages: [1]   Go Down
Author Topic: Photo resistor reading LED brightness: noise?  (Read 705 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there all.

I have a project which involves sampling the light blocking properties of photoresistors.

I have a photo resistor, and an LED. The LED brightness changes, and the desire is that a serial analogue read from the photoresistor returns the brightness of the LED. This way i can acquire data on any filter placed inbetween the two components.
I acutally have two PRs, in order that i can use one as a control (not subjected to filtering), and the other as the test.
However my serial output is getting just NOISE.


I pressume this is because the LED brightness is being managed by PWM, and the PR is picking up, and reporting the strobing.
is there anyway i can smooth this out?

This is the offending section of code:

Code:
  Serial.println("Comma Separated Values (CSV): First is X Axis, then PR1 value then PR2 value"); 

  //Green Up
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
    analogWrite(LEDG, fadeValue);

    Serial.print(Scale += 1);
    PR1 = analogRead(PR1);
    Serial.print(",");
    Serial.print(PR1);
    PR2 = analogRead(PR2);
    Serial.print(",");
    Serial.print(PR2);
    Serial.println(",");

the "Scale" value is there in order to provide an X axis, to graph the data
The data It is returning looks like this: I was hoping for a pair of fairly stable numbers

Code:
Comma Seperated Values (CSV): First is X Axis, then PR1 value then PR2 value

1,0,0,
2,107,109,
3,229,244,
4,245,260,
5,255,271,
6,0,0,
7,59,60,
8,205,217,
9,226,252,
10,260,247,
11,253,0,
12,63,85,
13,0,21,
14,57,48,
15,148,0,
16,68,73,
17,91,123,
18,153,155,
19,176,185,
20,0,64,
21,105,0,
22,32,61,
23,0,41,
24,64,65,
25,0,29,
26,66,71,
27,160,0,
28,0,42,
29,43,117,
30,188,167,

I think my hypothesis is correct...
« Last Edit: October 24, 2012, 03:26:07 pm by OllyR » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The 'duino is reading once per cycle, which actually means the data is 312 rows long!
I suppose what i need to is get it to read each data point "between" brightness changes, say 5 or 10 cycles long.

as in, PR starts reading, waits 5 cycles, then prints the data.

that could work?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.arduino.cc/en/Tutorial/Smoothing

It is not going to be easy to build this into my sketch smiley-cry smiley-eek-blue
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Photoresistors are very slow (on the orders of 100ms) in reacting to light changes, particularly on the lighting up part.

So if your pwm is really fast, or its period really long, you will need sufficient time for the photoresistors to catch up with the changing light intensity.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so if it is being bathed in a half power glow of an LED powered by arduino PWM, it should pick up the overall light level surely?
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know what your "bathed" is. But if you shine a flashlight on it, it should return some (relatively) steady values. If not, you have other problems.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Think i will check my wiring and run a simple test sketch on the PRs on their own. That data looks like it might be static from a miss wire. Thanks for the input guys. Tis helpful
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please accept my humble apologies. I had wired it wrong, like a twit.
DOH!
Logged

Pages: [1]   Go Up
Jump to: