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.

Tuesday, November 29, 2011

Exams again.

I have many posts to publish here from November,but exams are fast closing in,so the blog will be inactive till December 12th.

Current Status on the PSoC3 Board,as of 28th is :
-Pricing for prototype batch finalized
-Payment pending.
-Fixed an important bug in the Power section(thanks,radner!) and added a few cosmetic changes to the board's silkscreen.

Sunday, November 20, 2011

PSoC3 Custom Board - Redone

Even though it was good and all,I wasnt satisfied with the initial design.And the power section in my opinion was just rubbish.I ripped up the whole PCB,and started designing from scratch,adding a few things here and there.

Notable inclusions are that of a watch crystal(for the RTC) and a 24Mhz crystal for the chip.I've also taken care this time around to make it breadboard pluginable and done some tighter placement.Final board dimensions are at 2.1"x2.2",from the previously 3x3,so thats good.

I spent a lot of time trying to think of some simple power setups for this board which would be foolproof.Trying to implement my lofty goals,I realized that the routing was getting really messy.So in the end,just went with a simple one, 5V,3.3V select and 3.3V source(USB or DC IN) select.So yeah,you cant run the board off a DC supply at 5V.I could've added a pin or something to allow that,but I don't want unregulated input to the board.(adding another regulator was getting messy)Thats just shabby design.Actually,there is a way to have unregulated input with this board too,just connect the +ve to the central pin on the logic level select jumper,and tie the grounds,ofcourse.

So heres what it looks like

 click for a full size version

Just an after thought,I could probably add a receptacle for a 16x2 LCD too.But then those are usually only good for 5V.

I have a few more cosmetic changes planned,so will do those and post the files soon.

Sunday, November 6, 2011

24LC512 with PSoC3

Carrying over from the previous post,It was natural expected behavior that I was looking at,but the issue was elsewhere,and I quickly rectified it.

I implemented the Random Read,Sequential Read and Current Read functions,as well as the Page Write and Byte Write ones.I've packed all those into a header file,and written a small demo routine that tests all those functions.

Currently the code is kind of dumb,i.e it assumes (and doesnt check for the chip) EEPROM's presence.I'll add that soon too.

I'll add more details(schematics and code explanation) 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.

YSI 44006 Thermistor with the PSoC3

This is a brief account of how I interfaced the YSI 44006 Precision Thermistor,with the PSoC3.
I wont go into what they are,their functional description etc,since thats already very well written,here.

Going with the Steinhart-Hart Equation,I needed the constants A,B and C for this model.I found these here.The thermistor also came with a roll of paper bearing a large table of R v/s T values,which I could've used and solved 3 simultaneous equations(in MATLAB of-course.) and got A,B,C,and they are

 A = 1.025227462259867e-03;
 B = 2.397895314112997e-04;
 C = 1.539983937555444e-07;

Once these were in order,it was a simple matter of rigging up a Delta Sigma ADC for input,and a Character LCD for output.Using a 10k resistor it was wired as here.I used sprintf to format the output for display on the LCD.

The code isn't very robust,i.e doesn't use any averaging or advanced sampling techniques,so the temperature does jump about a bit.I'll try and implement those in my next session.

Code will be up soon.
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.

Saturday, November 5, 2011

24LC512 with the PSoC3 - PageWrite Problems

So I had this I2C EEPROM from Microchip,the 24LC512 lying around(must've sampled it ages ago,don't recall..) and decided to give it a go with the PSoC3.

I'll be posting all the code with schematics once I'm done.(on my new github repo :) )

I got the ByteRead and ByteWrite working fine in an hour after some tweaking(this is my first encounter with I2C),but the PageWrite stuff is not going that smoothly.I mean,I've defined the function such,

uint8 EEPROM_WritePage(uint8 SlaveAddress, int wAddress, uint8 *wData);

So,the wData is basically an Array that will be passed to the function,who'll use it further.And heres how I've called it.


Where SLAVE_ADDR has been given a value already,(0x50) and TxData is defined as uint8 TxData[128] and then populated with a for loop,for writing purposes.Ideally,the function should take in TxData as a pointer to TxData[0] and then the code uses that further.But in my case,the function refuses to see the data.
Heres a screenshot of what I mean:

This is a view of the Locals window,while stepping through.As you can see,the other variables(SlaveAddress and wAddress) have taken on the values,but wData is still some nonsense.

I dont know whats going off.

I think I might be stepping into some interesting territory here..

Update: Could it be because of the array being stored in External RAM(XDATA) ? I'll need to explore that.
Update(next morning): Stupid Mistake on my end.Hmm,I guess that is how we learn.
                                      Implemented All Read and Write Functions,will put up the code soon.

Thursday, November 3, 2011

Labview for Engineers

NI Labview's a great software package and in many respects considered better than its more established(among students specifically) rival MATLAB.But there seem to be fewer free resources to learn this and maybe thats why its lesser used.Or maybe I'm just wrong.

To get into this exciting world of Labview,I'm currently reading (& practicing) this book,titled 'Labview for Engineers',which is written in a nice and precise style giving you content at a good pace,minus the frilly words or the silly comics.So far,I'm about 2 chapters in,and its good.

More details about the book:
Title: LabVIEW For Engineers
Author: Ronald W. Larsen
ISBN: 0136094295
ISBN-13: 9780136094296,978-0136094296
Binding: Paperback
Publishing Date: Jan 2010
Publisher: Prentice Hall
Number of Pages: 391
Language: English
Dimensions: 9.8 x 7.9 x 0.6 inches
Weight: 726 grams

 (Details taken from its flipkart page)

I'm not saying that this is the best book to start with,there are tons out there,and if you know a few,feel free to leave details in the comments below.

Shape Recognition in MATLAB

This post is about something I contributed to a larger Neural Networks project.This isnt a proper tutorial on image processing,and the code discussed is also specific.And in my humble opinion,MATLAB isnt the best choice for Image Processing(OpenCV would be the way to go) anyway.Here it was the only choice since rest of the project was implemented in it.

The idea was to read an RGB Image which has the following characteristics:
-- 400x400px
-- RGB
-- has only one shape,any of a Triangle,Rectangle,Pentagon or a Hexagon,with a solid color fill.
-- has a colored background.

The project required my code to output:
-- The Identity of the shape
-- 2 Images,each of 400x400 px and each with a solid color fill,where one would be of the Shape's fill color and the other of the background color.

So heres my function .m file,all commented.It isnt very clean,and probably not very optimal too,processing wise.Its also not robust(then what use is it? :-/ ) so do tweak it for your specific application.If you spot any areas of improvement,do mention it in the comments below.

I'll briefly explain the shape characterization part,since the rest is pretty much straightforward and already commented.
I've used the Extrema property of the regionprops function and used the relative positions of the various extrem(a)e vertices to identify the shape.See the picture below for a better idea.

So,if we check for the equality(actually closeness of points.Since the left and right points detected will differ by a few pixels,even though the image is perfect.) of the extrema vertices ( whose co-ordinates are stored in the 8x2 Extrema matrix returned by regionprops) we can characterize a shape.

Heres the hexagon case:

Similarly,we can also see what extreme vertices are on the triangle,rectangle and other polygons.

Heres a link to the m-file (hosted on Google Docs)

Drop a line in the comments for any clarification or query.

PS:You can see the output of the different operations on the image using the imshow function.

PSoC3 Custom Board - PreFabrication

So I've finally gone ahead and frozen the PCB files for the prototype,after doing yet another batch of changes(placement,tracks and some more).I've also tried to improve the text and labels on the board.After running it through Sparkfun and SeeedStudio's Fusion DRU files,I'm convinced we're ready for running a prototype fab.
I've been posting updates over at the PSoCDeveloper forums and the DangerousPrototype forums.So you can view those threads too for tidbits and other people's take on it.
(click for a full size view)
Heres a link to the Pre-fab PCB files,linked over from the PSoC Developer forums.
(This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.)

Wednesday, October 26, 2011

PSoC3 Custom Board - Prototype soon

Phillip and I added few more changes,and looks like its finally ready for prototype.
Heres a shot of the board:
 click the image for a full size version

Drop a line in the comments if youre interested in the latest PCB files. 

PSoC3 Custom Board - Almost ready!

After my tests,I've finally got a chance to devote some more time to this project,so heres the result:
 click the image for a full size version

 I would like to thank Phillip Radner for his help and contribution to the design.

-Added the top layer copper fill,connected to the GND net,
-Added test points for all the important voltage levels on the board,
-Fixed the silkscreen and added the OSHW logo :)
-Ran the ERC and DRC,and fixed all errors that came up.I used the sparkfun DRU for that.
-Minor placement shifts and such.

I should probably add extra vias between the 2 layers.

Drop a line in the comments if youre interested in the latest PCB files.

Thursday, October 6, 2011

PSoC3 Custom Board - More changes

 click the image for a full size version
Heres the latest view of the PCB.Many changes from the previous version,which I'll quickly list.
-Removed the external DC jack.
-Removed zero ohm resistors,and added solder jumpers(from SparkFun's eagle library).
-Added the ground plane,which is of the "GND" net.(GND net is the USB's ground,shorted with the VSSA and VDDA using a solder jumper.)
-Changed the type of USB connector,since I had a bad experience with a miniusb one.Too small to comfortably solder,with an thick iron like mine.

And yeah,I've decided on a name - "EzPSoC3".

I'm still waiting for confirmation from Cypress on the ground plane placement,but other than that,it seems ready :)

Drop a line in the comments if youre interested in the PCB files.

Wednesday, October 5, 2011

Part of the Day - Magnetic Reed Switch

A very simple and elegant non-contact switching mechanism,which can support currents upto 1.2A (but look into datasheets for part specific values).

The device consists of 2 ferromagnetic contacts,parallel and overhanging,encased in a glass case(much like diodes are.) They range in length from 2.0 inches long to as small as  0.025 inches long.When the device is in proximity of a magnet, the two ferrous contacts inside the switch pull together and the switch closes.So,not terribly great switching times(~1mS),but useful nonetheless.

Theres an app note and working description at Sparkfun,click here to read it.(PDF) They also have it in the catalog(here),and can be purchased for $1.50 a piece.

Common applications include sensors and alarms.They can also be used for checking orientation of various objects(which have some magnet attached,so proximity would turn on the switch) etc.

A very detailed writeup on them,at

Wednesday, September 28, 2011

PSoC3 Custom Board - Second PCB

Many small changes and revisions later,I've got the 2nd version(Rev 5) of the PCB ready.
Changes include
-addition of a 3.3V Power regulator and a power level selection jumper.
-Ext DC Power Source connector.
-widened all power tracks to 40mils.
-shortened USB tracks,since long high speed tracks add noise.
-added a 5 pin power header(Vin,Gnd,Gnd,5 and 3.3V).
-added an external pullup to XRES,since the internal one is weak.
-fixed the header alignment.
-and a few other routing and placement errors.
Below is a board view:

and here it is rendered in 3D:

-Work on the silkscreen
-Decide on the ground plane
-Make it production ready.(DRU)

Drop a line in the comments if youre interested in the PCB files.

Friday, September 23, 2011

PSoC3 Custom Board - First PCB

I've tried to adhere to the "rules" of mixed signal design,and the guidelines in the Datasheet,regarding decoupling capacitors.However,I'm not able to conclusively decide where the ground planes should be.(Since theres no "exclusive analog half" and "exclusive digital half".Its more like digital(USB part) then analog(VDDa and Port 1),then Digital again(remaining right half of the board)..
Below is a shot of the board with VDDa and VDDd highlighted,to show you the digital and analog sections of the board..

Drop a line in the comments if youre interested in the PCB files.

Thursday, September 22, 2011

PSoC3 Custom Board - First Schematic

So,heres the first schematic.
A few points -
1.I've blatantly tied VDDd and VDDa together,at the VBUS of the USB port.I think I'll be changing that very soon.
2.Same for VSSd and VSSa.
3.Also,except for maybe a voltage regulator for the 3.3V level,I'll stick to this.
4.This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

If youre interested in the PCB files,drop a line in the comments.

Wednesday, September 21, 2011

PSoC3 Custom Board - Hardware Revisions

Though I havent started on the first revision,I'd like to get my ideas out before I forget em :P

Initial Design -5V operation,power source USB,USB Bootloader,SWD header.
-There,I've decided the power system too. :)

Rev1 - 5,3.3V operation,Power source USB & External DC Jack as well as a "VIN",USB Bootloader,SWD header,JTAG solder-on header.

Other general Ideas I'd like to add,
-"Shields" for the Board.(Yeah,I know.Need to find a name for this design.)
-Have part of the IO pins at 5,and a part at 3.3,and remove the concept of everything at one IO level.
-More as they hit me.

So what are my plans with this?
Well,I'd like to allow fellow students like myself,a chance to purchase one of these.(No,I dont look at this as a money spinner.Thats not my current focus.).The simple reason being,that'll allow them a better chance to learn this stuff,especially if their college or institute doesn't have the required setup for such an opportunity.Plus,I hear sad stories of very poor lab access from my friends in other colleges,something which I too am deeply frustrated about.

I'm not creating an Arduino killer,but something that can be easy to use,and yet very powerful at the same time.I mean,I see the Atmel and Microchip series of MCUs,while I've not used the latter,I find the PSoC3 way better,but not so accessible.Also,I really want to go further with the PSoC,but I need some hardware too :)

PSoC3 Custom Board - Bootloading

This was a part that,in my opinion is the weakest link,and yet the crux of this design's philosophy.But,like I mentioned earlier,Cypress has some ground work in this direction,which encouraged me to go forward with this on the first place.Links to that below:

PSoC 3/5 Creator Bootloader Overview Video

AN60317 - PSoC® 3/PSoC 5 I2C Bootloader (video,code and documentation.What more do ya want?)

After going through the 2 sources,I must say I was impressed at the simplicity of the whole process.Great Job Cypress!

I'll detail this further as I do it first hand.

Update : 15 Dec 2011 : With PSoC Creator 2.0 available for general access,the USB Bootloader has been included as a code example for the USBFS component.I gave it a spin on a 001 kit,and it works brilliantly :-)

Tuesday, September 20, 2011

PSoC3 Custom Board - Schematics

The schematics are the first real design I've done for this project.Based on the reference design(in the datasheet),I've come up with a basic schematic for the design.I'll post it here after I figure out what power level I want to go with.

(A recap of the power dilemma, Which Source? - USB,DC Power Jack,Header ..all 3 ? and Which Power level? 5,3.3 or a custom level? ..all 3?)

About the USB connections,whats the simplest way,while not abusing specs? I've seen a range of designs,some with direct connections,some with just resistors on the D+,D- lines,while most use the 3.6V zeners too.But all production level designs(the PSoC kits,mbed and more) use USB Transient suppressors(like the TI's SN65220) chips with some more passive parts.

While that does sound exotic to me,its there for a solid reason.Again,I find myself torn between keeping it simple and cheap,and doing the right thing.

Update 21/9/11 - Based on U2's inputs on the cypress forums,I've added only 2 22ohm resistors on each of the D+,D- lines since the PSoC has an internal regulator to stick to 3.3V on them.

PSoC3 Custom Board - Prototyping

So,with design goals and the parts decided,its time to prototype the design.

This being a 48pin SSOP chip,needs a breakout board which can be plugged into a breadboard.That done,I'll wire up the required caps,as in the Datasheet,and connect a MiniProg3 to burn in the bootloader via SWD,and then try burning a program in via USB,and wait for the blinky.Thats the rough order of events for this phase of the design.(I wonder how the pros do it...)

Before I started this,I was pondering about going to PCB stage directly,since its a straightforward design(there,I've jinxed it.).A chip,caps,a regulated supply and a 2 wire programming header.Still pondering.Any suggestions?

So far,the breakout board is done(with help from my friend Arup Basak) and heres what it looks like.
 The PCB design was made in Fritzing,since they already had a 48pin SSOP footprint that I could use.After I finalized the design,Arup etched it for me.(Update - Eagle has it too,its in the BurrBrown library.)

If youre interested in the pcb files,just leave a comment below stating the same.

 I opened a tech support ticket with Cypress about this project of mine,for which I got a really encouraging response,some interesting points,and samples of the required chip.

I'll solder the chip on,and wire the caps according to the schematic.

The next post(s) will describe the schematics involved.

PSoC3 Custom Board - Design Goals

With this design,as decided,the idea is to keep it simple and low-cost for the end user.

It'll have 3 main parts,

1.The PSoC3 Chip:
There are 2(+1) variants,the 100pin TQFP and the 48pin SSOP(and the 68pin QFN),which have some feature differences,with the 100pin TQFP CY8C3866AXI-040 being the big daddy of 'em all.

While bigger is better,the SSOP part I had chosen initially satisfied my goals.That was the CY8C3866PVI-070(check the PSoC3 parts available at Cypress' Part Selector).I switched to the CY8C3866PVI-021 later,and more on what prompted that change.
So,the final choice for the chip is the CY8C3866PVI-021.Over to programming now.

2.The Programmer:
Now while the PSoC3 supports SWD(Serial Wire Debug) and JTAG for burning your code,both these modes need an external programming setup of some kind.The First Touch Kit has an FX2LP chip doing SWD for us,while the bigger boards have a MiniProg3(more on that here) supplied to do both(and also act as an I2C bridge,SWV etc.) JTAG as well as SWD.
If you'll goto the MiniProg3 page,an $89 price tag in red is the first thing that you see.Now,I don't mean that its overpriced,but as a student,I cant afford one.(especially when the First Touch Kit itself is $49)

Both programming ways,the FX2LP chip and the MiniProg are complicated(not what I want in my design) and costly.Again,more reference to the Arduino,(which was the source of inspiration for this design.)which uses a Bootloader(the Arduino Bootloader),on an ordinary atmega328(or similar) to simplify the programming.Sure,you need a programmer to get the bootloader burnt on in the first place,but I'll discuss that later.

So,Bootloader it is.Cypress has appnotes for UART(currently under review),I2C(here) and USB(catch my drift?) bootloaders.I didnt know about the USB Bootloader appnote initially,so chose the CY8C3866PVI-070 for my board.Later,realizing the (obvious) advantages of a USB bootloader,which is natively supported(yay!) ,I switched parts to the CY8C3866PVI-021,which is the exact same as the previous choice,but with USBFS(full speed USB2.0).

So the chip is going to be the CY8C3866PVI-021,running a USB bootloader for easy programming.

Now,I havent really nailed down the design goals for this one,but heres what I think.
So,since we'll be using USB,theres the direct access to +5V.Nice.But what about 3.3V? and an external power jack? Or custom voltage levels from external sources(battery,or solar cell etc) ?

While it'd be very easy(for me) to use the USB for power also,it'd be restricting.Okay,so add a "VIN" for connection of any external regulated source.But doesnt that sound a little 'half done'? Fine,add a regulator with jumpers to switch between 5 and 3.3V operation.What about USB v/s an External wall wart adapter for power sources? More jumpers?

That adds a lot of components to the design.But then theres lots of platforms running 5V(Arduino) or fixed 3.3V(mbed,I think.) and still considered "user friendly".

Need to come to a final choice for this.

Update: 29 Nov 11: So the power section is frozen,with 3.3V and 5V selectable levels,where the 5V comes from USB(only) and the 3.3V can be sourced from either USB,or an unregulated DC supply fed into an LM1117-3.3,depending on jumper config.

Its going to be a chip+power with GPIOs broken out to headers.Low cost,simple to use,simple to re-design for custom implementation.

PSoC3 Custom Board - The What,Why,How

I know,long time nothing.That also means I have a lot to write,so I'll start with the current stuff,and deplete the backlog over time.
Update 18 Jan : Here are some pics of the finished board.

A PSoC3 Custom Board.

A self designed PSoC3 board that is open source,prototyping friendly,low cost and can be used with ease(in terms of hardware).

Apart from the really good learning opportunity this provides,also doing it because I find the PSoC3 First Touch Kit(here) too constrained(specific reference to header layout.) and the DVK(here) too big and costly.Overall,the cons of current kits on offer by Cypress being cost and ease of use.

Also,since I really feel that the penetration for such awesome hardware is minimal among us students,compared to what it can and should be.Again,I'd attribute it to the 2 above factors on their hardware.But that said,CUA(Cypress University Alliance) is a really great initiative.

If people could buy a board for around INR 1000-1200(the Arduino price point),then that'd really open them up to this awesome world,and maximize exposure to *real* embedded systems (Arduino bashing :P )

The basic idea is to replicate the arduino philosophy.By that I mean,chip,power and easy programming,all on one board.Simple to use,hack and modify for custom designs.Aim being to increase ease of use,of which the arduino is an epitome among simple micro-controller platforms.

Since the PSoC3 is no atmega328,this makes this idea all the more interesting,since the power of the PSoC,available at the simplicity of the arduino is a great combo,in my opinion.Thats also my aim for this.

Like I said,Open Source.So all material for this design is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

I'll be detailing the design process as I live it :)

Wednesday, June 22, 2011

Breadboard before you solder.

I repeat the title - Breadboard before you solder.I didnt say simulate,'cuz simulations are a personal pref.,but PROTOTYPE. Dont get that smoking gun out too early.

Just wanted to get this across. :P


I recently recd a 'SchmartBoard' sample in the post.Its basically a PCB,which makes prototyping with SMD components easier.See a pic here.

See the site for their entire(and very innovative,I must add.) product range.


This is a common topic learners deal with.A great article here. Must Read for all embedded systems enthusiasts :)

SMD with through hole components

One can always solder through hole components as SMDs,by laying their legs out flat.Why?
Well,while making your own PCBs(homebrew),it can save you drilling,and still allow you to use conventional components.
Pics up soon :P

Sunday, June 19, 2011

Whats that middle pin?

The popular Nokia BL5C battery(pic here) has 3 pins.One -ve,one +ve .. and the other one?
Mobile servicemen call it the "BSI" pin.BSI? They say its short for 'Battery Size Indicator'.Hmm,ok.Turns out,its a fixed resistor behind it,between the BSI pin and ground.The phone measures the resistance of the BSI - GND pins, and can determine what kind of battery is in.

The BSI GND Resistance for a normal BL5C comes out to 82.5k,and on a 4C to around 74.6k.Interesting.


While working on my ENC28J60 Project with the PSoC3 FTK,I felt a pressing need to get some debugging data out,in realtime(dont wanna pause it >.< ).There are a few direct solutions,
2.Serial Interface(UART)

LCD can be run at 3.3(here) but its too many wires,and limited text.That makes UART our preferred option.Which explains the title,TTL-UART.

PSoC Creator has a UART component,which can output RX-TX lines(TTL) to the GPIOs on the underside.Hunting around on the net,there are a couple of solutions.Keep in mind,that these will be 3.3V signals.

Before we discuss various options,Serial Port interfacing is basically about turning a 0-3.3V signal to a +/- 12V signal(Inverted) and the reverse for RX.

1.Use a dedicated chip.
MAXIM Semiconductors has a dedicated bunch of chips,each with different features.The one we'd need is the MAX3232(here).Its a one-chip solution,with only some decoupling caps externally.Make a neat PCB,and we're done :)
Sadly,this isnt a common chip here(unlike the MAX232),and ordering is costly :(

2.Use a popular "2 Transistor" Solution.
This is another popular method,which involves  basic NPN and PNP switches based on the 3906 and 3904,though there are variants around.(a detailed explanation of this circuit)

3.Bring in the MOSFETs! :)
Another solution uses a 2N7000,an N-Channel FET.Images,PCB and more here.

4.Use the MSP430 Launchpad(or similar)
If you do have an existing board which has some kind of TTL to USB/UART interface,get it out,and rig it up with the FTK :) .. A messy arrangement,what with 3 boards(Ethernet module too :P ) but it works.Even a PSoC1 Eval kit is a candidate here.

5.Use a MAX232
Yes,this 5V chip can be run at 3.3,to no special side effects,and with perfect results.However,this is abuse of the chip,and shouldnt be used for production level designs.

6.Use a FT232RL or similar USB UART IC.
This chip is another great way to approach this.More at the SparkFun store,here.

7.Mod an existing USB-Serial Cable.
The title says it all.Details here and here.(Many such on the net)

8.Use OpAmps :P
This was an Idea i thought of as I was reading the RS232 specs.It blared comparator at me,since a 0-3.3V signal,needs to be inverted and made a -12V/+12V one.While you can use a dedicated voltage comparator chip,or wire a 741 as an inverting comparator with hysterisis,both should work.How about using the analog blocks on the PSoC3? :)

9.Quick & Dirty : A Hex Inverter
Use a hex inverter for a quick and dirty solution.But its success depends on how far you can violate the standard RS232 protocol.
I'll add more as I find/think of em.Take your pick :)

No Go :(

Seems something is off some place else on my PSoC 3 FTK.Adding my own powersupply is keeping it running,but something is defn off. :( Maybe a capacitor leak or similar,which is shorting Vcc-Gnd somewhere.

Saturday, April 30, 2011

PSoC 3 FTK - Prototyping friendly

The PSoC 3 FTK has a 28 pin DIP IC socket compatible pin layout below.While this can be inserted into a breadboard for prototyping,it covers a lot of breadboard area.

A few ideas to make it more prototyping friendly,

1.Replace the existing simple male headers,with double height ones,allowing access to them from the top as well as below.Though,this would then render the Wireless CyFi port inaccessible..So then, maybe half of the pins could be double height ones.

2.Make a Dev Board : Make a board with basic peripherals,like a 5 & 3.3V supply,Level shifing,UART,an LCD,push button switches etc and all the pins broken out to female headers,where the PSoC3 FTK plugs on into a 28pin socket on this board.

3.Shields : Just like the Arduino,we could have stack-able shields for the PSoC3 FTK too.I aim to finally make a PSoC 3 shield out of the Ethernet thing.

4.Have a dummy 9v battery holder,mounted face up,to which the Board can be plugged in,making it stand upright,giving easy access to both faces of the board.

I'll have pictures of these,once I have implemented em.But thats a long way right now,as the first thing I need to do,is build a small 3.3v regulated power supply,that can be neatly accommodated onto the FTK's board.

Wednesday, April 27, 2011

Robert Noyce

From the Adafruit blog,

On April 26th 1961, the silicon integrated circuit was patented by Robert Noyce (No. 2,981,877).
Robert (Norton) Noyce was a U.S. engineer and coinventor (1959), with Jack Kilby, of the integrated circuit, a system of interconnected transistors on a single silicon microchip. He held sixteen patents for semiconductor devices, methods, and structures. In 1968, he and colleague Gordon E. Moore cofounded N.M. Electronics, which later was renamed Intel Corporation. Noyce served as Intel’s president and chairman (1968-75), then as vice chairman until 1979.
Src: Today in Science History
It is also worth mentioning this MIT graduate went on to co-found Fairchild Semiconductor and the production of the first commercially practical integrated circuit.

Thursday, April 21, 2011

PSoC 3 Project Ideas

This post just details some ideas for the PSoC 3 that cross my head.
 In no specifc order,I list some ideas I plan to materialize soon :)

0.Port Stuff  from other Platforms - A lot of the designs we see online,can be made simpler,more robust,and powerful,had they been done on a PSoC.This is one game I love to play,i.e use the PSoC to outplay other platforms on their pet applications,in terms of simplicity and elegance of the design,covering speed,power consumption,expected output,whatever,purely using just a PSoC,and nothing else ;) ....anything from an AVR ISP to a PIC based function generator,the PSoC can give them a run for their money :)

1.A LC Meter - Taking inspiration from some existing designs,and the analog power of the PSoC,I think this is a good idea to excercise the analog blocks on the chip.
Build a Tank circuit,with the L,C being added depending on the other quantity being unknown,(if u wanna measure L,toggle a switch to add a C to the tank,the L being an unknown inductance connected in,and vice versa).Send the Tank's output to the PSoC,where a comparator 'square waves' the sine output from the oscillator,and then use a counter to count the frequency of that wave.Since f=1/2*pi*(LC)^0.5,and one of L or C are known already,we can compute the other.

2.A Logic Analyser(& Oscilloscope & Function Generator?) - Power and speed of the PSoC can be put to good use over USB,with this one.This stuff has already been done on other platforms,so that should help.Converting your existing board into a money saving diagnostic tool,is a good pursuit.

3.Embedded Webserver - Something that I'm currently working on,this one has limitless possibilities.

4.A Bus Pirate clone - The bus pirate is a really handy device,and looking at its feature set,making a PSoC version of it,could be a fun exercise :)

5.USB Applications - This is one side Ive not explored,and would love to,but the FTK I have(currently doesnt work :( ...and also cant do the USB bit,since its USB capable pins are routed elsewhere. ).The USBFS component opens us up to plethora of applications.A USB based anything! :)

6.Verilog On the PSoC - Something I knew only recently about,the PSoC can do Verilog.Though I dont know Verilog all that well,the PSoC offers a great chance to change that :)

7.Shields for the FTK? - For the sake of arduino-ism,this could be a neat project in PCB Design :P

8.Wireless Designs - CyFi is a great wireless solution,and throw USB,Wireless together,and the list is already too attractive.All kinds of wireless sensor networks could come to life.

9.UI stuff: Capsense + a GLCD,to make a proper menu driven UI,could be something useful across a whole range of applications.Hell,a GLCD itself holds a lot of room for exploration.

..Lots more to come,as I give them some more thought. :) with the PSoC,lots is the only measure of ideas :P

PSoC 3 - Unrecognized USB Device

Update - It Works!

A rude shock,when i plugged the board back in,between trying to play around with the POV Example,the FTK showed up as an unrecognized USB device.My "Redo" instincts kicked in,and I reinstalled the software(drivers,creator,programmer,..the whole deal).Still no luck.Calming down,I took the problem piece by piece.Cable,Board,PC.Dug out a cable that came with my TI MSP430 Launchpad board,..still the yellow exclamation sign,bearing the grim message.To eliminate the PC,i did the whole install on a friend's VAIO,but the kit refused to co-operate.
Throughout all this,i did notice that the kit was getting power.

A discussion I had with tinman(from the PSoCDeveloper forums) some time ago,did give me a clear picture of what the board had.The PSoC3 chip,the FX2 chip and an EEPROM with a proper USB id,apart from the power circuity and the sensors,capsense,LEDs etc.

Since the power comes on,and the LEDs+Accelero work(POV Display),that section seems ok.Since the PSoC itself is driving them,I'd give it a green too.The shadow of doubt is on the FX2 and the EEPROM. Is it the EEPROM? Did the FX2 chip face sudden death?

Ive opened this to discussion on the PSoCDeveloper forums(here).I pray the kit isnt dead.I was just beginning to love it :'(

Update - 22-04-11 :Is it the EEPROM? In USB designs,this kind of problem is attributed to zeroed values of VID and PID,which in our case are on the EEPROM,a really tiny SMD part at that,making replacement(after reprogamming the VID,PID into the replacement part) impossible without a hot air rework station.

Update - 23-04-11 : As suggested by undesh of the PSoCDeveloper forums,I'll try sniffing the USB traffic to see what goes on.

Update - 25-04-11 : USB traffic,shows no response.Is the chip off? I pull out my trusty multimeter,and the schematics for the FTK.All the places that are supposed to be 3.3V,are 2.4V.The ZLD 0330's Vout,the FX2's Vcc-s,EEPROM Vcc etc. That doesnt look right,but I am no CyPro.I'll head off to bed,4am in the morning.

Update - 25-04-11 : I touch the probes from my LM317 based 3.3v supply to pins 5(Vout) and 7(Gnd) on the ZLD,and reinsert the USB cable,and Bingo!..We are back! :) ..the FTK3 comes up.Looks if like i'll wire in my own 3.3v regulator,then will be able to use it again. :) Thank You God. Rebirth!!

PSoC 3 : Verilog too!

Among its dazzling features,The PSoC 3 can do verilog too.You can create custom logic in Verilog using just a PSoC 3 FTK.

Some Documentation:
Creating Your Own Components
PSoC Creator 113: PLD Based Verilog Components ( a training on demand video)
PSoC Creator Tutorial - Creating a Verilog Implementation
( From the CypressSemi Youtube Channel)

The PSoC just keeps getting awesome-er :P

Great Video Tutorials for the Arduino

Among the vast sea of resources for the widely popular and simplistic arduino,good tutorials for the average newbie,are rare.I recently came across a set of video tutorials by Jeremy Blum.He has put the basics across quite well in a series of 11(so far) videos,that cover more than baby talk about LEDs and motors.Check them out here.

PSoC3 + ENC28J60 : It blinks!

So,having finally worked out SPI communication(at 10Mbits/sec! ),I set about writing the driver for the chip.
So far,Ive been able to make the Status LEDs blink :)

The code,so far.(Its really rough,no safety nets or any slick optimization tricks.)

I'll end this post with a picture of the working setup :

    • Compare and Improve the existing Driver code with respect to the EtherShield 1.6 one. 
                Update - 06-05-11 : Done.Awaits testing once the kit is back up.
    • Add UART & LCD to the FTK,using this & this,for debugging purposes.
    • Use the basic Ping/UDP code from Tuxgraphics' "An AVR microcontroller based Ethernet device",and get that to work.
    • Add on higher stuff like Webserver,NTP,DNS etc,using the EtherShield 1.6 code

    Sunday, April 17, 2011

    Random Data Over SPI

    I'm trying to interface a PSoC 3 FTK with a MX25L6406E 64Mb(datasheet) serial flash module.It talks over SPI.
    Heres a pic of my setup:

    Thats the memory module on the right.A close up here:
    I appoached this by writing basic SPI functions,of Sending,and Receiving a Byte.Make a neat .h file of those,and we can move onto the actual read/write operations on the chip.

    To start off,I'm sending it 0x9F(Read ID or RDID Command),and i should get back
    C2,20,17 in MID,DID1,DID2 ( Page 22 of the datasheet),MI is the manufacturing ID,and DID stands for Device Id.

    But for some unknown reason(to me),I'm not able to get the Rx/Tx part properly working.I keep getting inconsistent data.Below are a set of shots showing the received values from each run of the code.

    Most puzzling.Ive posted this issue to the PSoCDeveloper forums(here).

    Will this post updated with my progress.

    19-04-11 : Ive just realised,based on the input from abitkin of the PSoC Developer forums,and the syntax I kept using with the SPI Explorer,that the issue is with the Chip Select Line not being low for the entire time.Will test this out soon. Exams :(

    21-04-11 : Managed to get over the nagging tension of exams,and tried out the code..Turns out,abitkin was right! \m/ Flawless SPI Communication at 10MBits/sec :)