Logo
Builders' Plan Gallery  |  Hip Pocket Web Site  |  Contact Forum Admin  |  Contact Global Moderator
December 18, 2018, 12:38:52 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with email, password and session length
 
Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: DIY flight profiler using Adafruit Trinket  (Read 1244 times)
0 Members and 1 Guest are viewing this topic.
mike_st
Bronze Member
***

Kudos: 0
Offline Offline

New Zealand New Zealand

Posts: 27

Topic starter


Ignore
« on: March 02, 2018, 07:58:40 PM »

    For those who like a bit of electronics & code as well as building planes, here is a DIY flight profiler for DC motors. It is based on a small board called an Adafruit Trinket, which is a variant of a thing called an Arduino, which has become very popular for learning to control electronics with code.

    As presented, it has 3 trimpots to set
    - a ramptime, which is how long the motor takes to start up, and then slow down at the end of the flight
    - a max speed - hopefully self explanatory
    - a cruisetime, which is how long the motor will run for before it begins the ramp down to a stop.

    It can be powered by 1-4 cell lipos, the Trinket will accept anything up to 16 volts, though I admit I've only tried it with 1, 2 & 3 cells. The circuit delivers up to that voltage to the motor, depending on where you set the max speed trimpot and how much current the transistor can deliver. The one used here is supposedly good for up to half an amp - my KP01 only seemed to draw 25 milliamps. (I've done some, but not extensive testing, on bigger & smaller motors)

    I've used commonly available components because the intention was that you could build it with parts from your local electronics store. There are other transistors that can be used, but require a bit more effort to buy. All up weight of the breadboard version, including battery wires & connector, is 7.9 grams.

    In this thread I'll cover a Trinket-based breadboard and pcb version. The breadboard version is doable, but ugly and difficult and I don't really recommend it unless you like annoying, fiddly things. The PCB version is much nicer, but you need to get the board manufactured (its really easy).

    In a later, different, thread, I hope to present a "shrunk" version - that's Arduino talk for the same idea but without the Trinket, using just a programmable chip. This saves weight, space and cost, and is more or less what you see in commercial boards. The downside is you're soldering very small surface mount components....

Overview.
The Adafruit Trinket is a small development board containing an ATtiny85 chip. This is the chip that has the smarts on it, and as I understand things (I'm no expert) programming it requires some reasonably specialist skills. But the Trinket lets you program it in a much easier manner, something I can at least understand. However, to use the Trinket you still need to jump through some hoops:
- install the Arduino integrated development environment (IDE) on your pc
- install the windows USB drivers (I've not used Macs or Linux for this)
- install and set the Adafruit libraries
- open the code in the IDE and send it to the Trinket over USB.

The best place to learn all this is https://learn.adafruit.com/introducing-trinket/introduction It's one of those things that is pretty simple except for when its not. Usually it all works just fine, but for a first timer it can be frustrating.

The code tells the Trinket to read the values from the trimpots. For ramp and cruisetime, the values are used to determine how long it takes to get going/slow down and the time spent cruising at max speed. For max speed, the value is sent to a transistor which allows the power from the battery to get to the motor.

You need the following parts:
- an Adafruit Trinket (the 3.3v version. not the 5v one) https://www.adafruit.com/product/1500
- 3 trimpots, it doesn't really matter what value, I used 5k
- PN2222 transistor
- 1n4001 diode
- 120 ohm resistor (or up to 270 ohm)
- 2x microswitches (momentary)
- header pins to go between the Trinket and the board
- sundry wire, battery connectors etc.[/li][/list]

Breadboard version
The breadboard is just a way to attach the components to the Trinket. I tried directly wiring to the Trinket but it didn't work out, so instead, you can follow this layout and attach it to the Trinket. After the code is loaded to the Trinket and the battery and motor connected, pressing the run switch should get you going. I've found that at lower power setting you sometimes need to help the prop get going, I guess as there is a certain electrical inertia to overcome? I'm not sure.

The "lowV" is a placeholder for a lipo low voltage indicator and you can just ignore it (don't solder a wire across there else you'll short the battery!). The "fuse" is also a placeholder - I put a couple of small sockets there for future fusing, and just bridged it for now (you can see it in the photos).
 
The four white lines are connectors and you need to solder a piece of wire in for each of them.
 
"on" and "rst" are microswitches. "on", not surprisingly, starts the motor run. "rst" reboots the Trinket, which takes all of 3 seconds. So if you are trying different settings, instead of waiting for the complete cycle to finish, you can just reset it and start again. Both of these switches could be mounted off the board (e.g. on the side of a fuselage) and connected to the board with wires. I think the reset could be done more elegantly in code, but haven't got there yet.

"bat+" and "bat-" are the battery leads, positive and negative respectively. Similarly "m+" and "m-" are the positive and negative wires that go to the motor.

The 3 circular things down the middle are the trimpots for ramp, speed and cruise time. Any value will do, I used 5k. You could also mount one or more of the trimpots offboard too, for example if the board is going to end up somewhere that is difficult to get to, but you want to change the settings often.

The "120r" is a 120 ohm resister, and the other rectangular thing is a 1n4001 diode. The diode must be mounted in the orientation shown.  These values are not super critical - I've seen values up to 270 ohm for the resister and a 1n4004 for the diode. The transistor is a PN2222, and must go in the orientation shown with the flat side facing in (viewed from above).


PCB version
I've received my PCB's, which attach to the Trinket in the same way but are a lot neater, but haven't built it yet. I'll update the thread when I have.

Code
This is what you open in the Arduino IDE and sent to the Trinket:

Code:

    // dc motor "flight profiler" for freeflight model planes
    // uses a trimpot to set a startup/shutdown time. motor speed, and cruise duration.
    // v1.0 Jan 2018 mike stoodley
    // released under gnu public licence

    // designate pins here so they easily changed for a different board e.g. nano
    //pins
    int startPin = 0;
    int motorPin = 1;
    int rampTimePin = 1;      //not board pin1! analogRead A1 = pot wiper to trinket pin 2 - but use "1" for analogRead
    int maxSpeedPin = 2;      //not board pin2! analogRead A2 = pot wiper to trinket pin 4 - but use "2" for analogRead
    int cruiseTimePin = 3;    //analogRead A3 = pot wiper to trinket pin 3 - use "3" for analogRead

    //variables
    int motorSpeed;
    int maxSpeed;             //var for top speed, set my speed pot, cannot be more than 255
    int rampMax = 15000;     //set a maximum ramp time, the pot will vary up to it
    int rampTime;             //the time in ms that will be used for ramp up/down
    int cruiseMax = 30000;    //set a maximum cruise time up to 30 seconds, the pot will vary up to it
    int cruiseTime;           //analogRead of A3 = trinket pin 3, up to cruiseMax

    void setup()
    {
    pinMode(motorPin, OUTPUT);
    pinMode(startPin, INPUT_PULLUP);
    }

    void loop(){
    rampTime = map(analogRead(rampTimePin), 0, 1023, 0, rampMax);   //map the pot range to our preset max ramp time
    maxSpeed = map(analogRead(maxSpeedPin), 0, 1023, 0, 255);      //map the pot range to usable pwm output
    cruiseTime = map(analogRead(cruiseTimePin),0,1023,0,cruiseMax);   //map the pot range to our preset max cruise time

    if(digitalRead(startPin) == LOW)
    {
      // power up to maxSpeed. Start motorspeed above 0 to not overload mosfet
         for (motorSpeed = 50; motorSpeed < maxSpeed; motorSpeed++)
          {
            analogWrite(motorPin, motorSpeed);
            delay(rampTime/maxSpeed);
          }

      // cruise at maxSpeed for (int t = 1; t < cruiseTime; t++)
          {
            maxSpeed = map(analogRead(maxSpeedPin), 0, 1023, 0, 255);   // lets us tweak motor speed as it runs
            analogWrite(motorPin, maxSpeed);
            delay(1);
          }

      // descend from maxSpeed
      for (motorSpeed = maxSpeed; motorSpeed > 0; motorSpeed--)
          {
            analogWrite(motorPin, motorSpeed);
            delay (rampTime/maxSpeed);
          }

      //shutdown as a precaution
      analogWrite(motorPin,0);
      }
      delay(50);     //for analogRead() stability?
      }

Annoying things
- to load the code onto the Trinket, you need to press the little button on it and then "send" the code while the light blinks. Unfortunately by the time the Trinket is connected to the breadboard, you can't get at the button. The process to load the code then is: connect the Trinket to the USB cable. The light will blink for 10 seconds or so. Send the code while it is still blinking. If you're not quick enough, the lights tops blinking, and you'll get an error like "device not found". Just pull the usb cable out, plug it back in and try again a bit faster!

- for some unknown reason, I've had trouble loading the code if any of the trimpots are set either fully on or off. The "ready to load code" light won't blink and you won't be able to load the code. I make a habit now of putting the trimpots about center every time I load or reload the code.

- at the moment the cruise time is limited to 30 seconds.


Ratz Edit: Replaced Code at author's request.
Ratz Edit: Replaced Circuit Board diagram image.
Attached files Thumbnail(s):
DIY flight profiler using Adafruit Trinket
DIY flight profiler using Adafruit Trinket
DIY flight profiler using Adafruit Trinket
« Last Edit: March 05, 2018, 06:34:39 PM by Ratz » Logged
Yak 52
Titanium Member
*******

Kudos: 58
Online Online

United Kingdom United Kingdom

Posts: 2,292


Free Flight Vagrant



Ignore
« Reply #1 on: March 03, 2018, 04:18:04 AM »

Hello Mike,

I've been following your articles in Slipstream, interesting stuff!
Would you be able to provide a standard circuit diagram at all please?

Also would you mind sharing where you sourced your PCB's please?

The circuit delivers up to that voltage to the motor, depending on where you set the max speed trimpot and how much current the transistor can deliver. The one used here is supposedly good for up to half an amp - my KP01 only seemed to draw 25 milliamps. (I've done some, but not extensive testing, on bigger & smaller motors)

That seems rather low to me. A Didel 7mm motor draws about 0.5A on the Voodoo 15 gearbox (15g thrust). The low amp limit is a potential problem if you can't get sufficient thrust to fly the weight of the profiler unit. So 'shrinking' is an obvious next step but I would also look at upping the amp capability?


Jon
« Last Edit: March 03, 2018, 04:29:20 AM by Yak 52 » Logged
mike_st
Bronze Member
***

Kudos: 0
Offline Offline

New Zealand New Zealand

Posts: 27

Topic starter


Ignore
« Reply #2 on: March 03, 2018, 02:42:47 PM »

Would you be able to provide a standard circuit diagram at all please?

Also would you mind sharing where you sourced your PCB's please?

That seems rather low to me. A Didel 7mm motor draws about 0.5A on the Voodoo 15 gearbox (15g thrust). The low amp limit is a potential problem if you can't get sufficient thrust to fly the weight of the profiler unit. So 'shrinking' is an obvious next step but I would also look at upping the amp capability?
re the circuit, it all starts here https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/overview, which isn't really a schematic. I'll draw one up. The trimpots are a voltage divider between ground and the regulated 3v provided by the Trinket, with the output going to a pin that is read by an AD converter. The resistor protects the Trinket output from having too much current drawn on that pin, and the diode is to protect from back-emf from the motor (apparently a schottky would be better here).

PCB - note that the picture attached to the first article looks like a pcb but is just a drawing of a breadboard layout - use breadboard and connect everything along the green lines. But my actual pcb I got via https://easyeda.com/ , who now seem to use https://jlcpcb.com/. I'll upload the gerbers once I know its working.

re. current - I plan to make a better test rig, as I was surprised at such a low value. In fact I was looking for a cheap digital ammeter yesterday! But there are heaps of alternative mosfets that can deliver more current in the same circuit (though they likely have different pin arrangements), I have a bunch of NTD5867NL waiting to try. But I'm pretty confident with the PN2222 and KP01 an Earl Stahl Rearwin will be fine (as an example). I just started with that transistor because it is cheap and readily available.
Attached files Thumbnail(s):
Re: DIY flight profiler using Adafruit Trinket
Re: DIY flight profiler using Adafruit Trinket
« Last Edit: March 03, 2018, 02:58:24 PM by mike_st » Logged
Nigel Monk
Bronze Member
***

Kudos: 2
Offline Offline

United Kingdom United Kingdom

Posts: 64



Ignore
« Reply #3 on: March 03, 2018, 07:18:40 PM »

Thanks for this, please keep it going.
Nigel
Logged
mike_st
Bronze Member
***

Kudos: 0
Offline Offline

New Zealand New Zealand

Posts: 27

Topic starter


Ignore
« Reply #4 on: March 03, 2018, 09:04:27 PM »

I've ordered a little LED volt/ammeter so I can do better tests. I might have been overly optimistic on the capabilities of the PN2222, but without metering as it runs it's hard to know exactly what is happening. I'll also go back to my original prototype to compare.
Attached files Thumbnail(s):
Re: DIY flight profiler using Adafruit Trinket
Logged
mike_st
Bronze Member
***

Kudos: 0
Offline Offline

New Zealand New Zealand

Posts: 27

Topic starter


Ignore
« Reply #5 on: March 04, 2018, 02:45:07 AM »

well, I've found a few mistakes that I need to sort out. Some are in the code, but the more worrying one was when I pulled the "fuse" out of the breadboard it kept running!! Not what should happen.
Logged
mike_st
Bronze Member
***

Kudos: 0
Offline Offline

New Zealand New Zealand

Posts: 27

Topic starter


Ignore
« Reply #6 on: March 04, 2018, 03:50:47 AM »

sort-of-schematic
Attached files Thumbnail(s):
Re: DIY flight profiler using Adafruit Trinket
Logged
pedr01
Bronze Member
***

Kudos: 0
Offline Offline

United Kingdom United Kingdom

Posts: 26



Ignore
« Reply #7 on: March 04, 2018, 06:43:28 AM »

well, I've found a few mistakes that I need to sort out. Some are in the code, but the more worrying one was when I pulled the "fuse" out of the breadboard it kept running!! Not what should happen.

1) The ATtiny85 is a listed microprocessor in the Tinkercad simulator, where you can debug your circuits and programs. I have used the tinkercad to debug previous programs where I was suffering from overflow problems. I find it really useful, but then my programming was never too fantastic to start with.

https://www.tinkercad.com/

2) To minimise weight, you can actually program an ATtiny85 using a nano, or other arduino board. There's lots of youtube videos that show you how, eg;

https://www.youtube.com/watch?v=vH5sx8qphdk


Logged
Yak 52
Titanium Member
*******

Kudos: 58
Online Online

United Kingdom United Kingdom

Posts: 2,292


Free Flight Vagrant



Ignore
« Reply #8 on: March 04, 2018, 08:24:07 AM »

Mike,

Thanks for the schematic. The NTD5867NL looks like it will handle quite a bit more (Power dissipation of 36W)

Look forward to hearing more.

Jon
Logged
mike_st
Bronze Member
***

Kudos: 0
Offline Offline

New Zealand New Zealand

Posts: 27

Topic starter


Ignore
« Reply #9 on: March 04, 2018, 02:19:08 PM »


1) The ATtiny85 is a listed microprocessor in the Tinkercad simulator, where you can debug your circuits and programs. I have used the tinkercad to debug previous programs where I was suffering from overflow problems. I find it really useful, but then my programming was never too fantastic to start with.

https://www.tinkercad.com/

2) To minimise weight, you can actually program an ATtiny85 using a nano, or other arduino board. There's lots of youtube videos that show you how, eg;

I didn't know about the Tinkercad simulator - thanks, will definitely take a look!

I've bought a Sparkfun board https://www.sparkfun.com/products/11801 for shrinking to the ATTiny85 - I'll make another thread when I get to that
Logged
ChrisH
Bronze Member
***

Kudos: 0
Offline Offline

United Kingdom United Kingdom

Posts: 35



Ignore
« Reply #10 on: March 04, 2018, 05:26:08 PM »

This is great stuff!   I too had been following your two articles published on 'Slipstream'.

You lead me to read about the Trinket and related stuff on their website.   I wondered whether the Trinket could control ramp, time and Volts directly from code, rather than the analog inputs from your pots on the separate board.

I can see that a program driven controller would be harder to use in a field, than your very practical solution with 3 pots on your board.

I read about the ability to program an ATTiny85 chip using an Arduino of sorts, and wonder whether it is possible/practicable to build an Arduino chip programming circuit, with your 3 pots on the Arduino programming board rather than in the model?    Could an Arduino board read the 3 pot values, and use these values to populate the code values sent to the chip in the model?

Regards
   Chris


Logged
mike_st
Bronze Member
***

Kudos: 0
Offline Offline

New Zealand New Zealand

Posts: 27

Topic starter


Ignore
« Reply #11 on: March 04, 2018, 07:46:22 PM »

This is great stuff!   I too had been following your two articles published on 'Slipstream'.

You lead me to read about the Trinket and related stuff on their website.   I wondered whether the Trinket could control ramp, time and Volts directly from code, rather than the analog inputs from your pots on the separate board.

I can see that a program driven controller would be harder to use in a field, than your very practical solution with 3 pots on your board.

I read about the ability to program an ATTiny85 chip using an Arduino of sorts, and wonder whether it is possible/practicable to build an Arduino chip programming circuit, with your 3 pots on the Arduino programming board rather than in the model?    Could an Arduino board read the 3 pot values, and use these values to populate the code values sent to the chip in the model?

Hi Chris,
yes certainly you can just set the values in code and dispense with the trimpots, very easy. or you could preset the ramp and cruisetime and just have one trimpot for speed, etc.
I suspect that having some setup as you describe with another board with the trimpots that dumps the settings to the flight board would be possible, but I haven't researched it. I also considered having a mobile phone app use bluetooth to set the flight parameters.....but seeing as I am learning as I go, I figure I need to get the basics right first!
Logged
mike_st
Bronze Member
***

Kudos: 0
Offline Offline

New Zealand New Zealand

Posts: 27

Topic starter


Ignore
« Reply #12 on: March 04, 2018, 11:41:13 PM »

latest measurements indicate the PN2222 delivering 3.5 amps @ 4 volts to a small motor and 3.5 amps @ 3 volts to a bigger motor. Neither of those were producing enough thrust to fly something. Unless there is something wrong with my design (quite possible), I guess that means we move on to other transistors/mosfets that can deliver the goods.
Logged
Nigel Monk
Bronze Member
***

Kudos: 2
Offline Offline

United Kingdom United Kingdom

Posts: 64



Ignore
« Reply #13 on: March 08, 2018, 05:00:28 PM »

Hmmm, it shouldn't be the transistor constraining the output - if it isn't capable, it would burn out. You want one with a low RDS_on in the region of milliohms.

The alternative you've suggested looks way OTT, you should find one that is quite close to the voltage you need and somewhat more than the current you think you might draw plus a bit. A 40A MOSFET will weigh too much for one thing. It's quite hard to get one component that will be the best solution at 1, 2, 3 and 4S. My advice would be to optimise the design for the application you have an immediate use for. You can potentially drive FETs in parallel later.

The output should be a simple ohm's law between voltage input and motor resistance, then output current = V/R, to a close enough approximation.  I can't remember the resistance of pager motors nor the B2C2 motors used in the KP01, which is a bit useless, but it shouldn't be hard to find. I seem to remember the old Vapor boards could deliver an amp or so from 1S LiPo into a geared early pager, that suggests about 4ohms for the pager. The Voodoo and later umx motors were considerably more powerful.

Incidentally, the surface mount components are not as scary as they seem if you stick to an older package such as SOT-23. It is better to use a solder paste with them and a pointy iron tip with maybe 0.5mm chisel. Some good how-to's on line. Here's one I made earlier - only half of it worked - the 3-legged flat things with a ground/heat sink lug on the opposite side are SOT-223 MOSFET's. I started this with no prior SM soldering experience to speak of, just some strong magnifier glasses  Grin.

Keep going!
Nigel
Attached files Thumbnail(s):
Re: DIY flight profiler using Adafruit Trinket
« Last Edit: March 08, 2018, 05:39:05 PM by Nigel Monk » Logged
mike_st
Bronze Member
***

Kudos: 0
Offline Offline

New Zealand New Zealand

Posts: 27

Topic starter


Ignore
« Reply #14 on: March 08, 2018, 07:33:29 PM »

Thanks Nigel.
>>it shouldn't be the transistor constraining the output - if it isn't capable, it would burn out
well the pn2222 is certainly getting very hot! Too hot to keep your finger on it.

the other mosfets I'm trying are ones that seem to be recommended for this purpose with Arduino's etc - will operate with the 3-5v gate, and low RDS_on as you mention. I am also thinking of light 40"-ish models that might otherwise have had a 0.5cc diesel, where a few more grams is neither here nor there. Is there anything to be achieved using a mosfet say 10v & 2amps when for the same package or smaller and a few cents more I can have 60v & 40 amps? (the NTD5867NL is tiny)

Also what I don't understand quite yet is if I am supplying the board with 7.4 or more volts from a 2s battery, which would make the motor go like the clappers if connected directly, why I am only getting about 3.5 volts coming out the other side? I figured that would be a function of the transistor, but maybe there some loss somewhere else? e.g. I haven't looked at the gate on an oscilloscope yet to see whether it is in fact fully open/on/high (whatever the terminology is).

I haven't tried it with a pager type motor yet, but will.
Logged
Nigel Monk
Bronze Member
***

Kudos: 2
Offline Offline

United Kingdom United Kingdom

Posts: 64



Ignore
« Reply #15 on: March 09, 2018, 05:32:06 PM »

I've gone round this a few times and have run out of time so if it reads a bit disjointed, that's why (mostly  Cheesy)

The contraption I was showing off is basically a switch, so the FET's are driven fully closed as fast as possible, then open again likewise. In the meantime, the conducting resistance was what was important. I'm not a natural electronics person though, it took a loooong time to simulate that into existence. Nuts and bolts I understand...

Anyway, your motor controller needs to operate at part throttle for which you use PWM - I haven't read and understood your code but I assume somewhere in there it tells the output to do this? Regardless, the transistor needs to turn fully on during the on part of the PWM. That depends on having enough current to switch it on fast enough for whatever speed its pulsing at.

The trinket pins are only good for 20mA. At 3.3V, if you place a 120ohm current control resistor between the GPIO and transistor Base, you'll get 3.3/120 = 27.5mA maximum - but the trinket can't deliver that, but if you use a 270ohm resistor you'll only get 3.3/270 = 12mA.

The load current through the transistor it's driving is then determined by the gain or hFE. The value of hFE depends on the base current and voltage, there are data in the spec sheet but it can be as low as 35. 35 x 12mA only provides 420mA throughput - the transistor isn't fully 'on'. Then the PWM chops that on the time dimension as well, so you get a time averaged value as well. 

the same problem will apply to bigger transistors more so. in that case you may need an additional transistor at low power to drive the higher power transistor.

PN2222 is only good for 600mA max according to the datasheet I was looking at - how did you get 3.5 or 4 A through it? https://www.onsemi.com/pub/Collateral/PN2222-D.PDF

So, there are a number of things that can control the throughput of transistors. Picking the right one needs a degree of artistry and experience I don't have. There must be folks on here who are cringing at the way I'm explaining this - I hope they chip in soon! 
Nigel
PS You can get a software oscilloscope for your PC by the way, that might be cheaper or easier than hardware. More to look into!!
« Last Edit: March 09, 2018, 06:59:22 PM by Nigel Monk » Logged
mike_st
Bronze Member
***

Kudos: 0
Offline Offline

New Zealand New Zealand

Posts: 27

Topic starter


Ignore
« Reply #16 on: March 10, 2018, 02:57:20 PM »

Thanks Nigel, some really useful points there for me to follow up on.
yes the code is managing the PWM.
In particular, I didn't realise the effect of the current control resistor.
>> how did you get 3.5 or 4 A through it?
....well, I was using my multimeter so perhaps, expecting amps, I misread by a factor of 10....confirmation bias??!
Unfortunately it'll be a week or more before I can get back to unravelling some of this.
Logged
Nigel Monk
Bronze Member
***

Kudos: 2
Offline Offline

United Kingdom United Kingdom

Posts: 64



Ignore
« Reply #17 on: March 13, 2018, 12:53:09 PM »

No worries. I happened to notice another forum article elsewhere that reproduced the same layout. Their estimation for beta (hFE) was a factor of only 10, so max current would only be 200mA. They were, however, talking about optimum conditions for running the PN2222 efficiently (so it wouldn't get hot).

Main reason for replying again was that the article mentioned something I had omitted - that is, the transistor itself will incur a voltage drop between base and emitter (because it is a silicon device), so the sum should be (3.3-0.7)V/120 Ohms = 21mA, closer to the reasonable output of the Trinket pin. Some state the voltage drop = 0.8V, I'm not certain which is correct. The resistors are likely to be 5% but in my experience are usually closer unless you picked up a really random one.
Logged
raggedflyer
Bronze Member
***

Kudos: 1
Offline Offline

United Kingdom United Kingdom

Posts: 65



Ignore
« Reply #18 on: March 13, 2018, 01:56:20 PM »

The better solution is to use a VMOS FET rather than a bipolar transistor to drive the motor. The FET is turned on by a voltage applied to the gate at very little current compared with the 20mA available from the processor output pin. A gate current limiting resistor may not be required with an FET but is often included for other reasons (beyond the scope of this story) for example to minimise electromagnetic radiation for EMC compliance. It’s not a bad idea to still use a resistor though as it would limit the maximum output current from the processor output should the gate be grounded or taken to the positive supply. ICs often have internal current limiting to protect the inputs/outputs - I’ve not checked this one.

Also remember besides the base emitter voltage ( say 0.7v or more depending on device and current) that the collector emitter saturation voltage is also a loss. I think for the bipolar transistor mentioned it’s of the order of 1.6v at 500mA. 1.6v is a large proportion of a 1S or 2S battery supply voltage. With these figures the power dissipation would be 800mW, enough to make a small device quite warm. The power dissipation in a typical FET at 500mA would be minimal due to its low Ron of milliohms.

Also remember that the output voltage waveform applied to the motor is a variable pulse width square wave. The motor load is both resistive and inductive. Consequently, a simple ac or dc voltmeter will not measure accurately although will offer comparative guidance. Most likely the waveforms will have other imperfections too. Fit a reverse biased shotttky diode across the motor terminals to protect the drive transistor.

Logged
mike_st
Bronze Member
***

Kudos: 0
Offline Offline

New Zealand New Zealand

Posts: 27

Topic starter


Ignore
« Reply #19 on: April 29, 2018, 04:24:50 AM »

Finally got back to this today. Replacing the 2222 transistor with a FQP30N06L(https://cdn.sparkfun.com/datasheets/Components/General/FQP30N06L.pdf) seemed to let the force through without any issues, didn't even get warm with a 2S pack and a GWS motor spinning a 7x6. Also had a KP01 going like the clappers. Now obviously a FQP30N06L is not micro, but we're still talking only 11 grams for trinket, breadboard, FQP30N06L, some terrible soldering and a few too many wires, battery and motor harness. Next I'll hook up the little volt/ammeter and see what it says. Pictures of my sophisticated test jig and FQP30N06L kludge attached (I think).
Attached files Thumbnail(s):
Re: DIY flight profiler using Adafruit Trinket
Re: DIY flight profiler using Adafruit Trinket
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!