Notifications
Clear all

ATTiny85 with PIR sensor and two LED strips USB connectors

49 Posts
5 Users
3 Likes
12.3 K Views
Farah Haddad
(@fhaddad)
Member
Joined: 4 years ago
Posts: 32
Topic starter  

ok I created this schematic and I have all the components, just want to know if I am going to burn anything before I wire it. Note the following:

Pin 5 on the gate of Q1

Pin 6 on the gate of Q2

R1 between ground and gate Q1

R2 between ground and gate Q2

Source of Q1 on Ground direct

Source of Q2 on ground direct

Drain of Q1 on ground of USB 1, the VBUS of the USB is connected to 5V directly

Drain of Q2 on USB 2, the VBUS of the USB is connected to 5V directly

Here's the Schematic (fingers crossed) 

PIR Sensor with ATTiny85 schem

 


   
ReplyQuote
NewburyPi
(@dale)
Member
Joined: 5 years ago
Posts: 97
 

Looks fine. I'd have gone with a lighter gate resistor (maybe 4.7k or 10k), but 1.0k shouldn't give you any grief. Keep an eye on the heat sink of the MOSFETs. The datasheet seems to say that your application shouldn't cost more than a hand full of milli-watts,  so they shouldn't heat up at all.  

--
Dale


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2037
 

I noticed that in most circuit examples the Gate was often connected to the ground via a 10k ohm resister and the pin output was connected to the gate via a 220 ohm resister. Really I should spend some time learning more about the operating requirements of a MOSFET.  I notice Bill covers it in a tutorial. There is probably software that allows you to connect up a virtual circuit so you can test it without something going up in smoke 🙂  Just for fun I tried to work out how I might have connected up the components on a breadboard but I am not sure if I got it right?

testCircuit2

 


   
ReplyQuote
Farah Haddad
(@fhaddad)
Member
Joined: 4 years ago
Posts: 32
Topic starter  

@casey

Thanks a million, though I was hoping to reach to the final solution without someone giving me the solution but thanks really appreciate it. For your note about the heat I saw a nice video explaining how we decide if it is safe to operate without a heat sink and I followed the same steps and did the calculations as shown below, so this is not a concern anymore 

D4106051 2B9E 4D4A 983D 7F46788CBD9E

   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2037
 

@fhaddad

I haven't necessarily given you the final solution and I can already see a better way to arrange the components on the breadboard.

So I assume it is working now?

Yes it all comes down to doing some calculations based on your knowledge of how it works and the component's spec sheet.

The Mosfet is being used as a switch.  Fully on (saturation) or fully off (cutoff). The in between input range is where you can amplify an ac signal.  I found the utube below a good refresher and it also shows the usefulness of an oscilloscope in seeing what is going on and the effect of different value changes.

 

 


   
ReplyQuote
Farah Haddad
(@fhaddad)
Member
Joined: 4 years ago
Posts: 32
Topic starter  

@casey

No it’s not working, looks like the resistor 10k you’ve put between the gate and earth is a problem. 


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2037
 

@fhaddad

Sorry.  I  should have tested it myself.  As I wrote I just noticed without understanding their actual role in the circuit the use of the resisters.  I will have to do some study on MOSFET circuits.

My view is that you do need to know the role of every component in a circuit and why it is that value and not another value.

I notice no resisters used here and a Attiny85 is being used.


   
ReplyQuote
Farah Haddad
(@fhaddad)
Member
Joined: 4 years ago
Posts: 32
Topic starter  

Thank you all for the support and the great information you've given me, the project is working fine and all is good. I am posting the project schematic on breadboard and I have just two question to wrap up the knowledge 

1- Why using MOSFET why not BJT transistor since the output PIN from Arduino can drive a small current on the Base and allow bigger current to pass? Just want to make sure I totally understand the difference between them and when to use each one. 

2- When I connected both strips the total current drawn is supposed to be 600mA according to the calculations but the current drawn was less than that (less than 400mA) what is the reason for that ?

PIR Sensor with Arduino UNO bb
Pic1
Pic2

   
ReplyQuote
NewburyPi
(@dale)
Member
Joined: 5 years ago
Posts: 97
 

I like a mosfet because it has a lower resistance (drain to source) and therefore consumes less power (generatws less heat). They can be a smidge tricky, as you need to pick one that will saturate with your drive voltage. Vgs(th) for yourmosfet was 4 volts, and thus suitable. It may not have worked as well fir 3.3v logic. 

 

For question 2, I'd first need to know how each LED string behaved on its own. Could you just run your power supply into a single LED string (no mosfets or anything else) and measure the current? It may be that the internal current limiting draws less than the specified 300 mA.

 

PS: happy to hear things are up and running ?

--
Dale


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2037
 
Posted by: @fhaddad

1- Why using MOSFET why not BJT transistor since the output PIN from Arduino can drive a small current on the Base and allow bigger current to pass? Just want to make sure I totally understand the difference between them and when to use each one. 

2- When I connected both strips the total current drawn is supposed to be 600mA according to the calculations but the current drawn was less than that (less than 400mA) what is the reason for that ?

1 - As mentioned the BJT has a turn on  value of 0.7v or more and the mosfet of 4v or more.  The pins do not "drive a current" they just provide a voltage, the resulting current depends on the resistance in the load which in this case is the input mosfet circuit which in this case are two resistors in series. They divide the 5 volts by the ratio of their values which in this case places about 4.9 volts on the mosfet gate.

When the pin goes to 5volts a  short lived current charges up the gate to 5volts and then the current essentially becomes almost zero unless you have that 10k resistor.  The 5volt charge (like static electricity) remains on the gate allowing a current between the source and drain.

If the pin output was less than 4 volts then you would have to amplify it to turn on the MOSFET.

2. Where did you measure the current? Was that the current coming out of the power supply?

-----------------------------------

They are different types of transistors (active semiconductors). In the BJT it is the current between the base and the emitter that controls the current between the collector and the emitter whereas in the MOSFET it is the electric charge (voltage) at the gate that controls the amount of current between the drain and source.

A MOSFET is a field effect transistor (FET) and ideally uses no current at the gate except to turn it on or off.

You might think of the transistor as a variable resister between the emitter and collector (or the source and drain) that can have a very high value (cutoff no current) and a very low value (saturation full current possible). When they are used as switches you use the extreme values of cutoff and saturation. When they are used to amplify an analog signal they are biased between those two extremes.

In the case of the BJT the base to emitter current adjusts the emitter to collector resistance so that the current between the emitter and collector is some multiple of the base to emitter current. In other words a small current is controlling a larger current and thus acting as a power amplifier. In the case of a field effect transistor it is the voltage at the gate that controls the resistance and thus current between the source and drain.

I notice you have used the resistors? Are they required in this case?   If I understand it correctly the arrangement would allow a very small current between the pin and the earth with a slight voltage drop over the 220 ohm resistor making the voltage at the gate maybe 4.9 volts instead of 5 volts. (You can measure it with a voltmeter). It would offer protection against static build up on the gate by draining it away via the 10k resistor.

Voltage drop over 220 ohm resistor = 220 * (5 / 10220 )

circuit2

 

 

 


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2037
 

Sorry in the image I have it as I = 10220/5 when of course it should be I = 5 /10220

Again unable to fix it in the actual post due to a limit to the edit time given.  I would think you should be able to edit and even delete a post at any time in the future unless it already has a follow up post.

Bill?

In another forum the first post in a thread is often edited with the latest updates on a project,  even years later,  to save anyone new having to read through all the posts in the thread to find the latest update.

 


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@casey

Posted by: @casey

Again unable to fix it in the actual post due to a limit to the edit time given.

I've come across this issue as well.

I did ask Bill @dronebot-workshop in my post at the time if it could be extended, but not sure if he read it... I think it should be extended, and that it's in Bill's interest to allow editing or even deletions, as you don't really want potential members deciding their membership on poor or incorrect information anyway.

Cheers!


   
ReplyQuote
Farah Haddad
(@fhaddad)
Member
Joined: 4 years ago
Posts: 32
Topic starter  

Hi All, I really don't want to bother you with my project cause it surly is a simple project for you all here but there is a fundamental problem and I've been working for more than a week to understand it but didn't manage to. I did the project and is all working fine, when I moved it to PCB with ATTINY85 twice then I used the ATTiny85 on a breadboard because I though my PCB design is wrong the same happened in all cases. The current coming out to the LED strip is about 10mA which makes the LED very weak (light is not visible) while the LED strip works find and the Voltage from my circuit is also fine at 5V. There is something wrong making the LED draw very weak current. What did I do wrong and by the way with Arduino its perfect but when I use the ATTiny85 it doesn't work fine ??


   
ReplyQuote
NewburyPi
(@dale)
Member
Joined: 5 years ago
Posts: 97
 

@fhaddad

First a few questions...

1. Is the following correct? You've implemented your circuit on a PCB and it does not appear to supply enough current to the LEDs. The circuit works properly on the solderless bread board, but not on the PCB.

2. What is the voltage measured at the gate of the MOSFET? I this voltage in not high enough, the MOSFET may not be getting into saturation. 

3. Are you able to give us a scan or photograph of the PCB? One problem, that I saw a very long ago, was tiny (sub-hairline) copper shorts on PCBs. you might want to try measuring the resistance of the PCB tracks. you'll want to ensure that the tracks are 0 ohms where you want to see the traces go, and infinite between traces. 

There. That's a start.

Dale

--
Dale


   
ReplyQuote
NewburyPi
(@dale)
Member
Joined: 5 years ago
Posts: 97
 

@fhaddad

Any update on this? Interested I  your findings/resolution.

--
Dale


   
ReplyQuote
Page 3 / 4