Circuit Negma

C++, C, VB.NET, PCB, Electronics, Circuit Design

Archive for September, 2008

Enumerated Data Type

Posted by Circuit Negma on September 22, 2008

Create By: Hussein Nosair

   1: /***********************************************************************************
   2:  *                                                                                 * 
   3:  * Created By  : Hussein Nosair                                                    *
   4:  * Date        : 9/22/2008                                                         *
   5:  * File        : enumTest.c                                                        *
   6:  * Description :                                                                   *
   7:  *             This code tests the enum variables and                              *
   8:  *              declarations.                                                      *
   9:  * Definition  :                                                                   *
  10:  *             1. enum (enumerated data type): is a user created data type         *
  11:  *                  with its own specified values in a user defined list           *
  12:  *                  ex:                                                            *
  13:  *                       enum Flags {true, false};                                 *
  14:  *                  I have created a data type called Flags and it has only 2      *
  15:  *                   values. You could consider Flags as a predefined data types   *
  16:  *                   like int, char, double, and long.                             *
  17:  *                                                                                 *
  18:  *                       enum Flags tst;                                           *
  19:  *                  tst is a variable of Flags data type with valid values of true *
  20:  *                   and false only and nothing else.                              *
  21:  *                                                                                 *
  22:  *                       tst = true;                     VALID                     *
  23:  *                       tst = false;                    VALID                     *
  24:  *                       tst = gdfgkieroi;               NOT VALID                 *
  25:  *                       tst = 5345234256;               NOT VALID                 *
  26:  * Reference:                                                                      *
  27:  * "A First Book of C: Fundamentals of C Programming" Gary Bronson& Stephen Menconi*
  28:  ***********************************************************************************/
  30: // define the required library for this project
  31: #include <stdio.h>             // Input/Output Library
  33: // define user functions and routines
  34: void Generic1(void)
  35: {
  36:      // The following variable is only local to Generic1() function, and it is
  37:      //   not accessible by any functions out side Generic1() function. 
  38:      static enum _Color 
  39:      {
  40:           red,              // Index = 0
  41:           green,            // Index = 1
  42:           yellow            // Index = 2
  43:      } iColor = red;
  45:      switch(iColor)
  46:      {
  47:            case red:
  48:                 printf(" This is =RED= state\n");
  49:                 iColor = yellow;
  50:                 break;
  51:            case green:
  52:                 printf(" This is =GREEN= state\n");
  53:                 break;
  54:            case yellow:
  55:                 printf(" This is =YELLOW= state\n");
  56:                 iColor = 1;
  57:                 break;
  58:            default:
  59:                    printf(" This is =default= state\n");
  60:                    break;
  61:      }
  63: }
  65: void Generic2(void)
  66: {
  67:      // The following variable is only local to Generic1() function, and it is
  68:      //   not accessible by any functions out side Generic1() function. 
  69:      enum time
  70:      {
  71:           am,
  72:           pm
  73:      }iTime = am;
  75:      switch(iTime)
  76:      {
  77:            case am:
  78:                 printf(" This is =AM= state\n");
  79:                 iTime = pm;
  80:                 break;
  81:            case pm:
  82:                 printf(" This is =PM= state\n");
  83:                 break;
  84:            default:
  85:                    printf(" This is =default= state\n");
  86:                    break;
  87:      }
  89: }
  91: // Main Function
  92: int main(void)
  93: {
  94:     printf("/**************************************\n");
  95:     printf(" * Created By  : Hussein Nosair       *\n");
  96:     printf(" * Date        : 9/22/2008            *\n");
  97:     printf(" * File        : enumTest.c           *\n");
  98:     printf(" **************************************\n");
 100:     printf("\n");
 101:     printf("***************************************\n");
 102:     printf("* Press 'ENTER' to see result         *\n");
 103:     printf("* Press 'TAB' then 'ENTER' to Exit    *\n");
 104:     printf("***************************************\n");
 106:     printf("\n");    
 107:     printf("****--> Pay close attention to the state of each function\n");
 108:     printf("          for every time you hit enter\n");
 109:     printf("\n");
 111:      while((getchar() != '\t'))
 112:      {
 113:           printf("---***** Generic1 Function *****---\n");
 114:           Generic1();
 115:           printf("\n");
 116:           printf("---***** Generic2 Function *****---\n");
 117:           Generic2();
 118:           printf("*----------------------------------------*\n");
 119:      }
 121:     printf("\n");
 122:     printf("***************************************\n");
 123:     printf("* Press 'ENTER' to exit               *\n");
 124:     printf("***************************************\n");
 125:     getchar();
 127:     return 0;     
 128: }



Posted in C Programming | Leave a Comment »

12 Sly Web Tricks That Put You in Control

Posted by Circuit Negma on September 16, 2008

Created By: Hussein Nosair

Article By Adam Pash, PC World 

Turn a Wi-Fi thief’s world upside down. Send an e-mail that self-destructs. And ensure that your boss thinks you’re always hard at work. These tweaks and tools let you gain the upper hand.

So it’s Friday afternoon, the weekend is just around the corner, and you’re up to no good. Rather than waste your time turning monitors upside down around the office, why not update your tech arsenal? If you have a computer or cell phone on hand, you’re more than ready to beef up your weapons and spy kit with these 12 sly tricks. We’ll teach you why and how (and with what) to do them, and tell you how well you can expect them to work. And you will forget where you heard this information …

(© PC World)

Turn Wi-Fi thieves’ worlds upside down

The problem: You took the time and expense to set up a wireless Internet connection at your place. But you’re pretty sure that the cheapskate next door is stealing it — that is, connecting to the Internet on your dime. Sure, you could take the easy step of password-protecting your network, but what fun is settling for a little common-sense measure like that?

The trick: With the help of a lovely little service called Upside-Down-Ternet, you can turn that Wi-Fi thief’s free Internet scheme upside down — literally. With a little clever scripting, every image the thief views via your connection is flipped upside down on his monitor and mirrored, making Web browsing difficult to say the least. You can also redirect every Web request the thief makes to a particular site — the author of the hack suggests Kittenwar. Pretty good, but I would go with an old standby.

The effect: The trick takes a little work to set up right, but if you can pull it off, it works perfectly. And doing right by one’s neighbor just makes you feel good inside.

(© PC World)

Never be ‘away’ with your AIM bot

The problem: Some employers use IM clients to track their workers and ensure they’re keeping their noses to the grindstone — but, hey, you don’t like Big Brother staring over your shoulder.

The trick: Create your own AIM bot with the Web site RunABot. An AIM bot is an automated chat robot that resembles any other AIM user, and — if you set it up well — it responds to messages like a real person. Once you register with RunABot, the site walks you through setting up your bare-bones bot; then it’s up to you to make your bot believable.

The effect: In the time it takes to customize your bot to fool your boss in all situations, you could probably finish several work projects and earn a few promotions. With just a few minutes of setup time, however, the “hardworker” bot I put together can convincingly participate in simple workplace conversations.

(© PC World)

Make a laptop thief regret it

The problem: Every time you leave your table at the bookstore for another cup of coffee, you’ve got to choose what to do with your laptop. You’ll be gone for only a few seconds, so lugging it with you is a pain. Still, the guy with a double espresso has been eyeing your gear since you sat down, and he looks like he could have sticky fingers.

The trick: Install an anti-theft program on your laptop that monitors unusual behavior when you’re away, setting off an alarm whenever it detects a possible theft. The freeware Windows application Laptop Alarm sounds an alarm whenever your laptop’s power cable is unplugged, the mouse is moved or the laptop is shut down. Mac users should check out iAlertU, a freeware app that uses your MacBook’s built-in accelerometer to set off the alarm and snag a webcam picture whenever someone so much as moves your laptop. You can smoothly disable the alarm with your Apple remote like a proper car alarm.

The effect: Under the right circumstances, these applications can be enough to deter a thief from running off with your laptop. Neither application is foolproof, however: Don’t consider these apps as anything more than deterrents.

(© PC World)

Spoof your caller ID

The problem: Before caller ID became standard on every phone, making an anonymous call meant little more than dialing the number. Today it’s easy to screen calls and send unknown numbers to voicemail. If you’re looking to make an old-fashioned prank call (heavy breathing optional) or simply surprise the person you’re calling, the ubiquity of caller ID has ruined the fun.

The trick: Several caller ID spoofing services are available online that not only hide your number from the recipient’s caller ID, they also make the call appear to be coming from another phone number altogether. Even better, you decide what number you want to show up when you call. I tested this trick at SpoofCard, one of many such services. Just give SpoofCard your number, the number you want to call, and the number you want to show up in the caller ID; SpoofCard takes care of rest.

The effect: SpoofCard was very easy to use, and it did exactly what it advertised. In my test, that meant spoofing with Tommy TuTone’s 867-5309 without a hitch. SpoofCard offers free trial calls, which is probably enough for most users.

(© PC World)

Did they read your e-mail? When?

The problem: You send out an important e-mail message reminding your co-worker to bring copies of your PowerPoint presentation to the big meeting. You get there, and he doesn’t have them. His excuse: He never got your e-mail. Possible, but questionable; anyway, you want to know for sure.

The trick: Send messages you want to monitor through DidTheyReadIt. The Web site embeds a tiny image in each e-mail it sends. When the e-mail is opened, the recipient’s e-mail client, in many cases, will automatically send a request for the embedded image; when that request is made, DidTheyRead then knows that the e-mail was indeed opened, when it was opened, and for how long it was open.

The effect: If you really need to be sure that someone received a particular message, DidTheyReadIt works as advertised. The only catch: If the recipient’s e-mail client doesn’t automatically download embedded images, DidTheyReadIt’s tracking mechanism may not work.

Create a web-streaming spycam

The problem: You want to keep a closer eye on your kids when you’re away without having to buy a nanny cam.

The trick: The free application WebcamXP streams video from your webcam over the Internet so you can keep an eye on your home from anywhere. If you have a webcam with a tracking motor, WebcamXP can even control the pan and tilt of the camera over the Internet, giving you full control over what you’re seeing.

The effect: The application works very well, though the free version supports just one video source. Upgrading to one of the shareware versions gives you motion detection and the ability to hook up and view feeds from multiple webcams.

Crack a Windows password

The problem: You lost your Windows password (or you want to discover someone else’s). Now you have no way to fully access your account without getting it back.

The trick: Download Ophcrack Live CD and burn it to a disc; then restart your computer and boot from the CD. Point Ophcrack at the hard drive where Windows is installed, and it’ll start cracking your Windows password.

The effect: The shorter and simpler the Windows password, the more quickly and easily Ophcrack will break it. But Ophcrack can crack only alphanumeric passwords. If the password contains other characters or symbols (like “@”), Ophcrack won’t do the job.

(© PC World)

Read books on the D.L. at work

The problem: Whether or not you’ve got any work to do, most employers frown on cracking a book at your desk.

The trick: The Web site Read at Work is a full-screen Flash application that mimics a Windows desktop and serves up public-domain works in a format that resembles PowerPoint presentations. Classics by Twain, Fitzgerald, Dickinson and Tolstoy are all yours to read on company time. (Well, if it’s Tolstoy, you might rather just work.)

The effectiveness: To the casual onlooker, Read at Work convincingly looks like a standard Windows XP window. Whether or not your boss will believe that the Oscar Wilde you’re reading is actually a PowerPoint presentation depends on your boss. And it helps if reading PowerPoint presentations is actually part of your job.

(© PC World)

Say it with self-destructing e-mail

The problem: E-mail is forever. If you fire off an angry or ill-thought-out message, the recipient could hold onto it — and hold it against you — indefinitely.

The trick: Send a self-destructing e-mail message by going to the Web site DestructingMessage. Just specify how much time you want to give the recipient before the message implodes (15 seconds to five minutes), write your message, and send it.

The effect: DestructingMessage can send the e-mail anonymously, or you can send a link to the message yourself. Either way, the recipient has a limited time to read it before it’s gone for good. If the recipient is quick on her feet, though, she could grab a screen shot before it’s gone forever.

Go straight to voicemail

The problem: Everybody’s been there. You’d rather leave a voicemail than deal with a drawn-out phone conversation. Or you’re a coward with bad news to deliver.

The trick: SlyDial connects you directly with your contacts’ voicemail — whether they’ve got their phone turned on or not. Just dial 267-SLYDIAL, enter the number you want to leave a voicemail with, and then, when prompted, just leave your message.

The effect: SlyDial works exactly as advertised. Use SlyDial gratis as much as you want, but if you tire of the in-call advertising, premium plans get you to voicemail faster and ad-free. SlyDial voicemails, however, do not self-destruct — I guess they haven’t thought of that yet.

(© PC World)

Spoof your e-mail address
The problem: You want to send e-mail from a bogus account.

The trick: Forge an e-mail address with your desktop e-mail client. In Thunderbird, all you need is a working SMTP server and a fake account. As long as the SMTP server can send e-mail without requiring authentication, you can use your fake e-mail address as much as you want.

The effect: To most people, your spoofed e-mail will appear indistinguishable from a real one. The catch: You won’t get any replies, and a look at the message’s headers can reveal to the recipient that you’re using an unusual SMTP server for that e-mail address.

(© PC World)

Browse the Net without leaving a trace

The problem: Web sites you visit are tracked by your Web browser in several ways that aren’t immediately obvious — such as browser history, cookies or cached files. Whether you’re doing some online shopping on a shared computer or visiting Web sites that are, let’s say, embarrassing, it’s hard to make sure that a browsing session doesn’t leave a trace.

The trick: Go off the record when you want browsing privacy with the Stealther Firefox extension. Enabled, Stealther makes sure that your browsing history, downloads, disk cache, saved form information and cookies aren’t saved to your browser.

The effect: Stealther works in every respect. Whenever you want to go off the record with your browsing, just go to Tools, Stealther. When you’re ready to go back on the record (after all, browser history and cookies can be very useful), just turn off Stealther. Muahahahahaha!!!

Content by:


Posted in Uncategorized | 4 Comments »

NOTES :: PIC Timer 0

Posted by Circuit Negma on September 11, 2008

Create By: Hussein Nosair

Few notes on TMR0 module in PIC16 and PIC18 processors.

General Notes for both PIC16 and PIC18 processors from Microchip:

1, Writing to TMR0 register in PIC16 or writing to TMR0L in PIC18 (8-bit mode) or TMR0L, TMR0H in PIC18 (16-bit mode) will clear Timer 0 prescaler’s counter but not assignment.

ex: PIC16

void main(void)
    TMR0 = 0x1A;    //<--------- Instruct the PIC to start TMR0 module at 0x1A and increment until reach 0xFF
    PSA = 0b0011;   //<--------- Instruct the PIC to increment TMR0 by 1 after counting 16 Tcyc 
    .//<--------------- Prescaler counter = 0 (reset counter done by wirting to TMR0 register);
    .//<--------------- Prescaler counter =  10
    TMR0 = 0xDF;
    .//<--------------- Prescaler counter = 0 (it has been reset), but still PSA = 0b011

2. TMR0 Interrupt
TMR0 overflows from:
0xFF to 0x00                    8-bit mode
0xFFFF to 0x0000             16-bit mode

3. TMR0 cannot be used to wake up the processor (PIC) since it is turned off once the PIC in sleep mode.

4. Prescaler assignment PSA is fully controlled by software, as PSA inhibit the “on-the-fly” feature.

5. Once TMR0 overflow, the new value in TMR0 register is 0x00 (8-bit mode) or 0x0000 (16-bit mode)

Posted in Microchip PIC | Leave a Comment »

NOTES ::Terms

Posted by Circuit Negma on September 11, 2008

Create By: Hussein Nosair



Term (Acronym) [units]: Definition

Acoustic Pulse Recognition (APR): A new touch screen technology that works by sensing the sound made when a touch screen is touched and comparing it with a stored table of sounds in order to locate the user’s contact point within the active area.

Active Area: The dimensions of the area in a display that contains pixels.

Active Matrix (AM): A display backplane structure in which switching transistors control the voltage or current for each pixel. It produces a brighter, sharper and faster display with a broader viewing angle than a passive matrix display. Used in reference to both LCDs and OLEDs; used synonymously with TFT (thin-film transistor).

Active Matrix Liquid Crystal Display (AMLCD): An LCD display in which each pixel has its own transistor on/off switch rather than being activated by its address within a passive matrix of rows and columns. This is the most common type of LCD; it’s also called “TFT-LCD”.

Active Matrix Organic Light-Emitting Display (AMOLED): An OLED display in which each pixel has its own transistor on/off switch (see TFT and Active Matrix) rather than being activated by its address within a passive matrix of rows and columns. This type of OLED is just entering initial production in mid-2006; most current OLED displays are passive matrix.

Additive Primaries: In color reproduction, the colors of red, green and blue. When lights in these colors are combined (e.g., from an LCD backlight and color filter combination), they produce the visual sensation of white light. When these three colors are combined at varying intensities, a range of different colors is produced. Combining two primaries at 100% produces a subtractive primary, called cyan, magenta or yellow.

Alignment Layer: A thin-film layer in an LCD display that’s used to line up liquid crystal molecules in a uniform direction. The thin film is typically applied by spin coating, and then treated to impart a desired direction in which the liquid crystal molecules will attach and align. (See Rubbing.)

Ambient Light: Whatever lighting exists in any situation. In a living room at home, ambient lighting could be the light from two incandescent lights; on the beach it could be direct sun plus all the light reflected from the sand and water.

Ambient Light Sensor: A light-sensitive electronic component used to adjust the brightness of an LCD display’s backlight so that the display remains comfortably readable over a range of ambient light conditions.

Amorphous Silicon (a-Si): A semiconductor material that has no definite or regular crystal structure and is used to make the thin-film transistors (TFTs) in an active-matrix LCD or OLED.

Amorphous Silicon Thin-Film Transistor (a-Si TFT): Thin-film transistors made with amorphous silicon, typically used in the active matrix backplane of an LCD or OLED display. However, since AMOLEDs haven’t reached the mainstream yet, the term “a-Si TFT” is often used as a shorthand way of referring just to AMLCDs.

Analog: In analog technology, a wave is recorded or used in its original form, as opposed to being digitized and reduced to a stream of ones and zeros (digital data).

Analog Resistive Touch Screen: See Resistive Touch.

Analog-to-Digital Converter (ADC): A device that converts analog (continuously varying) input signals into digital output signals. An LCD monitor with an analog interface (e.g., a VGA connector) uses an analog-to-digital converter to convert the analog signal into a digital signal that the LCD panel can display. LCD monitors with only a digital interface (e.g., a DVI connector) require that the analog-to-digital conversion take place before the signal arrives at the monitor.

Anti-Aliasing: The technique of minimizing aliasing (jagged or blocky appearance) when representing a high-resolution signal at a lower resolution. Used in sub-pixel rendering.

Anti-Glare (AG): A physical treatment on the top surface of a display that changes light reflected from the display into a diffuse reflection rather than a specular reflection. The treatment can be produced by mechanical or chemical etching. Anti-glare doesn’t reduce the amount of light reflected from the surface; it only changes its characteristics. You can tell if a display has anti-glare treatment by looking at the reflected image of a bright light such as a light bulb or the sun. If the reflected image is clear and sharp like a mirror, there’s no AG. If the reflected image is a generalized area of light with no sharp boundaries, AG is present.

Anti-Reflection (AR): A thin-film coating that reduces the reflection of light from a surface via the use of refractive-index matching and destructive interference techniques.

Aperture Ratio: The ratio between the transmissive portion of a pixel and its surrounding opaque electronics (e.g., the thin-film transistors), expressed as a percentage. Aperture ratio, also known as “fill factor”, is the limiting factor for luminance. Higher aperture-ratio designs enable brighter displays (more light for the same amount of power) or lower-power displays (less power to produce the same amount of light).

Array: The term used to describe either the back substrate (TFT array) or front substrate (color filter array) of an LCD display during manufacture.

Array Process: The process of fabricating thin-film transistors on a glass substrate. This is the first major process group in manufacturing an LCD.

Aspect Ratio: The width-to-height ratio of the active area of a display. The standard PC display aspect ratio has been 4:3 since 1981; the standard is now migrating to 16:10 (“widescreen” displays). Similarly, the standard TV aspect ratio has been 4:3 for 50+ years; now it’s migrating to the HDTV standard of 16:9.

Average Selling Price (ASP): The average price at which a product (e.g., 15″ LCDs) sells across multiple distribution channels.


Term (Acronym) [units]: Definition

Backlight: The light source for a transmissive LCD, located directly behind the LCD (for small or very large LCDs), or at the side of the LCD (for small or medium LCDs). The light from the backlight is either blocked (black) or passed (white) by the LCD cell. LEDs or EL panels are used for most backlights smaller than five inches in diagonal size; fluorescent lamps are used for most backlights larger than five inches.

Backlight Unit (BLU): The complete backlight assembly for an LCD display, typically consisting of the light source, a light guide, reflectors, brightness enhancement films or prism sheets (if used), a diffuser and a housing.

Backplane: The portion of a display that controls the pixels located in the frontplane. In an AMLCD or AMOLED display, the backplane contains the thin-film transistors (TFTs).

Bezel: A metal or plastic frame that surrounds the active area of a display. The bezel protects the edges of the display and any circuitry that may be located there.

Bill Of Materials (BOM): A detailed list of materials and components that make up an assembly. The BOM is a building block of the manufacturing information system and is often used in cost accounting.

Birefringence: Birefringence, also called double-refraction, is the decomposition of a single light ray into two light rays when it passes through certain types of material, depending on the polarization of the light. Birefringent materials are used in many devices that manipulate the polarization of light, such as retardation films and polarizing prisms.

Bit Depth: See Color Depth .

Black Luminance: The amount of light that a display emits when every pixel is set to black. Ideally this is zero, but LCDs (in particular) have problems with leakage of light from the backlight. Emissive displays such as PDPs and OLEDs typically have much lower black luminance levels.

Black Matrix (BM): A patterned layer in an LCD’s color filter assembly whose purpose is to prevent light leakage and improve contrast.

Blu-ray: One of two next-generation (post-DVD) optical disc formats designed for storage of high-definition video and data. Developed by Sony. The name is derived from the blue-violet laser used to read and write the disc.

Brightness: The dimension of color that is referred to on an achromatic scale ranging from black to white; also called luminous intensity or lightness.

Brightness Enhancement Film (BEF): A prism film that increases a display’s brightness. 3M is the dominant supplier of BEF, although because of recent patent expirations, many new suppliers are entering the market.

Posted in Electronics | Leave a Comment »