Qinsi-QS5100 Sn63Pb37 Solder Profile

About 2 years ago, I bought a Qinsi QS5100 reflow oven from China via Amazon.com.  My decision was based almost completely on the nice youtube video that Ian Lesnet from Dangerous Prototypes posted about his results.  After I got the oven, I successfully built a series of Physics Lab boards with it.  Then one day about a year ago, I got two boards in a row with horrible results which I attributed to the temperature profile.  A few weeks later, I dug around on the internet and decided to change to the Lesnet profile and things seemed to be working again.

I have always had this bouncing around in the back of my head as a potential problem because I wasn’t SURE about the source of my original problem.  And, I don’t really believe in magic, but I didn’t have time to pursue a root cause.  As I have had a little bit of time the last few days, I decided to dig in.  First, I found the data sheet for the Kester solder paste that I have been using.  Here is scan of the printout of a blown up section from the datasheet with my handwritten notes from the Lesnet video (which I incorrectly denote as Sparkfun)

screen-shot-2016-11-27-at-8-41-17-am

In fact in the video Mr. Lesnet shows a screenshot of a solder profile which is similar to the Kester data sheet.  I wondered why he didnt use that profile?

screen-shot-2016-11-27-at-8-57-22-am

I had switched to using the Lesnet profile and was having consistently good results.  However, yesterday I decided that I wanted to compare that program with reality.  I found at least a couple of places on the internet where a comparison of the actual temperature and the programmed temperature were made with a Fluke & Thermocouple.

screen-shot-2016-11-27-at-9-00-03-amscreen-shot-2016-11-27-at-9-01-36-am

In the past I used the Fluke/Thermocouple method as well, but I found it difficult to compare a time based profile with instantaneous readings from the Fluke.  Moreover the numbers that you can read from the Kester data sheet don’t seem to match what you can enter into the QS-5100.  So, what in the world is the oven doing?

What I really wanted was to capture the data in realtime so that I could plot and analyze what the oven was doing.  To do this I used CY8CKIT-025 Precision Temperature Sensor Expansion Board attached to a PSoC5LP CY8CKIT-050 connected to the Bridge Control Panel to capture the actual PCB temperature into an excel file.  The CY8CKIT-025 has a K-Type thermocouple, a DS600 for cold junction compensation, a thermistor, an RTD and a temperature diode.  When paired with the 20-bit ADC in the PSoC5LP you are able to demonstrate a bunch of different methods for measuring temperature.  I used the example project that came with the kit with one modification, the addition of an “EZI2C”.   By putting in an EZI2C I was able to use the Bridge Control Panel to measure the temperature every 100ms and record that data to a file for analysis.  Here are several pictures of the setup:

img_3386

The board on the right side of the CY8CKIT-050 has a little header where you can plug in a miniprog-3 to use as an USB->I2C bridge

img_3390

img_3388

In the picture below, the PCB has been through about 15 reflows (which is why it looks so crappy).  The yellow wires are holding the board and the thermocouple wire in place.

img_3392

The modification that I made to the Cy8CKIT-025 kit example project were

  • Add the EZI2C Component

screen-shot-2016-11-27-at-10-26-23-am

  • Make a floating point buffer and attach it to the I2C

screen-shot-2016-11-27-at-10-27-20-am

  • Save the thermocouple data into the floating point buffer

screen-shot-2016-11-27-at-10-27-34-am

Once that was done, I can start the Bridge Control Panel and set it up to automatically read from the I2C by first setting up the variable tempC, setting up the read and then setting up the 100ms repeat.

screen-shot-2016-11-27-at-10-50-45-am

bcp

Now, I can run the whole thing and view the chart.

bcpgraph

All of the temperature measurement is setup, so I can take some real data.  First I look for repeatability by running a couple of heat cycles.  The oven seems to act the same way every time here is an overlay of the 12th and 13th run.  (bad Alan… label your axis)

data-overlay

And finally we are ready to do a little bit of analysis.  Here is an annotated plot of Run12 which was done with the Lesnet profile:

  • Preheat 150 degrees 60 seconds
  • Heat 180 degrees 58 seconds
  • Solder 210 30 seconds
  • Keep 180 degrees
  • Cool 150 degrees

Based on the graph you can see that the oven seems to have 4 modes:

  1. Heat
  2. Hold
  3. Cool
  4. Cool with fan

In the graph below:

  •  The heater turns on to drive the temperature to the preheat phase (mode 1).  The oven heater appears to be able to raise the temperature linearly at about 1.6 degrees C per second.  Once it gets to the preheat temperature, it try’s to hold the temperature at about 145 degrees for 58 seconds (151-93) in mode 2.  Looking at the graph this section isn’t very flat, so I wonder if there is really a 5th mode?
  • The oven turns on the heater and the temperature ramps up to about 186 degrees (mode 1), which it then attempts to hold for about 60 seconds (mode 2)
  • Then the oven turns on the heater and raises the temperature to about 219 degree (mode 1), which it then holds for about 30 seconds (mode 2)
  • Then the oven lets the temperature drop naturally until it reaches about 180 degrees (mode 3)
  • Then the oven turns on the fans and drives the temperature in a steeper line down to 150 degrees (mode 4)
  • Then the oven turns off the fans and lets the oven cool down (mode 3)

analysis

As far as accuracy goes, the time measurement seems pretty good (one website bitched about this).  With regards to temperature it appears that the oven is a bit low during the preheat phase (which is also not very flat) and is a bit high during the heat and solder phases.  I think that I might lower the heat/solder temperatures a little bit.. 5 degrees?

As far as matching the Kester profile goes, or the the profile on the screenshot that Mr. Lesnet showed in his video, the heat/soak phase the temperature is just a little bit high.  However, he never says that his profile is intended for Sn63Pb37 solder so maybe he was trying to achieve something else (that is what I get for making an assumption).  The profile does however, work very well for me for that solder.  So where does that leave me?

The book that came with the oven (which is obviously translated from Chinese into very funny English) says about the same numbers for the preheat and heat and a bit hotter for the solder.

img_3393

But interestingly, the oven does not come pre-programmed that way for any of the default profiles:

img_3394

The book that came with the oven also has a nice chart with some properties of different alloys of solder.  On that chart it says that the melting point of Sn63Pb37 is 183 degrees. That means that the soak/preheat phase is just below the melting point of the solder.  My best guess it that the spot where the thermocouple measures the temperature-just off of the surface of the board-is actually just touch higher than the actual junction temperature which is why I think that it works.

img_3396

The next real boards that I do I think that I will run an experiment and lower the preheat temperature by 5 degrees.  Unfortunately that still leaves me with the question… why did I have bad solder joints originally?  I think that the answer is old solder paste, but I am not sure that I will ever know.

That is it. While I was looking for information I found a number of resources on the internet to be useful

Link Comment
Ian Lesnet youtube video
Marks Tech Channel teardown of QS-5100 He warns you that a wire isn't connected properly
Kester Datasheet Graph profile on 2nd page of document
Reflow 7 youtube video A sweep of the temperature measured with a multi-meter
Dangerous Prototype Forum discussion a few solder profiles + some proposed modifications
MakeICT scan of QS-5100 manual Just a scan of the manual
An EEVBlog Forum discussion of the QS-5100 A bit of chatter
Despectus blog teardown of QS-5100 A modification of the placement of the thermocouple
Labitat wiki A few different reflow profiles & instructions

Install AMQP + MQTT + RabbitMQ + Docker + Vagrant + VirtualBox

A couple of weeks ago I told you about teaching the first Cypress Academy WICED WiFi class.  In that class, one of the things that I taught people is how to connect a WICED WiFi devkit to the Amazon AWS IOT Cloud using MQTT (which I am going to will publish here).  At the time I was writing the material I wanted to create a “cloud” server that ran on the LAN for the classroom, but there were too many moving parts for me to attack that.  However, the last couple of days I have had some free time so I have gone through all of the steps to create the first part of the Cypress Academy Cloud.  The cloud will have:

  • An RabbitMQ MQTT server
  • An RabbitMQ AMQP server
  • A COAP server (future)
  • An HTTP server

Each of these four protocols are in common use by IoT devices to transfer data to the cloud as they are all lightweight.

In order to simply things, I wanted to run MQTT and AMQP in Docker containers.  And to make matters a bit more fun, on my laptop I only run test stuff inside of a virtual machine (VirtualBox in this case), never on the bare metal.  In order to facilitate the provisioning of the virtual machine I use a tool called Vagrant which can create and configure a virtual machine from a single configuration file called “Vagrantfile”.

Nicholas, my son, always comes in my office and asks “what are you doing”.  I decided years ago to always do my best to answer this question.  On Tuesday, when he asked the question I started talking and quickly realized that this whole thing was a little bit complicated…. well, actually a lot complicated.  So, I did what I always do, drew a picture:

mqtt-network-pic

The get all of this going I:

  1. Install VirtualBox 5.1 on the Mac (Use the simple Mac installer)
  2. Install Vagrant 1.8.7 on the Mac (Use the simple Mac installer)
  3. Create a “Vagrantfile” (by running “vagrant init”) that:
    1. (line 3) Creates a Ubuntu trusty installation in VirtualBox
    2. (lines 5-7) Forwards ports TCP ports 15672, 1883 and 5672
    3. (line 11) Install emacs (which is the best editor)
    4. (lines 12-20) Installs Docker into the Ubuntu 14.04 (Trusty) virtual machine using instructions from the docker website.  There is a vagrant Ubuntu box based on Precise Pangolin 12.04 but the built in kernel does not seem to work with Docker and it wasn’t worth figuring out why/how to fix it.
      1. (line 21-22) Configures Docker to get the RabbitMQ and Management docker images using instructions from the docker rabbitmq website
        1. (line 23) Creates a Docker container called “rabbitmq” and forwards ports 15672, 1883, and 5672
        2. (line 24) Enables the MQTT Plugin
      2. (line 25)Configures Docker to get the NGINX HTTP container
        1. (line 26) Create and run a docker container with NGINX and forward Port 80

screen-shot-2016-11-25-at-9-51-57-am

The networking aspect of this was a bit tricky to understand when I first went through the process.  Docker and VirtualBox both create private networks for the virtual machines/containers to run in.   In order to get from the native Mac –> Ubuntu VirtualBox –> Docker RabbitMQ container you need to setup port forwarding tables.

To test all of this first prove that the NGIX server is working go to http://127.0.0.1:8000

screen-shot-2016-11-25-at-10-16-19-am

And the RabbitMQ Management Console at http://127.0.0.1:15672

screen-shot-2016-11-25-at-10-16-37-am

And test the MQTT server on port 1883 using MQTTBox

screen-shot-2016-11-25-at-10-17-37-am

Eagle PCB Layout Guidelines + OSH Park

Summary of Eagle PCB Layout Guidelines

I typically design my PCB’s in Eagle and have them manufactured at OSH Park.  Each new PCB layout feels like I am starting nearly from scratch because I only do about 1 or 2 boards per year.  Every time, as I go through the process, I promise myself that I am going to write down the list of things that I always need to relearn.  But, I never seem to get the list written down.  Today things change.  Here is my list:

  1. Make sure that you can actually purchase the components you put in your design
  2. No Airwires
  3. Vias tented (or not)
  4. Ideally no more than 2 vias on a net
  5. Power nets > 40mil
  6. Auto router setup
  7. Fill on the ground plane
  8. Ground fill around CapSense Widgets
  9. Test points on key nets – at very least power and ground
  10. Silkscreen font size
  11. Silkscreen labels on key nets
  12. Silkscreen key information onto the board
  13. Put in power supply jumper
  14. If there is I2C then put in a blank header to connect a mini-prog-3
  15. Extend the QFN footprints enough to be able to rework them
  16. Try not to route under QFNs
  17. Try not to use QFN with 0.5mm pitch
  18. Use the eye tool to compare every net in the schematic and layout
  19. DRC
  20. ERC
  21. CAM Job
  22. Don’t forget about the stencil

Make sure that you can actually purchase the components you put in your design

I used a footprint I found on the internet assuming that there was good availability for it.  But, I ended up having to order some weird USB connectors from a salvage shop in Poland.  I guess that I felt lucky to have been able to find them at all.  Unfortunately, I did the whole board and sent it to the shop before I was sure that I could buy everything.  Always always check to make sure you can purchase the device you place on the board.

No Airwires (seems like it would be obvious… but)

Airwires show the connectivity that is drawn in the schematic.  Unfortunately they don’t conduct electricity.  Until a REAL connection is made you will have a yellow flight line connecting between the pins in your layout.  Before you tapeout the board you MUST MUST press the Ratsnest button and get the message “Ratsnest: Nothing to do!”

Eagle PCB message when all connections are made i.e. no airwires exist

If you do this:

An example of an air wire that will make you Eagle PCB not be connected.

Then you will need this:

An example in Eagle PCB of what happens if you leave an airwire unconnected

Vias tented (or not)

A tented via or a plugged via is a connection between the top and bottom of the printed circuit board that is covered with solder mask.  In general there are probably enough vias on your board that if you don’t cover them you will not be able to see the silkscreen (either because it won’t print on copper or because the PCB vendor will trim it).  Here is a picture of one of the versions of Physics Lab where I forgot to tent the vias.  In the upper left where it says “Elkhorn Creek Engineering” you can see that the “l” in Elkhorn and the “g” in Engineering is partially missing where there is a via in the board.

An example of an Eagle PCB with untented vias.  This board was made at OSHPark

In Eagle PCB, Vias (and Pads) are automatically covered with the “tStop” mask.  Here is a screen shot of a PCB that I am working on with just the “Pads”, “Vias” and “tStop” layers shown.  You can see the “big” holes which are Pads for through-hole components.  You can see that they have the diagonal white lines through them that represents the “tStop” mask.  tStop is the mask that prevents the solder mask from being applied.  In the picture you can also see the tStop on places where there are SMD pads.  And, you can see a bunch of the smaller vias which are not covered.

An example of an Eagle PCB with via and stop mask turned on.

To tell Eagle PCB to turn off the tStop for vias you need to change the design rules on the “Tools->DRC->Masks” screen.  The limit parameter tells Eagle PCB to NOT create “tStop” for any via/pad that is less than 30mil in diameter.

Eagle PCB DRC rules screen where tented vias are specified.

No more than 2 vias on a net

I always strive to keep all of the nets on my two layer print circuit boards to have no more than 2 vias.   To look for this I click on the “eye” tool to probe each net of the layout, then I manually trace the net.  Here is a screen shot of a net that I try to avoid.  You can see that the net starts on the SMD pad in the lower right, then winds its way to the top left.  It goes through 4 vias.  Unfortunately it goes through one more via before reaching the SMD pad just below the upper left.

An example of proving a network using the Eagle PCB eye tool to look for more than 2 vias on a net.

Power nets > 40mil

I like the power and ground nets to be routed in at least 40mil wires.  To do this, you first need to create another net class in the “Edit–>Net classes” menu.  I always create a class called “power”.  Then I set the minimum width to 40mil.  If for some reason you want to have a minimum clearance or drill you can set this here as well.  If you leave it at 0,  Eagle PCB will use the default rules.

How to specify 40mil spacing on a power net in Eagle PCB.

After you have created the power net class, you then need to assign the correct nets to the net class.  You do this in the schematic by selecting the “I” tool, then clicking on the net.  Then you can select the “Net Class” for that net.  In this case I am editing the V50 net.

How to attach a signal to a specific net class in Eagle PCB.

Auto Router Setup

I am absolutely terrible at designing PCBs.  This frustrates me to no end.  One of the crutches that I like to use the the Eagle PCB Autorouter.  The only change that I currently make is to use the “*” option to let the router go whatever direction it thinks that it should.

Configuring the Eagle PCB Auto Router.

Fill on the ground plane

To create a ground plan you need to:

  • Draw a “polygon” around your board in the “top and bottom” layers.
  • Attach those polygons to the correct net e.g. “gnd” by typing the “name” command and then clicking on the ground polygon

When you press the “ratsnest” button Eagle will fill the ground plane.

An example of the ground plan pour in Eagle PCB.

If you want it to unpour it you can run “ripup @;”.  When the ground plane is not filled it will appear as a dotted line around the board:

Eagle PCB ground plane pour example

To attach the top and the bottom ground planes together you need to put a via on the correct net.  To do this:

  • Click on the “via”
  • Click where you want it to attach the top and bottom
  • Add to the the right net using the “name” command and then typing the signal name

How to attach a polygon to the ground plan in Eagle PCB.

Ground Fill Around CapSense Widgets

In order to get the best CapSense performance you want to have a “hatched” ground plane surrounding your widgets.  The methods for doing this are documented in the CapSense Design Guideline Section 6.4.9 “Ground Plane”.  Here is an idealized view of the back of the front and back of the board:

PSoC CapSense ground plane

PSoC CapSense ground plane example

The guidelines go on to recommend that you use 25% (7 width 45 spacing) coverage on the top and 17% (7 width 70 spacing) on the back.  To do this in Eagle PCB you draw a normal polygon on the top and bottom.  Then you use the name command to give it the “ground” name.  Then you click the “i” to set the parameters.

  • Set the width to 7 (mil)
  • Set the polygon pour to “hatch”
  • Set the Spacing to 52 (mil).  The only trick is that the Eagle PCB spacing isn’t actually the spacing between the lines but the Pitch between the hatched cells.  So to achieve 45 mil spacing with a 7mil line you need 45+7=52 “spacing”

Specifying the ground plane pour for a PSoC Capsense in Eagle PCB

Test points on key nets – at very least power and ground

It is a serious PITA to debug a board if there is no place to attach test leads.  I like to use a looped wire that you can install onto the board through a PAD.  Here is a red one that I use on power nets that I bought from digikey.com

PCB Probe Point

Silkscreen Font Size (don’t go less than 30mil@15%)

I believe that the best practice for your silkscreen fonts is to first tell Eagle PCB to use “Always vector font” on the “Options–>User Interface” menu.  This will make what you see on the board much closer to what you see on the screen.

Eagle PCB Vector Font

There are two issues with font size.

  • First, what can you see (Im 48… so my fine vision is going away) so I think 30mil is the absolute minimum.  40mil or 50mil is even better.
  • Second, what your PCB design house can print (about 5mil at OSH Park)

I am having my current PCB made at www.oshpark.com.  I could not find their silkscreen spec on their website… but an OSH Park Person “tweeted” that they can print 5mil silkscreen.

Given all of that.  Your best bet is to use a “vector font”.  When you select a vector font, you specify how tall the characters are, and how thick the lines are as a % of the height.  Here is a screenshot of my “SDAT” label.

Creating a silkscreen in Eagle PCB

I made this table of what I think is a safe range:

Eagle PCB Font Size Guidelines

On the the lukemiller.org blog I found a picture of an OSH park board with some different vector combinations:

Example PCB Font Sizes

On the justgeek.de blog I found another board:

Example PCB Font Sizes

Silkscreen on key nets

You should make sure and label every pin that you would need to interact with or debug.  For example, the board below has a place to plug in a miniprog-3 in 5-pin mode:  The connection is directional so labeling the pins is key: [Note: A friend of mine noticed that I labeled the MiniProg-3 connection INCORRECTLY!!!! notice that there are two V50 (when in reality the inboard one is supposed to be ground]

Example of an error in an Eagle PCB Silkscreen

Don’t forget about the back of the board.  If you don’t put labels on the back, you will endup trying to figure out what the holes are (like the ones in the lower right) by flipping the board back and forth.

Example of Eagle PCB Silkscreen

Silkscreen key information onto the board

You should definitely “comment” your board on the silkscreen with at very least:

  • Name of the board
  • Version number of the board
  • Name of the maker e.g. www.iotexpert.com

Key information on Eagle PCB Silkscreen

Put on Power Jumper

You should also put in a 2x100mil spaced jumpers with a 0 ohm resistor shorting them in the path of the power so that you can measure the power supply current.

If there is I2C then put in a blank header to connect a mini-prog-3

If you have an I2C bus in your design, and you have room on the board, you should provide a place to plug in the 5-pin mini-prog3 to help you debug.  This will let you interact with chips on the bus without having completed the firmware for the central MCU.

Cypress Miniprog-3

Extend the QFN footprints enough to be able to rework them

If you extend the edge of a QFN pad by 0.3mm past the edge of the chip, you will have some chance to be able to see that the original reflow worked (or didn’t).  In addition you will give yourself a small chance to be able to rework it with a soldering iron.  For example in the picture below you can see the pin one in from the left has no solder on it.  I was able to successfully rework this pin with a soldering iron.

Eagle PCB QFN Footprint

Try not to route under QFNs

If you have all solder mask under your QFNs it will be much easier to do the original reflow as it will push solder out from under the chip.  On tiny pitch QFNs if you have routing you may end up with a messy blob of solder.  Here is an example of what not to do.

Example Eagle PCB QFN Footprint

Try not to use QFN with 0.5mm pitch

Try to use 0.65mm pitch QFNs as they are much easier to reflow.  If you use 0.5mm pitch QFNs you are going to struggle to get them correct.  If you use a pitch less than 0.5mm then good luck to you.

Use the eye tool to compare the schematic and layout

I always open up the schematic and layout in side by side windows.  Then I click on each device in the schematic and look at the results in the layout.  In the picture below I clicked on “SWCOL2”.  This is called cross probing.  You should look at each net one by one to make sure that nothing funky happened.

Eagle PCB Eye Tool for net cross probing

DRC

The Design Rule Checker (DRC) in Eagle PCB works pretty well.  USE IT.  You can get a rules file from OSH Park (for their two layer process) from their website

You can also use the freedfm.com website to check your files.

Two things that you should be aware of when you run your final DRC.

  1. If you setup a special rule for the power net-clasesses that is greater than the minimum rule you may want to turn it back to the minimum when you run the final DRC.  For example, when I setup the ground layer as a power layer, I set the minimum rule to be 40.  Before I run the final DRC I set it back to 6.
  2. For any polygon that is setup as a pour, you will need to set the minimum width of that polygon to be the same as the minimum for the layer.  For example: the minimum top metal width at OSH park is 6mil.  This means you need to set the minimum width of the ground pour to be 6mil.  Here is a screenshot of the corner of the board:

Eagle PCB DRC

ERC

The Eagle Electrical Rule Checker (ERC) typically catches some problems.  By far my biggest problem with the schematics in Eagle is that I occasionally make two wires “connect” by touching, but Eagle doesn’t think that they are connected.  The ERC seems to catch this problem pretty well.  You should at least run it and go through the errors to make sure that they are false.

CAM Job

In order for OSH Park to make your PCB you need to make Gerber files.  Actually, OSH Park can do that for you, but I recommend you do it for yourself so that you are sure what is going to get made.  Gerber files are the lingua franca of the PCB business.  One file contains one layer for manufacturing, so you will need one file for each layer.

To do maker the Gerbers you need to run the “CAM Processor” which can be found on the tools menu.  I reccomend that you start with a preexisting CAM job (like the one that you can download from OSH Park)

The CAM job will have one “tab” for each layer that it creates.  In the picture below you can see that I am making the Top Silkscreen.  That layer is created by combining “tPlace” and “tNames” onto one layer and then writing it to the file “…/…/…/gerber/.GTO” in the GERBER_RS274X format.

Eagle PCB CAM Job Configuration

The file naming convention is:

File Extension Description
.GTO Top silkscreen
.GTL Top copper
.GBL Bottom copper
.GTP Top Paste (aka the solder paste layer.. you make the solder stencil from this layer)
.GBO Bottom silkscreen
.GTS Top Solder Mask
.GBS Bottom Solder Mask
.TXT Drill file – used for CNC mill that drills the holes in your board.. this is not a Gerber file

After you have the Gerber files you can look at them in gerbv which is an open source tool.

Gerbv Gerber Viewer

Stencils

Lastly, don’t forget your stencil.  I buy mine from www.oshstencils.com which is linked to www.oshpark.com, so you can just select your solder mask from the project that you already uploaded.

Electronica 2016 – The WICED Server

The last three days at Electronica I have been showing people how to build the Robot ARM Controller.  In previous posts I talked about the process for the Servo Motor controller and the CapSense user interface.

image009

In this post I am going to focus on the TCP/IP Server running on the Cypress WICED board.  Remember that this board performs two functions

  1. An I2C Master which writes data to the PSoC Servo Motor Controller
  2. A TCP/IP Server listening on TCP Port 40508.  The command format of the TCP/IP Packet is a 2-digit ASCII coded hex number representing the position of motor 1 followed by a 2-digit ASCII coded hex number for motor 2 e.g 3240 takes motor 1 to 0x32 aka 50% and 0x40 aka 64% for motor 2

The first section of code (lines 11-14) gets things going by starting WICED and attaching to the network.  The next section (lines 16-26) sets up the I2C Master and creates a standard message buffer (called tx_buffer).  Finally on lines 28-30 creates a socket and starts listening to TCP/IP Port 40508.

screen-shot-2016-11-11-at-7-30-38-am

The main loop of my server starts by waiting for a valid active connection (line 34-36).  Then when it gets a valid connection it

  • Line 43: receives the data into a packet
  • Line 45: gets a pointer (rbuffer) to the data in the packet
  • Line 46: translates the ASCII data into integers
  • Line 50: frees the tcp pack
  • Line 52: sends the updated position to the PSoC via I2C

screen-shot-2016-11-11-at-7-35-08-am

All of this source code is posted to the iotexpert GitHub site at git@github.com:iotexpert/E2016RobotArm.git

Electronica 2016 – CY8CKIT-145 User Interface

I finally made it to Munich late yesterday afternoon… then I proceeded to turn my hotel room into an electronics lab as I frantically worked to finish everything for tomorrow.  Earlier this year I wrote a whole series of posts about the PSoC4000S & CY8CKIT-145 after the Embedded World show.  We finally have volume production on the development kit and will be giving them out at the show this week.  So, I decided to use the -145 as part of the user interface for my Electronica project.  The devkit functions as the block labeled “PSoC Capsense”.  The wire between the “PSoC Capsense” and the “WICED WiFi” will be I2C (the green and red wire from the picture below)

electronica-wiced

The -145 devkit has the PSoC4000S silicon on it which has the new mutual capacitance capsense block.  On the devkit, there are three mutual cap buttons and one slider.  Here is a picture of the devkit connected to the WICED WiFi board that I am going to use:

img_3318

I want to make as simple of a PSoC Creator project as I can possibly do as I want to be able to easily do it live.  Here it is:

screen-shot-2016-11-07-at-10-12-23-am

The CapSense block is configured with three mutual cap buttons and 1 self-cap slider:

screen-shot-2016-11-07-at-10-13-54-am

On this development board, the three mutual cap buttons share the same transmit line, so you need to configure the component that way. The screen shot below shows the configuration of the “Button1_Tx” which is set to share the “Button0_Tx”.  You need to make the same setting for “Button2_Tx”.

screen-shot-2016-11-07-at-10-15-34-am

The next step is to assign all of the pins to the proper locations:

screen-shot-2016-11-07-at-10-18-10-am

Finally the smallest amount of firmware that I could think up to hold it all together.

Line 3-6: define a structure that the WICED board will be able to read.  It will represent the position of two of the Servo motors.  The CY_PACKED provides the compiler appropriate key words to make the bytes be right next to each other in the RAM, i.e. not word aligned..

Line 8: initializes both positions to 50%.

Lines 12-17 get the components going

Line 22: Checks to make sure that the CapSense block is not scanning before it reads the results

Line 24: Tells the CapSense block to process the results from the previous scan

Lines 25-31: Looks at the three buttons, sets the LEDs and sets pos1 to be either 25%, 50% or 75%

Line 33: Reads the position of the slider and assigns it to “pos0”

Lines 34-35: Gets the scanning going again

screen-shot-2016-11-07-at-10-21-02-am

To test the system I first used the bridge control panel.  First, connect to the kitprog2.  Then I setup a read from the I2C address (0x08) which is the address of my board.  I then click repeat which runs the read command over and over again.  In the picture below you can see that I tested the three position of the button (25,50 and 75 which are also known as 0x19, 0x32 and 0x4B).  Then I tested the slider by touching it about in the middle (0x3A)

screen-shot-2016-11-07-at-10-31-52-am

The next thing to do was make sure that the WICED devkit could read my I2C slave, so I wrote some WICED firmware to read the I2C registers every 500ms:

screen-shot-2016-11-07-at-10-55-08-am

But, occasionally I  was getting a “read failed”:

screen-shot-2016-11-07-at-10-58-48-am

Last night in my sleep deprived state I was struggling like crazy to figure it out.  This morning after some sleep I realized that the WICED board that I have must not like getting its I2C clock stretched.  So, I changed the priority of the I2C interrupt on the PSoC and that fixed the problem:

screen-shot-2016-11-07-at-10-28-03-am

Keep watching here for more updates on the project.

Electronica 2016 – Servo Motor PWMs

As I talked about in my previous post I am going to use a PSoC as a servo motor controller as well as a CapSense UI.  The problem is that I wanted a really easy way to plug the servo motors into the PSoC.  It seems like all of the servos have a 3 wire interface, Power, Ground and PWM.  Here is a picture that I got from Adafruit’s website.

155-01

I was originally hoping that I could connect that servo directly to the PSoC, drive a ‘1’ to the power and a ‘0’ to the ground and PWM to the third input.  But, it turns out that these things suck some serious juice (100+ma?) so driving the power with the PSoC isn’t in the cards.  Given them amount of time that I had left, there was not time for a custom board, so I was in the situation of using a breadboard with wires all over the place which is ugly and a bit of a pain.  However, on Thursday I thought that I might find a “Servo Shield” and sure enough there are a number of them out there including this one which I got from Adafruit.  The problem is this shield uses a 16 channel I2C –> PWM driver from NXP.  I am not a fan of doing things with peripheral chips that PSoC can do for itself.  But, when I got the shield this morning in the mail there was a cool prototyping area on the shield.  So, I made my own header for connecting to the PSoC.  Here is the front:

img_3309

And here is the back:

img_3308

You can see that I shorted the whole row of ground together with a big blog of solder and wire.  I did the same thing with the power (the middle row).  Then I made a wire from each of the 4 PWMs pins to a good place on the PSoC (which I could drive the pins directly from one of the TCPWMs)

img_3300

The board worked great on my bench.  The only thing that I have done which is VERY questionable is that I wired the power supply for the system directly to the V5.0 aka VBUS… which I suppose will get me through the conference, but is probably a bad idea (the green wire in the top picture)

As I was flying to Detroit I thought that I might try to see how the I2C->PWM worked… so I read the data sheet for the NXP PCA9685.  It turns out that the chip is pretty cool.  You can set the output frequency by setting a divider value in one of the registers (oxFE).  The number you set is val=round(25e6/(4096*rate)) – 1.  That means for me to get 50hz to drive the motors I need to set the divider to 121.  Then to set the duty cycle each output has a 12-bit PWM where you can set “LED ON” and a “LED Off” count.  For instance to get a 25% duty cycle you can set the On to 0 and the off to 1024.

After I got off the airplane in Detroit I went to get some “dinner” and I wanted to try out the shield so I hooked it up:

img_3304

You always get a bunch of funny looks in the airport when your table looks like this:

img_3310This left me with only one problem.  How to drive the shield PWMs onto something that I could see… I didnt pack my Tek in my carry on (though I suppose I could have used one of those little scopes).  But, I digress.  What I decided to do is make the PSoC echo an input onto on output pin that was connected to an LED.  So, I drew this schematic.  This can only be done in with a PSoC because I used a logic gate in the UDB to flip the 9685 PWM from Low to High so that my active low LED would work right.

screen-shot-2016-11-05-at-8-02-36-pm

Next I fly to Charles De Gaul, the suckiest airport in the first world.  What will I do on the airplane there?  I don’t, but given those empty beer glasses I may sleep.  More to follow when I get to Germany.

Electronica + WICED + The Robot Arm

The good news is that the Robot Arm arrived from Amazon, which I was very happy about because it was a day late.  The even better news is that it works like a charm.  First I needed to assemble it, which I did with a little bit of help from my able lab technician and a trip to Lowe’s to get a base.

img_0003

Then “we” attached the base to the Robot.

img_0008

After the robot arm was put together on the base, I needed a little bit of firmware to run it.  First the schematic:  You can see that I have

  1. Two PWMs – one for each Servo motor
  2. A Capsense slider to move one of the axis on the robot
  3. A switch and LED to turn On/Off the PWMs

screen-shot-2016-11-05-at-7-04-50-am

The robot arm has 4 “axis” which are each controlled by “servo” motors.  Servo motors have a small controller built into them that takes an input signal that is created by a PWM and turns the motor to the right place.  To drive the motor you need a input signal that is 50HZ, with a high pulse that ranges from ABOUT 1ms to 2ms.  When the pulse is 1ms the motor is all the way one direction, when the pulse is 2ms it is all the way the other direction.  To make the motor do what you want you give it a pulse somewhere in the middle, for instance if you want it to be half way then the pulse width is 1.5ms.

The easiest way to make this work is with a Pulse Width Modulator (PWM).  Conveniently enough, the PSoC4 BLE that I am using to build this project has 4 of them.  I set the input clock on the PWM to 12MHz, then I turned on the prescaler to divide by 4.  I then set the period to 60000.  Given all of that, the output frequency is 50hz.  which you can calculate by 12,000,000 / 4 / 60,000 = 50.  Given the period is 50HZ and there are 60000 clock ticks per period, each tick is 3us.  To make things easier on the rest of the system I want to give the input a range between 0% and 100% (as an Integer).  This lets me calculate the number of ticks I need to set the pulse width.  The formula is 3*(1000 + 10*percent).  I determined this empirically with an oscilloscope and changing the values to see the range of motion of the Robot Arm.

img_0012 img_0013

To achieve all of this, the PWM configuration is:

screen-shot-2016-11-04-at-7-49-33-pm

Now I configure the CapSense block to have a linear slider.

screen-shot-2016-11-04-at-7-52-55-pm

Finally I assign the pins:

screen-shot-2016-11-05-at-7-11-02-am

And a little bit of firmware:

Line 4 is a #define macro that calculate the correct compare value for the PWM.  After a little bit of experimenting with the Robot I figured out that it really wants the PWM to range between 800 microseconds and 1.8 milliseconds.

Line 5-7 initialize the original position of the PWM

Line 15-19 and 19-23 are helper functions which just turn on and off the PWMs.

Line 25-34 is an interrupt handler that is trigger when the user presses the switch.  It toggles a global state variable, turns on or off the PWMs and turns on/off the led.

In main I get things going on lines 38-43.  Then start an infinite loop that reads the capsense, and if the value is set then I set the value for the PWMs.  Remember that the capsense slider returns a value 0-100 so I can use it directly.

screen-shot-2016-11-05-at-7-03-25-am

After all of that my lab technician once again test it:

Electronica & WICED & PSoC

I am headed to Electronica in Munich tomorrow.  Cypress has a maker space in our booth where I will be teaching people how to use our products.  For some reason they always give me a microphone which seems crazy given that I am a bit wild.  The last show or two I have done demos using PSoC BLE.  This time I thought that I would also add WICED to the mix… so what is it going to be?

I saw this video on the Amazon AWS IOT website where their CTO introduces the AWS IOT platform by showing a demo of a robot arm.  The arm is connected to the AWS IoT Cloud (in some magic way) and is controlled by a Leap Motion controller connected to the cloud (also magic).  I hope that both of them were connected using WICED WiFi… but who knows since de didn’t show what was up his sleeves.

I thought that was really lame that he just magically brought the robot arm and controller from under the table and didn’t actually show you how to make it.  I am not really into doing things half ass and I don’t believe in magic, so what I am going to do is show people how to actually build that… live… Ginsu Knife Tiger Style

No magic, other than the magic of PSoC and WICED.  So, the day before yesterday I ordered what I think is the same robot arm… and now I need to write a little bit of firmware.  This is what I am going to build:

electronica-wiced

The only thing that I am a little bit worried about is getting to the Amazon Cloud from the LTE router in an high radio traffic environment of an electronics show… If that turns out to be a problem then Ill have to figure something else out… which will make life interesting.

Over the several days Ill post the firmware and pictures as I get it sorted out.

Alan