Arduino Uno: Running multiple servos - arduino-uno

I have a Arduino Uno, and I am pretty new to the Arduino stuff. I am new to circuits also. I am thinking about working on a simple spider robot and making it more complex as I learn about the Arduino. Anyways, yesterday I tried seeing if I could run 10 server motors (small ones) with the Arduino. I linked all the positive wires in parrel and connected it to the 5v on the board. I observed that not all the servers moved like the code says. I looked it up and found out I can't do that or else I might fry it. I did not fry it thank goodness. I then found out that I have to have a separate power supply and connect the servers red wires(positive wire) to the power supplies red wire and connect the ground wires to ground on the Arduino. I found this picture showing this.
https://www.google.com/search?q=arduino+uno+connecting+multiple+servos&biw=1920&bih=974&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjU5r6ovv7RAhVp5oMKHV_cDqAQ_AUIBigB#imgrc=DmQfCRVK9SXwAM:
I also saw that in another forum someone said something about using a capacitor. So I have some questions still. My first question is do I have to have a capacitor or can I just do what the picture in the link I gave does? It shows the power supply being a 6v NiMH 2800 mAh battery. I looked online I could not find that exact same battery with a charger, but I found this on ebay.
http://www.ebay.com/itm/121963271143
So I thought if I connect 5 of the batteries in series that way the amps is left alone for 2800 mAh and 6v, the exact spec of the battery in the picture. So my second question is will this work? I have this pack from Radio Shack near my house that I got.
https://www.radioshack.com/products/radioshack-8-aa-battery-holder#
There is a problem with this one though and that is it holds 8 and not 5. So my third question is will it still work with only 5 batteries in it? The forth question is how do I connect the wires to this item since it has no wires coming off of it? My fifth question is are these battery packs connected in series since they add the volts? Thank you for reading this and taking your time to clear up my confusion. I will restate the questions down below.
Do I have to have a capacitor or can I just do what the picture in the first link I gave does?
Will this work?
Connecting 5 of the batteries in series that way the amps is left alone for 2800 mAh and 6v, the exact spec of the battery in the picture.
Will it still work with only 5 batteries in the 8 battery holder?
How do I connect the wires to this battery holder since it has no wires coming off of it?
Are these battery packs connected in series since they add the volts?
Again, thank you for reading this long forum question and thank you for your time.

Related

arduino - servo stuttering - used to work fine

I am using an Arduino Uno to control two ANNIMOS 20KG Digital Servo, DS3218MG.
The servos have each had 100,000ish movements.
For some unknown reason, after sitting inactive for several weeks, one of the servos started moving super slow-mo and stuttering while it was moving from A to B or B to A.
At first I thought it was a power supply issue so I replaced the power supply. Nope. Then I soldered all of my connections. Nope.
Then I thought the Arduino was confused and I replaced that. Nope.
Then I replaced the servo with a new one. That fixed it.
The servo that failed has to apply more force than the one that did not. I don't know how much more force, but some, and I would think it wasn't too much force for the servo to handle. It doesn't seem to strain at all when it is working properly.
My question is: do these servos have a limited number of operations they can perform? Why would sitting around doing nothing cause this problem?
As a result of this experience, I ordered several more of these servos so that I have spares on hand. But it would be good to know what is causing this so I can either fix the issue or plan on the number of spares I need.

digital to analog conversion

I have a SRF04 distance module and I don't want to use it with it's digital output. So I have to convert it to analog. To do that I bought a small AT-tiny micro controller.
Can help me how can I convert digital to analog. I'm using codevision-AVR program.
thanks a lot.
FDMX.
The SRF04 unit sends back a pulse to the ATTiny. You have to measure the time of the pulse using interrupts or polling. The time of the pulse will be 58 us times the distance in cm.
Once you have that number, you can use the ATTiny to convert the number to a voltage using PWM.
There are lots of code examples of both these things on the Internet. Search for AVR interrupts, and for PWM. Stack Overflow is not meant to be a place to repeat the examples for everyone who posts a question. If you get some code almost working, you can come back here to post your code and ask why is doesn't work.

Want to Write a Program that Will Switch Networks (Wireless)

I have two units on my property, one residence, other is now an office. I have an Airport Extreme in each place and they are bridged. Sadly, the basic software in the devices (iPads, phone, laptop) do a truly awful job of deciding when to change networks. What really sucks about this is I do some calling sometimes, and the call will drop even though the other network is there and has a great signal.
I posted on the Apple Discussion Forums, and a dude gave me a good answer, but it sounds like their reasoning is still not going to produce a good result.
I want to write a program that does this:
The minute it sees a drop in the signal, it looks for the other network.
Then it starts to monitor the ratio of signal between the two.
Soon as it favors one over the other by more than a marginal amount, it changes.
I hope this is not seen as an admin question. This is a programming question. Has anyone any experience with the frameworks that Apple's developer tools would have for this?
Thanks.

Stopping my room getting too hot via AppleScript + a USB Thermometer? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
So I'm a coder, I do PHP, JavaScript, and Objective-C. I'm currently working on a website prettymuch full-time and, being 16, don't really have an 'office' except a desk in my bedroom... So I'm spending quite a long time in my room coding this website and I have a bit of a problem.
My bedroom is at the back of our house, with the windows facing West, so in the afternoon the sun shines in the windows heating up the room. Right now as I type this, it's 28.5 degrees C, but it does get as hot as 32 which is seriously too uncomfortable to work in.
Being the sort of geek I am, I was wondering whether it would be possible - or, feasible - to get a USB thermometer or the like, which is Mac-compatible, and then use AppleScript to detect when the temperature gets to a certain level. If, for example, it gets to 23 degrees, I would like a Growl notification to appear saying "Open the small window", at 25 degrees "Open both large windows", and at 28 degrees "Open all windows and the door", for example...
I think this'd be pretty neat, even if I am the only person who'd ever use it! So, is this sort of thing possible, and where would I get a USB thermometer (if they even exist...) from? eBay? I also realise, this question isn't directly related to programming, but, I didn't really know where else to ask it... so, a programmey-question would be is it possible to fetch data from USB devices via AppleScript? - there, that'll do.
Cheers!
Jack
P.S. For all you hardcore Arizonians or Texans or whatever, I live in the UK, and temperatures like 30 degrees make us pass out ;)
Cheers Matee, There are plenty of them rickey 'ol USB thermometers up on the Amazon and eBay and whatnot, and also Google Shopping for around $15 American (Thats right around 22 of your pounds, for those of you across the pond, coincidentally, that's 1.2x twice the weight of the original XBox). Anyway, as far as the code, I'd wager you're in a bit of a sticky wicket, 'ol top. So far as the eye can wander, AppleScript doesn't support much hardware integration, it's more of a macro thing, aye? Don't go thinking I'm all talk and no trousers, though, if'n I'm not no barrack-room lawyer, I've been doin' it for donkey's years. The mothercompany (God save the King) might implement it in the next release, but i'd wager they'd throw us a canary in a coal mine first. Whose to say, I'm just a man in a clapham omnibus, either way, drafting this comment has been right royal. You brits take care over there ;)
-See you anon
You won't be able to directly monitor a usb device using applescript. Even if you could access the usb outputs directly you wouldn't know how to convert the signals into a temperature. However, if the device is mac compatible it will come with software for the thermometer... and you will be able to monitor that software using applescript. A quick google search turned up this and it says the software is apple-scriptable.
http://practsol.com/thummac.htm
A little late reply here, but right now, in Texas, I've got my nephew digging a 60in X 16in X 4ft hole just outside my home office. Into it I'll be placing a 40ft copper tubing "radiator". This with be the "core" of a geothermal loop to cool my mac. Yeah, it's wildly watercooled because the mods cause me to exceed the TDP (it's a MacPro1,1) of the case, but even before that my office got uncomfortably hot. Now it just causes my computer to shut down when I try to encode video. Not good.
In the UK you should be able to do the same (well, cool your room at least) with just a ground loop, a cheap pump, and a fan with more copper tubing coiled behind it. My project has ended up costing me quite a bit because of its complexity and mistakes make along the way, but a simple system to cool just the room should cost less than £150-200 and is definitely a DIY project you and your dad could do.
One of of the biggest reasons to do this are the electricity (cooling) costs saved for me, literally several hundred $ per year. And it's "Green" cooling. But the biggest reason is for the amount of science I've learned in the past 3 months.
Talk to your Dad about it. It's been fun, and would be a good project for a young Scottish engineer!

How does the Half-Life 2 multiplayer protocol work?

I was wondering how the Half-Life 2 multiplayer protocol works in mods like Counter-Strike: Source or Day Of Defeat: Source. I believe that they use some kind of obfuscation and proprietary compression algorithm. I would like to know how different kinds of messages are encoded in a packet.
Half-Life 2, Counter-Strike:Source etc all use Valves Source engine. Valve has a developer wiki which covers a lot of stuff (its pretty cool check it out!)...
These articles might interest you:
Latency Compensating Methods in Client/Server In-game Protocol, Design and Optimization
Source Multiplayer Networking
You should check out Luigi Auriemmas papers on Half-Life. You'll find a packet decoder and some disassembled algorithms there, too.
Reverse engineering information on Half-Life 2 may be hard to come by, because of its relevance for cheating. I'd guess boards like mpcforum are your best bet.
This is a really complicated question, my suggestion would be to look at some of the open source network game engines:
http://www.hawksoft.com/hawknl/
http://www.zoidcom.com/
http://sourceforge.net/projects/opentnl
http://www.gillius.org/gne/
You could also look at the source code for the quake series upon which the original half life engine is based.
Though details might differ, the general framework is pretty old. Here's a quick overview:
In early fps games such as doom and Quake the player's position was updated only on the server's response to your move command. That is, you pressed the move-forward button and the client communicated that to the server, the server udpated your position on its memory and then relayed a new game-state to your client with your new position. This led to very laggy play: shooting, even moving in narrow corridors was a game of predicting lag.
Newer games let the client handle the player's shooting and movement by themselves. Though this led to lag-less movement and fire it opened more possibilities of cheating by hacking the client code. Now every player moves and fires independently on their own computer and communicates to the server what they have done. This only breaks down when two players bump into one another or try to catch a power up at the same time.
Now the server has this stream of client state coming from each player and has to sync them and make a coherent game out of them. The trick is to measure each player's latency. The ultimate goal is to be able to fire a very low latency weapon (such as sniper rifle or railgun) on an enemy moving sideways and have it hit correctly. If the latency from each player is know, suppose player A (latency 50ms) fires a gun on B (latency 60ms). To make a hit, the shot has to hit B where B was 60ms ago, from where A was 50ms ago.
That's a very rough overview but should give you the general idea.
I suggest that you look into Quake 1-3 engines. They are available with source code. Half-life's protocol might be a bit different but most likely close enough.

Resources