Calling all electronics wizards!

Status
Not open for further replies.

Alexander Mundy

Ribbon Twister
ECF Veteran
Verified Member
Apr 1, 2013
4,408
26,100
Springfield, MO
Thought I had a 3914 but can't find one. It may be in the stacks of containers in the basement I can't get to due to the stacks of stuff from the man room since our daughter moved back in and the man room became her bedroom. The circuit has to be bread boarded to get the proper results due to small extra currents involved from the chip. For those that might be reading this and want to play with the LM3914/5/6 at 3V to 5.5V don't do it by the book. That is what most do and fail. The internal voltage divider network feeding the comparators must be fed a maximum of V+ minus 1.5V or strange things happen. This means if you play by the book you need a 5.7V power supply if the top of the divider stack is fed with 4.2V for a maximum reading of 4.2V. The trick is to make a 3 resistor voltage divider (2 in series with the battery & 1 from the middle to chip input) to reduce the input to be read, while providing full B+ to chip power. There is some current circulation interaction with the external voltage divider so doing it on paper is close but no cigar. Linear chips need a little more breadboard TLC than digital. All that clear as mud?

On the bright side for the OP, look at what I found:

db9ba74de02aa718c2aa91c223b1d490_zpsec1ed313.jpg


LED Battery Level Voltage Monitor Meter Indicator Alkaline NiCad NiMH LiPo L | eBay
 

MadOtis

Full Member
Verified Member
Oct 16, 2013
44
26
Georgia

There goes all my fun trying to do it with an arduino board! :)

Never having used an IC before, I have 2 questions:

1) Using the device in the link above, would it still allow enough voltage/wattage to pass through to still be able to fire a kayfun Lite?

2) I see the link says it will work with Alkaline, NiMh, NiCad, and LiPO... so, does an IMR 18650 still considered a LiPO or Li-ion?

I'm still going to order one of those circuits you linked, but since I've already ordered the Arduino board MorpheusPM recommended I'm still going to challenge myself to do it using the ATTiny45, too. I'll just have to make TWO mods (1 for each circuit). :toast:
 

Alexander Mundy

Ribbon Twister
ECF Veteran
Verified Member
Apr 1, 2013
4,408
26,100
Springfield, MO
By all means have fun with microcontrollers.

1) The little board I linked to is not a fire button. It is a level indicator only. Might even be an attiny on board? Looks like the button is used to program it to what battery(s) you are using.

2) You would want to set it to LiPo since Lithium Manganese (IMR) has the same working voltage range as Lithium Polymer.
 

MadOtis

Full Member
Verified Member
Oct 16, 2013
44
26
Georgia
MorpheusPA and other Arduino enthusiasts...

Does something like this look like it'll work? I'm still waiting for the Arduino and ATTiny85's to arrive, so this is just speculation. I don't know if the analog pin 3 on the ATTiny can be used as an output.

BatteryMeter.ino
Code:
int redPin = 0;     // physical pin 5
int yellowPin = 1;  // physical pin 6
int bluePin = 2;    // physical pin 7
int vvPin = 3;      // physical pin 2
int relayPin = 4;   // physical pin 3

int sensorValue = 0;
float voltageIn = 0;

void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  pinMode(relayPin, OUTPUT);
  pinMode(vvPin, INPUT);
  digitalWrite(redPin, LOW);
  digitalWrite(yellowPin, LOW);
  digitalWrite(bluePin, LOW);
  analogWrite(relayPin, 0.0);
}

void loop() {
  // first, read the variable voltage coming in from the 18650
  sensorValue = analogRead(vvPin);
  voltageIn = sensorValue * (5.0 / 1024.0);
  
  if (voltageIn >= 3.7) {
    illuminate(LOW, HIGH, HIGH);
    analogWrite(relayPin, voltageIn);
  } else if (voltageIn >= 3.5) {
    illuminate(LOW, HIGH, LOW);
    analogWrite(relayPin, voltageIn);
  } else if (voltageIn >= 3.2) {
    illuminate(HIGH, LOW, LOW);
    analogWrite(relayPin, voltageIn); 
  } else if (voltageIn < 3.2) {
    analogWrite(relayPin, 0.0);
    for (int x = 0; x < 5; x++) {
      illuminate(HIGH, LOW, LOW);
      delay(500);
      illuminate(LOW, LOW, LOW);
      delay(500);
    }
  } else {
    illuminate(LOW, LOW, LOW);
  }
}

void illuminate(boolean red, boolean yellow, boolean blue) {
  digitalWrite(redPin, red);
  digitalWrite(yellowPin, yellow);
  digitalWrite(bluePin, blue);
}

The idea has expanded to use a Direct-Control DC SSR (like a KF0604D) to fire off the mod. If the voltage coming from the 18650 is above 3.2 volts, it'll energize the relay and let the battery fire the mod. If it's below 3.2v, then the relay won't trigger and the mod won't fire. Obviously, I'll be using protected batteries!
 

Mike_S

Full Member
Sep 16, 2012
16
6
Charlotte, NC
MorpheusPA and other Arduino enthusiasts...

I don't know if the analog pin 3 on the ATTiny can be used as an output.

You can set physical pin 2 as an analog input or digital input/output. Are you planning on using it as an output instead?

Also, it appears that they are powering the uC from an external 5V source. You'll instead want to turn on the internal 2.56 voltage reference and change this line of code:

Code:
voltageIn = sensorValue * (5.0 / 1024.0);

to this:

Code:
voltageIn = sensorValue * (4.2 / 1024.0);

One other thing, I'd use a logic level MOSFET rather than a relay. Although you probably already going to do that.
 
Last edited:

MadOtis

Full Member
Verified Member
Oct 16, 2013
44
26
Georgia
You can set physical pin 2 as an analog input or digital input/output. Are you planning on using it as an output instead?

Pin 3, actually. Pin 2 would be used as the analog INPUT voltage directly from the 18650 battery. Pin 3 would be used as the digital HIGH (OUTPUT) to fire the relay.

Thanks for clarifying the battery voltage of 4.2 vs. 5.0, too. I'm sure I would have figured that out once I actually have the Uno and ATTiny85's in-hand. :)

What would using a logic-level MOSFET give that the SSR wouldn't give? Wouldn't the SSR just be alot simpler (albeit more expensive at $10 US)? I'm not familiar with MOSFETs, this project is my first dive into Arduino and anything more complicated than a few resistors and perhaps a capacitor or transistor.
 
Last edited:
On the ATTiny, Analog Pin 3 is Digital Pin 3. But Analog Pin 2 is Digital Pin 4. Yeah, have fun with that one, we all forget it when working with the things casually.

analogRead function in ATtiny chip - Arduino Forum There's a great thread that whines about it and mentions some challenges with working with the digital/analog difference.

According to the reference text, the analog reading will be from 0 to 5 volts on a 0 to 1024 scale, as noted. You could map that, but your supply voltage doesn't seem to be involved here (anything from 2.7 to 5.5 volts, or about 3.2 to 4.2 V in your case). There's a cute way of reading the voltage directly from VCC, but you have plenty of input pins not used.

I'm more familiar with MOSFETs and transistors than I am with relays, but a casual glance at relays shows they'll do the job. In the computer world, relays are very slow, but in the human world you won't even notice 2 ms, or 1/50th of a second.

The downside of a relay is the expense (the upside being the circuit isolation). A small MOSFET, which is easily capable of handling the power in a mod, runs about $0.65--http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_787798_-1

In a MOSFET, there are three wires--Source, Drain, and Gate. Power flows from the drain to the source (plus from anything you put between the ground rail and source, or between the drain and power rail). Applying voltage to the gate activates the power flow, cutting off voltage to the gate stops the power flow. In this case, if you check the data sheet's figure 4, your applied voltage range will be switching far more power than you need.

Mike suggested a logic MOSFET because many MOSFETs require higher gate voltage than source-drain voltage to activate the full power from source to drain power flow. Logic MOSFETs charge pump and don't require this, they're designed to work with the 3 to 5 volts that logic ICs output.

Here's a really basic circuit to light an LED with a MOSFET: File:Mosfet n-ch circuit.svg - Wikipedia, the free encyclopedia

The MOSFET is the circle with the arrow in it; the arrow's end is the source, the other side is the drain, the thing in the middle is the gate.
 

MadOtis

Full Member
Verified Member
Oct 16, 2013
44
26
Georgia
Follow-up: My Arduino finally got here, but no ATtiny yet, so I can't test this yet (ATtiny and a few other components should be here next week). Does this schematic look like it should suffice? Any suggestions to make the circuit safer electronically, or just "dude, you'll blow your face off with that" type of comments are welcome.

Mech Schematic.jpg
 
Status
Not open for further replies.

Users who are viewing this thread