go away spammer

Author Topic: 50$ robot, 5V all around  (Read 4100 times)

0 Members and 1 Guest are viewing this topic.

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
50$ robot, 5V all around
« on: February 03, 2008, 09:59:33 AM »
Alright since I didnt want to spend money on new batteries, or damage my servos, I hooked them into the 5V regulated power, it makes sense now that I think about it but if I spin the servo it produces power which turns on the microcontroller( I know this because I have a buzzer that plays when I power up and it makes noises) and everything else on the board, is it possible for me to damge the controller, or would its attempts to position the servo counteract the power sent by the surges?

Also, if I want a battery monitoring circuit, could I just hook up a wire from 5 V reg into the analog port of the controller? That way the volatge ranges from 5.04 to 4.8ish, or is that too small of a window?
« Last Edit: February 03, 2008, 11:35:24 AM by gamefreak »
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: 50$ robot, 5V all around
« Reply #1 on: February 04, 2008, 11:13:14 PM »
I don't believe it will damage the microcontroller . . . especially if you have capacitors on your circuit. The ground wire on a servo is always ground, and the power wire is always power, so no reverse voltage should ever occur.

Quote
if I want a battery monitoring circuit, could I just hook up a wire from 5 V reg into the analog port of the controller?
This won't work, since your ADC will max out at the voltage your mcu is powered at. What will happen, with that setup, is that it will always say your battery is full.

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: 50$ robot, 5V all around
« Reply #2 on: February 05, 2008, 11:03:14 AM »
alright, so the only way to do this is to have a set type of battery that I want? If I normally use 9 volt then the resistor will be very high if I chose to switch to 6 volts, what is the max discharge of a 9 volt battery? If it ends up being higher then the 6 volt fully charge, then my bot will think its always out of energy.
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline HDL_CinC_Dragon

  • Supreme Robot
  • *****
  • Posts: 1,261
  • Helpful? 5
Re: 50$ robot, 5V all around
« Reply #3 on: February 06, 2008, 02:30:50 PM »
Quote
if I want a battery monitoring circuit, could I just hook up a wire from 5 V reg into the analog port of the controller?
This won't work, since your ADC will max out at the voltage your mcu is powered at. What will happen, with that setup, is that it will always say your battery is full.
What if we take a resistor from the unregulated source and drop that voltage to about 4volts at full charge. (so for mine I use the 6v NiMH pack, so max of ~7v?) That way, when the unregulated voltage, accounting for the voltage drop across the resistor, reaches like 5.5v or w/e, you can have it do whatever you want it to do to conserver power or warn of the impending brownouts.
United States Marine Corps
Infantry
Returns to society: 2014JAN11

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: 50$ robot, 5V all around
« Reply #4 on: February 06, 2008, 03:43:03 PM »
Hmmmm yea that will work.

Except you need two resistors to make a voltage divider ;D

I guess two 100k resistors in series, where the node between them is read by the ADC, will work.

Just remember, if the voltage powering the ADC changes, then so does the reading.

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: 50$ robot, 5V all around
« Reply #5 on: February 06, 2008, 06:22:38 PM »
My 6 volt batteries finally arrived after sitting in California for 10 days and I intend to use them.

so 50000 / ((6.5 v / 5 v) - 1)
50000 / 0.3

166,666.7 ohm

So can someone explain to me how exactly this circuit works? I know the laws state the R=V/I, RI=V, I=V/R so how exactly do these work?
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline HDL_CinC_Dragon

  • Supreme Robot
  • *****
  • Posts: 1,261
  • Helpful? 5
Re: 50$ robot, 5V all around
« Reply #6 on: February 06, 2008, 09:13:43 PM »
Lets say you have a 9 volt battery. If you put only a 10 ohm resistor between the two leads, then that circuit would have an amperage of 900mA
If you used a 20 ohm resistor, the amperage would be 450mA
9v / 10Ω = .9A
9v / 20Ω = .45A

Where is the 50,000 coming from in your equation?... and what are you trying to solve for?
United States Marine Corps
Infantry
Returns to society: 2014JAN11

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: 50$ robot, 5V all around
« Reply #7 on: February 06, 2008, 09:15:33 PM »
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline HDL_CinC_Dragon

  • Supreme Robot
  • *****
  • Posts: 1,261
  • Helpful? 5
Re: 50$ robot, 5V all around
« Reply #8 on: February 06, 2008, 09:28:13 PM »
oooooh right right so:
R = 50000 / (Vin / Vlog - 1)
R = 50000 / (7v / 5 - 1)
R = 50000 / (1.4 - 1)
R = 50000 / (.4)
R = 125000Ω
R = 125kΩ
(The 6v battery packs usually contain a maximum of 7v.... at least mine does anyway :P)
Vout goes to your ADC pin on your MCU for reading. Vin is taken directly from the batteries output voltage. Not the regulated voltage. Thats a critical detail :)
So basically it takes a reference voltage (the MCUs operating voltage) and compares it to the batteries supply voltage.

Hope this helped at all
United States Marine Corps
Infantry
Returns to society: 2014JAN11

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: 50$ robot, 5V all around
« Reply #9 on: February 06, 2008, 09:42:21 PM »
I understood that part, what I want to know is how it works, knowing how to do it is one part, but I also need to understand why it works.

How exactly the 7 volts go down to 5, and why connecting a resistor between positive and ground doesnt count as a short circuit.
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline HDL_CinC_Dragon

  • Supreme Robot
  • *****
  • Posts: 1,261
  • Helpful? 5
Re: 50$ robot, 5V all around
« Reply #10 on: February 06, 2008, 09:54:17 PM »
Well a short circuit is when there is almost NO resistance between the voltage source and ground meaning there is no load for the electricity to be used by.
The resistor in this case is the load for that little circuit so that the electricity cant just shoot through to ground, it has to go through the resistor first.

The 7v steps down to 5v when the electricity cant just shoot through and is instead converted into heat via the load or the resistor in this case. Basically those 2 volts get converted into heat.
United States Marine Corps
Infantry
Returns to society: 2014JAN11

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: 50$ robot, 5V all around
« Reply #11 on: February 07, 2008, 06:33:00 AM »
so what does the second resistor do if the first one creates heat?
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • Hardware and Firmware Designer
    • The Hellinic Robots Portal
Re: 50$ robot, 5V all around
« Reply #12 on: February 07, 2008, 07:10:32 AM »
I don't believe it will damage the microcontroller . . . especially if you have capacitors on your circuit. The ground wire on a servo is always ground, and the power wire is always power, so no reverse voltage should ever occur.

Yep Admin is right... but reserve voltage for very short periods shouldn't harm actually your micro... I do NOT advice you to do it I just mention it so to be careful... By reserve volting your micro it should start heating up (tested with ATMEGA8)... But it you open the circuit soon enough you won't burn it... So just be careful with datasheets and if you are prototyping on soldering breadboard REMEMBER that you solder upside down...


Now that was some general knowledge... For you problem... It never happent to me despite how hard I have tried... I don't know if it is possible to damage your regulator that way... Try placing a diode (1N400X preferably 1N4001 or 1N4007) between the power pin of the servo and the else circuit preventing your servo to power up the board... If you have high current consuption try a "bigger" diode... But it's this is generally the easiest solution to your problem if not the only...
« Last Edit: February 07, 2008, 11:48:51 AM by TrickyNekro »
For whom the interrupts toll...

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: 50$ robot, 5V all around
« Reply #13 on: February 07, 2008, 09:41:59 AM »
Quote
so what does the second resistor do if the first one creates heat?
It creates a voltage divider.

For example, suppose you only had one resistor:

Vin --- resistor --- Ground

Then your circuit only has two voltages, Vin and ground. Since Vin (battery voltage) is greater than your regulated microcontroller voltage, sending it to your ADC will cause it to break. And ground is always 0V. Useless!

But if you had two:

Vin --- resistorA --- Va --- resistorB --- Ground

Now you have a 3rd voltage, Va, which is defined as:
(Vin - Va)/resistorA = (Va - Ground)/resistorB

Set ground = 0, and solve for Va, and you got the voltage that is sent to your ADC. This voltage must always be less than your regulated microcontroller voltage.

Quote
why connecting a resistor between positive and ground doesnt count as a short circuit.
Exactly what HDL_CinC_Dragon said.

The reason why its such a high resistance is to minimize the shorted current to be near zero, while voltage still remains the same. Its shorted, but to where only 5V/100k = .00005A current is wasted. Almost nothing! But it can't be too low, as the ADC requires some current to work (check the datasheets).

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: 50$ robot, 5V all around
« Reply #14 on: February 07, 2008, 10:55:26 AM »
So, could I optimize it even further by making the resistors equal to each other, or having more resistance on one side versus the other?

Since I already know what Va is supposed to be, I can plug anything in except the resistor values.

(vin-Va)/A = (Va--Grn)/B
(7-5)/A = (5-0)/B
2/A = 5/B
2B/A = 5
B/A =2.5
B=2.5A

So if im reading/doing this right, reistor B should be 2.5 times greater then resistor A, but how do I determine the value without entering in a bunch of resistances? According to the math from earlier B is 2.5 times greater then A, but why are they not the same?
« Last Edit: February 07, 2008, 11:16:31 AM by gamefreak »
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: 50$ robot, 5V all around
« Reply #15 on: February 07, 2008, 11:34:58 AM »
Your equation is mostly correct.

But you actually have two cases:
battery is full
battery is drained

Calculate for both, and then determine the resistor that will make sure your voltage never goes above maximum ADC voltage (I think 4.7V? check datasheets) for both cases.

So lets say its B=2.5A . . . well, you want to have a total of about 100k resistance in series, so you have a 2nd equation:

A + B = 100k

So if B = 2.5A, then you have:

A + 2.5A = 100k . . . now solve for A and you now know what A and B should be.

Now, knowing your resistors, go back to original equation and solve for Va for both the full battery and drained battery cases.

This will tell you the voltage swing that your ADC will see. Ideally, higher voltage swings are optimal.

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: 50$ robot, 5V all around
« Reply #16 on: February 07, 2008, 12:12:32 PM »
Why 100K, why not higher? the original equation provides 200 K.

but with 100 K, a should be 40 k, and b should be 60

(7-Va)/40000 = 7/60000
(4.7-Va)/40000 = 7/60000

(7-Va)/40000 = .0001166
(4.7-Va)/40000 = .0001166

7-va = 4.66
4.7 - va = 4.66

Va = 2.34
Va =0.04

so a voltage swing of 2.3 V with 100K max resistance
« Last Edit: February 07, 2008, 12:19:44 PM by gamefreak »
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: 50$ robot, 5V all around
« Reply #17 on: February 07, 2008, 02:39:07 PM »
Quote
Why 100K, why not higher? the original equation provides 200 K.
because:
Quote
The reason why its such a high resistance is to minimize the shorted current to be near zero, while voltage still remains the same. Its shorted, but to where only 5V/100k = .00005A current is wasted. Almost nothing! But it can't be too low, as the ADC requires some current to work (check the datasheets).
The actual total resistance doesn't really matter, its insensitive to it. 10k, 50k, 100k, whatever - the current is still really really low.

I am confused which battery you are using . . . but lets say you use a 6V battery . . . fully charged might be like 6.7V, while fully drained would be 5.6V . . . That will give you more like a .5V or 1V swing, but thats still good enough.

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: 50$ robot, 5V all around
« Reply #18 on: February 07, 2008, 08:41:27 PM »
kk, so to optimize battery life beyond what little is being drawn now, I could look into the spec sheets and see the bare minimum current the analog pins need and then go slightly above that, correct?

I dont intend to, im just trying to get my facts straight.
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: 50$ robot, 5V all around
« Reply #19 on: February 07, 2008, 08:47:55 PM »
In theory, yes.

But thats assuming your circuit is 100% reliable and predictable, as well as the microcontroller. You'd want some safety margin in there, of course.

I'm using a 300k resistor for one of my microcontroller circuits and it works fine.

 


Get Your Ad Here

data_list