Jar of Sparkly Things is now on Google Play! It’s just a fun simulator toy you can break out when your in one of those boring places and need a casual, yet colorful way to pass the time. Available on all devices running Android 4.1 and up.

This is basically my kind of “Hello World” for HTML5/Javascript. Super difficult to figure out where to start, but got it going after a couple nights of programming. It looks almost identical to the android version I made, I just haven’t added any other functions to it. There are some scrolling and resizing issues where the mouse is concerned. Not sure why that has become the difficult part.

]]>

Download Jar of Sparkly Things 0.9 – Android APK

Here it is which some major updates. A new menu system, new color choices, and new movements. The options now persist from when you close the app to when you open it again. The option to invert the accelerometer’s output is also now available. It’s version 0.9 because there are just a couple more things that need polishing. Enjoy!

]]>

So the Jar of Sparkly things has been updated to include color changing, a couple of different fields, and different ways for the particles to move. The latest is that not only is this a runnable jar file, but I also created an Android App. It’s not quite the same due to my device not being able to handle a simple triple nested for loop (it took eight minutes to run through one frame of this on my Galaxy S5!). But here it is in action!

If you compare the way they look, you’ll notice that the dots in the android version are drawn using a bunch of circles that fade out from white, to their color, then to black. Here is a screen shot of the the same particles, but drawn on the field in the runnable jar:

Being able to plot the field around the dot instead of drawing the dot gives a very nice glowing effect. It is pretty hard on the computer though. With 1/4 resolution my computer runs this at 20 frames per second. The problem is in the triple nested loop. If you read the earlier post about the math involved in calculating an Electric Field, you’ll know that the field is calculated by running every pixel against every point. So at 320 x 180 pixels, and 20 points, there are 1.1 million calculations going on per frame. That’s pretty far out, and I’m guessing that is just to much to run on an Android device.

What was done in the android device was just drawing 20 circles that fade out from the point, and the colors are added together on the canvas. This drastically cuts down on the number of calculations. This makes the number of calculations 50 dots x 20 radius,which is only 1,000 calculations (relatively speaking). So it runs much smoother and can handle much more particles. However if there is a way any one knows about that can allow me to do something like what was done in the PC version, please let me know.

OH! and don’t forget to download them both right here:

]]>I took the e field simulator, and decided to turn it into a toy of sorts. These programs use the same type of math used (only much nicer on the hardware by using integers everywhere possible.) and basically map out the field around a point. Since it looks so cool I decided to make the points interact with the mouse and have different properties. In these examples, the dots accelerate towards the mouse pointer when clicked, and have a pulsing charge on them. The fire flies just float around, bumping off the walls, while the sparks fall to the ground like gravity is pulling them down. Let me know what you think! ]]>

Getting pretty handy with my vector algebra, so as I was doing some homework for my Engineering Analysis class(EE310 for those NMSU folks), I decided to write a program that would let me map out some of the problems. This one deals with electrostatics and point charges. Basically given some points with charges, what is the E field direction for one given point, and the force exerted on it given it’s and the other’s charge.

“Hey! That’s not programming!”, one might say, and one is right. We have here some bonafide mathematics. Not to worry though, it can be turned into a program. However, to use this, you need to have some kind of particle system set up. I came up with a class called TheDot() that I could turn into an array. TheDot() contains variables for what are needed; x, y, x velocity, y velocity, mass, radius, charge… This gave me an array points I can access and update in a game loop. I’m using Java for this so it was a class. if you are using some other language you can create what is needed maybe a 2 dimension array of points, or an array of custom types maybe. You can also render them how you like. I used a JFrame and Graphics2D to draw evreything.

We have points in space (x, y), and they have charges, now it’s time to make the line of code that uses those points. The math above describes the E field and Force field based off of how close the particles are to each other and their individual charges. You can tell by how many R’s (distances) and Q’s (charges) there are in the formulas. There is a K as well which should defined as 9*10^-9. It’s just the permittivity of free space, and it stays constant in this example.

“Ok, what about the scary E thing there?”, that right there is a summation, and it is only fancy talk for a ‘for loop’. You know the one:

for(int i = 1; i < n; i++){ //do something 1 to n times }

They even have the same variables. It just says do the thing on the right 1 to n times and add all the results together (get it? ‘summation’). Every time you do the math on the right you increase ‘i’ by 1 until it reaches n, and you have your answer. You’ll also notice the i subscript on the Q on the right side of the summation. This increases with each time you calculate the right side. So basically what you get is:

Now we aren’t going to write out every summation of every dot on the screen, this is a ‘for loop’ remember. But we still have one more thing… The Vector R. Right now we have described enough to get all of the charges added up… if they were on top of each other. We need their distances and this is where the vector algebra comes in. It’s not complicated though. To find the distance between two points, we subtract one point from the other. So since we are in (x,y), we have two distances, so we do x2 – x1 and y2 – y1, and this gives a vector R that has the distance from one point to the other in x and y coordinates. To get the actual distance, you use Pythagorean Theorem on that new vector R and you get:

So what this whole thing ends up with is a new (x,y) vector in the direction from a point to another, multiplied by the other’s charge and divided by the distance cubed. It’s probably best to have a couple of functions that do some of the work, and come together. Like one for the distance, and one for finding the new vector. So let’s have 3 functions, one that updates the loop (in my case was part of TheDot() class), a function to get the new vector, and a function to get the distance from the new vector.

public void update(int point2update, int n){ double Ex = 0; double Ey = 0; double K = 9*10^9; double newVectorX = 0; double newVectorY = 0; for(int i = 0; i < n; i++){ newVectorX = vector(point[i].x, point[point2update].x); newVectorY = vector(point[i].y, point[point2update].y); // heres the important part! Ex = k*point[i].charge*newVectorX/Math.pow(Magnitude(newVectorX, newVectorY), 3) Ey = k*point[i].charge*newVectorY/Math.pow(Magnitude(newVectorX, newVectorY), 3) } } private double vector(double x2, double x1){ return x2 - x1; } private double Magnitude(double x, double y){ return Math.sqrt(Math.pow(x, 2)+Math.pow(y, 2)); }

This bit of code though won’t exactly do anything to the particles. This only gives the E field. The next thing to do it multiply the E vector by the points charge, and you get your force in the x and y directions. You can take this force and get your acceleration from the mass, and then velocity from that acceleration. This would give the x and y coordinates in the direction of the E field given the force. The stuff moves around like there is gravity (which is almost the same!), however, with just this, the points can overlap, which creates an infinite force, and things go really crazy. So from here you just have to implement a collision system and, Bam! A nice little particle system based on the Forces from the E-field generated by the points in the system

Check out two of the examples I made, which model the problem 4.2 and 4.3 from the book Elements of Electrostatics by Matthew N. O. Sadiku:

I wanted to publish this somewhere so that maybe I could remember better if I showed others. Hope you enjoyed this bit of writing and hopefully this might help you with your homework. Thanks for reading!

]]>

This is the placement for the sensors in the alternator. It’s a little crude, and not exact, but you get the idea. Each sensor is off center from the coil it controls.

Here is a photo of the package I made that fits inside the alternator. The electrical tape is just for electrical insulation, the whole thing is held in place by Gorilla super glue. Below the electrical tape you can see the sensors poking out towards the core, and how they line right up with every other slot on the iron core.

]]>So I decided to build a more traditional style quadcopter with a CC3D flight controller as oppsosed to my arduino quad. This is the entire build from start to finish, which took me about 3 hours to complete. This is a very simple craft to put together when you use these electronics. This was my first traditional build and I was able to do it in one shot. Testing and tuning however was a totally different story, that took a few days and flights. Any questions or suggestions just let me know, and don’t forget to subscribe on Youtube and Facebook!

]]>

It’s been an interesting run with this alternator business, and it’s actually just starting a whole other side of experiments. Adding in bridge rectifiers allows me to check out the high voltage spikes that come out as back EMF. Hopefully soon I will be able to check this out on a oscilloscope in order to really see what is going on. Until then here is an updated schematic! Enjoy!

]]>