Go Down

Topic: Attiny13a LM35 and pot 10K affect each other. (Read 347 times) previous topic - next topic

Tofer

Feb 11, 2019, 11:34 pm Last Edit: Feb 12, 2019, 12:18 am by Tofer
Hello!

Here is my schematics attached.

I have a fan controlled by LM35DZ and a pot for controlling a led dimmer.
Here is I have a code:
Code: [Select]
void setup()
{
 TCCR0A = 2<<COM0A0 |  3<<WGM00; // clear 0c0a at compare match //enable fast pwm
 TCCR0B =  1<<CS00;
 
}

void loop() {
     
    analogWrite(0, map(analogRead(3), 0, 1023, 0, 72)); 

   
    int t = analogRead(2)/2;
   
    if (t>80) {
      int value = (t-80)+55; 
      analogWrite( 1, value);
      delay(100);
     
    }
   
    else {
      analogWrite( 1, 0);
    }

   
}


LM35 works fine when the pot stays at the position 0 and the fan starts just when the temperature becomes the one when the fan has to start. As soon as I start rotating the pot the voltage on LM35 also changes and goes higher, and it starts the fan. How can I eliminate this interference? I've tried to add delay or dummies to give the Tiny's ADC time to recover, but it hasn't helped.

JohnRob

It sounds to me like a wiring issue.  I would double (triple etc) check the wiring especially all the grounds.

Please do not PM me with thread based messages.  If your thoughts are worth responding,  the group should benefit from your insight.

Wawa

+1 about wiring.
5A LED current, and associated volt drop in wiring/connectors, can upset measuring the small returned voltage of the analogue sensor.
LM35 ground should connect directly to Attiny ground (not shared).

From the datasheet:
"Like most micropower circuits, the LM35 device has a limited ability to drive heavy capacitive loads. Alone, the LM35 device is able to drive 50 pF"
Means the 100n from out to ground has to go.

Try to read the LM35 twice after each other (no delays).
If that doesn't help, then move to an easier to use digital DS18B20 sensor.
Leo..

Tofer

+1 about wiring.
5A LED current, and associated volt drop in wiring/connectors, can upset measuring the small returned voltage of the analogue sensor.
LM35 ground should connect directly to Attiny ground (not shared).

From the datasheet:
"Like most micropower circuits, the LM35 device has a limited ability to drive heavy capacitive loads. Alone, the LM35 device is able to drive 50 pF"
Means the 100n from out to ground has to go.

Try to read the LM35 twice after each other (no delays).
If that doesn't help, then move to an easier to use digital DS18B20 sensor.
Leo..
Checked and rechecked with a multimeter so many times)

The LM 35 is connected to Attiny GND directly. The 100nF cap is already there if you have a look at the schematics.
I've tried reading  the LM35 twice  with a dummy and it hasn't helped. It seems like the voltage raises proportionally to the pot at all analog pins. I've measured the LM35 out. It goes from 450mV to 1000mV. And it's not the noise.

Wawa

The 100nF cap is already there if you have a look at the schematics.
Yes, and I said it shouldn't be there.

Returned value of the A/D depends on two things. input voltage and VCC.
Did you measure VCC of the Attiny when turning the pot.
Leo..

jackthom41

#5
Feb 12, 2019, 03:10 am Last Edit: Feb 25, 2019, 09:32 pm by jackthom41
LM35 works fine when the pot stays at the position 0 and the fan starts just when the temperature becomes the one when the fan has to start. As soon as I start rotating the pot the voltage on LM35 also changes and goes higher, and it starts the fan. How can I eliminate this interference? I've tried to add delay or dummies to give the Tiny's ADC time to recover, but it hasn't helped.
You should try them one by one. First of all, simply serial print your temperature sensor LM35 value and pot analog value on the serial monitor, and check if they are dependent on each other or not. Do some testings and you will find the issue. Share images of your hardware setup.
Technopreneur

Smajdalf

BTW the MOSFET used is NOT a logic level device. The Tiny should be barely able to turn it on - it does not get hot?
Banned forever by Coding Badly for "trolling". Good luck with such attitude.
Update: Timeout "Extended, yet again, for lying." From eternity to Apr 19, 2019. Interesting...

Tofer

You should try them one by one. First of all, simply serial print your temperature sensor LM35 value and pot analog value on the serial monitor, and check if they are dependent on each other or not. Do some testings and you will find the issue. Share images of your hardware setup.
It's an Attiny chip - there is no way I can print it. I can just measure everything via multimeter. And they are depending.
Yes, and I said it shouldn't be there.

Returned value of the A/D depends on two things. input voltage and VCC.
Did you measure VCC of the Attiny when turning the pot.
Leo..
Yes, I've measured. There is no change found on the Tiny's VCC.

BTW the MOSFET used is NOT a logic level device. The Tiny should be barely able to turn it on - it does not get hot?
I would check it later cause this part of scheme is not connected yet. It's not a logic level, but according to the datasheet it could provide more than 10A at with 4.5V at the gate.

Grumpy_Mike

Quote
I would check it later cause this part of scheme is not connected yet
When you do, do not connect the LED the way you have shown it.
1) it is the wrong way round
2) there is no current limiting, with such a high powered LED you need a constant current supply to control it not a simple PWM signal.

It is best if you post a photograph of your wiring so we can check the ground arrangement. I would also add better capacitors to that regulator you need to look up the actual data sheet from the manufacturers you are using to find the minimum values.

Wawa

I do agree with Smajdalf.
Vgs and Qg of this fet are both too high for the Attiny.
Make sure you got those protective glasses on when you power up the LED.
Leo..

MarkT

C7 should be 10nF to 100nF at most, you're crow-barring the supply everytime Q2 switches on.  Perhaps
you meant there to be a decoupling cap to ground for the motor?

R5 should be more like 150 ohms, your powering a motor from that transistor, so the base needs enough current.

Q1 needs a pull-down resistor from gate to source, 10k to 100k will do, value not critical, to keep it from
switching on during reset/power cycling.

Any reason for the large value of R6?  150 ohms is fine, if you are using PWM you likely need a gate driver IC
anyway.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Smajdalf

It's not a logic level, but according to the datasheet it could provide more than 10A at with 4.5V at the gate.
It may work for static switching. I did not make the calculations but I am quite sure the (relatively) week ATTiny's  pin slowed down by  the 550 Ohm resistor have no chance to keep the gate above 4.5V for considerable amount of time.
OTOH the gate capacitance and the resistor will form a low pass filter - the transistor will be in its active region most of time, acting as a variable resistor. A way to drive the LED safely (maybe) but you will burn all the excess power in the transistor. It will need considerable cooling.
Banned forever by Coding Badly for "trolling". Good luck with such attitude.
Update: Timeout "Extended, yet again, for lying." From eternity to Apr 19, 2019. Interesting...

Tofer

Yes, and I said it shouldn't be there.

Returned value of the A/D depends on two things. input voltage and VCC.
Did you measure VCC of the Attiny when turning the pot.
Leo..
I've added the cap there because the voltage was a bit noisy without it. Someone has recommended to add a cap in another topic I've found about LM35.

I've measured VCC. The pot doesn't influence it.

When you do, do not connect the LED the way you have shown it.
1) it is the wrong way round
2) there is no current limiting, with such a high powered LED you need a constant current supply to control it not a simple PWM signal.

It is best if you post a photograph of your wiring so we can check the ground arrangement. I would also add better capacitors to that regulator you need to look up the actual data sheet from the manufacturers you are using to find the minimum values.
What is the write way?
C7 should be 10nF to 100nF at most, you're crow-barring the supply everytime Q2 switches on.  Perhaps
you meant there to be a decoupling cap to ground for the motor?

R5 should be more like 150 ohms, your powering a motor from that transistor, so the base needs enough current.

Q1 needs a pull-down resistor from gate to source, 10k to 100k will do, value not critical, to keep it from
switching on during reset/power cycling.

Any reason for the large value of R6?  150 ohms is fine, if you are using PWM you likely need a gate driver IC
anyway.
Should I connect C7 to GND or the way it is now is ok?

R5 - will do it.

Q1 pull-down resistor from G to GND right?

R6 - will do it.

I do agree with Smajdalf.
Vgs and Qg of this fet are both too high for the Attiny.
Make sure you got those protective glasses on when you power up the LED.
Leo..
I can change it to IRL1404ZPBF.


Grumpy_Mike

Quote
What is the write way?
The right way is to do what I said in reply #8. If you don't understand what I said then ask about specifically what you don't understand.

As for posting a picture see image guide

Smajdalf

I've added the cap there because the voltage was a bit noisy without it. Someone has recommended to add a cap in another topic I've found about LM35.
Try to put some (Datasheet suggests 2k) resistor between the cap and LM35's output. If the LM35 is oscillating (you cannot see that on a DMM) due to heavy capacitive load it should fix it.
Banned forever by Coding Badly for "trolling". Good luck with such attitude.
Update: Timeout "Extended, yet again, for lying." From eternity to Apr 19, 2019. Interesting...

Go Up