Wednesday, March 13, 2019

Minimal 3-Axis Magnetometer Rapid Prototype




This project started when a friend asked me to develop a method to measure the strength of a low-level magnetic field for a fixture in one stage of the playing field for a robotics competition. This was a college level event with teams from around the globe. The system used a low-level magnetic field so detecting the field was more challenging than simply using a reed-switch or hall effect sensor.


The design target for the magnetic field stage of the event was 1000 microtesla. To ensure fair competition, the event manager needed a way to verify all of the boards produced a field meeting or exceeding 1000 microtesla. I suggested a potential sensor, the Melexis MLX90393 Triaxis Magnetometer for calibrating the fields and was quickly asked if I could put something together. That is the ever present danger of tossing out an idea in a meeting, "That sounds great! Why don't you make that happen!".

It sound like a great opportunity to quickly assemble a minimal viable product (MVP) and share some rapid prototyping tips. Here is how I built the magnetometer used to validate the magnetic field generators for the IEEE Southeastcon 2017 Hardware Competition

One of the robot challenges required performing an action only when a magnetic field was present (there was a Star Wars theme for this stage so detecting the field was referred to as sensing "The Force"). The goal was for the robot to detect the field and mechanically tap the target to score and turn off the magnetic field. After a random time delay the field turns back on and the process repeats until the end of that timed stage. Tapping the target when the field was off would award negative points. The video below shows The University of Alabama on this stage. You can watch the whole video to see all of the event's stages.

"Sense the Force" Stage from The University of Alabama

There were many innovated robots on display at the event. Here are more videos from this and other IEEE Southeastcon events.

The MLX90393 was available from Sparkfun as a SparkX product (SparkX devices are early development boards made available to adventurous customers for early testing). Note that this breakout board is now availability as a regular Sparkfun product with the modular Qwiic connectors. Sparkfun also offers a full hookup guide to get you started with your own project.


I purchased a couple of SparkX boards, combined them with a Sparkfun Arduino Pro Mini and a Sparkfun Basic Serial board along with an OLED display on a bread board and got started. Below you can see all of the elements on a breadboard on my workbench.




I began with an example sketch, modified it to send the the data to the OLED, added a little text formatting for the display and the programming was done! Here is a link to the code that was hacked together from several sources.

https://github.com/sdtrent/Minimal-Magnetometer

Next up, the breadboard was fine for my workbench, but how should I package the magnetometer for travel and use on the floor at the actual IEEE event? This was a fast and dirty project so I did not want to design a case. I wanted something that was just good enough to meet my minimal requirements. A quick glance around my workbench provided the answer! At arm's reach was a Sparkfun box that fit the bill nicely!

It was quickly re-purposed to hold the sensor, display and power switch. It took only a few minutes to make holes in the box for each of those. By carefully cutting the holes as slits and keeping the fit tight, the flex and friction of the box held everything in place. I did cover the actual sensor with a layer of clear packing tape to provide some insulation since we were going to be placing the sensor up against the the metal head of the bolt used for the core of the electromagnet. The clear tape also made it easy to see the sensor to help ensure we were putting it directly over the head of the bolt.



The 18650 Lithium Ion battery is massively over spec for the use-case, but I had the battery and holders on hand so in they went! The breadboard and battery holder were attached with Velcro dots.


The device worked great in the field. We even caught when a few of the boards were wired (or wound) with the opposite magnetic polarity. Those boards were quickly rewired to ensure a level playing field for all of the teams.

I was impressed with the performance of the Melexis MLX90393. It could easily measure the change in magnetic field when a neodymium magnet is rotated 15 cm from the sensor.

This is one example of how you can quickly assemble a proof-of-concept prototype to test an idea or even provide a Minimum Viable Product for initial field testing. I hope this helps you with your prototyping!

Saturday, January 19, 2019

Building a Lightweight Folding LEGO Sumo Bot Practice Board

Here is an easy to build, lightweight, folding LEGO Sumo Bot practice board. Note that this board is NOT suitable for competition because it does not meet the requirements for the board dimension in the rules and does not provide a drop from the edge of the board to the floor as seen in competition. However, it is super light, easy to carry in one arm and can fit in any car. It provides a great platform for testing your robot programming and sensors in preparation for a Sumo bot event.

Our first effort at testing a Sumo Bot was actually putting black electrical tape on a table for the robot to detect and stop and then turn around. We figured we could change the Light Sensor thresholds from Black to White before the competition. We quickly learned to be ready to catch the robot when it ran off the table! That got old quickly so we wanted a better solution. So we came up with a folding practice board described here.

Folding Sumo Bot Practice Board



The board is made by simply using white tape to add a border to a black tri-fold poster board (I like foam-core if you can find it) and drawing starting boxes with a marker. I used 2" white masking tape on a foam core 36" x 48" tri-fold. The boxes were drawn with a gold Sharpie marker. We tried a silver Sharpie but it triggered our robot's light sensor, causing problems when traversing the board.

The size and location of the starting boxes are the only items here that follow the official rules. But these are the most important requirements because they accurately define the only time in the match that you will know the location of both your robot and your opponent's robot.

The dimensions and placement of the boxes came from the Watauga Rules linked below. We actually cut a cardboard square the size the starting box and centered it on the center panel. Using the orientation of the image above, we traced just the top and bottom sides of the cardboard square which will be the bottom of the top box and the top of the bottom box respectively. This step ensures the starting boxes are the correct distance apart. Then we added the other three sides of each square to produce what you see above.

The placement of the tape is not that critical. We start with a strip at the top and bottom of the center section, stopping at the fold line. Then we added the four angled pieces before finally added the lines on the left and right ends to finish up the frame. While it is not a circle, it still provides an effective test platform for the robot.

Sumo Bot Events

LEGO Sumo Bot events offer competitors a chance to design, build and program a LEGO MINDSTORMS robot to compete head to head with another robot. I have coached in FIRST LEGO League for several years and my students have enjoyed participating in Sumo Bot (and LEGO Line Follower) events. The single day events do not require the extended effort needed to compete in FLL and let the students enjoy the head-to-head competition. It is also nice for the students to have a simple goal that allows them to quickly test different mechanical designs and programming strategies.

The events we attend follows the Watauga Sumo Bot rules as shared by Dr. Eric Marland at Appalachian State University in Boone, North Carolina. The link below has information for their Sumo Bot program. Other events may follow different rules but most are similar. 

Here is a link for the Watauga LEGO Sumo Bot Rules for 2019 (unchanged from 2018).

Note that many events also offer an "Open Category" that allows robots with non-LEGO components. I expect this practice board would be helpful for them as well. 

Sumo Bot has a simple premise, after a 5 second delayed start, your robot leaves the 10" starting square and then works to push the other robot out of the Sumo Bot ring without your robot leaving first. The action is made more interested because the ring is generally elevated slightly from the floor and a robot is officially out of the ring when any part of the robot touches the floor. This includes parts that fall off of your robot (if a piece touches the floor, you are out). 

Note there are some great instructions online for building a real Sumo bot ring, the kind you will need if you are going to host an actual LEGO Sumo Bot event (in fact you will probably need at least two or three boards to keep an event moving). But official boards require materials, tools and time to build them. In addition the boards are very large (77 cm across) and heavy, making it a hassle to move them from room to room let alone try to transport them.

Practice Board in the Pits

We take our practice board to the pits at events for use if the students need to test tweaks to the software or verify calibration of the light sensors. It also provides a great platform for demonstrating the robot's behavior or even doing some friendly scrimmages before the event starts. Most events include practice rounds but you must sign up for specific time slots. 




Each spring, Triangle Math & Science Academy holds both a LEGO Sumo Bot and LEGO Line Follower event. I recommend these for students who want to improve their LEGO MINDSTORMS building and programming skills.

Both events are fun and each offer k-5th and k-8th brackets and each bracket has it's own competition ring (or line following field for the Line Follower). Typically they matches in both brackets at the same time. Below you can see one of our team members setting up for a run. Notice how the official Sumo Bot board is larger and is elevated from the floor. 



I hope this information helps you build a great practice board and get a chance to participate LEGO Sumo Bot event!

Thursday, October 25, 2018

Roasting Coffee with a Hot Air Poppcorn Popper

There are many methods of roasting your own coffee. In fact,  roasting your own coffee on an as needed basis using a stove, oven or fire to was common until relatively recently. I have used several machines for roasting coffee at home. Today one of the fastest and easiest methods of roasting coffee is using a hot-air popcorn popper and the method I use most often myself (although I have purchased two dedicated roasting appliance over the years). Here I will share some details about the roasting set up that evolved over almost 16 years of recreational coffee roasting.


The Beans

Today's roast is Timor Leste Lacao Village from Sweet Maria's. They are my favorite supplier of green coffee and a great source of information about roasting and the history of coffee.
https://legacy.sweetmarias.com/library/how-to-roast-your-own-coffee/




The Roaster

My current roaster of choice is a donated vintage popcorn popper that has worked well for several years. Often poppers are available in thrift shops. If you ask friends and family I expect you will find someone who is happy to give you one that has been setting unused in the cabinet for years.


I have had the power switch fail on a couple of poppers over the years. Now I connect the popper and cooling fan to a switched power strip so I can turn them both off and on at the same time. In addition to eliminating the popper switch as a failure point, it also save the hassle of wrestling the popper looking for the switch. One detail I like about this popper is the open topped discharge shoot that works well with the vent used in my setup.


Roasting coffee produces chaff (piece of the parchment like wrapper that comes loose from the bean during roasting) and smoke and keeping both of these under control makes roasting much more pleasant. My approach is to keep the popper a box with a top mounted vent connected to a bilge blower that exhausts through a insulated panel installed in a window in my garage.


Power for the bilge blower comes from a adjustable power supply on my workbench. By turning down the power to the blower and slightly closing the flaps on the box, I can improve how quickly the roaster warms up during cold weather. It is no fun waiting for a slow roast to finish in an unheated garage.



Automated Control Options

Without hacking into the electronics of the popper, this setup still offers two clear options for automated control. The first option is to use a hobby RC servo to control a vent (flap or sliding window) on the side of the box. The idea is to close the vent until and operate the roaster in the seald box until the interior temperature of the box reaches a specific threshold (100 F?) to get the roast started quickly, even in cold weather.

The second option would be to add PWM control of the blower to run at be off or run at low speed until the temperature reaches a desired threshold. Again to help the roast comes up temperature quickly in even the coldest temperatures while still ensuring the the fan is on to vent smoke and chaff outside once the roast gets going. 


Roasting Technique

I start the popper and pour green beans into the chamber until the beans just stop swirling (maybe just a little extra). I will then give the roaster a few shakes (it might take a minute) until the beans are swirling on their own. The goal is to use as much coffee as the popper can circulate.

The bean will go through many stages during the roast. Where you stop the roast depends on the type of bean and the degree of roast that you want. The article below outlines the differences between the stages of roast.
https://legacy.sweetmarias.com/library/using-sight-to-determine-degree-of-roast

As the beans warm the coffee beans will begin to change color and the start losing some of the their chaff. As the beans begin to roast you will hear a popping sound, the first crack, and the chaff will come off of the beans very quickly. I like to stop the roast when the first crack has just finished. This is generally described as a City Roast. For this batch I stopped the roast at a little under 6 minutes.

I feel most coffee reach their peak of flavor between the end of the first crack and the very start of the second crack. If you want to roast past City Roast the quickness of your cooling method becomes more critical as the roast begins to be exothermic and can coast for some time after being removed from the heat. If your cooling is too slow it is very easy to overshoot and get a darker roast than you intended.


Cooling the Roasted Coffee

I cool the roasted coffee by dumping into a wire mesh colander setting on a fan aimed straight up. I found that cooling time can be shorted by bending a dome into the bottom of the colander and using a little painter's tape to direct the airflow inward. With this set up the beans are cool to the touch in less than two minutes.



The dome keeps the beans away from the center of the fan that has low airflow. Before the dome, I had to shake the beans around to ensure even cooling. 



This batch yield 116 grams, or just over 4 ounces, of roasted coffee. The beans get lighter as they lose moisture and volatiles during roasting so this probably started out as close to 5 ounces of green coffee.



I usually do at least two batches of whatever I am roasting. This usually means two batches of caffeinated and two batches of decaf. This is just the right amount to fill the jars that I like. Coffee brewed with beans fresh from roasting tastes great to me but many types of bean will improve in flavor with a rest of 6 to 48 hours.


If you would like to try roasting yourself, I recommend starting with a hot-air popper and coffee sampler from Sweet Maria's. Try the half-decaf bundle and you may be surprised at how good decaff coffee can taste. My favorite everyday coffee is half decavintaed Indoneasian and half caffinated Yeman or Ethiopean. I also like having decaf on hand for a occasional evening cup of coffee.

https://www.sweetmarias.com/nostalgia-electric-popcorn-popper.html


I hope you have learned something that helps you improve your coffee roasting.

Tuesday, September 26, 2017

Research Links on Weight Loss, Nutrition and Fasting

I began researching weight loss approaches and fasting in particular in early 2017. Here are some links for the sources that I found most informative. I used periodic fasting (ranging from not eating until dinner time all the way up to having a meal Sunday evening and not eating again until dinner on Friday). 

I lost 40 pounds (and have kept it off for a year). I also used fasting to help improve my concentration when studying for and taking the USPTO Patent Bar Exam (I passed!)  I hope you find this information helpful.

Forks over knives article on fasting
https://www.forksoverknives.com/who-benefits-from-medically-supervised-fasting/?utm_source=facebook&utm_content=plant-based&utm_term=vegan#gs.nTX0Lrs

Experiments in intermittent fasting by an athlete who is already in great shape and eating well. 
http://www.precisionnutrition.com/intermittent-fasting

Interesting paper on metformin impact on blood sugar and weight loss
https://www.thieme-connect.com/products/ejournals/pdf/10.1055/s-0032-1327734.pdf

Dietary restriction with and without caloric restriction for healthy aging
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4755412/

Health Impacts of Calorie Reduction
https://www.scientificamerican.com/article/the-hunger-gains-extreme-calorie-restriction-diet-shows-anti-aging-results

Fasting Weight Loss Paper
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2466480/?page=1

Investigation of Starvation Mechanisms
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3529354/

Why fasting bolsters brain power.
https://www.youtube.com/watch?v=4UkZAwKoCP8

Why does fasting boost learning?
http://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.2002032#sec002

Intermittent Fasting and Weight Loss
https://authoritynutrition.com/intermittent-fasting-and-weight-loss/

Write up about a supervised 382 day fast, patient lost 276 lbs.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2495396/pdf/postmedj00315-0056.pdf

A History of Modern Researchinto Fasting, Starvation, and Inanition
https://www.springer.com/cda/content/document/cda_downloaddocument/9783642290558-c2.pdf?SGWID=0-0-45-1331359-p174310858

Interesting fasting information collected from several reference sources
http://anabolicapex.com/2016/02/03/intermittent-fasting-benefits/

Good video with links for references on Longevity and eating one meal a day.
https://www.youtube.com/watch?v=PKfR6bAXr-c

Is Ketosis Dangerous?
https://www.youtube.com/watch?v=Dan8qtgQRi8&feature=youtu.be

Fasting versus eating less.
https://www.youtube.com/watch?v=APZCfmgzoS0

We should never have told people they could 'burn off' calories with exercise.
https://www.businessinsider.com.au/exercise-not-weight-loss-key-2017-6?r=US&IR=T

Where does the fat go when you lose weight?
http://www.sciencealert.com/this-is-where-body-fat-ends-up-when-you-lose-weight

Cancer cells use glucose for energy to build with amino acids
http://news.mit.edu/2016/how-cancer-cells-fuel-their-growth-0307

Friday, June 02, 2017

12V Cellphone and GPS Socket for 6V Positive Ground Studebaker

The Car

Sam (my Step-Father) has a 1952 Studebaker Champion that he has restored. During one of our too infrequent visits he was showing me his latest work when I noticed a small 12V battery (like you would find in a UPS or alarm system) in the trunk with a cigarette lighter socket attached via a short cable. He explained that the car had a 6V positive ground electrical system and he used the 12V battery to power his GPS when he drives to car events and for charging his cellphone while he is in the car. He said a 12V outlet for the car would be nice and asked if I thought I could build one. Challenge accepted!

Sam's 1952 Studebaker Champion
Design Steps

Initially I used electrical tape to insulate the power socket from the metal dash (which is at +6V) so the body of the socket could be connected to battery negative. This allowed the use of boost converter to generate 12V from the 6V battery.
First attempt insulated the power socket from the 6V positive ground metal dash.
While this worked and was installed in the car for over a year, insulating the outlet was an extra step and failure of the insulation between the socket and the metal dash paneled seemed to be a likely failure point. Before sharing the design I wanted a more robust solution that would be easy to install.

I considered a fully insulated power socket but could not find one that would fit the existing dash opening. I also considered using a plastic bracket to mount the power socket but that would spoil the factory look the dash. Sam was so kind as to offer to use a pigtail socket that he stows under the seat when not needed but I was determined to find a way to use the existing mounting spot in the dash.

The eureka moment came when I wrote out the the system assumptions and requirements and noticed that devices plugged into the power socket make no other connections to the vehicle electrical system. This means that the power socket does not require an absolute voltage output, but actually needs only a 12 volt difference between the power socket center terminal and the body or chassis connected terminal. So if I apply 18V to the center terminal of the power socket, any device plugged into the socket will see 18V - 6V or 12V between the socket's terminals. Sometime just writing a spec can help set the direction for a project!

A search of Pololu's DC-DC Boost Converters found no 18 V boost converters but I did find the U3V50 adjustable boost converters. These small module have a 5A input switch and adjustable output (9-30 V) for $17. Notice that these modules are offered in several fixed voltages (but not 18V) and two adjustable voltage ranges. Be sure to get the higher (30V) adjustable range, U3V50AHV. Perhaps Pololu will offer an 18V option in the future.



https://www.pololu.com/product/2571

Once I received the module, I added some wires, powered it up and dialed the voltage to 18V. The product page at Pololu has some great information about the module's efficiency. There is even a chart showing efficiency when set for an 18V output with several input voltages.



Looking at the chart we can see that a 5V input provides an 18V output at 1 amp at better than 80% efficiency. So our 6V nominal input should give us even higher output and higher efficiency. I tested the module with a USB car charger and a PortaPow USB Power Meter. The image below shows the unit providing over 10W while charging an iPad.

The module got hot before the current started dropping off as the iPad reached full charge but the module never reached the high-temperature cut-off. The Pololu module is very robust but I would not try to draw more than 1 amp from the 12V power socket. So no high power stereos or ham radio rigs. But you should be able to charge your phone or run your GPS all day long.



The Studebaker's existing lighter socket was power via a switched negative wire with a bullet connector on the socket center terminal and an empty spade terminal on the socket body (our positive chassis 6V power source). To make the installation easier, I added a different color wire to each of our module connections and a matching connector for each terminal. I also insulated the module with clear heat-shrink tubing.





Connections:
Blue wire to the power socket center terminal (module Vout)
Green wire to the power socket center terminal (module Vin)
Black wire to switched negative terminal (module GND)

Installing the new module was simple, requiring only unplugging the existing wires from the socket and connecting those wires to the module. So we unplugged the wire from the existing socket center bullet terminal and connected this to the module GND wire. Then we connected the body/chassis wire from the power module to the tab on the light socket (electrically connected to the chassis positive ground via the metal dash). Finally the output voltage wire (boosted to 18V) of the power module was connect the lighter socket center terminal.

After inserting the connectors, the wires were bundled and zip-tied to the firewall. The install only took a couple of minutes. The interior appears stock other than a plastic socket cover that indicates that it is actually a 12V outlet.





The voltage of a conventional 12V automotive system actually vary over a wide range. Wikipedia says that "Equipment intended to be powered by the receptacle needs to account for intermittent contact, and voltages outside the nominal 12V DC, such as maximum voltage 9–16V continuously. To function in this environment, 12V automotive accessories are designed to operate over a wide range of input voltages. For example, the Amazon top selling Schoche reVolt dual USB car charger specifies an input voltage range of 10 to 16 volts.

I measured the output voltage under different engine conditions to get a feel for the range produced by the boost converter on the Studebaker. At key on with the engine not running the socket put out 12.75V. The voltage varies once the engine is running though because the generator output varies with engine speed. The voltage varies because the socket output is actually 18V - generator output voltage.  The socket voltage output dipped as low as 11 volts at some engine speeds. The module could be modified to produce a stable voltage difference of 12V but this appears to be unnecessary for the vast majority of applications.

Update

Sam upgraded the install with a matching cigarette lighter plug and socket. He removed the heating coil to keep it from being able to make electrical contact with the power socket voltage.


The new lighter plug gives the dash a factory look while retaining the ability to power modern 12V electrical accessories. 


Conclusion

The module worked with every device tested and has been installed and working in the Studebaker for over four years now. If you want, it is simple to build your own 6V Positive Ground to 12V power socket converter.

1 - Order the Pololu Module (U3V50AHV)
2 - Adjust module to 18V
3 - Add wires, terminals and insulate the module (tape or heat-shrink)
4 - Install and enjoy!

I was pleased with the look and performance of the project. I hope this approach can help you solve your own power system design problems!




Wednesday, February 22, 2017

Creating a Stencil from a Bitmap Image

I began searching online for a Minecraft stencil when my son (5th grade) had a school assignment to find a way to earn money to donate to the Make a Wish Foundation. He wanted to use bleach to stencil tee-shirts with MineCraft artwork to sell to his friends at school. We supported his efforts and purchased a small supply of shirts from the local variety store (Dollar Tree).

We first tried cutting stencils using Freezer Paper and ironing that onto the shirt. It worked for some shirts but the bleach had little impact on some colors. So back to the craft store for some fabric spray paint. The freezer paper stencils did not hold up well when the kids used the shirt spray paint. The stencil wanted to peel off of the shirt.

We needed a more substantial material to make a reusable stencil that would give us more detail and hold up better. I found some flexible thin plastic sheet that looks like a good candidate. This seemed like a great job for the laser cutter but I was not sure how to convert an image into a stencil. It took an an entire evening of working with a drawing program but I finally figured out a process that seems to work. Here are the steps I followed.

First, find a bitmap of the Minecraft item that you like. I used a Google Image search to find the image below. 


Here is how that image appears in CorelDraw. I will leave all of objects selected to make it more clear when we shift between a bitmap and objects. 


Next use your favorite drawing program to auto-trace the image. For CorelDraw you can get good results using Trace: Outline for High Quality Image. Move the Detail slider all the way to the right to ensure you get all of the squares. Smoothing did not seem to matter and I used 0 (slider all the way to the left) for Corner Smoothness. If the tracing went well you will get a group of objects that looks similar to the original image. Note the new selection handles for the newly created objects.



Next select all of the traced objects and apply a black fill.


Now change the Outline to 8.0 pt, solid line, in white.



This looks like a stencil and can be used if you want to print it and cut by hand. I read that you can get great results if you print on card-stock and laminate the card-stock before cutting the pattern out with an Xacto knife. But I want to use a laser cutter so there are still a few steps left. 

The laser cutter wants lines showing where the beam should cut. So we want lines that define the outline of the black boxes in the image above. But those black boxes are actually the fill inside the boxes defined by the 8.0 pt white rectangles. So we need to convert the fill of each square into it's own object without the white outline. 

I suspect there are easier ways to convert the black fill to objects but I did it by converting the objects to a bitmap (150 dpi, Black and White, 1-bit) and then tracing the new bitmap. Below is the bitmap produced when you convert the objects to bitmap. 



Next we Trace Outline for High Quality Art.  Set the Detail slider full right, and both Smoothing and Corner smoothness full left. You should get a group of objects like shown below. Again notice the selection handles for the new objects created by tracing.



Finally, we select all of the objects and set the Outline to Hairline, solid black line, set the fill to none and adjust the size to match the desired stencil size. You are limited only by the cutting bed size of your laser cutter. Here is the pickaxe on a letter size sheet. 

Finally save in the preferred file format for your laser cutter, I used DXF, and you should be ready to cut the stencil on your laser cutter.

The laser will cut along the lines, giving you a stencil. Below are some photos of the stencils and shirts the kids make using them. The green images are fabric paint. The lighter images were made applying bleach to black fabric.






















We were pleased with the results. I hope this workflow can help you create your own stencils!