Showing posts with label Hardware. Show all posts
Showing posts with label Hardware. Show all posts

Saturday, January 27, 2007

555 Astable multivibrator and software product line.

So here I am, staring at bookshelf, thinking on what to read. While going through I found my old school note book where I had notes about creating electronic circuits. One of my favorite one is 555. Later that afternoon going through some shoe boxes, I found electronic components that were sitting there since long time. The moment I open the shoe box they started screaming at me: Solder me!, let me achieve the purpose in my life as a component. Get me wired and jolt me. I could not ignore their dramatic pleas to get burned with hot melting lead.

I quickly found one 555 chip and other components that could be assembled in an astable multivibrator. Lot of information related to IC chip 555 is available on web so, I will keep the description short.

An astable circuit produces a 'square wave', this is a digital waveform with sharp transitions between low (0V) and high (+Vs). This little circuit has many applications. Inner working of chip 555 and their application can be found on the web.

The time period (T) of the square wave is the time for one complete cycle, but it is usually better to consider frequency (f) which is the number of cycles per second.

T = 0.7 × (R1 + 2R2) × C1
f = 1.4 (R1 + 2R2) × C1

T = time period in seconds (s)
f = frequency in hertz (Hz)
R1 = resistance in ohms
R2 = resistance in ohms
C1 = capacitance in farads (F)

The time period can be split into two parts: T = Tm + Ts
Mark time (output high): Tm = 0.7 × (R1 + R2) × C1
Space time (output low): Ts = 0.7 × R2 × C1

Many circuits require Tm and Ts to be almost equal; this is achieved if R2 is much larger than R1.

So, here I am at my soldering station and I was able to assemble an astable mutivibrator in 20 mins. Please see the pictures.

It is nice feeling to work with real components after working with software components so long. There are significant similarities between hardware components and software components. Have long experience with software components and enough experience with hardware components I am able to draw similarities in their working, design, reliability, features, cost to manufacture, cost to support and cost & effort to use it reliably. Most importantly the assembly and manufacturing of the components. Unlike hardware product assembly lines, there no software product line that are available that can match the agility, cost & reliability of the hardware product assembly lines. This is an emerging field with lots of tools coming into market. There are many more aspects that we can compare and talk about software product line and hardware product lines. To keep this blog short I will talk about these aspects in my later blogs of software production line automation.
Posted by Picasa

Wednesday, January 12, 2005

Vacation and Scaled List

It is wonderfull to see everybody at home. I been travelling a lot and spending time with famliy matters. Weather here is wonderfull, though at the times I feel cold but normally in the range of 50 to 60 F.

Sneaking out to do some reading on "non-linear presentation techniques for saving screen real-estate and accessiblity". After doing some experimentation and some code I was able to create a simple list control for Windows.Forms and CF framework. Please refer my previous article about how to setup VS project and develop a CF Control.

List,

I am choosing simplest of all controls for demonstration purposes. Lets try to summarize on aspects of information presentation of a list.
  • List for choices - Enumerating information items as list to present user with various choices available.
  • List for selection - Allow user to select from the choices made.
  • List for an overview - Allow user to see overview of choices presented.

Focus plus context

Limitation in the viewing space presents the problem that either the overview of all the data or zoomed view of interesting subspace can be shown with linear magnification factor. Non linear magnification suggested as a technique to distort the presentation space for benefit. [Leung and Apperley, 1994]. Various ways like fisheye view, perspective wall and hyperbolic tree view are few of them. Basic idea is to present information and interact with it using non-linear magnification factor space.

Not going into too much of detail of Focus+context and related non-linear magnification presentation techniques. Intead of describing the behaviour of this list control in words, let me try to show you what it looks like. Following is the link of macromedia demo of the list.

http://img146.exs.cx/my.php?loc=img146&image=scaledlist5rf.swf

For more information search at,
http://citeseer.ist.psu.edu/cs?cs=1&q=focus+context&submit=Citations&co=Citations&cm=50&cf=Any&ao=Citations&am=20&af=Any
Design,


Here, in this article, I will show an implementation of such focus plus context technique applied to a list.

References
Leung and Apperley, 1994 Y. K. Leung and M. D. Apperley (1994). A review and taxonomy of distortion-oriented presentation techniques. ACM Transactions on Computer-Human Interaction (TOCHI), 1(2):126-160.

Sunday, December 19, 2004

Pocket PC project and developer setup

For CF control we have to do following,

  • Create CF Control solution and source code (actual control)
  • Create Windows Control solution and share the source (designer)
  • Copy them at right location and use them


Wipe you slate clean. Forget everything you know about windows/web/mobile control. Listen carefully what I say.


For any control we have following ways to look at a control

  • Control when running.
  • Control when being designed.

Reasons to highlight the abovementioned obvious perspective is due to differences in the compact framework run time and design time. This understanding of this perspective
difference will make us understand things more clearly later.

  • Control when running, is running in limited resources compact framework. Nothing but compact framework is available

  • Control when designed. It is designed in Visual studio. This requires control to interact with visual-studio and other heavy weight dlls which are not available in compact-framework.

Now the dilemma is, if we just use compact framework to generate the dll to cater design-time and run-time, we can only do so much, and if we use the windows forms regular framework to create dlls we can't run it on the CF DEVICE. In order to deal with this scenario we create TWO Dlls,

  • Control Dll (run-time dll, linked with pocket pc framework dlls) and
  • Control Designer dll (design time dll, linked with .Net PC framework dlls)

Now lets see how one/VS will use them.

  • you use Designer Dll to design the application
  • you run (F5), and the other dll (the actual CF one) gets deployed and used in run time.

Now in order to establish this connection and automatic switching of design to run-time dlls following is done. In "AssemblyInfo.cs" of Designer Dll we add following attribute.


#if DESIGN
[assembly:
System.CF.Design.RuntimeAssemblyAttribute("MySmartDeviceControl, Version=5.1.20051.3, Culture=neutral, PublicKeyToken=null")]
#endif


In summary,

  • Designer Dll designs the application,
  • Control Dll is used for running the application.
  • and above attribute does that.

Now the question is? in order to create two dlls do we write two source codes ? The answer is 'no'. Let me explain you in easy steps, Although the steps might seem to be long, but they are
described in detail for easy understanding.

1 Create a directory say at some location like following,

c:\work\PocketPC

2 Open Visual studio and Create a Windows Smart Device Application




3 Delete Form1.cs


to get


4 Open AssemblyInfo.cs and add the abovementioned attribute.




5 Add new Class "MyControl.cs" and add following code, the simplest control,



Add following code.

using System;

using System.Drawing;
namespace MySmartDeviceControl
{
public class MyControl : System.Windows.Forms.Control
{
public MyControl()
{
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
base.OnPaint (e);
e.Graphics.DrawRectangle(Pens.Red, 0,0,this.Width-1, this.Height-1);
e.Graphics.DrawString("MySmartDeviceControl", this.Font, Brushes.Blue,10,10);
}
protected override void OnResize(EventArgs e)
{
base.OnResize (e);
this.Invalidate();
}
}
}
6 Save everything and close the visual studio.

7 Open Visual Studio and create a new Project of WINDOWS CONTROL LIBRARY, Yes, NO Smart Device, the plain windows Control Library.



9 Delete the "UserControl1.cs"


to get,



10 Now, pay attention as this is tricky part, from references, delete

"System.Data"
"System.Drawing"
"System.Windows.Forms"
"System.XML"


11Add the reference, click "Browse"





use path "C:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE\Designer"


"System.CF.Design.dll"
"System.CF.Drawing.dll"
"System.CF.Windows.Forms.dll"

Now Add "Windows Forms" references AGAIN, (these are the ones you deleted in step 10). This sequence of removing and adding the references does matter. You will learn that in a moment. In short, when looking for a type that exist in more than one place, first one is used for binding. Add,

"System.Data"
"System.Drawing"
"System.Windows.Forms"
"System.XML"


to notice following,

12 Right click the project and open properties,






Add "Conditional Compilation Constant" "DESIGN", please notice that was used in AssemblyInfo.cs.

13 Save everything and close the visual studio.

14 Open "C:\PocketPC" directory and you will notice,

MySmartDeviceControl
MySmartDeviceControlDesigner





15 From "MySmartDeviceControlDesigner" and CUT (^X),



MySmartDeviceControlDesigner.csproj
MySmartDeviceControlDesigner.csproj.user
MySmartDeviceControlDesigner.sln
MySmartDeviceControlDesigner.suo

PASTE (^V) to MySmartDeviceControl



and delete MySmartDeviceControlDesigner directory.

16 Now open "MySmartDeviceControl\MySmartDeviceControlDesigner.sln". Right click and add existing item, select "MyControl.cs" and you.






17 Build the control [Ctrl+Shift+B"] When you compile you will get following warning,


'XXX' is defined in multiple places; using definition from 'YYY'


Since 'XXX' is defined in more than one place it uses from the location found first. In this case it happens to be "System.CF.*.dll". This is intented, and thus was reason for to add them in sequence.

'System.Windows.Forms.Control' is defined in multiple places; using definition from 'System.CF.Windows.Forms.dll'

'System.Windows.Forms.PaintEventArgs' is defined in multiple places; using definition from 'System.CF.Windows.Forms.dll'

'System.Drawing.Pens' is defined in multiple places; using definition from 'System.CF.Drawing.DLL'

'System.Drawing.Brushes' is defined in multiple places; using definition from 'System.CF.Drawing.DLL'

Thus following references,

"System.CF.Design.dll"
"System.CF.Drawing.dll"
"System.CF.Windows.Forms.dll"

must come before

"System.Data"
"System.Drawing"
"System.Windows.Forms"
"System.XML"

as you will notice in following image.





17 Summarizing , we have following

  • One directory "C:\WORK\PocketPC\MySmartDeviceControl"
  • Two Solutions "MySmartDeviceControl.sln" and "MySmartDeviceControlDesigner.sln"
  • Two DLLs that are generated after compiling above solutions.


18 Now these DLLS should be copied at following locations (this is very important),

"MySmartDeviceControl.dll"

C:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE

and

"MySmartDeviceControlDesigner.dll"

C:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE\Designer





19 Adding the control to the toolbox

Open Visual Studio and Create new Smart Device Application,





20Using the control and running the test Smart Device Test Application



The Application is running.