Close
0%
0%

SAB3T - PID Loop Educational Tool

Learn how to use PID loops for fun: SAB3T - Servo Actuated Ball Bearing Balancing Touchscreen.

timTim
Similar projects worth following
SAB3T is short for Servo Actuated Ball Bearing Balancing Touchscreen.

A 7" resistive touchscreen is used to sense the position of a steel ball bearing. The touchscreen is mounted to a universal joint allowing it to tilt in 2 axes. 2 small servos are connected to the touchscreen through ball and cup joints. They work together to control the tilt of the touchscreen. Touchscreen data is processed in an Arduino Nano where the data is fed into a PID loop that outputs servo movements.

STEM education is often talked about as something that needs to be improved and made more accessible. In recent years STEM has made newspaper headlines and become a political hot topic in the US. SAB3T offers a hands-on learning experience that is as equally suited for the class room as it for a tinkerer's desk.

PID loops are a fascinating piece of engineering that are in use all around us. They move the nozzles in your inkjet printer, they keep quadcopters in sky, they keep your car cruising at 55; and with SAB3T they can balance a ball on a flat surface. They are so prevalent yet most people know little about them. With SAB3T you can watch the loop run and tune it in while viewing the actual PID data in real time. (Viewing data in real time requires a computer to run the python script)

SAB3T will be sold as a kit to be assembled along with code examples and educational materials about the mathematics of control loops. Currently the SAB3T design is mechanically sound and functioning, working Arduino code is able to balance a ball bearing, and a python script is able to take data from the Arduino and live plot it.

SAB3T doing it's thing:

System Design Documentation

Electrical Connection Diagrams

If you are building with the SAB3T PCB the following connection diagram applies:

If you are building point to point with jumper wires then the following diagram applies:

Full build instructions are available below in the "Build Instructions" section

Example Arduino Code

Working code is available on the SAB3T github. Here are some of the features of SAB3T_PreProduction.ino:
- Initial servo position is stored in EEPROM
- All PID loop data is sent out the serial port to be graphed and studied. It is sent in a comma separated format after each control loop iteration

- A simple serial command interface has been implemented to allow live tuning of the control loop while it is balancing the ball bearing.

BalancerDisplay.py

This script requires python, pygame, and pyserial. I've tested it on Raspberry PI (Linux) and Windows.

There are 3 modes of operation: XY position graph, PID line graph, XY position overlaid on PID line graph. You can cycle through the modes by pressing "G" on your keyboard.

Updating PID parameters:
To update PID parameters, activate a parameter and use the "UP" and "DOWN" arrow keys on your keyboard to adjust the setting. You can activate a control parameter by typing it's letter.
"P" - proportional
"D" - differential
"I" - integral

When the PID line graph is active the traces can be turned on and off by pressing the number keys on the keyboard.
"1" - enable/disable position error
"2" - enable/disable differential error
"3" - enable/disable integral error
"4" - enable/disable touchscreen angle
"5" - enable/disable X/Y shift from touchscreen angle

Setting the level point:
Press the "E" key when the touchscreen is level to overwrite the servo start points in the EEPROM.

Website

I bought SAB3T.com. Right now it just redirects to my Build Instruction here on hackaday.io. I'd like to make that website into a central point of information for SAB3T, including tutorials, code and a forum for users to share.

Artists Rendering of Productized Look and Feel


What's Next

PCB rev 2: Instead of an Arduino Nano breakout board I want to create a custom Arduino compatible board that is small and has the appropriate connections for SAB3T. I need to study the cost of this approach and figure out at what volume a custom board like that will make financial sense. Bringing SAB3T to market with a fully custom Arduino might take a crowd funding campaign to hit some order requirements.

Retail Packaging: I want to explore unique packaging options. I want it to be sleek and cool and functional. My first attempt ended up being a regular old box with some engraving on it.

Educational Material: I've positioned SAB3T well to be useful educational tool. Now I need to create some supplementary educational stuff.

Licenses

All hardware and software is licensed under "Creative Commons - Attribution...

Read more »

  • 1 × Arduino Nano
  • 2 × 9 gram servo
  • 1 × 7" Resistive Touchscreen
  • 1 × 3D printed parts
  • 1 × Laser Cut Parts

View all 10 components

  • Hackaday Front Page!

    Tim09/09/2015 at 02:22 0 comments

    I figured SAB3T would make the front page sooner or later and today was the day! This is now my most Skulled project! Thanks everybody!

  • 9/7/2015 Update

    Tim09/08/2015 at 02:56 0 comments

    New PCB!

    One of the things on my to do at the 8/17 deadline was a new PCB design. My Previous PCB was just a breakout board for an Arduino Nano to make the connections easy. I wanted to create a dedicated SAB3T arduino compatible board. I based this design off the Sparkfun Arduino Pro Micro. I started by taking out some stuff I didn't need then added some headers and mounting holes. I went with the TQFP-44 package of the ATmega32u4 to make soldering easier. All the passives are 0603, also to ease soldering.

    Thermoforming

    I've continued my thermoforming experiments. This week I found some thing plastic that is sold in 2'x4' sheets to cover big florescent lights in drop ceilings. (I had bought it a while ago for a project.) Results were much better with this plastic than I've seen so far.

    Still not as good as I'd like, but I might not have let the plastic get hot enough.

  • Thermoformer

    Tim08/31/2015 at 02:23 1 comment

    I wanted to explore packaging options, so I thought that I should explore thermoforming. Thermoforming takes a flat sheet of material, heats it up enough to be formable, then uses a suction table to suck it into a shape. It's a pretty simple concept. I thought that I should go ahead and make a thermoformer.

    I have an old electric skillet, I thought it would make a good heat source. I have a big shop vac, that should make a good vaccum source. I just need to fabricate a suction table.

    I drew up what I was imagining in Designspark Mechanical:

    It's a pretty simple design. It's constructed of lasercut 1/4" plywood and 3D printed plastic corners. A 3D printed hose adapter comes out the side. I used an 8mm diameter rod that I had laying around (came out of an inkjet printer) as the hinge pin. Lasercutting is the way to go when you have hundreds of small holes to fabricate.

    I took lots of pictures of the assembly. I figure if it works then I should make the thermoformer it's own Hackaday.io project.

    I spent a while looking around online for a good plastic source. There are lots of places that you can buy thermoformable plastics, but they aren't low enough cost for what I'd like. This is packaging and I want it to be low cost. I decided to test Pepsi bottle plastic. Those bottles have a value of $0.05 in my home state and are readily available. The window that I designed in my thermoformer is sized just right to accept the plastic cut from the center for a 2 liter bottle.

    Here is my full setup ready to test. I decided that a crescent wrench would make a good test subject.

    Unfortunately my bottle plastic wants to shrink as soon as it is heated. It Really wants to shrink. My first attempt I cut the plastic just smaller than the screws in the frame. Tightening the screws was supposed to smoosh the plastic under the frame and hold it. No such luck. The plastic immediately pulled out.

    Next I tried a larger peice of plastic that I punched holes in and threaded all the screws through. Surely that will strong enough to hold, right?

    Not quite. The plastic wants to shrink with so much force that I tore itself out from the screws. Also, it never got pliable enough to be thermoformed.

    The only other thing I had lying around was some 1/8" acrylic. I lasered a piece to the right size and gave it a go.

    This almost worked! My skillet doesn't seem to have gotten the acrylic quite hot enough. I let it soak for a long time and then gave the thermoformer a shot.

    Looks marginally wrench-ish! Sweet!

    Unfortunately my Pepsi bottle plastic is a no a go. I need to find a better and low cost plastic to run in my thermoformer. Also, I'm not sure that my skillet can deliver enough heat.

    To be continued...

  • 8/25/15 Update

    Tim08/26/2015 at 03:12 0 comments

    Yesterday was both exciting and disappointing. I got 2 emails from Hackaday. First I found out that SAB3T is 1 of 100 advancing to the semifinals of the Hackaday Prize! (Yay!). Then I found a Hackaday post about the 10 Best Product entries advancing, which SAB3T is not a part of (Ouch!). Then I got another email from Hackaday saying that due to my excellent documentation for SAB3T I was getting a free T-Shirt (Yay again!)

    I have to say the 10 Best Product entries moving forward look great, so great work to everyone continuing on. However I'm a bit disappointed. I though that SAB3T had the best shot in the Best Product category. The judges have already decided that 10 of the competitors in the overall competition are cooler than SAB3T. Will things shake out better for SAB3T when we go head to head again in the semifinals? I hope so.

    OSHpark Boards

    My OSHpark boards came in the day after I shipped my protos for the "Best Product" judging. This weekend I got one all soldered up and tested. It works great just as I predicted.

    Now that I'm out of the "Best Product" category I'm reviewing my plan for SAB3T. I want to make sure that I'm focusing on the most useful things.

  • Best Product Entry!

    Tim08/17/2015 at 04:04 0 comments

    I think that I've finished everything needed for the best product entry.

    I wasn't sure if it was going to be sufficient to just do the "system design document" in the details of the project, so I took all the content in the details section and made it a document linked to in the side bar.

    My Semifinals video is uploading now, you can see it here:

    My boards from OSHpark came in on Thursday, so I wasn't able to ship them in the protos I sent to Hackaday HQ. It's a good thing that I was able to make some with a PCB router!

    I took a lot of the content from my project logs and updated the "Details" section of this project. I think it's looking a pretty good entry now.

    I also did a short video of SAB3T doing it's thing:

    I put up an "Artists Rendering" of the finished product because that is a requirement. SAB3T doesn't need a rendering though, it looks right now basically how I anticipate it looking when it is offered for sale.

    All the code is now updated on the project's github page, the best product units were shipped with SAB3T_PreProduction.ino pre loaded and the screens are pre-leveled.

  • Assembly Instructions Complete

    Tim08/16/2015 at 22:43 0 comments

    Towards the bottom of this project page there are now a complete set of build instructions. Sweet!

    I took all the pictures when assembling my copy of the final prototypes that I sent for Best Product judging. I'm happy with how the instruction came out. I shot a video to explain the last step.

  • Shipping Update

    Tim08/15/2015 at 22:19 0 comments

    Time is winding down to the 8/17 deadline, but I think I'm in good shape. I have a few things left to take care of tomorrow, including putting up my 5 minute video and finishing posting my build instructions.

    Late Tuesday night I finished packaging up all my prototypes and they left via USPS priority mail on Wednesday, due to arrive on Friday. I tweeted out a photo Tuesday night.

    Unfortunately as you can see in the tracking update above, my package went out on the mail truck Friday without being delivered. How does that happen? The mailman must have found it in his truck today and noted that the business is closed. With any luck the mailman will drop it off on Monday, and if he doesn't I hope I'm not penalized.

  • Preparing for Shipping

    Tim08/11/2015 at 04:26 0 comments

    When I bring SAB3T to market it will be sold as a kit that is assembled by the end user. With that in mind I sent a message to Sophi looking for clarification on what state I should ship the 3 proto units to Hackaday in for Best Product judging. On the one hand, assembly is part of the fun and experience with SAB3T. But on the other hand there will probably be more than 3 judges (I think? who knows.) They won't all get the same experience, and if they get 70 projects that need to be assembled they'll spend days on it.

    Sophi suggested that I ship 2 assembled, and one unassembled. Tonight I got the 2 assembled minus the PCBs.

    My proto unit on the left, 2 of the HaD protos on the right

    Packaging:

    I've been kicking around ideas for how to package SAB3T for the past couple of weeks. Tonight I got it all down in CAD and lasered a proto box for my proto SAB3T kit.

    I didn't have a big enough piece of cardboard so I taped 2 together. I did a little engraving on it but it didn't come out dark enough. You can only see the engraving if you hold it just right in the light.

    It folded up quite nicely. I've never designed a box before so that was exciting.There is a divider that goes in there too. I didn't cut one out tonight. Tomorrow I'm going to stop somewhere and see if I can get some cardboard that is white on one side. I'll redo the box and it should look sharp.

    Shipping Update:
    I'm still waiting on my PCBs to arrive from OSHpark. I'm going to delay shipping the demo units out until Wednesday in hopes that my boards show up. Unfortunately I decided to make a board a little late, so I'll probably be shipping without them.

  • Going from Proto to Production

    Tim08/10/2015 at 03:25 2 comments

    I've designed SAB3T to be producible in low volumes with the tools that I have at my disposal. All of the parts that you can't go to Digikey or McMaster and buy can be fabricated by tools that I have access to. This is a proven process for me as I've had success selling my creations online. Thanks 6 Packer and Pivena!

    In the process of creating my prototypes of SAB3T I gathered data that I can use to make some production estimates.

    Making Time for one SAB3T:
    Laser cutting: 10.4 minutes
    3D printing: 121 minutes

    Obviously the slow thing is the 3D printing. In 2 hours I can 3D print 1 set of parts and lasercut 12 sets of parts. The upside though is that I could scale the number of 3D printers at my disposal. I use an UP! Mini currently. Below I've maxed out the parts that I can fit on the build plate, this would take about 4 hours to print and would make 2 sets of parts.

    Using the above time estimates I've put together a projection of how this would scale as a product. Since I can run my 3D printer unattended these numbers assume that my printer is maxed out when I do 3 prints a day. At 4 hours a print this would mean starting a print before I leave for work, starting another print when I get home from work, and starting another print before I go to bed. So a fully utilized printer is printing for over 12 hours a day.

    Hobby:
    This assumes that I can spare 1 hour a day to SAB3T production. I spend 1 hour watching the laser cutter and packing sold orders. The 3D printer is restarted morning, afternoon and night. All together my equipment is able to produce 6 kits a day. Working 5 days a week I can create 30 kits a week. If I lose a day during the week I can make up on Saturday or Sunday.

    Contract Labor:
    I need to produce between 6 and 30 kits a day I will bring in contract labor. For every 6 additional kits per day another 3D printer needs to be added to my workbench. For example at 20 kits per day I need 3 additional printers working to keep up with orders

    Full Time:
    If SAB3T sustains a rate of between 30 and 46 kits per day I could make it a full time job. Running 8 hours a day I'll have my laser cutter maxed out, an army of 8 3D printers humming away, and a production capacity of 46 kits per day. I will have needed to invest a little over $4000 in the additional printers.

    There are a lot of variables to consider here such as the speed / capacity of a different printer, profit per SAB3T, machine downtime for maintenance, etc. I won't try and graph everything, that would just be silly.

    This exercise has shown me that I should be able to avoid the "pit of despair" https://www.sparkfun.com/news/909

  • Quarter Finals Video Posted

    Tim08/09/2015 at 18:55 0 comments

    Here is my video for the quarter finals of the 2015 Hackaday Prize!

    This is an edited version of the video that I put up on July 28th. I edited it to meet the time requirements for a quarter final entry. The original video is 2:50 long, but a quarter final video needs to be no more than 2:00. I don't know how strict that rule is, but I wanted to make sure that I'm not breaking it! This video is 0.1 seconds under the 2 minute limit.

    Unfortunately I couldn't just shoot a new video now because I've made quite a bit of progress since I shot that video. Projects competing in the best product category have the quarterfinal and semifinal video due on the same day, and I want my videos to have different content and show my progress.

View all 18 project logs

  • 1
    Step 1

    Gather your parts / Tools

    You will need:
    - All the parts listed in the components section above
    - Small phillips head screwdriver
    - USB cable with Mini-B connector
    - A computer to program your Arduino
    - (optional) USB 5V Charger to power SAB3T when not connected to PC.

  • 2
    Step 2

    Coil Your Wires!

    Grab your 2 servos and the touch screen wires. Wrap them tightly around a cylinder, such as a screw driver.

    When you let go the wires will relax a little bit and should slide right off the end of the screwdriver. The wires hold the coiled shape which makes routing them later look much cleaner.

  • 3
    Step 3

    Install the Arduino

    You need:
    - Arduino (soldered to interface board)
    - 3 screws
    - 3D Printed Central Tower

    Install the Arduino oriented as shown. There are only 3 screw holes so it will only go in one way.

    Screw it in! The holes in the 3D print are sized so that the screws will self thread, so the screws should go in with a little bit of resistence.

View all 15 instructions

Enjoy this project?

Share

Discussions

Burner Kaif wrote 02/11/2023 at 08:25 point

Thanks for providing us this great knowledge, I love the green space so visit automatic washing machine

  Are you sure? yes | no

Kris Keillor wrote 04/11/2022 at 22:04 point

This is SUCH a cool way to demonstrate control loops! I love how the feedback is tactile and immediate. It's also a bit dramatic, which is good for drawing and keeping interest. This could be a huge hit in classrooms and workshops.

  Are you sure? yes | no

seba wrote 03/05/2020 at 12:11 point

Hey man, nice project. I am currently trying to build one as well. Do you maybe still have the files for the 3D printing and don't mind sharing them?

  Are you sure? yes | no

DBBillups wrote 02/19/2017 at 00:06 point

A newbie here. I built my version of the SAB3T and have it operational. On the maiden voyage all was well and it just sat there balancing back and forth. I decided to take the protective film off the screen. Now it seems like it has too much gain. It overcorrects and throws the ball. Can I simply reduce the gain and where in the code? 

Thanks, DBillups. 

  Are you sure? yes | no

Dan Royer wrote 09/30/2015 at 13:29 point

Thanks for stopping by our booth at makerfair. I'd like to distribute this kit when it's ready. Pm me.

  Are you sure? yes | no

Romain wrote 09/21/2015 at 14:09 point

Awesome design!

There's a class I'm teaching starting late November where I try to get my student to understand the PID regulation. Do you think you'll have the product available by then? Or are the design files already available somewhere? (I can't find them if they are!)
Thanks!

  Are you sure? yes | no

Michael Ratcliffe wrote 08/05/2015 at 20:17 point

Great Tutorial! 

I made a PID learning Platform myself, I would recommend fitting a removable channels so the students can first learn on a system with once degree of freedom. Then Work their way up to controlling side motions. 

  Are you sure? yes | no

Tim wrote 08/06/2015 at 00:27 point

Thanks!  That is a great idea.  I'm planning on making some teaching material, and I'll see if I can include something like that.  I haven't gotten to the teaching material yet.  Currently I'm racing to meet the Best Product deadline!

  Are you sure? yes | no

zakqwy wrote 07/30/2015 at 15:32 point

Great project! PID tuning is an excellent skill to have. Excellent use of a resistive touchscreen!

  Are you sure? yes | no

rx7man wrote 07/30/2015 at 04:38 point

PID loops are something that I've been working on a lot myself... Looks like you made a really useful tool to demonstrate them!

  Are you sure? yes | no

Tim wrote 07/30/2015 at 14:56 point

Thanks rx7man!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates