Archive for the 'Prototyping' Category

TWANG32 – An ESP32 Port of TWANG

 

I ported the TWANG game over to ESP32. I wanted to do this for several reasons.

  • Cost: The ESP32 is generally lower cost than the Arduino Mega
  • Speed: The ESP32 has a dual core 80MHz processor vs. the 16MHz Arduino Mega
  • Memory: The ESP32 has much more RAM and program space to allow more features, levels and audio files.
  • Physical Size: A Mega is very big. This creates a large enclosure that takes a while to print. The smaller enclosure is also more portable.
  • DAC Pins: The audio capabilities on the Mega are very crude and basically limited to square wave tones. A DAC can output digital audio. Currently I am just using a similar square wave tone to the Mega, but it works much better for adjusting the volume.
  • Wireless: The ESP32 has Wifi and Bluetooth. This will allow easier (smartphone) interfacing for options (brightness, volume) and level pack uploads. I also want to consider dual player battle type games with linked controllers.

The Audio

The original TWANG bit banged audio directly from I/O to a speaker. This was super simple, but the volume at max was not loud enough for noisy environments. The ESP32 I/O is a lower voltage (3.3v) and less current, so something needed to be done. I prototyped with a PAM8403 based amplifier (~$4 on Amazon). This worked great, so I added that I.C. to my shield. The volume is controlled by the amplitude of the DAC.

The Shield

I made a shield to simply the wiring and provide a stable way to mount the ESP32. I used a NodeMCU 32S development board for the ESP32. Under the ESP32 is a the audio circuitry. I should have some extra boards to sell on Tindie soon. I will publish the source files soon.

The Firmware

The code is on Github. The port was relatively easy, but I had to rewrite a few libraries. They were designed so the main “setup” and “loop” parts did not change much. Currently the serial port based setup from the Mega version was not ported. This probably won’t be used. A wireless version is in the works.

Enclosure

The new enclosure is smaller. It prints quicker and is easier to fit in my backpack. The size is still big enough to hold comfortably while playing. The files will be uploaded to Thingiverse within the week.

Next Steps

  • Wireless control: I want a simple way to read the game statistics (average score, levels played, boos kills, etc) and tweak simple settings like audio volume and brightness. I think the easiest way is to make it a wifi access point with a simple web server. This eliminates having to write any client side apps and any smartphone or computer can hope on easily.
  • Levels: Make some way to edit or upload levels via wifi.
  • Multiplayer: I should be able to link multiple controllers. If I can think of a good dual player game idea, I might try to add that.
  • Python: It might be a fun challenge to write the game in Micro Python. This might open up the development to more people.

If you want to be notified of future blog posts, please subscribe.

 

PSoC 5 Daughter Card for XCC

I finished a PSoC 5 daughter card design for X-Controller-Controller project.  10 boards should arrive in about a week. This will clean up all the wiring from the breadboard testing I have been doing. My goal is to have a clean development platform for me and possibly others to work with.

The design has the following features.

  • Mounts CY8CKIT-059 dev board directly
  • Mates directly to the X-controller-Controller
  • Independent control of 4 axes.
  • Connector for X-Controller button panel
  • Connector for  X-Controller power supply PCB
  • Connector for a Serial LCD panel (Itead Studio Nextion style)
  • PSoC controlled stepper motor current.
  • PCoC controlled idle current.

Here is an image of the CYC8CKIT-059 development board.  The CPU is a PSoC 5LP.  The price is only about $10.  It comes with a built in programmer, debugger, and USB/UART. This can be snapped off.  To fit into the X-Controller, I snap off the programmer and mount it in another location.  The connections are made on the PCB.  I plan to use stackable headers so all of the pins are still easily accessible.

Links

Please subscribe to me on YouTube or follow me on Twitter.

 

X-Controller-Controller (X-Controller minus controller)

MakeMag_0527

I am very happy with the X-Controller.  It packs everything you need to run Grbl into a clean little package.  It is super easy to hook up and move between machines. With that said, I had a quite a bit different idea in mind when I began the design.

The X-Controller was designed to be the motion controller for the X-Carve. The “X” in X-Carve was meant to signify that it was sold through a configurator and there were a lot of options. The X-controller was going to follow the same concept. It would support Grbl, Beaglebone Machinekit, Smoothy, and others. Additionally, alternate stepper driver PCBs might be developed.

To enable the configurability, the stepper driver section would be separated from the controller section. Every feature the stepper drivers supported would be available to the controller. The plug in controller PCB would control the features via firmware or jumpers and pots, depending on the power of the controller. The current X-controller has 4 stepper drivers, but (2) are wired together. In the split concept the controller card would decide how that was done.

At the time Easel was starting to get some real traction and Easel only supports the Grbl protocol. We decided that it was best to pick the easiest solution for our customers and make the X-Controller Grbl only.

My experiments in Beaglebone and PSoC have been such tangled messes of wires. I always wished I had that disconnected stepper PCB. I finally decided to make one.

xcc1

The XCC Stepper Driver PCB uses the same Toshiba TB6600 drivers as the X-Controller. It fits in the X-controller just like a stock PCB, but it is quite a bit shorter.  The interface side of the PCB has (1) 2×5 right angle header connector for each axis. Brought out the the connector are…

  • Step
  • Direction
  • Torque  (high=full current, low=1/3 current)
  • Enable
  • Micro-stepping selection
  • VRef (sets the motor current)
  • Ground and VMot

xcc2

 

For this version, I put a current selection pot and micro step selection jumpers for each axis to simply testing.  These function should be on the controller board, so most of these will be built without those installed.   The PCB also needs 12VDC to 40VDC power for the motors.  Each driver has a small 5VDC supply built in, so an external source is not needed.

xcc3

Here is a snapshot of the schematic.  This is just 1 of the 4 identical sections.

 

schem

Here is snapshot of the layout. I was able to get everything on 2 layers.

layout

 

It fits into the X-Controller great.  I used a small piece of black acrylic to fit the gap due to the shorter length.  It is working perfectly.  I have been testing it with my PSoC port manually wired in.  A PSoC5 controller will probably be the first controller card I will have made.

xcc4

xcc5

 

 

 

Lost PLA Casting

cast2

We recently did some aluminum casting at the Inventables Beer and Making night. The primary mission was to do some lost foam casting, but I wanted to try lost PLA.

Beer and Making is typically a gonzo/hackathon type event, so we deliberately try to use materials on hand and try to learn for ourselves. We used pink insulation foam because it could be easily hand carved during the event. This was the first time for everyone, so I was quite happy with our success.  I’ll point out some areas where we probably could have done better.

The furnace

One of the perks of working at Inventables is our personal Exploration and Project budgets.  We all get a budget for personal exploration and making things. The furnace was recently purchased by Jon, one of the fulfillment team members, with some of his budget. This furnace runs off standard 110V and can heat the material up to 1150°C.  We set it for about 1000°C for the aluminum.

furnace

 

The Model

sprues

 

The model I used is the unofficial mascot for the CNC build Club, the CNC Ninja Squirrel.  I tried to use as little PLA as possible.  I used 2 perimeters and 5% infill.  There are a few steep overhangs, so I typically need at least 2 perimeters for success with this model. I didn’t use any special filament, just the PLA was in the printer at the time.

The model will be buried in the sand.  You need to create a couple of channels (sprues) to reach the surface for the casting process.  The channels have several functions.

  • Provide a place to pour the aluminum.
  • Provided an escape path for the air and other gasses created when the material is burned out.
  • Provide a a source of aluminum for the part to draw from when it shrinks.

I created the channels from pink foam and hot glued them onto the PLA model.

The Sand

We used what we could find quickly.  We used about 9 parts of a play sand and pool sand mixture and 1 part of bentonite power (the Tait mix).  We added just enough water to make it clump a little.

The Setup

cast1

We got a large metal metal tray and put some dry sand on top.  This was a bit of a fire pit in case of any spills or fires.  You can see the size of the crucible in the foreground and the tongs that came with it.

We made a small enclosure out of MDF.  We filled it half way with the sand mix. We placed 3 items to cast in it.  We then covered the items in sand.  We added the sand slowly and packed it down with a rod at several levels.  We poured each of the 3 items with separate pours.  We wanted to make sure each item got a lot of aluminum.

We used scraps of MakerSlide as the aluminum to melt.  We cut the pieces to the length of the crucible.  We would add a piece at a time as they melted.  It took about 30 minutes for the first batch and about 10 minutes for the other batches.

Pouring

IMG_1722

The pouring was pretty exciting.  Some of the aluminum ran to the MDF sides and started a little fire.  We had a fire extinguisher ready, but simply put a cover over the box to kill the flames. Most of the flames you see in the image are the foam being burned away.

Results

We did three separate parts.  2 were foam and 1 was PLA.  The PLA probably had the best quality finish, but the part came out noticeably darker.  It was easy to clean up with a stiff wire brush.

Next Time

  • The first change I would make is to use something non flammable for to hold the sand.  I think a ceramic flower pot might be good.
  • Build up the sand around the sprues to keep the aluminum from spreading.
  • Cover the part in dry wall paste.  This creates a thin shell between the part and sand to get a better finish.
  • Get some better sand and a little fire clay to make a better sand mix.
  • I might try to model the sprues onto the part in PLA
  • Mark the in and out sprues, so you know what side to pour into.
  • The smoke and fumes were pretty nasty, especially the MDF.  Do this outside!

 

 

Line-us Clone Controlled by Easel and Grbl

Last week I made a Line-us drawing robot clone.  Unfortunately I had no good way to make it draw easily.  I thought I would give the CNC toolpath a shot.  My goal is to have a super portable thing to generate conversation at meetups. If I used Easel it would allow anyone with a web connection to easily make something.

2dbenchy

Grbl

Grbl Logo 250px

The most compact machine controller is Grbl and I have a lot of experience with it.  Grbl is designed to send step and direction signals to stepper motors.  The draw ‘bot uses hobby servos.  The nice thing about hobby servos is they don’t need to be homed.  They have feedback to tell them where they are. They also don’t care about speed, acceleration or steps/mm.  They just go wherever you tell them as fast as they can go. It occurred to me, the easiest way to hack this into Grbl was to not modify the Grbl code at all.  I would let Grbl think it is using stepper motors.  I would just add some extra code that runs on regular interval to tell the hobby servos where the stepper motors are in 3D space and they would be told to go there.  I played around with some intervals and 8 times per second (8Hz) seemed to work pretty well.  The ‘bot uses machine coordinates. The work coordinates are offset to the left because the ‘bot cannot draw at 0,0.  The pen would crash into the frame.

PSoC

I recently port Grbl to PSoC. I used (3) 16bit PWM components to control the hobby servos.  See this blog post on how I did that.  I then attached a 8Hz clock signal to an interrupt.  The interrupt sets a flag when it is time to update the servos.  When the main code sees this flag it does the calculations and and sets the PWM values.  Keeping the code out of the interrupts gets Grbl happier.

servospwms

Easel

Easel is already setup to use Grbl.  You can either import gcode or create a design right in Easel.  I started out with importing gcode because the Benchy design was not in a format I could import. I created a template that shows the allowable work area. This will allow anyone to quickly create a drawing.

easel_template

2D Benchy

I wanted to have a little fun with the first print.  “Hello World” was not good enough.  3D printers use benchmark prints, so I thought I would do a 2D version of the classic 3DBenchy.  To get a 2D drawing of 3DBenchy, I traced over an image with the line tool in CorelDRAW.  I then exported a DXF of that.

trace

Hobby/RC Servo Control in PSoC

psoc_setup

 

The PSoC family is my go to line of processors for prototyping.  It is like having a breadboard full of digital and analog circuits that you can wire up on the fly. I have been doing some stuff with hobby servos lately so I needed to figure out how to do it on the PSoC.

Hobby Servos

Wikipedia

From Wikipedia

servo_timing

Image from Adafruit

 

Hobby servos set their rotation based on the length or a repeating pulse. The pulse should be 1ms to 2ms long and repeat every 20ms.  One end of the rotation is at 1ms and the other is at 2ms.

The PSoC PWM  Component

PWM_Comp

The PWM component is perfect for this job.  The PWM component can be setup to have a period and an on time.  The period should be 20ms and the on time would be between 1ms and 2ms.  The component uses a clock and two counter values.  The component will count on every clock pulse.  It resets the counters after the period count has been reached and the CMP value determines how long the pulse is logic high.

The PWM output goes to the servo control line.  Here is the configuration dialog box for the PWM component. The graph at the top is a good reference for what the output will look like.

pwm_setup

The goal is to have a pretty decent resolution to set the 1ms to 2ms pulse.  I chose a 2MHz clock.  I picked the fastest clock that would still fit within the 16bit (65535) limit of the control.  PSoC clocks are derived from system clocks, so you need to pick values easily divided down from them.  The IDE helps with creation of these clocks.  At 2Mhz the period (repeat rate) should be set to 40,000.  The equation is the clock * period(in second) = period counts (2,000,000 counts/sec * 0.02 secs = 40,000 counts).

The CMP Value is how many counts the high pulse should last.  The equation is the same. For 1ms the count would be (2,000,000 cnts/sec * 0.001secs =  2,000 counts) and for 2ms the counts would be 4,000.  The range is 2,000 to 4,000 (2,000 count resolution).  This is better than most hobby servos can do.

The Code

The IDE will generate a bunch of functions, a custom API, for each component used when the application is built. There are two PWM Component functions we need to use for this application .

  • PWM_Servo_Start() This will initialize the component and get it running. This is called once at the beginning of the program.
  • PWM_Servo_WriteCompare(val) This sets the CMP Value that will be used to set the pulse length.

I also wrote a function the can set the value by degrees.

void setServo(float degrees)
{
unsigned int val;
// convert degrees to compare value
// 2000 to 4000 = 0 to 180
// value is
val = (degrees / 180.0 * 2000.0) + 2000;

PWM_Servo_WriteCompare(val);
}

The Results

Here is a screen shot of my logic analyzer. The output was set for 1/2 rotation. The pulse is 1.51ms and the period is 20.14ms.  That is close enough for me.  It is likely the clock speed is different between the PSoC and  and the analyzer.

capture1

 

Typically you will have to tune the to the actual servos used.  Just tweak the endpoint values until you get the rotation you want.

A Line-us Clone

image1

I have been going to the monthly Amp Hour, Hardware Happy Hour meetup.  A lot of people bring something to show.  My projects are too big.  Also, you need to bring your own power.  The meetup standard seems to be running off a USB cord. I was brainstorming ideas, when I saw the Line-us project on Kickstarter. It looked like the perfect size and power. I also love the challenge of non linear kinematics.

8d65c4576042e58c834aa36d1098ceb6_original

I decided to make a clone of it.  I started by importing one if their drawings into CorelDRAW and scaling it up to 1:1.  I then added some measurements.  I rounded them up to 80mm for the pen arm and 30mm and 50mm for the linkages.

measurements

I looked into hobby servos and found that the “mini” size looked about right.  I ordered 4 of them from Amazon.  I made sure to get metal output shafts because I thought I might have to press them into the 3D printed arms.

mini_servo

 

Design

I created a basic design in PTC CREO.  I added a lot of construction sketches for the linkages to help me with the kinematics later.  I downloaded a model of the servo from GrabCAD  to use while I waited the delivery.

design2

I used 3mm bearings for all the joints.  These are pressed into the linkages.  This would allow me to firmly tighten the joints and not have to worry about slop in the joints.

Assembly

When the servos arrived, there were slight differences in from the model.  The mounting holes we much smaller at about 2mm.  I had to reprint with some changes.

My concept was to press the arms onto the servo shafts.  This sort of worked, but after a few crashes, they loosened up.  I ended up using a drop of thick super glue to secure them.  They were able to stall the motor without slipping.  It is important to mount the arms at the precise angle.  I made an Arduino sketch to hold the servo in the precise position while attaching the arms at the angle I wanted.  Each servo has a 180° travel.  The upper arm travels from 135° to negative 45°.  The lower arm travels from 45° to 225°.

Kinematics

In order make the pen go where you want it to go, you have to figure out what angle to set the arms. This is not a simple linear equation. You have to solve a multi-step geometry problem for each new location. I’ll walk you through the basic process. I placed the axis of the two servos at XY 0,0 to simplify things. You know the desired Pen Tip location, so start working back towards the cranks.

  • Step1: Find the Pen A point. You know the lengths of the linkages between the 0,0 point and the pen tip. They are both 50mm. Each arm end has a set of points where it can exist that scribes a circle. If the desired pen point is within reach of the machine, the circles (green ones) will cross at two points. The solution is a well documented process. I used the C code from this page. So far, I found that using the location, of the two, with a higher Y value is the one to use.
  • Step 2: Find the Pen B point. Pen B is easy to find because you now know the slope of the Pen Arm. Multiply the X distance from the pen tip to the Pen A point by the ratio of the length of the pen arm (80mm) over the length of the arm from Pen Tip to Pen A (50mm) and add it to the pen tip. Do the same for the Y axis.
  • Step 3: Now that you know the Pen B location, you can do the intersecting circles (red ones) trick again. This time I used the left most point of the two.
  • Step 4: Find the angles. Use the X and Y distances of the crank tips and the atan function to get the angles. ( angle = atan(deltaY / deltaX) )

Another problem with non linear machines is that moving between two points will not be a straight line. The points will typically be connected with a slightly curved line. You need to constantly recalculate points along the way to keep it straight. If you break a line into smaller segments, the connecting curves also get smaller to the point where they are not notices.

 

 

kin2

Electronics.

Everything I chose was for prototyping ease and probably not the final solution. I used an Arduino UNO as the controller. I used a PCA9685 based servo motor controller for the servo. The Arduino could probably handle it on its own, but the wiring is so clean and simple with this. I used a breadboard power supply to power the servos. It had a handy switch to kill the power to the servos without killing the Arduino.

pca9685-16-channel-12-bit-pwm-servo-driver_1

PowerMBV21

 

The Results

Here is a video of the machine running. The rectangle is hard coded via some for loops recalculating at 1mm increments. The results are shaky, but consistent with the Line-us results. The machine is quite rigid. Most of the shakiness comes from the servo motion. I also do not have the machine held down. If I get some magnets like Line-us, it might help.

image2

Open Source (sorry)

I don’t think it is fair to the Line-us folks to release any files at this time. I think there are plenty of resources in this blog post if you want to clone it yourself. So far I only have about 5-6 hours into the project, so it is pretty a pretty easy project.

The real Line-us looks very polished and they are selling it at a good price. I am sure a lot of the work they did was on the UI, which I did not replicate at all.

Next Steps

I need a way to stream drawing data to the machine. I would like to use g-code. It also needs a UI and I thought Easel might be best. For the gcode I might try hacking Grbl. I would just add a timer that reads the current location at about 5hz, send it through the math and set the servos. Any value above Z 0 would be pen up.

For Easel, I could create a template that shows the usable work area. You would then just click Carve.

 

Firmware

Here is the firmware I used.  It is a quick and dirty port of my PSoC port of Grbl. I cannot give support for this. Only experienced PSoC programmers will be able to install and use this.

Grbl Line-us PSoC Firmware

CAD File

Here is my STEP file of the design. This contains all of the printed parts and some of the hardware.  You will need to figure out a few things on your own.

Line-us Clone STEP File

 

 

 

 

 

 

DIY Jumper Wires

I love using these jumper wires for prototyping. They work great for breadboards and Arduino headers.

You can buy them all over the place including SparkFun.  They are available male/male, male/female and female/female in various lengths.

Sometimes you need to hook up something that already has wires attached. I got these pins and single pin housings from Pololu the other day.

I really like them.  The housing works for either male or female pins.  You can either manually crimp the pins with a needle nose pliers or use a real crimper.  The crimper works for both the male and female pins.

Here are the links to the parts.  If you know of other sources, please add them in the comments.

Male Pins

Female Pins

Single Pin Housing.

Crimpers

Proper use of a crimper is a learned skill.  You need to take the time to learn it.  I lend out my crimpers all the time.  Many people try to use their first attempt in project.  The pin falls off or does not have a connection.  They then give up and use pliers.  The bottom line is there is no better way to put the pin on than a proper set of crimpers.  This is how the professionals do it.  It only takes a few attempts to get it right.  Take the time.

One of the biggest mistakes newbies make is stripping too much insulation.  It is usually just a tiny amount and only the length of the wire barrel portion.  It is very important that the insulation barrel of the crimp grabs onto the insulation.  That is the thing that really holds the pin from being pulled off.

I always buy my crimpers from eBay where they are usually about 25% of retail.  Avoid generic or all purpose crimpers.  Try to get the manufacturers brand.

The crimpers I used are Ampmodu Mod 90418-1.  The can be found used on eBay for around $50.  Pololu suggests you can use this general purpose crimper.  I also have that crimper and it works better than anything you could do by hand, but is no where near as good as the real one.  The 90418-1 has a little “gate” thing that fits between the part the crimps on the insulation vs the part that crimps on the wire.  This allows it to crimp just right on each part and sets the depth of the inserted wire.  It also has two different wire size ranges.You can see this gate in the picture as the shiny bit with the square cuts.

 

 

Pololu Compatible Relay Driver


I just got my production boards for my Pololu compatible relay driver. This is a little plug in module that can be used to drive off board relays. It uses the signals that are normally used for step and direction to control two relays with the voltage that is normally used to power motors.

Pololu stepper drivers are great little items.  They are inexpensive and very easy to use.  You only need a step and direction signal to control them.  If you use them in sockets, as I show here, they are portable between projects and experiments.  If you accidentally smoke one, you only need to replace the single driver.

There are a lot of carrier boards for these.  There are Arduino shields and many other applications.  Often, it would be nice to be able to drive a larger external load like a spindle or blower.  You can then use the existing step and direction signals to drive the relays.  It uses the voltage normally used to drive the motors for the coil voltage.  The only wiring required is two wires to the relay.

I chose to put the relays off board because the real estate was pretty limited and I wanted to provide the voltage isolation for AC powered devices. I am also a big fan of DIN rail mounted relays. They are very reliable and inexpensive. They are easy to swap around and have some nice features. The relays shown have a LED indicator and also a manually test button that moves the contacts. The relays shown are about $10 each, including the DIN rail sockets.

I got the boards from Gold Phoenix in 2 sheets of 50. They were not cut out, only V scored. Fortunately I have access to a depanelizer at work and was able to easily separate them. I probably could have snapped them apart too. The depanelizer looks similar to this one. Two slowly spinning sharp disks chop them apart.

The boards have all the components required to drive the relay including a supression diode. I am using a pretty hefty transistor here, but you could substitute a smaller one.

Schematic (PDF)

Gerber Files

New 3D Printer For Sale

UP! Printer

There is a new additive thermo plastic printer for sale at PP3D.com.  They call it the UP! printer.  They are selling the first 100 units for $1500 USD, then the price goes up to $2990 USD.  They claim a 0.2mm resolution.  The models do look quite good.  There was a video, after the jump.

UP! Printer

Continue reading ‘New 3D Printer For Sale’