Saturday, December 31, 2011

PSoC3 Custom Board - Soldering the chip

For any first timers that stumbled onto this post,the chip here refers to a 48 pin SSOP package with a 0.635mm(25mils) pin pitch.

Things didnt go that well on the first board I tried out,mainly due to me using the wrong type of tip.After this,I was able to use sharper tip (from my brother,all credits to him.),which did the trick and I was able to do chips with little effort.The equipment and sequence of events that worked for me,in order are as below.The method I describe below is inspired from this post by Arup Basak of CircuitsDIY ,so credits to him :-).

Equipment Used:
1.Any cheaply available 1mm solder wire,(don't recall the price,bought this last year)
2.Liquid Flux,I used a locally available liquid flux,its a pinkish liquid in an unmarked dropper bottle.
(A 30ml bottle cost me Rs.10)
3.A chisel tip and a sharp pin like tip for your iron,(Soldron tips cost me around Rs.40 per tip,a few months ago.)
4.The soldering iron itself.Many claim that cheap 25-30W irons that connect directly to your AC mains supply wouldn't be used for SMD work,but that is all I had around,so that is what I used.It is a 25W one from Soldron,the most common one you'll see in India.
5.Solder wick(Rs.10 for a 1m roll)
6.Patience,which is extremely critical for this number of pins and fine pitch we are working with here.


1.Flux the pads.

2.Use a chisel tipped soldering iron and 'relay' solder onto it.What I mean is,no applying solder directly to the pads,rather melt some solder onto the tip and then lightly pass the thick(relatively) tip lightly over 5-8 pins,applying solder this way.The ideal height would be where only the solder blob grazes the pins,getting consumed while you pass it over the pins.

3.After you're done adding solder to the pads this way,align the chip and use some means to hold it in place while you solder the pins.Many people use Kapton Tape,or let the viscous flux do that,but I just held it down with my index and forefinger.

4.While you make sure its aligned,come in with a sharp tipped iron and solder the 4 corner pins,in the order of top left,top right,bottom left and finally bottom right.When I write solder,I mean, NO SOLDER on the tip.Clean your tip and just touch the pins to melt the solder on the pads into a nice union of pin and pad.DO NOT keep your iron there for more than 2 seconds,or come in for consecutive 'tacks' on the same pin,doubting the joint or just wanting to make it look shinier(the pad(s) will overheat,and you will cause it to come off),you could wreck your PCB.Solder each of the 48 pins this way.

5.After you've patiently done one row of 24 pins,flip it around,do the other row and then test the pins' joints by prodding them individually with sharp forceps(I use the kind used for dissection of lab animals).

In case you get solder bridges between pins (which you wont,if you follow the no-solder-on-tip-while-tacking-pins very strictly) use the solder-wick,but don't keep your iron there for more than a second or two,since the tracks there will be fine,and can come off.That is how I made those 2 mistakes earlier.

Here are some pics of my end result:

I have currently populated all the parts I have,so progress will pause on this till I get more parts from local dealers+KitsNSpares.

PSoC3 Custom Board - What next?

While development on this is underway,I've been thinking of the future of this project.
The initial goal I set out with,was to provide easy access to the PSoC3 platform to students and hobbyists,at a low price.
Though this sounds good,I'm not so sure now.There are a number of issues to do with the design(?),fabrication and parts sourcing that I'm concerned about.

The Design:
-I've missed 1uF storage caps at 2 places,but I'm hoping that isnt a deal breaker.
-Theres going to be a change in the USB connector,towards a miniusb type instead of the current one..(for sure in the future revisions)
-I guess this list shall extend as I test this further..

-The current deal I have is just too costly.The way ahead on this front would mostly be engaging the services of either SeeedStudio's Fusion Service or ITead's OpenPCB,both giving me 10 5cmX5cm boards for a total of around USD 14(incl. shipping),excluding the import duty I might have to pay.
-Theres another option here,the SeeedStudio Propagate service,which is board fabrication+assembly,with a minimum order of 100 boards.

Parts Sourcing:
-Currently,I'm using chips I got as free samples from Cypress.The price listed on the chip's page is almost USD 20,with an MOQ of 60,which screws up everything to do with "low cost".
-Other parts(SMD passives mainly)can be taken care of by ordering in larger quantities (MOQ is 100 on most smd parts at locally),and again not a problem if I'm using the Propagate service.

Now the real question and answer to the above doubts and concerns is,"Does anyone even want to buy this?".Since,if there is a market out there for these,then things move to a different scale and the above issues can be resolved.
If not,then the project ends as a very enriching academic pursuit.

PSoC3 Custom Board - Burnt Tracks

I've populated the chip on 4/5 boards,with some issues(fine tracks came off on 2 boards) like I mentioned in the last post.Its immaterial if its my fault or the board quality wasn't up to the mark,or the iron overheated,since the end result is the same and irreversible.Well,I guess thats how we learn best,by failing.
Heres one of those cases.

I dont have any solvent to clean up that fluxy mess,need to get some.Worst part is,those two wrecked tracks are SWDIO and SWDCK,the 2 main programming lines.Thats bad,but not a big concern since the USB lines are alternatives that I still have(P15[7] is D- and SWDCK,and D+ is SWDIO).But that will need me to solder in wires temporarily to get the bootloader in.Oh well,its not a perfect world anyway.

PSoC3 Custom Board - First Pictures

After a long wait,the boards are finally in!
Here are a few pics:
Top Copper

Top Copper
Bottom Copper

I ordered 5 of these for a total price of INR 1100.I've started populating the other 4 boards,leaving this one for the pics.
A few issues,
1.I shouldve got soldermask done too.
   But then I was told that the setup cost would be ~INR 1000,so it was a no-go.
2.I shouldve used a temperature controlled thin tip iron.
   Well,what happened was,the iron overheated at one point,and burnt out a few tracks(completely,so they came off) on 2 boards,so I've lost those tracks.I'm really pissed with myself about that.

More pics as I continue working on them!

Sunday, December 25, 2011

TMP105 - Tiny!

Another temperature sensor from the bunch of TI samples I recently acquired from a friend,is the TMP105.
From the datasheet(PDF),
"The TMP105 is a two-wire, serial output temperature sensor available in a WCSP package. Requiring no external components, the TMP105 is capable of reading temperatures with a resolution of 0.0625°C. The TMP105 features a Two-Wire interface that is SMBus-compatible, with the TMP105 allowing up to two devices on one bus. The TMP105 features an SMBus Alert function.The TMP105 is specified for operation over a temperature range of –40°C to +125°C."

0.0625°C! woah,thats precise great resolution,but accuracy is an okay 2°C. Anyway,the package I have it in,is a 6-BGA.Tiny is the new large,with this.Heres a picture to amplify that statement.

It has many neat features,but I guess I'll have to wait till I get a reflow oven.

TMP20 and the PSoC3 - Part 2

Like I said,the idea is to build an analog temperature switch.While I want to use DMA some how,all an analog temperature switch needs is a comparator,and a VDAC(Calibrated ofcourse) to provide the analog value to compare with.
But a few ideas that can be introduced into this simple design are:
1.Capacitive touch based interface to set the switching temperature.
2.Temperature Tracking(via DMA?,or interrupts?) of minimum,maximum etc.
The words,'Analog Temperature Switch' bring PID among many other control features to mind,but I'm a little unclear on how I would implement such a system.I mean,setting up a hot plate,a temperature sensor and a PSoC3 wired to do PID control isnt the best thing to have on my study table.

I'll add more ideas and functionality to this as I go along designing it.

TMP20 and the PSoC3 - Part 1

Another part from the same TI samples bunch,the TMP20.
From the datasheet(PDF),
"The TMP20 is a CMOS, precision analog output temperature sensor available in the tiny SOT563. The TMP20 operates from –55°C to +130°C on a supply voltage of 2.7V to 5.5V with a supply current of 4μA. Operation as low as 1.8V is possible for temperatures between +15°C and +130°C. The
linear transfer function has a slope of –11.77mV/°C  and has an output voltage of 1.8639V (typ) at 0°C. The TMP20 has a ±2.5°C accuracy across the entire specified temperature range of –55°C to +130°C."

You may check out this video from UniTI on the same sensor.Cool.

Here is a pic of the chip(in an SC70-5 pack) soldered on a standard 0.1" strip board for prototyping.

And heres another pic with the concerned pins marked.
The idea here will be to build an Analog Temperature switch,using of course,only hardware(its the PSoC 3 after all.) and also an implementation of ADC buffering via DMA.Thats something which has been on my to-explore list,since quite some time since DMA is something new(for me),compared to the usual SPI,I2C,ADC etc blocks that I have used on other controllers as well.
I'll work on this and write another post as soon as that is complete.

Friday, December 23, 2011

PSoC3 and the TMP141 - Part 3

So if you've been following these few posts(Part 1,Part 2) on the TMP141 sensor,you'll know I had some problems with read/write ops,and then fixed those too.
Heres a picture of my working setup,before I go further:

Back to the topic.With 16bit reads fixed,I went on to parity calculations and the write functions.

Now,the transmission on the SensePath Bus uses EP(Even Parity),i.e there is an Even Parity bit sent by the master to the slave during write operations,and vice versa during reads.There are many ways to do Parity computations,the one I implemented takes 2 machine cycles only(but is specific to C51 systems.It can be implemented in a similar way on others too,I think.)
Say we want to calculate the parity of a byte of data,all we need to do is load it into the Accumulator Register and then check the P flag.What does that mean in code? Well,just one line:
uint8 parity=(ACC=DataByte,P);               ....Cool,eh?
After implementing the required parity calculations in this way,and confirming that implementation with success in reads,both 8 and 16bit,I moved onto the write functions.

The 8 and 16bit write functions aren't too complex either.One must remember that data is transmitted MSB first(irrespective of who is transmitting it,slave(s) or master(s) ).So you shift the data out,MSB first,bit by bit.
Similar EP calculations are involved in write transactions also,which include the device address,register address,R/W# flag,and data payload,8 or 16bit,as the case may be.

With the basic structure now in place,the setup and config is just 3 lines of code.You need to enable the sensor by setting the 'ENAB' bit in register 0x05(Device Control Register).Even 'EN_S' bit in register 0x0A(Temp. Control Register) needs to be set to start conversions.Lastly,set the conversion rate by writing the appropriate values to register 0x20(Conversion Rate).After wrapping these lines between curly brackets,TMP141_Start() is what I called this part.Returning the OR-ed the return values on all the 3 write operations helps the caller track the errors(if any) during the data transmission.

Reading Temperature is what comes next,where we need wait for SF1 bit in Register 0x04(Status) to become '1',indicating completion of a conversion.Once that is set,we swoop in and read off the temperature in 16 bit glory from register 0x09,and process those to get a commonly understandable temperature value in degrees Celsius.

So looking that,if we got 0x1B80,that'd come to a pleasant 27.5°C.Try it.
Note that negative temperature values are in 2's complement,so do the needful if you're expecting those.

I wrote some demo code comprising of an ID check and then continuous polling and display of temperature.This demo code uses functions from TMP141.h,which can easily be ported to other platforms as well.

This code was tested on the CY8CKIT-030,and was written in PSoC Creator 2.0.
Heres what the top design view looks like:
You can find the code in my 4shared account,linked here.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Drop a line in the comments for any clarifications.

Thursday, December 22, 2011

PSoC3 Custom Board - The gerbers are in!

I recently recieved the gerbers for my board,and they look great! I expect the boards soon(within a day or two now).I dont have all the components I need,but enough to test the board.
I'm currently missing the LEDs,the USB connector,22ohm resistors(why does no one keep these locally?),the 1117 and 1uF caps.I know,I have very little of the BOM.Its partly because I'm anxious to see how this goes,and only then invest more of my tiny hobby budget .Plus these parts werent available a few days ago,when I went parts hunting.
I'm putting up pictures of the gerbs below:
Top Copper:
..and heres the bottom layer
I used the free online gerber viewer at CircuitPeople,which works great.If you want to see the whole deal(with the excellon drill data superimposed,try the viewer here.)
Feel free to contact me for the files,incase youre interested in taking a stab at fabricating them.

Wednesday, December 21, 2011

PSoC3 and the TMP141 - Part 2

(Click the links to goto Part 1 and Part 3.)
Good news,I figured out the 16bit reads too! :-)
Now,I dont know why the previous code didnt give me the expected output,but heres what works:
So yeah,thats 2 8-bit reads,with their results combined into a 16bit result.
Now that these are working,I'll go onto Parity Calculations to wind up the read functions in their entirety.
More Explanation and Code as soon as I finish this baby.  Read Part 3 for the conclusion and source files.

PSoC3 and the TMP141 - Part 1

(Click the links to goto Part 2 and Part 3)
A friend recently gave me some TI chips,he'd sampled a long time ago.One of these,was the TMP141.I decided to give it a spin with the PSoC3.

Heres more on it from its datasheet(PDF),
"The TMP141 is a digital output temperature sensor that utilizes the single-wire SensorPath interface. The TMP141 is capable of measuring temperatures within 2°C of accuracy over a temperature range of −25°C to +85°C and 3°C of accuracy over −40°C to +125°C. Low supply current, and a supply range from 2.7V to 5.5V, make the TMP141 an excellent candidate for a wide range of low-power applications. The TMP141 is available in SOT23-6 and MSOP-8 packages."

The samples he had were in SOT23-6,so it was only either of 2 roads,either develop a PCB/ Breakout Board for it,or use the handy wiring pen.(While this is a popular instrument listed at various places,heres where I came across it first.)

So the wiring pen I chose,and after some careful soldering,in "dead-bug" position,heres what I made:
With this done,I wired it according to the reference schematic with the required pullup and the optional 0.1uF bypass cap,as below:

Before I talk about the code,heres a bit about the interface.The datasheet provides a good explanation about the "SWD - Single-Wire Data" Bus used here,(which is very similar to the 1-Wire Interface from Dallas).Typical one-master-many-slaves-sharing-the-same-data-line type of topology.

Data  needs to be bit-banged,by pulling the line down for varying intervals of time.So here is a quick explanation of a Bit Read and Bit Write on this bus.

  • Bit Write(by Master):
    • Delay for 11us(thats the time the bus should be inactive between signals)
    • if a '1' has to be written,the master should hold the line low for ~42us.(this time is tMtr1 in the datasheet)
    • Or,if a '0' has to be written,the master should hold the line low for ~15us(this time is tMtr0 in the datasheet)
    • After the relevant time(either of  tMtr1 or  tMtr0 depending on what was "written")  has elapsed,the Master should set the line back high.
  • Bit Read(by Master):
    • Again,Delay for 11us(thats the time the bus should be inactive between signals)
    • The master should write a  '0' (as per above timing,irrespective of the data to be read),and there can be 2 cases after this.
      • Case 1: If the Slave wants to send the master a '0',it doesn't change the bus state,after its "realization" (of the bus having been pulled down) time of a maximum of 9.6us.So the master is supposed to check the bus state after it has finished writing the  '0' ,and if its high,implies that the slave did not change the bus state,and wanted to send a  '0' ,so a  '0' is said to have been "read" by the master.
      • Case 2:  If the Slave wants to send the master a 1,within 9.6us of the bus being pulled down,the slave acts and decides to keep the bus down for a time of tMtr1,or ~42us.
    • So,the scheme I thought of to read a bit,was to do a TMP141_BitWrite(0); so that a  '0'  is written to the bus(slave?),and then right after this call,check the status of the bus.If it is high,implies that the slave did not touch the bus state,and wanted to send us a  '0' .If the bus is low, that implies its being held down(for a time of tMtr1,or ~42us) by the slave who is doing so to indicate a '1'.
So,once the bit read and write functions are in,we can look at complete data transactions,as listed on Page 9 of the datasheet.I wont write more about those here,since the datasheet mentions the required details clearly enough.

So I wrote code to do 8-bit reads,and 16-bit reads.Heres the funny part.
While I can read 8bit registers flawlessly(i.e the expected defaults are read in consistently),the 16bit registers are giving me a headache.

If I do a 16bit read,on register address 0x01(Manufacturer ID- Expected 0x104C),all I get is 0x004C.Similarly,if I do a 16bit read on register address 0x08(Temp. Capabilities - Expected 0x014A),what I get is 0x004A.Where is half my data going?

But wait,there is more.If I do an 8bit read on a 16 bit register,like on register address 0x01(Manufacturer ID- Expected 0x104C),I do get the elusive 0x10.

It cant be an issue of the wrong drive mode(currently is Hi-Z),or pull-up resistor,since the 8bit reads come in with no issues at all.Also,since the 16bit and 8bit read functions use the same underlying Bit Read/Write functions,they cant be bad either.So whats going wrong?

I'll post as soon as I crack this mystery. Mystery solved.See Part-2 of this post.

Tuesday, December 13, 2011

PSoC3 - HH10 Humidity Sensor

I got a chance to work with the HH10D humidity sensor(sparkfun link)recently,as part of a greenhouse control system,to be implemented on the PSoC3(using the CY8CKIT-001).

From the datasheet(PDF),
"The HH10D relative humidity sensor module is comprised with a capacitive type humidity sensor, a CMOS capacitor to frequency converter and an EEPROM used to holding the calibration factors."

So,the code basically has to,
  1. Read the calibration factors from the I2C EEPROM,
  2. Sense the Frequency being output by the sensor,
  3. Use the data from 1. and 2. to calculate Relative Humidity using the formula given in the datasheet,RH=(offset-Soh)*sens/2^12,where offset and sens are 16bit calibration constants read in step 1,and Soh is the frequency output read in step 2.
(I'll be writing a separate post on the common application of Frequency Measurement,soon.)

This code was tested on the CY8CKIT-001,and was written in PSoC Creator 2.0.

Heres what the top design view looks like:

You can find the code in my 4shared account,linked here.

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

PSoC3 - Basic UART

A friend requested some code to get a basic UART setup a few weeks ago,(with Interrupts on RX.) running on the PSoC3(using the CY8CKIT-001).I wrote out some code for her and below is the top design view:

Note that the code was written in PSoC Creator 2.0.
You can find the code in my 4shared account,linked here.

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

Saturday, December 10, 2011

PSoC3 Custom Board - USB Routing and Crystals

Its been some time since I posted about the above titled project,so heres the latest:

With the layout close to satisfaction,things finally seemed to be heading for a fabrication order.So far,all the thought that had gone toward the USB signals was only to keep 'em differentially routed.Turns out,its much more than that.I went through the USB design guidelines from and found that my USB design lacked a fair bit.
Theres a handy checklist at the end(Page 17/19) of that PDF,which gives you clear points that you should evaluate your design on.Two main points I found for my design were,
  • Crystal being too close to USB lines:Infact,they were almost under the crystal,(if there would be a crystal soldered in )so this would cause issues for the high speed(yes,I know the PSoC3 USB module is Full Speed,not High Speed.) D+,D- data lines.
    • So this would definitely need some change.Based on the recommendation from the Design Engineers(at Cypress) I was in contact with on this,I decided to swap the crystal and its load capacitor setup for a SMD resonator from Murata,(specifically this one).Element14 India showed its cost to be a mere INR 7,so I happily made the consequent changes. 
    • Problem with this was,Element14(in India) doesn't directly sell to consumers,but does so via KitsNSpares,which unfortunately does not carry this part.I knew it was too good(and tiny!) to be true.
    • I referred to the existing board designs,and there was one thing I noticed across all those,was the absence of an external crystal (Except the CY8CKIT-030). Now,for accurate digital clocking a crystal is definitely recommended,but the PSoC3's internal clocking is robust enough for USB,and since this is for student and hobby level projects/learning,(and not meant to be designed into the next scope from Tektronix,I decided to skip the crystal totally.)
    • So,before I talk about the next point,conclusion is,No external crystal.That said,I have kept a 3 pin through hole resonator on the board instead,but that not intended for active use(atleast as of now),just to satisfy my curiosity on the 'what if..' of its presence.
  •  Ground Planes and Impedance of the USB lines:
    • The USB spec recommends 90 ohm differential impedance(+/-15%),and also a continuous ground plane beneath the data lines.My design didnt have either.
    • I hunted around for some impedance calculators to estimate those values for my traces,but couldn't get very far with this,since I don't know much about the board's physical conditions,and even trying out "working configurations"(7.5mil width seperated by 7.5mil,as I read someplace..) didnt give expected values.Looking back to existing USB based boards and designs,I noticed very few seemed to worry about USB routing guidelines.I wont name examples here,but for a particular case,I was surprised it worked,since it violated a lot many of these guidelines.But it works,and very well.So I'm gonna cross my fingers and let the design fix itself.Kidding,but in my case,not only are the traces short,and stay on the same layer,with a continuous ground plane beneath,with little high frequency noise,so I assume it should work out okay.
    • For the requirement of a continuous power plane beneath the data lines,I ripped out the traces to P12[0] and P12[1],sacrificing them for better(?) USB performance.
So that was a quick look into the recent changes on this board.

There is still a lot that can be changed and made tinier,but the current decisions in parts and their packages are made on the basis of my confidence in their local availability.As I hit the streets for parts soon,I hope to broaden my know of the components available,so I can incorporate them into future changes.
If you have affordable access(read no shipping or heavy import duties) from parts sourced from places like Mouser,Digi-key etc,feel free to use that luxury to better this board's design and layout.

Here are the latest files,linked over from the forum post at

Friday, December 2, 2011

PSoC3 Custom Board - Improved

I was fortunate enough to get a few tips and suggestions from the gurus at Cypress who created the CY8CKIT-030(High Precision Analog being one of its key features),which is an epitome of top class design,for me.So,to have my board reviewed by them really thrilled me.

I have tried to incorporate their suggestions,and heres the latest batch of changes:

--Added additional vias between the top and bottom layers to improve return paths.
--Crystal routing improved(Capacitors on same side,traces shorter).
--Added reverse polarity protection diode across Unregulated DC Input(VIN).
--Added Fuse to USB supply.
--Added LED for Bootloader Status.
--Widened Power tracks for better stability.
--Differential Routing for SWD and USB tracks.
--Changed back to Type B USB connector,easier to solder.

And here are the design files(linked up from my post at DangerousPrototypes).

Back to exam prep.