bart796:
Ok so I order the “trinket” which is the very small arduino based board Mee_n_mac linked to and then I buy the other product Mee_n_mac linked to which was the MOSFET switch. After those I would need code to tell it when to do what I need it to do correct? The board has the ability to read the voltage without anything separate or do I still need to include more components to read the voltage coming from the battery?
In addition to any wiring, you'd need at least 1 potentiometer (aka a 'pot'). This is because the 10+ V you want to read is too large to be input to either micro (5 V max). You would use one as a voltage divider to reduce the 10+ V to something under 5 V max. Read this ...
The battery voltage, after being divided down, is input to an analog pin and read. Depending on the voltage read, a digital pin is used to control the FET to turn on/off the LED strings at whatever rate(s) you want.
Depending on the micro you chose you’ll need a cable to connect the PC to the micro (aka MCU). For the Trinket it’s a simple USB cable but with the correct end connectors. For the Pro Mini you’ll need an active (it has circuitry in it) “FTDI” cable (or equivalent adapter board AND USB cable). This translates USB communications in to the type of serial communications that the Pro Mini can understand. You may also have to solder some header pins onto the Pro Mini inorder to plug the cable/adapter into it.
I think you can figure out why a Trinket (or [Pro Micro) is easier to use than the Pro Mini. But you probably pay a weight penalty to have the USB connector and circuitry on the the board. You make the tradeoff.
Wow amazing! yall are awesome! The absolute battery voltage is 12.60 fully charged (3.2v per cell 3 cells). The absolute minimum it should be discharged to is 9.0 volts but that will wear down the battery and the optimal drain point is something like 10.8-11.3 but I went in the middle and chose 11.1 as the first indicator. I would actually de-solder that usb connector once I had it working to save weight and in the future if I needed to use it I could simply resolder it back on no big deal! I will get the amp draw for you when I get home I get off between 3:30 and 5:30 it is 2:37 right now.
Oh wow I have taken a look at the 2 sets of codes linked in here and realized I have bitten off far more than I can chew. I may need to see if I have a buddy who knows this code and see if they can write that portion it looks beyond my learning level or I will find some tutorials when I get home and check out how to write this stuff. I don’t want to ask anyone in here to write the whole code because yall have already provided me with plenty to work with! I imagine I should have researched the code before hand but I think I can still get this to work.
Baby-steps is the keyword. Don’t expect to arrive at your goal in one stride. First try the analog measuring, pin state changing, and maybe PWM output on pins for blinking as separate intermediate goals. Don’t forget to learn about program flow, if-then, While-loops and sending to serial port. Especially the last part is very important to let your program tell you what is going on inside it’s mind. Only after that start consider combining all parts to arrive at your true goal: battery voltage based ledstrip ligth modulation.
FWIW this could all be done w/other common timer hardware, no programming involved. But it’ll take more components, more space and be a bit heavier as a result. If have some space time, I’ll how it could be done w/a quad comparator and 556. Enginerds can’t resist trying to be clever w/555 (556) circuits.
Can I assume your ESC/BEC/??? outputs a regulated 5 V from the battery pack ?
The ESC does have a BEC in it that send 5volts to the reciever and then its sent to the servos i could pull power from that but only 5 volts of course. A little heavier would not be a problem at all.I had someone on another forum show me a few ideas with some 555 chips but they were leaving variables out telling me to fill them in and i kept telling them im a complete noob and filling in variables might blow my 250 dollar plane and 50 dollars worth of leds lol that would not be good.
Here’s one possible way to implement part of what the OP wanted in the … well … OP. What the req was were 3 blinking states vs voltage and a constant on state for “high” voltage. What I’ve got is a constant on plus 2 blinking states as the voltage decreases. A third state was/is possible but would require additional hardware that I thought wasn’t worth the additional warning. I note the solution below uses 3 individual comparators, which would be expected to be 3/4 of a quad comparator IC (LM339). Also it uses 2 555’s vs a single 556. Still the idea was to demonstrate a concept to solve the OP’s problem w/o resorting to programming a MCU (though IMO that remains the preferable solution). Here’s the schematic of that solution and the LTSpice .asc file, re-typed as a .txt file.
(click on to open and enlarge)
Note that V1 is the battery voltage, which I have ramping down form 12.6 V to 9 V. V2 is the BEC supplied regulated 5 V. The battery voltage is divided down before being inputted to a comparator block which detects battery voltage above a window, in a window (~11.1V to ~10V re: battery voltage) and below a window. When the battery voltage is above the window, the 555’s are held in reset resulting in the FET being on and the LEDs being constantly illuminated. When in the window, 555 #1 oscillates at ~2 Hz and so the LEDs blink 2x/sec. When below the window, 555 #1 is again held in reset but 555 #2 now runs and ‘blinks’ the FET, and LEDs, at a ~4 Hz rate. Of course the rates could be different w/different “timing” resistor and cap values. And the window voltages can also be changed w/different setpoint resistors. The schematic does not show the SFE FEt kit nor the OP’s LED string(s). I would mention that the 10k pulldown resistor in the SFE FET kit would need to be eliminated for this solution to work
I happen to think a better solution exists, one that could implement 3 blinking states using the spare comparator (from a quad) and using only a single 555 (thus no Q1, Q2 etal) but it didn’t come to mind. Take that as a challenge ! :twisted:
Ok that looks much easier and should not be too big at all. Looks like ill need to get a bunch of various resistors (or just order a resistor kit I saw with like 1200 in it for 5-10 bucks). I also would need the MOSFET kit but if you say I need to modify that one would a different one be a better choice? That’s as much as I can read of the circuit schematic however as I mentioned my dad is much better at this than me and he should be able to read the rest and figure out what we need to order to attempt this!
EDIT: Ah and 3 LT1017 Comparators I see this now it was clearly labeled!
bart796:
Ok that looks much easier and should not be too big at all. Looks like ill need to get a bunch of various resistors (or just order a resistor kit I saw with like 1200 in it for 5-10 bucks). I also would need the MOSFET kit but if you say I need to modify that one would a different one be a better choice? That’s as much as I can read of the circuit schematic however as I mentioned my dad is much better at this than me and he should be able to read the rest and figure out what we need to order to attempt this!
EDIT: Ah and 3 LT1017 Comparators I see this now it was clearly labeled!
Before you go out and spend the (few) $$, let’s review at bit. You originally wanted on/blink1/blink2/bkink3 states, depending on battery voltage. What that circuit does is on/blink1/blink2 states. Is that good enough ? As I said it could be expanded to do your original requirements. Or it could be reduced to just on/blink1 states and thereby eliminate a 555 timer (really go from a dual timer 556 IC to a single timer 555 IC) and it’s associated 2 resistors and 2 caps. This would also eliminate the need for the 2 transistors (2N2222) and their 2 resistors. You also only need a dual comparator IC vs a quad (LM339), loosing 1 more resistor in the process.
You don’t need the FET kit but could just use the same FET. I believe SF sells that separately.
You should think about how you’re going to wire all these components up and whether that result is any smaller or lighter than going w/an Arduino plus stuff. Or any easier. I know the coding might be “over your head” ATM but it’s a more flexible solution. I set-up the timers above for 2 Hz and 4 Hz rates. If you want different, you have to change R’s and C’s. The duty cycle (on time vs total period) is set to 50% (equal LED on and off times). If you want different, yup, you have to change R’s and C’s. No biggie now as it’s not built but after it is … And you may find other improvements to make. Perhaps the battery voltage needs some filtering to remove noise. Time to add an R and a C. Perhaps something we’ve not even considered. That’s the blessing, and curse, of doing things w/software … it’s “easy” to change.
So with that said I took 30 mins and came up with a preliminary version of that code. If you had an Arduino you could watch the onboard LED do it’s thing as the voltage at pin A0 changes. See if you can follow how the code works using some of the links posted above.
// Ver 0.1 of code to blink an LED string based on
// a measured analog voltage
//declare the constants used
const float tripVolts1 = 11.1; //above this voltage the LEDs are always on
const float tripVolts2 = 10.5; //above this voltage the LEDs blink at rate 1
const float tripVolts3 = 9.9; //above this voltage the LEDs blink at rate 2
const float scaleFactor = 0.4; //ratio of divided down voltage to battery voltage
const int blinkRate1 = 1; //blink rate1 in Hz (blinks/sec)
const int blinkRate2 = 2; //blink rate2 in Hz (blinks/sec)
const int blinkRate3 = 4; //blink rate4 in Hz (blinks/sec)
const int FETpin = 13; //number of digital pin used to control FET
const int battPin = A0; //number of analog pin used to measure battery voltage
//declare the variables used
boolean blinkState = false; //variable to control LEDs on or off
unsigned long blinkPeriod = 0; //period in msec of blinking
unsigned long blinkTime = millis(); //variable to store when blink state was last changed
float battVolts = 0; //battery voltage
void setup() {
//setup digital pin used to control FET
pinMode(FETpin, OUTPUT); //set pin to be an output
digitalWrite(FETpin, LOW); //turn FET off
}
void loop() {
//measure the divided down voltage and convert back into battery voltage
battVolts = (float(analogRead(battPin)) * 5.0 / 1023.0) / scaleFactor;
if (battVolts > tripVolts1) { //check voltage above or below high trip point
blinkPeriod = 0; //voltage above, special condition for no blinking
} else if (battVolts > tripVolts2) { //check voltage above or below 2nd trip point
blinkPeriod = (1000 / blinkRate1); //voltage above, blink at rate1
} else if (battVolts > tripVolts3) { //check voltage above or below 3rd trip point
blinkPeriod = (1000 / blinkRate2); //voltage above, blink at rate2
} else {
blinkPeriod = (1000 / blinkRate3); //voltage below, blink at rate3
}
//now blink the LEDs if conditions are correct
if (blinkPeriod == 0) { //special condition means no blinking
digitalWrite(FETpin, HIGH); //turn FET on
} else {
//blink the LEDs on and off
//check is blinkTime/2 has passed since last on/off change
//if true change on to off or off to on
if (millis() - blinkTime >= (blinkPeriod / 2)) {
blinkState = ~blinkState; //change blinkState
blinkTime = millis(); //reset blinkTime
}
digitalWrite(FETpin, blinkState); //turn FET on or off per blinkState
}
delay(blinkPeriod/10);
}
Honestly I could just drop it to 1 trip voltage and just land it would be better. I think the arduino would be 100% better due to space issues but like I said I would need to learn the code. I am able to follow that code and see what it is doing just writing it myself would have been next to impossible. I think the arduino is better and as best as I can tell it only uses the arduino board and that FET? That is a lot less space.
bart796:
Honestly I could just drop it to 1 trip voltage and just land it would be better.
I'll have to think a bit more on that. It might be even easier to do that than I had previously thought. Also I'd be surprised if other forum regulars don't come up with better, simpler circuitry than I posted. But in the end it's your decision. :o :mrgreen:
You know just for the sake of making life easy how about this circuit. 1 voltage trip at like 10.8 (i saw 10.8 because when you give it full throttle it will drastically drop the voltage until you let off and then it will settle back out so it could potentially instantly drop to 11.1 and would start flashing so 10.8 might be better. start flashing at 10.8 and then ill just land that makes life easier im sure. The other stuff was over-complicating things because i should land at around 11 anyway going down to 9 is just asking for a destroyed battery.
I should be able to make an oscillator out of 1-2 comparators and then control it with a 3’rd … meaning a 1 IC solution to your on/blink1 requirement. But I’ve yet to discover that magic and I’m now tied up taking apart my #$%^#^# Mini (again) to get the $^&$ thing running. So it might be a day or 3 before I have a chance to get back to this.
I’m surprised nobody has bested my prior answer ! (that’s a challenge that can’t go uncontested) :mrgreen:
Provided i had the stuff i would test it just for the heck of it lol but i def appreciate all the help. I need to learn how to do this stuff but i imagine this type of circuit is not at the beginning of the learning process and is perhaps in the middle or later stages of it heh.
OK not so fine tuned but here’s the guts of it, some resistor and perhaps C1 values to change.
(click on to open)
The above circuit uses 2 comparators of the quad LM339, so it’s only 1 IC plus the R’s and C1 and FET (M1). I suspect that Rtop and Rbot(tom) would actually be a pot so that you could fine tune the trip point (from on to blinking). The circuit presently has that set at 10V. You might be able to see the 2 parts; the left part being the comparator that chooses on vs blinking and the right part being an oscillator that works much like the 555 timer does internally. The frequency of the blinking is set via C1 and R2. Increasing either slows down the rate.
I believe there’s a dual version of a “339” but I don’t recall it’s part number. It may also be possible to use the other 2 “spare” comparator to get back to a on/blink1/blink2 circuit design. It has also occurred to me that if I ran the LM339’s off of the battery voltage (instead of the BEC’s 5V), I could eliminate a pair of resistors (Rset1/2) in the comparator part of the circuit, thus simplifying the circuit a bit more. It would depend on the power FET you choose (I’ve included a generic one in the circuit so you could see it all).
The shaded yellow portion is the circuit you’d build. The LED and resistor is just there to simulate your LED string(s).
I note that it’s max voltage, gate - source is 20V. So it could easily stand the 12+ volts it’s gate input would see if I ran the above circuit off the raw battery voltage.
Ok that is awesome thanks! I am a bit confused on the POT part. I know what that is but are you saying it uses one or does not? It would be good if it did because I would like the value closer to 10.8 and I assume with a POT I could just grab my flat head and turn it a little until it blinks at the exact voltage I want right? (I am not complaining though trust me I am very grateful that you have taken time to help me!)
NVM I see it instead of using the resistors you mentioned I should get POT’s that are in the same range and then I can modify the values by turning. Not sure what 2 would be useful for though? I would only ever want to modify the volts at which it starts blinking. Unless I would have to turn both to achieve the desired voltage? Also it would honestly be easier to run off battery voltage and less circuit is better for space saving so I will use whichever FET allows me to run off battery voltage if you can simplify that. If not ill just run it off the 5 volts and not worry about it. Also could I replace R2 with a POT? Not saying I want to but perhaps on a bigger plane it would be cool to be able to adjust the blink rate on the spot.
Here’s that simpler circuit and yes you’d replace the “top” and “bottom” resistors w/a single pot (see figure below) so as to be able to adjust the voltage trip point. You could also use a pot as a variable resistor in place of R2, though it might be hard to find one in the 0 - 500k range. I suppose you could use a pot (0-250k) in series with a fixed resistor (150k) to get sufficient range ?