Pages: [1] 2   Go Down
Author Topic: LED dimming affects sensor data  (Read 1793 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I've just started playing around with my brand new Arduino Mega 2560 and - after some success - run into a problem I do not understand. Before I explain it I should mention that I'm absolutely new to Arduino, working with micro controllers and electrics in general so no background about volts/watts/amps/... is available, just starting from scratch... smiley-wink I've got a ITDB02-3.2s LCD screen with touch pad connected to my Arduino board without any shield -> first success smiley-wink Then I got a DHT11 temperature/humidity sensor connected, too -> second success. Finally I got the data from the sensor to be shown on the LCD -> third success smiley-wink

Ok, here's my problem. I control the LCD with the UTFT library and figured out that turning the lcd on and off in the code did not work. Searching the net I found a sollution and it also lead me to the idea to control the brightness of the background lights - LEDs - by connecting the LED pin of the screen to an transistor which I control over Arduino's PWM port 8. Running this setup I'm able to dim the LCD's background light. So far so good but I had to figure out that the results of the measurements through the DHT11 sensor are getting affected by the puls (correct term?) I set at the PWM port. An example would be:

  • Having defined an output of 255 on the pin, the sensor reports: Temperature: 24 | Humidity: 34
  • Having defined an output of e.g. 115, the sensor reports: Temperature: 26-27 | Humidity 36-37

I did several test runs so I can confirm that the different setting on the PWM port affects the data comming from the sensor.

Here's my question: What's going on? smiley-wink I have no glue why the settings on the PWM port affects the readings from the sensor. Could somebody please help me figuring out what's happening and how to prevent this? I would be highly thankfull.

Greez,

dialsc
Logged

UK
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3969
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Please post your schematic so we can see how everything is wired up.
Logged

Why not visit my eBay shop? http://stores.ebay.co.uk/Majenko-Technologies
Replacement for the Arduino IDE: UECIDE - Proper serial terminal, graphing facilities, plugins, overhauled internals.
Java isn't bad in itself, but it has enabled morons to write programs.

Valencia, Spain
Online Online
Faraday Member
**
Karma: 119
Posts: 4592
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's my question: What's going on? smiley-wink I have no glue why the settings on the PWM port affects the readings from the sensor. Could somebody please help me figuring out what's happening and how to prevent this? I would be highly thankfull.

Most likely a decoupling problem.

Try putting a big ceramic capacitor across the wires that power the sensor (+5V and GND). Maybe another one between the screen LED's anode and ground.

Logged

No, I don't answer questions sent in private messages...

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

First of all, thank you very much for your very fast answer. majenko asked me to post my schematic but I cannot right now. Currently I'm fighting with getting the basic knowledge of how to do all those things, e.g. creating such a schematic file... smiley-wink What I can do right now is making some images and attache them.

The tip of using ceramic capacitor is what I did already for the sensor. According to the data sheet of the sensor I used a 100 Nanofarads capacitor. The power for the sensor is taken from Ardunio's 5V pin.

Does the images help you to get an idea of what I did? There are four images I took but I have to upload them in three more iterrations as the file sice is too big.

Greez,

dialsc

BTW: Is there a good tool to create such schematic files? One that doesn't kost that much?


* 20121114_130502.jpg (3530.77 KB, 3264x2448 - viewed 41 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Image #2


* 20121114_130512.jpg (3413.05 KB, 3264x2448 - viewed 21 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Image #3


* 20121114_130520.jpg (3401.22 KB, 2448x3264 - viewed 24 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Image #4


* 20121114_130531.jpg (3374.36 KB, 3264x2448 - viewed 20 times.)
Logged

UK
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3969
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The digital signal from the sensor consists of long (70uS) and short (28uS) pulses.  Timing is critical, so interrupts are disabled by the library (you are using the DHT library, yes?).

Also, noise could be an issue with that protocol.  You have a low for a period, then a high for a period - the period of that high, up until it goes low, is what determines if it's a 0 or a 1.  If you get a bit of noise, that period could be measured wrongly.

If it is the PWM signal inducing noise, you could try to counter it by reducing the pull-up resistor on the data line to say 4.7KΩ.  You could also try ensuring that your PWM signal is as far away from the data line as practicable.
Logged

Why not visit my eBay shop? http://stores.ebay.co.uk/Majenko-Technologies
Replacement for the Arduino IDE: UECIDE - Proper serial terminal, graphing facilities, plugins, overhauled internals.
Java isn't bad in itself, but it has enabled morons to write programs.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried now with a 4.7KΩ pull-up resistor but without success. Then I took the data line cable and changed its pin from 7 to 13 on the Arduino board. Unfortunately this did not solve the problem. Do you see anything else I could try?
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

1. Decoupling capacitors should be connected as close to the device they are decoupling as possible. Plug that 100nF capacitor directly into the same 2 breadboard rows that the DHT11 is plugged into.

2. Use one ground pin on fhe Mega to connect just the DHT11 and its decoupling capacitor. Use a different one to connect the backlight or the transistor controlling the backlight. Similarly for the +5V supply.

The above changes will reduce the extent to which the switched backlight current induces noise on the DHT22 power and ground lines, which may be what is causing the problem.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

UK
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3969
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, and for schematics...  There is a free version of Eagle for more "normal" schematic capture, or for basic stuff, there is Fritzing which is very Arduino friendly (it's what does those breadboard schematic pictures you often see).
Logged

Why not visit my eBay shop? http://stores.ebay.co.uk/Majenko-Technologies
Replacement for the Arduino IDE: UECIDE - Proper serial terminal, graphing facilities, plugins, overhauled internals.
Java isn't bad in itself, but it has enabled morons to write programs.

0
Offline Offline
Shannon Member
****
Karma: 162
Posts: 10496
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's my question: What's going on? smiley-wink I have no glue why the settings on the PWM port affects the readings from the sensor. Could somebody please help me figuring out what's happening and how to prevent this? I would be highly thankfull.

Most likely a decoupling problem.

Try putting a big ceramic capacitor across the wires that power the sensor (+5V and GND).
Not too bad an idea, but the source of the noise should be tackled first, the LED backlight.
Quote
Maybe another one between the screen LED's anode and ground.
You decouple the supply, not the switching voltage - so this is only appropriate if the LED is being switched on the low-side - do we know that?  In fact something big like 220uF really close to the transistor that's
switching the PWM to the backlight - across the supply, not the LED!  The idea is to soak up the heavy current pulses at source and not export them to the rest of the supply rails on other boards.
« Last Edit: November 14, 2012, 01:43:20 pm by MarkT » Logged

[ I won't respond to messages, use the forum please ]

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

BTW: Is there a good tool to create such schematic files? One that doesn't kost that much?

If you have a PC, ExpressSCH is easy to use (and free):

http://www.expresspcb.com/expresspcbhtm/Free_schematic_software.htm
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, I moved the ceramic capacitor directly infront of the DHT11 sensor. I also tried to use as few as possible cables. The sensor was already conected to a dedicated ground pin on the Arduino board. Things look like getting better now. Instead of having temperature and humidity data with a difference of 2-3 when dimming the back light it's now only the humidity that has a difference of something betwenn 0.5 and 1. It's kind of hard to know as the sensor's resolution is 1.0.

Think we got near the sollution smiley-wink Anything else someone could think of what I also could try? Maybe another capacitor or something like that? Sorry for the dump question but in fact I even do not know what this little thing made of ceramic is actually doing there... smiley-wink

Oh, and thanks for the info about the software for the schematics. I'll take a look to each one and check if I will be able to cope with one of them.

Greez,

dialsc
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I started playing with Fritzing and attached you'll find the circuit I've created using breadboards. I hope it's okay, it's my first one... smiley-wink

Does anybody see the problem this way? I still get different values when changing the PWM signal to dimm the LCD's back light LEDs.


* Breadboard Layout.png (685.24 KB, 2793x2166 - viewed 42 times.)
Logged

Pages: [1] 2   Go Up
Jump to: