News Feed

3d printing

So 3d printing has made me pretty lazy. I really hate milling aluminum when I can just 3d print. I have 3 printer right now. 2 FDM and 1 SLA. I never use the sla tbh.

I bought the ender 3 printer and upgraded them with new firmware, raspberry pi an auto level and a few 3d printed hardware pieces. The whole thing is tented to preserve heat. Works great and prints incredibly strong and accurate parts.

The featured image of this post is a perfect example. Something incredibly tie consuming to make and requiring several pieces of equipment can now be churned out in an hour as I read a book.

I’m glad I got some experience with other methods of fabrication because 3d printing is like heroin. Its really hard to stop and makes you really lazy. But its so useful. Check out the mini table saw jig I made to cut steel. Its powered by a little fishing weight.

 

Here are a few pics of my setup. The ender 3 is a great printer. Notice Im printing tough pla left and polymac pc on right. Both super durable.

Then I turn up the heat.

Here’s the SLA. Quality is great but the parts are fragile. Still I’m keeping it around I keep it enclosed in black and I have venting set up to keep my work space air clean at all times.

 

 

Computer Screens Cause Blindness

If you didn’t know count yourself lucky to find out now.I was dumbfounded and angry when I found out.

 I had unknowingly subjected myself to an experiment and lost some vision in my right eye as a result!

Below is my computer set up with two screens. After about a year of this my right eyes vision started to deteriorate. Dry eyes and pain still plague me to this day but I am recovering to some degree.

computer screen cause blindness

My front screen was opened to an IDE with a black background and my right screen was opened to a search engine with a white background.  In about a year of installing that second screen I started to notice my right eye was struggling to focus.

I though I was just getting old, working too hard, all kinds of excuses. But thankfully someone recommended me to get blue light glasses.

I purchased glasses on amazon to block out the damaging light and I wear them all the time now because my right eye remains sensitive and is prone to being strained. Check them out through the amazon link below as it helps my website out.

EVEN IF YOU DON’T WANT TO USE THIS LINK PLEASE GET A PAIR  NOW.

YOUR EYE ARE LITERALLY BEING DAMAGED AS YOU READ THIS AND ONCE YOU REALIZE HAVE DAMAGE ITS TOO LATE!

What would a blind person pay to have their vision restored?

The most embarrassing part was my brother had recommended them to me a few years earlier but I just didn’t even care at the time. Now I have to suffer, as even 1 year after starting to wear them I still have eye strain.

Your eye are damaged by certain types of light toward the colors blue. These radiate from all sorts of thing like light bulbs to computer screens.

Save your vision while you still can! I tell everyone I meet to get a pair of these. I preach it like a religion. Blue light glasses, 3d printing and java are my holy trinity.

Toyota Tundra Backup Camera

Vehicle back up cams are kind of a pain to install. this was no exception but the results are nice. I installed this in my 09 tundra. With this kit from amazon. Please use link as it help support my website.


Open and in reverse.

tundra backup cam

When its closed.

 

Backside

 

 

The kits only $25 so it not that bad. The hard part is figuring out the wiring.

 

 

 

 

 

Electronic Speed Controller

Every project I take on teaches me something new. Oddly enough its never humility.

My recent design of an electronic speed controller for a brush less motor was a long and winding road in understanding how a motor could be controlled.

The why is simple. If you want to build a robot there are zero…I mean Zero low cost and effective solutions for actuation. Take that servo and send it back to wherever the hell it came. Its weak and expensive. However there are, separately a large selection of very powerful and cost effective motors thanks to the quad copter market.

If you have ever noticed though these motors require an electronic speed controller (esc) and the esc does quad copter things. Like accelerate in a single direction. That’s pretty much it. So I set out to make this motor do exactly what I required from it. EVERYTHING.

I chose arduino nano simply because I do not want to buy a motor control chip and rely on sourcing parts. These arduinos are cheap and I buy them in bulk becuse everything I own has an arduino hot glued to it.

The code

The code is simple in concept. Allow power to flow in and out of stator at different wires at different times in order to attract the stator coils to the magnets in a coherent and useful way.

/*
* PIN Chart   PWR  GND   Comp/BEMF
 *  
 * Phase A      2    3      8     
 * Phase B      4    5      9
 * Phase C      6    7      10
 * 
 * Phase Cycle Chart
 * 
 * PWR GND BEMF     Step        Short-Step
 * A    C   B       11010000    11011100
 * B    C   A       11000100    11110100
 * B    A   C       01001100    01111100
 * C    A   B       00011100    11011100
 * C    B   A       00110100    11110100
 * A    B   C       01110000    01111100


*/


 

My arduino used 6 pins to control 3 high and 3 low side mosfets. As you can see I attempted to use back emf but this is no good for robots because the motors cant be guaranteed to be traveling fast enough. I ended up adding low active hall sensors which work great.

The codes broad strokes are as follows:

timer_1: This is used for timing steps. Each time its called a step counter is incremented. This allows precise step timing.

timer_2: This is used for pwm. It also actually checks if a step is due to be taken and performs the pin changes.

Besides these 2 function which are precisely timed everything else is in a loop and is done as needed as fast as it can. These other functions include reading serial comm, or the hall sensors. When data is read it pushed to a variable and the timer 1 or 2 sensor will notice affect the change when appropriate. Only a thousand lines of code but between debugging the board and my code it took me a while to build up to this.

 

Below you can see a preliminary test.

 

I’m still working on the code and probably will be for some time because I have included a strain gauge to help the motor determine when it should attempt to move a load or give up.

I’m also using the hall sensors as position encoders. They work great on their own and even better when you consider the gear ratio of 39 attached to the motor.

In the below video you can see the 3d printed support for the hall sensors is attached

 

The board

I feel more comfortable coding and board design sometimes is like black magic when my calculations don’t work out and I end up just guessing for a better result. The circuit isnt too crazy. Six mosfets 3 high and 3 low side allowing power in or out the 3 connections. The hall sensors are attached to 10k pull up resistors and leds for debugging.

 

Below is my end goal of building a cheap, powerful actuator for robotics. This video is my first test run of connecting a motor to a gearbox. It was exciting bu the motor could only move 1 lb at 10 inches. I have since moved 10lbs at 10 inches which is as far s I know makes it one of the strongest fastest and cheapest robotic actuators ever assembled. Cant wait to get this out to people!

Gear Design

 

1.  Types of gears

2. Gear arrangements

3. Considerations – Strength, speed,  friction/noise/vibration

4. Layout Calculations

5. Hypocycloid

6. Differential planet

1)  Types of gears

When looking at involute gears there are several categories of this type. Gear arrangements and types of gears are often used interchangeably but in my mind they are different. Lofting a gears dimensions to change the angle at which is attaches another gear does not make it inherently different to me .

Spur gears are easy and have the lowest tooth friction from rubbing friction.

Helical gears are stronger due to inclined teeth. Increased friction as teeth slide together but the transition is less dramatic and therefore smoother (noise, vibration)

Worm gears have the highest friction. Almost impossible to back drive. Properly designed can transmit high torque at significant reductions.

It’s fair to mention that each type of gear above can be designed simply or with great detail. A spur gear may be as simple as a wooden wheel nails in the radius. A worm gear may be a worm and helical meshed by single tooth or a throated worm gear. A helical can be mirrored into a herring bone. It goes on and on…

 

2.  Gears can be arranged a variety of ways. Not much to add except there are numerous other layouts and arrangements and gear shapes.  These layouts below are the most common. In each arrangement You will see variations in the cogs themselves that reflect the types listed previously.

Linear System

Compound

Bevel

 

Planetary

 

3. Design Considerations can become complicated quickly. Factors to consider are torque ratios, the speed at which the gears will operate, the loads they will encounter, the required lifespan, the noise or vibration created,  the types of metals and friction coefficients. I’m going to focus on planetary gears after observing someone else’s work designing gearboxes.

4. Layout calculations

If a gear system already exist its very easy to calculate the reduction ratio. For example  if two gears connect in linear and one has 25 teeth and the other 50 then its obvious that the small gear will need to turn 2 times to turn the big gear once.  Or observing a worm gear you will see that one turn of the worm will move the worm wheel 1 tooth forward.

When lay outing out gears on you cad software you need to be precise. Lets start easy and work towards the planetary gear system. Gears can be drawn as circles based on their pitch diameter. When two gears mesh and interact they both meet at their pitch Diameter. Below its the green circle between the smaller(root diameter) and the larger (outside diameter) in white.

gear layout In order to figure out a gear reduction we get the radius of the pitch diameters and divide.

x/1 = R1/R2

So a 100 mm pd (pitch diameter) circle and a 50mm pd would be

2/1 = 50/25

Now the next question is how to actually place them adjacent to each other. We simply add both radius up and place center points that distance away.

One last important number is module. Module = pitch diameter/ # of  teeth

There are other important names and references but they refer mostly to how the teeth interact. Briefly the most important 3 are…

Pressure angle = angle of top half of teeth

Clearance or backlash = extra spacing around teeth

Helix angle = helical gear cog/tooth angle

Based on the information above you could design a linear or compound system in cad fairly easily. But for a harder example let look at a planetary gear set. There is a lot to know about planetary gear sets but ill touch on the important starting points.

Planetary or epicyclic gears are similar to any linear gear arrangement except the are circular in arrangement. As seen below a center gear called a sun is surrounded by smaller gears called planets and then encased by a ring or annular gear.

These gears use the same spacing convention when designing in cad as linear gears. The use very similar reduction ratio math with two major differences.

First, the number of teeth on the planets is not used to calculate the reduction ratio. Add the sun gears number to the ring gears numbers to get conversion ratios.

Second, assume that 1 gear is drive gear, one gear is the load gear and one is fixed stationary.

So, imagine a gear as follows. Sun = 10 teeth, planets = 10 teeth(we will use 40), ring = 30 teeth. Using these number we make a fraction with the load gear as numerator and drive gear as denominator.

ratio = load/drive

Ring fixed and sun drive planets 40/10 = 4:1

planets fixed ring drives sun 10/30 = 1:3

The same math can be done using pitch diameter and circumference as shown in previous examples. Also consider if you could mechanically lock each of these gears or input/output force at will. You could get all sorts of interesting combinations on the fly similar to an automatic transmission.

There are other types of very interesting planetary gear systems.

 

Hypocycloid Gears

Here is an example gif that says it all.

Pitch diameter only plays a roll in the mechanical strength. Obviously there are ratios to maintain but to calculate reduction use this…

Ratio = (outter cogs/ cam cogs) – cam cogs

The example above has 11 outer cogs that look like white half circles and 10 inner cogs which are the yellow bumps. This gives a gear reduction of 10:1.  Green is the power and purple is the output. These can also be stacked very efficiently such as below to create a differential cycloid. You can see pitch diameter is less relevant as angular velocity is the deciding factor as opposed to tangential velocity. The example below is the single cam in a motor mounting gear reduction box that produces a parallel or co-linear output.

Calculating the difference in a differential hypocycloid is done as following.  I consider the bigger cam the drive side.

drive = d, load = l, ring = r, cam = c

so… drive cam = dc and load ring = lr

ratio = 1/( 1-(dr*lc/ dc*lc))

There are a few scripts and editors for different software to create these. I did mine in fusion 360.

 

Differential Planet

Here is a cool gear design I found on thingiverse. The creator uses two planetary gears stacked with separate rings and suns and connected by their planets only. Each stack is geared differently.

Planets #1    Sun = 10 planets = 10 and ring = 30

Planets #2     Sun = 18 planets = 16 and ring = 50

Below is a front view and it works like a normal planetary gear. As expected with previous formula 40/10 is 4 turns of the sun causes the rotation of the planets once. The interesting part is the backside.

The backside is geared different from the front and this gives the back ring and additional 25:1 reduction ratio.  On top of the 4:1 to one.

This is accomplished by creating a light difference between the front and back ring tooth count.  The tangential velocity of the front planets are a perfect match to the front ring. But because the back ring is slightly different in size and the planet gears must move with the front sun gear the back ring is forced to move slightly forward or backward. Much like a tire slipping on a wet surface.

To make this easier to imagine imagine just the back ring. If the planet gear were unable to rotate the exterior ring would rotate 1:1 with the planets. Juxtapose the planets could rotate at the exact speed needed to keep the outer ring from moving. Then when you alter that speed even slightly you end up with a very string very slow gear ratio.

I never found an documentation but I tried to define it mathematically.  All these refer to tooth but could probably be done with pitch diameter too.

D = drive ring, L = Load ring, S = Sun, P = Planet, R = annular ring,

LR/((LR/LP – DR/DP) * LP)/ ((DS+DR)/FS)

There may be an issue with this formula as it does no always match the reported gear ration of the device I’m measuring. Sorry for math styling, I do computer stuff so that’s how it should look to me!

Lastly there is also harmonic gear types. I did not do much research into these as the solutions above were suitable for my current needs. At this point the project I’m working on seems to moving forward but I would very much enjoy coming back to some of these gears designs and exploring more.

The Struggle of Custom Parts

Custom parts are hard to come by. Off the shelf parts are literally forming a trash island in the ocean. This is my dive into making custom parts. I could have gone at it a few different ways but my limitations are as follows.

Time – I don’t want to spend 10 hours milling a part

Money –  I don’t wan’t to buy a bunch of new machines

Space – My workshop is packed.  A lathe really wont fit…and I want one really really bad!

 

My solution is to use my cnc to make mold which I can then fill with aluminum. My goal is to create a worm drive.

In my mind I have defined 3 basic levels of tolerance for parts.

  1. Low tolerance – Toys, piston engine or machine exterior, frame/structural
  2. Medium tolerance – Low rpm gearboxes, actuators, machine interior
  3. High Tolerance – Internals of engine, high rpm gearbox

This worm drive is medium tolerance.

My first attempt started innocently enough with some foam purchased as the hardware store. Its housing insulation and its only $5 a sheet. Its reasonably dense and can be machined very very quickly. Here I am making half of a worm.

My original thought was to make a plaster mold of this foam cut out. But in reality the foam didn’t machine that cleanly. I tried to make a plaster mold of the screw by simply cutting the half’s out and placing them into plaster molds. Here is a mold I made and in this picture its doesn’t look half bad. But it looked terrible up close and because I cut the foam pieces out the precision was lost and it was lop sided. Second the plaster adhered to the foam because the foam had a rough surface after milling. Finally I was using paraffin wax which didn’t separate easily from the foam mold.

Below you can see the pieces I am working with. Not terrible but not great. I may still experiment with this foam and plaster because it would be a cheap and easy method if I could get it working.

I abandon the wax model I created and instead of a plaster mold I tried doing a “sand casting” with delft clay. This was the first time I have ever poured aluminum in my life. Fun, but I knew right away that  I could make it better. Obviously my pours and molds would get better over time.

Here you can see the result. I don’t think this is half bad for a first pour.

Here is my oven that I made. It gets pretty Hot.

 

Conclusions on first attempts. Sand casting can make type 1 low tolerance items. If I practice more I’m sure I can make items that will need further machining to finish them or parts that will not have any significant mechanical interaction. I’ve even seen lost foam pours into buckets of playground sand on you tube that looked very decent. For low precision work lost foam or wax molds from plaster can make decent items quickly and cheaply.

Moving On…

Now I was getting upset and worried I would not be able to make the parts I wanted. I knew I needed to exert pressure on the aluminum so I finally stumbled upon vacuum casting.

My previous mistakes and experience helped me tremendously. Instead of foam I ordered some machinable wax. I was recommended tooling board but tooling board is kind of a pain to come by and use.

Below I’m machining each half of the worm just as I did in foam except I’m using a tool change to speed it up and I also widened the cavity and added some reference keys so the negative if these would mate.

See the bumps and reverse female sections. Not sure what that big line was about! I used a flat 1mm end mill and the result is very rough. But I will continue with this as the machining lines will make great reference details to compare to my final pour.

Next I poured a two part silicon into each cavity. This is a A45 silicon so its harder and less flexible version than most you will run across prima facie. I could probably stand to increase that number a bit as well.

Here is my setup. I mixed the silicone on my lab scale. I built the vacuum chamber to degass my materials. After mixing I put the red cup in and degassed till the bubbles were evacuated. Then I poured them into the wax molds. Then, once again I degassed silicone in the mold and locked the chamber for maybe 10 minutes before bringing back to normal pressure.

This process resulted in a very successful silicon mold. Every detail was captured perfectly. Hooray!

Next I injected a jewelers wax into the mold. Once again I met a reasonable amount of success.  I could find no difference between the initial machinable wax and this with the naked eye.

After that I forgot to take a few pictures.  But basically I put this wax into a mold with a refractory plaster including degassing it twice. After loosing the wax and curing the mold I poured molten aluminum into the mold and quickly switched on the vacuum.

Here is the result. As you can see the machining marks are identical in both the machinable wax and the aluminum casting. I haven’t done any measurements to compare sizes but I see no reason the size of the final product won’t be 100% predictable and within tolerance of a machined product.

I’m not 100% there yet but you can see after 3 pours things are moving in the right direction.  Problems to still overcome are as follows

  1. Get machinable wax milled perfect texture (or lack of)
  2. Increase silicone mold side wall thickness and reference points
  3.  Glue my sprue on better. I made a mess at connection!
  4.  Minor bubbles were in refractory and show on aluminum
  5. Polish aluminum in vibrator
  6. Determine size variation formula between 3D model and final product

Based on today’s pour I think it will be possible to pour metals the engage in moderate mechanical action.

 

 

 

 

System -> model -> model -> System

What is the difference between working hard and working smart? I attempt to define that here. A very long time ago I read a Richard Maybury book and it touched on how the brain is attempting to model how the world around it works.

Being a curious person and always trying to sharpen my understanding I easily agreed with that. I built my strategy for accomplishing goals around this simple belief. The title of this post is a strategy I believe in, which is essentially common sense to me now. It goes as follows.

  1. There is an existing system I do not understand. It is abstract.
  2. I create a model based on my interactions. A model is a bunch of beliefs about that system.
  3. I create a model for how to best interact with that system. Synonym is strategy.
  4. I create my own system which will apply my desired model. Think routine, or long term planning.

For example consider fitness. The human body is the system. Too complex for me to fully understand with current research. In my mind I build an approximation of that system on belief at a time to create a model. For example that model says that I need food as sustenance and sleep to rework neurotransmitters and hormones. These are just a few of the many beliefs I have that make up the entire model.

Now lets say for example I want to get in shape. Based on my model of how the body works I need to create a model of interaction that will get me what I want. So for example I need to eat healthy or I need to perform physical training 3x a week. Well knowing what to do is great but doing it is another thing. Now I need to create a system that will enforce that model. So I start a workout journal, and begin packing healthier lunches or researching healthier restaurants, maybe I set a workout alarm or get some workout equipment.

Its easy to just overlook these things and say they are all kind of similar. But that would not be true. If you are attacking an enemy base you know there are soldiers inside(system). But knowing that the west wall is least guarded(model) gives you a strategy to attack there(model). However you failed to apply a way for recruiting and training soldiers(system) so your attack is rebuffed.

Imagine you have a well trained army but you attack at the south wall because you didn’t know about the west wall and still get your butt kicked. Really most people if not all people can take the model of the west wall being the weakest and create a model that focuses an attack there. The hard part is building the model of the foreign system and building your own system to properly utilize the information you have. Those take planning, patience and creativity.

Milling a PCB

In order to better speed up my prototyping and in consideration of possibly small scale manufacturing I have begun milling my circuit board designs.

This picture should give you a clear idea why this is so important. This is how myself, and many others, make circuit boards at home. By wrapping wire around the back and soldering in place. Its tedious and error prone.

I haven’t mastered it yet by any means but I can tell you about my journey and give you some tips. I’m using a self made CNC machine. Everything I used is off the shelf.

Design

I used Eagle to make the design. Its a popular software and free to use for non commercial. There’s so much to say on the subject of design and using the eagle software. Kicad is another. Not super easy to use and it gets a bit tougher if you want to export to a machine for production. After you make you schematic you click generate your board.

  1. You need to set the net thickness and spacing sizes based on your machine, bits, and personal skill.  I chose 30 mil size and 40 mil space.
  2. The measurements are not millimeters but thousands of an inch. Leave it that way and convert. Otherwise you’ll be fighting the software.
  3. Your origin is at the bottom left. After making you design you need to drag the entire thing to center it over your origin if you want to start your machine off in the center.

There’s a lot more to be said but I suggest you watch some tutorial or do research as needed. Use the cam processor and create your gerber files excellon file for next step

 

Creating G-Code to execute

A free software called flatcam can be used to transform the gerber files and excellon drill files into gcode. For simplicity same I made my project by using only two files the bottom.gerber and the drill.xls

Flatcam creates a tool path to isolate your circuits by using the layout and your input. A few key things.

  1. Your tool size must be smaller than the net spacing you entered in eagle. Otherwise it wont try and cam that area and you will have gaps. I chose .039 as my tool size which is a hair smaller than the 40 mil I put in eagle and is about 1mm for my sanity.
  2. I chose .5 for z travel because I have a floating Z I need .25 inches to lift the float and .25 for clearance. You will see more on floating below.
  3. Speed I use 3.5 and its running beautifully. The project you see above is milled in about 10 minutes.
  4. Flatcam cannot interpret drill files correctly. I’m still not sure why but two things I needed to do. When I imported my drill files they were miles away and huge. First type these two commands into the command line “get_sys excellon_zeros” and “set_sys excellon_zeros T”. Second open the drill file and set each hole size to .050 manually.

The floating Z

When you first try milling a pcb you will find that even the slightest unevenness between your board and the bit will result in all kinds of issues. There are two ways to solve this problem. The first is using a probe to electronically measure and calibrate for this issue over the entire board. The second is to just make the axis spring loaded and let it slide over the board and roll with the waves.

In the video I explain it and give you a good look. Those are just 6mm slide rails and a pack of miscellaneous springs. I now use a makita router due to runout issues from the cheaper router I had in this video.

Here is a video of it running.

I tried small drill bits without success and ended up using engraving bits. I had some really rough experiments where I was snapping bits left and right and making ugly cuts. Eventually I got my machine and software tuned.

Before floating… so much uglyness. Bottom right has tearing. The main line just lifts away
gross!
much better
didn’t have my origin set right
Great!

Finishing them up

Because I use the floating z and an enraging bit I would need to change my set up to drill them out. So for now my engraving bit marks the drill holes just a bit and I drill out the marking on my drill press. One drilled I lightly sand with 1000 grit, then use a steel brush then a nylon brush.

After I use compressed air to blow any dust off and check to make sure there the traces work with my multi meter by doing an audible continuity test.

After my designing and experimenting I can now take a circuit like this from a solder-less bread board to a finished project in about 2-4 hours.

 

Considerations on building a robot

Why…

One of my childhood interests has always been robotics. I think most people have at least somewhat of a fascination with robots when they are young. Over the last several years when I was working I began to realize that robots in construction are really underdeveloped.

The reason I believe this is because I spent a lot of time learning and teaching construction skills. I realized during that time that robots in construction are imminent and could have been introduced already.

My goal is to experiment and build a robotics platform that can accomplish some of those construction task and hopefully more.

Philosophy…

Frequently in construction a skilled tradesman learns a variety of skills necessary to accomplish a task. In many situations the task can be broken down into several parts and an several unskilled people can perform the task in assembly line fashion even faster. The biggest limiting factor in this situation is keeping them mobilized because work gets done fast, and bodies have to be moved and the set up at each location. You also need expert intervention 5% of the time.

Goals…

Here are some of my goals for a robot design that would make robotics go mainstream.

  1. The indifference to going mainstream( no hype benefit is obvious)
  2. Low production cost (self replication)
  3. modular hardware and software (easy to repair/upgrade, group learning, remote upgrades)
  4. Wide functionality ( building, cleaning, cooking, driving)
  5.  Remote intervention (1 person supervising 20 robots at remote location)

 

Final Thoughts…

Any one who knows me knows I’m trying to exit the economy. As a thought experiment imagine a square cube 18″ in size that glows with a soft white light. This box, by voice command, floats through the air absorbing zero point energy and can create any object imaginable. How would the world be different?  Self replicating robots have the power to make most people irrelevant or give them new purpose. The power to destroy conventional currency, which buys human labor, and replace it with a guaranteed deflationary electronic currency or simply replace currency with code. Robots will be necessary to build spacecraft as well or maybe fight a war. A war which  might be created because of the excess they themselves produce.

I wonder if the immediate downside is that it will increase production to such a large degree that our current culture of greed and conspicuous consumption in some countries and overpopulation in others may spiral out of control. There may also be a dramatic shift between people who understand how to manipulate the robots and the people who do not. Hopefully the smart and hardworking people can use the production increase to escape the current system and build something better.

 

Android data analysis and error handling

The featured picture for this post is actually a cnc project where my end mill broke moments before completing. But if you’re an android developer you probably have had the little gear icon in your email inbox or more recently emails from fabric.

Scroll down to the bold title to skip my rambling musings.

These are amazing tools but I ran into a problem that I couldn’t handle with these tools. I was creating a new revised method/function within my app that generates a string for the user to read.  I wanted the new method to produce the exact same result as the old method when handling old type situations, plus it needed to handle some new situations as well. After building it and debugging I found that it produced the exact same string 99.996% of the time. This variation appears to unavoidable. Even better I can use the old method 99% of the time thus making the chances that the user encounter this error non-existent.

Not foolish enough to make assumptions I deployed my new method invisible to the user and using fabric waited for my “events” to register showing a similar match rate. Once I had confidence that th match rate matched my testing I would make the switch visible to the user.

Much to my surprise the match rate was way lower. .. around 50%. I went through and made sure that everything was right. I then added a custom attribute to show me both strings. This is where my problem arose. Fabric truncates strings and custom attributes from the same event are split up in the online review area. The data was almost useless.

—  So I decided to make my own poor mans version. Here’s  how i did it. —

On the android side I used the Volley Network. Once imported I made the standard volley pattern which can be accessed statically. Volley is awesome.


public class VolleyNetwork {

    private static VolleyNetwork mInstance;
    private RequestQueue mRequestQueue;
    private static Context context;


    private VolleyNetwork(Context contex)
    {
        context = contex;
        mRequestQueue = getRequestQueue();


    }


    public static synchronized VolleyNetwork getmInstance(Context context){
        if (mInstance == null){
            mInstance = new VolleyNetwork(context);
        }
        return mInstance;

    }



    public RequestQueue getRequestQueue() {
        if (mRequestQueue == null){

            mRequestQueue = Volley.newRequestQueue(context.getApplicationContext());
        }
        return mRequestQueue;
    }

    public <T> void addToRequestQue(Request<T> req)
    {
        req.setShouldCache(false);
        getRequestQueue().add(req);
    }





}

I was already using the volley class above to make reports to my server. Now I added a new class for my “home brewed version of fabric”.  As you can see this static method report_Mismatch() has all the data needed to use volley and make a report to your server. I’m using a simple password because the worst a hacker could do with this info is post irrelevant strings to the server .txt file.  The “key1” attribute is how my server knows what type of data is coming in. Is it a custom error report? Or is this for some other process completely.


public class Reporting {


    private final static String TAG = "Reporting";
    public static String MY_PREF = "com.yourname.yourapp";

    final public static  String SERVERADD = "http://yourserver.com/server/";
    final static private String typeOne = "passwordp1";


    //report clock in/out status by updating my row - no feedback
    public static void report_MisMatch(final Context context, final String myReportData )
    {
        Log.d(TAG, "report_MistMatch: ");
        final String mTag = "report_MisMatch";  //if frequently use volley network to post different things the origination of the response needs to be tracked


        StringRequest postRequest = new StringRequest(Request.Method.POST, SERVERADD,  new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                Log.d(TAG, mTag + "onResponse: " + response);
               
                Log.d(TAG, "onResponse: sent");

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                                
                Log.d(TAG, "onErrorResponse: error");
            }
        })

        {
            @Override
            protected Map<String, String> getParams()
            {
                Map<String, String>  params = new HashMap<String, String>();
                params.put("key1", "somedata");
                params.put("report", myReportData);
                params.put("gentypeone", getLoginCredentials(context));


                return params;
            }
        };



        VolleyNetwork.getmInstance(context).addToRequestQue(postRequest);

    }


    //These will be retreived for all functions
    private static String getLoginCredentials(Context context)
    {
        String[] data = new String[4];

        SharedPreferences myPref = context.getSharedPreferences(MY_PREF, Activity.MODE_PRIVATE);

        return new String(typeOne + "randomly_generated_passkey");


    }



}

On the server side my code was already written due to other server feature. Its php because for literally no money you can setup a server/web address to provide back end app support. These type of low cost servers usually always have php/mysql. Im thinking of transitioning to digital ocean but it seems like a lot of work and I’m lazy.