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.

status=EEPROM_WritePage(SLAVE_ADDR,0x00,TxData);

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.)