ADC DAC External Memory(RAM)

This is what I am assigned to do, what are the aim

  • Generate Sinewave through DAC (why not PWM?)
  • Read the sinewave(through ADC810)
  • Save the values in a 32KB Ram.

And the tradeoffs are

  • Generate the highest frequency which will lead to impure sinewave.
  • DAC and ADC speed must match.
  • Simultaneously i have to save the data in RAM

 
 

The microcontroller U5 (AT89C51) is generating sinewave, loaded with the following code

#include<reg51.h>

void delay(int k)

{int i,j=k*10;

for(i=0;i<j;i++)

{}

}

main()

{

while(1)

{

    /*

P1=0x01;delay(5000);

P1=0x00;delay(5000);

P1=0x80;delay(5000);

P1=0x00;delay(5000);

*/

// P1=0x80; //delay(3); //10

// P1=0x96;//delay(3); //20

//P1=0xAB;//delay(3); //30

// P1=0xC0; //delay(3);     //40

// P1=0xD2; //delay(3); //50

P1=0xE2;    //delay(3);     //60

// P1=0xEE;    //delay(3);        //70

// P1=0xF8; //delay(3);    //80

//P1=0xFE; //delay(3); //90

//P1=0xFF; //delay(3);         //100

//P1=0xFE;     //delay(3);

P1=0xF8;    //delay(3);          //120

 

//P1=0xEF; //delay(3);

//P1=0xE2;//delay(3);

//P1=0xD2;//delay(3);         //150

//P1=0xC0; //delay(3);

// P1=0xAB; //delay(3);

P1=0x96;    //delay(3);         //180

//P1=0x80;    //delay(3);

//P1=0x69; //delay(3);

//P1=0x54; //delay(3);         //210

//P1=0x40; //delay(3);

//P1=0x2D;     //delay(3);

P1=0x1D;    //delay(3);     //240                

//P1=0x11;//delay(3);

//P1=0x07;//delay(3);

//P1=0x01; //delay(3);     //270

//P1=0x00; //delay(3);

//P1=0x01;    //delay(3);

P1=0x07;    //delay(3);     //300

//P1=0x11; //delay(3);

//P1=0x1D;//delay(3);

//P1=0x2D;//delay(3);     //330

// P1=0x40; //delay(3);

// P1=0x54; //delay(3);

P1=0x69;    //delay(3);     //360

 

                            

     /*

     P1=0x80;

     P1=0xC0;

     P1=0xEE;

     P1=0xFF;

     P1=0xEE;

     P1=0xC0;

     P1=0x80;

     P1=0x40;

     P1=0x11;

     P1=0x00;

     P1=0x11;

     P1=0X40;

     */

}

}

And the U1 doing 2 jobs one is to read the sinewave through a ADC810 and other is two save sinewave data to a external RAM 32KB. U1 loaded with following code

8051 External Memory with keil

Hi friends you must have interfaced memory chips to 8085 or 8086 microprocessor. Same is the case here as both are with 8 bit processing 16 bit address space. In both cases the higher address port is shared with the data port. Means one port dedicated lower byte of address and higher byte of address is goes through a data-address multiplexed chanel.

Here in 8051 P0 is for lower address and P2 used for upper address byte and for data also. The hardware connection is also same as in case of microprocessors. You have to use a latch to latch the higher byte of address .

And the Code….

I had searched a lot both in google and the help pages, but didn’t get anything except the DATA type declaration, but how will it do all the things.

unsigned char xdata datg[32000]; //I had used a 32K byte RAM to save my data.

**************************************************************************

Do you know about pointers, have u ever tried to store a variable at some specific memory location. (I guess u never tried this), if u have done please mail me the code.

We declare pointers like

Int *ptr ;

Or

Char * ptr;

Or

Unsigned Char * ptr;

Where ptr is the address of the variable. Value of the variable is *ptr is an integear.

But we can’t write

ptr=0x1278; assuming 0x1278 is a memory location. Try it.

**************************************************************************

Ok u may ask what is the use of pointing to specific location(usually called static pointer). In microcontrollers we have very less memory we can use the memory randomly. It may lead to data segmentation.

After a long search I got two three lines

*datg = (char xdata *) 0x0400;

volatile unsigned int *myPointer = (volatile unsigned int *)0x1234;

#define data (*((char *) 0x0170))    

The first one is quite odd, it doesn’t look like a type declaration statement, rather seems like a assignment statement.

 

References:

Keil application note http://www.keil.com/appnotes/files/apnt_129.pdf

http://www.esacademy.com/en/library/technical-articles-and-documents/8051-programming/8051-memory-configurations-with-c-compilers.html

http://supp.iar.com/Support/?note=98587

http://stackoverflow.com/questions/2389251/pointer-to-a-specific-fixed-address

Personal website Why and How

 


What ??

A personal website is a place where someone describe about himself.. Basically contains personal things like biodata, album and other personal stuffs. It doesn’t have to be about you, and it doesn’t have to contain personal information but it does need to be personal.

A personal website must exhibit content that tells your readers about your thoughts, ideas, interests, hobbies, family, friends, feelings, or something you feel strongly about. Online diaries, self-written books, poems, family, pets, or a page about your favorite topic such as a TV show, a sport, or a hobby are examples of things that could go on your personal website.

Or,

it could be a page written to help others with topics like C programming, or how to’s or tutorials on just about anything.

Is it necessary to learn HTML

Absolutely not! Personal Web pages have changed a lot over the years. Back in 1996 Web pages were small files with HTML code, and maybe some JavaScript thrown in for fun. There wasn’t much else. They were very plain and basic. You could add graphics, but not too many because they make the pages load very slow, and back then Internet service was slow to begin with.

These days most personal Web sites are not coded by the writer of the website.
They can often times add code if they want to, but they don’t need to. Most free hosting services have easy to use Web page builders with them. All you have to do is click, drag, copy/paste and type, and you have your very own personal Web page. Since Internet service, and computers, are faster you can add more graphics and photos to your site too.

Why Do People Create Personal Sites?

There are tons of reasons someone would want to create a personal website of their own. One of the most popular reasons to write a personal website is simply to write about oneself. People like to talk about themselves, they also like to write about themselves and tell other people who they are.

Another popular reason people write personal websites is to show off their family. They may include lots and lots of photos of their kids all over the site. Sometimes they create a separate page for each of their family members.

By creating your own site you can present yourself to the world. Your virtual online portrait will be there for the entire world to see 24 hours a day, 7 days a week. 
Do you know that your personal website can be your online CV or portfolio? 
It is a proven fact that the majority of the employers are looking for employees directly through the Internet. A similar online presentation of your qualification, as well as of projects you’ve been working on, would produce positive effect at the talks when your entrance into office is being discussed. Let’s not disregard the possibility that it might turn out to be the very reason for your eventual hiring.
Your web site could also serve as a forum/scene where the ‘real you’ could present thoughts or express opinion about one topic or another. Thanks to your personal web site you could acquaint yourself with many other likeminded people with similar interests, make contacts and keep up a correspondence with people from all over the world.

Your web site could also take the form of a family album, a diary of your daily life, which you could easily share with friends and relatives.

Online diaries have been popular ever since the beginning of the Web. This is where people create a website just so they can write about themselves in a more personal way then a standard personal website. They may post entries each day, weekly or monthly about what’s going on in their lives. Then they let other people comment on their entries.

There are also wedding sites, memorial sites, sites about people’s pets, and websites about people’s interests and hobbies. Maybe you really like the show “Survivor”, you could create a website about it and tell people why you like it. Maybe you like the Mets, you could keep a website that keeps track of their games and their standings.

A personal website is a place where you can relieve your soul. Create webpages about anything you like and get it all out there for everyone to see. If you’re a private person, you can still do create a personal website. Just make sure not to post your name or any other personal information that may let people know who you are.

How to get money from your site

For personal sites it is a tough job. Because for personal sites nobody will work for your site voluntarily, and making traffic is also tough. Making traffic does not mean distribute the link in your friends, it may raise temporary traffic, you need to write high quality useful articles about a specific topic.

Money can be made from a personal webpage but almost always indirectly. A good personal website creates demand for a person’s services. A resume is one or two pages of text. A website can be any number of pages of text and graphics.

My friend Amaan Akram created his website. some years back. He is a computer graphics (CG) artist who has no formal training in art, and no relevant job experience. Last I talked to him, he was planning on moving to London to work as a CG artist. The company that hired him was interested enough to arrange a work-permit and a visa for him. Could he have gotten hired on the basis of his resume?

A resume can contain false information. It is much harder to fool people with a website. A person can claim to be a very organized person in his/her resume, but a website will make the truth self-evident. The person evaluating the website can go back in time and see how the site looked six months, a year, two years back. Of course unorganized, lazy, and stupid people want to hide these qualities by not having a website. On the other hand smart individuals are simply handicapping themselves by not documenting their marketable skills.

Creating a good website requires time and effort. A good website is not about graphics, and fancy layout. It is about high quality content. High quality content is information that many people are likely to find useful. Such information takes the form of tutorials, interesting articles, fascinating images, and the like. No one can come up with high quality content overnight.

If a person is consistently able to come up with good content s/he will be recognized for that. People will perceive that person as an expert on topics s/he writes regularly about. There is no organization which awards people titles such as expert and wizard. Experts and wizards are known as so only on account of their reputations. Articles on a personal website are a great way to demonstrate one’s knowledge and build a reputation.

Try searching for “lighting tutorial” in a Google searchbox. Amaan Akram’s lighting tutorial will come up topmost in the list of results. He wrote that tutorial back in 1999. Unfortunately, he never read this article (he couldn’t have) otherwise he might have posted dozens of CG tutorials by now. His website could have been ten times more popular than it is now.

Good content always find an audience on the web. This being a consequence of the dearth of content on the web. The web is vast but it is also very shallow. If the web was not shallow people would be using search-engines only occasionally. They would be relying on their bookmarks to find all the information they require. People are always searching for content, and if someone puts content on the web, it will be found. Time spent on creating a high quality website is never wasted. It will attract an audience but might not do so immediately.

A website can also be used to collect information. Polls, statistics, and old fashioned requests for information, all depend on having a popular website. Once a person has a popular website they can ask for help with almost anything.

I routinely do programming work for classic-trash, a popular gaming website. I got to know the administrator of the site only because he posted an advert for a programmer on his website. In exchange for programming work, I get free hosting, a shell account, links, and other small favors. If the administrator of classic-trash had to pay for programming work he probably wouldn’t be able to make improvements to his website.

In the future personal websites will have an increasingly important role in our lives. Individuals and employers will depend on them to make decisions. People who have invested time and effort in creating interesting websites will have a distinct advantage over people who expended their efforts elsewhere.

 


 

Servo motors and Servo amplifiers

A  servo, is an automatic device that uses error-sensing negative feedback to correct the performance of a mechanism. The term correctly applies only to systems where the feedback or error-correction signals help control mechanical position or other parameters. For example, an automotive power window control is not a servomechanism, as there is no automatic feedback that controls position—the operator does this by observation. By contrast the car’s cruise control uses closed loop feedback, which classifies it as a servomechanism.

A servomechanism may or may not use a servomotor. For example, a household furnace controlled by a thermostat is a servomechanism, yet there is no motor being controlled directly by the servomechanism. A common type of servo provides position control.

 

Introduction to Servo Amplifiers

The output stage of all servo amplifiers is an analog circuit. The analog circuit provides a means to allow the voltage and current for the motor to be adjusted to control position, velocity, and torque. The feedback and comparator stages can be any mixture of digital and analog devices. For example, if the feedback section uses a resolver, the output of this device is analog, so the section it works with is generally also analog. If the feedback device is an encoder, its output is digital, and the digital signal can be converted through a frequency-to-voltage converter so that the signal is usable in an analog circuit. Or it can be filtered and can use a digital value. The advent of microprocessors has allowed the digital values to be used through every part of the servo controller except the final output stage.

Figure 1 shows a diagram of the components in a typical servo linear amplifier. The circuit shows the motor winding connected to a set of transistors (TR1 and TR2). The transistors can control positive (+V) or negative (—V) voltage to make the motor turn in the clockwise or counterclockwise direction. The transistors can be pulsed on and off as in a pulse-width modulation (PWM) circuit, or they can ramped up and down as a simple linear circuit. The base of the transistors can be controlled by a controller section of an amplifier that is completely linear. Or the controller can be digital with a D/A converter to provide the analog control signal to the base of Q1 and Q2, or the controller can be completely digital and the base of transistors Q1 and Q2 can be pulsed directly by the digital controller. Typically IGBTs (insulated gate bipolar transistors) are used in modern servo amplifiers where PWM or other switching circuits are used. The IGBTs allow the transistors to be switched on and off at frequencies that limit the harmonic hum in a motor or amplifier. The high-pitched hum represents both audio and electronic noise that must be eliminated or controlled.


A typical linear amplifier for a servo system.


The amplifier circuits for DC servomotors are similar to the AC circuits used for pulse-width modulation or other switching systems. In fact the complete amplifier for AC servomotors will be similar to the variable-frequency drive amplifiers shown earlier in this chapter.

Early Amplifiers (Push-Pull Amps)


The design of amplifiers has changed rapidly over the last 15 years because transistors, triacs, and SCRs have become able to handle larger voltages and currents without damaging themselves. It is easy to see the advantages that the changes in these devices have brought to motor drive amplifiers, but you must keep in mind that the early amplifiers were built so well that you will run into them even today when you are asked to troubleshoot a drive system. For this reason it is prudent to leam their basic parts and functions so you will be able to troubleshoot and analyze them. It is also a good idea to understand their basic operation because this is what has been modified to make the newer drives more efficient and more powerful.

One of the earliest types of linear amplifiers is called a push-pull amplifier, which was designed so that two transistors switched on and off to share the current load for the motor. Figure 2 shows an example of this type of amplifier, and you can see that Q2and Q3 are the power transistors. They are connected to the primary winding of transformer T2. The servomotor winding is connected to the secondary winding of transformer T2.

The operation of the push-pull amplifier begins with a sine wave signal that enters the input of the push-pull amplifier through capacitor C1. Capacitor C1 makes sure that the input signal is a pure sine wave with no DC bias. The base circuit of transistor Q1 has a DC bias on it of approximately 13.5 volts. The base-emitter junction needs only 0.7 volt to turn it on, the rest of the DC bias voltage providing DC current through R2 and R3. This causes the sine-wave input signal to practically turn transistor Q1 off at its minimum, causing Q2 to be driven almost into saturation at the sine wave’s maximum. This causes current to flow through the primary winding of transformer T1. Notice the secondary of T1 is center tapped to ground. When the positive half of the sine wave appears on the secondary, it appears across the entire secondary. Because of the center tap, only the upper portion of the secondary sees a positive voltage, and this forward bias transistor Q2 allows it to conduct. Transistor Q3 is turned off because it sees a negative voltage at its base. With Q2 conducting, current flows up through the primary of T2, providing a positive pulse to the secondary of T2. When Q3 conducts, a negative pulse is provided to the primary of T2.


FIGURE 2 Push-pull amplifier for an AC ser-vomotor. This diagram shows the power stages of the amplifier.

Chopper Amplifiers

Another type of early amplifier for a servomotor is called the chopper amplifier (see Fig. 3). In this type of amplifier the positive rectangular DC pulses arrive at the input of the amplifier circuit at capacitor C1. These pulses arrive at the base of Q1 as narrow spikes, which momentarily turn Q1on. This in turn momentarily turns Q2 on, which allows current to flow through the primary of transformer T1. Now the primary of transformer T1 is really an L-C tank circuit. (Remember that the primary winding of the transformer is actually a big inductor.) When this tank circuit is hit by a pulse, it will produce a cycle or two of pure sine wave. When hit, in other words, the tank circuit will ring like a bell. The amplifier circuit is the clapper that rings the bell. Notice the secondary of T1 is center tapped to —60 Vp. The secondary of T1 sees a pure AC sine wave, and to this AC signal, the —60Vp appears as a ground. This means that for the positive half-cycle of the sine wave, Q3 would see a positive pulse, and Q4 would see a negative pulse. Both power transistors are NPN transistors, so a positive bias is needed at the base to cause them to conduct. As both bases are grounded , Q4 would go into conduction because its emitter is lower than its base, giving it a forward base-emitter bias. The output of the tapped control winding would then be a sine wave. It should be noticed that the tapped control winding has +60 Vp on it, and the secondary of T1 has —60 Vp on it. This means that the output of the tapped control winding is going to be a 120-Vp sine wave.


FIGURE 3 Output stages of a chopper amplifier for an AC servomotor.


FIGURE 4 Two-transistor amplifier for a DC servomotor.

 

http://www.societyofrobots.com/actuators_servos.shtml#digitalanalogservos

http://www.seattlerobotics.org/guide/servos.html

PLC Vs Microcontrollers

I have never worked with a PLC , but I have read a number of articles on PLC. Microcontrollers!!! it is my life. I have heard a number of people arguing for importance of PLC over Microcontrollers. The following threads from some popular forums discussing the same.

http://www.electronicspoint.com/microcontroller-based-plc-designing-t36473.html

http://www.control.com/thread/1026158987

http://www.edaboard.com/thread93001.html

What I have concluded from the comments is that

PLC is actually runs with a microprocessor or microcontroller based design which supports PLC instructions as its inputs and decodes it to execute it.

If you are good at programming microcontroller and your job to be done with the system is fixed, then it is unnecessary to use a PLC. PLC is a user easy option for electricians where they don’t need to understand all the circuitry and no need to train for every other processor we are using.

If you have employees who are unknown to microcontrollers and the programming language(or unknown to the specific microcontroller you are using) then it is tedious for them understand the things.

But the PLC is independent of the processor inside the instructions are standard.

Atmega with AVR Codevision

Hi friends,

Atmega is the best microcontroller to start with and the AVR Codevision compiler is the easiest C compiler to learn. It has a no of library functions for LCD, serial/SPI/I2C communication, delay and floating point math (which is the most complicated). It has a inbuilt chip burner and code generator. Download the evaluation version from its site http://www.hpinfotech.ro/html/cvavr.htm

 

This is how the CodevisionAVR Desktop looks like. You can drag and drop the boxes. The first box shows source codes and other files associated with your project. The second box

Click at File->New, a pop up will be appear as shown below, select projects

Select yes to use CodeWizardAVR

Now the code wizard will appear, as shown below

Now you can set

 

 

Embedded C

    Few days ago my guide asked a question what is difference between embedded C and standard C.

Difference between Embedded C and standard C

Standard C compilers output a binary file that can be run over a Operating system (windows/Linux). The compilers used for embedded C are cross platform compilers. The main difference is embedded C targets embedded system and standard C targets are Personal computer or servers. Embedded C gives more power to the user to access the memory at bit level. In embedded C the programmer has to write most of the codes himself there is no standard library. Because in embedded systems there is no common I/O is defined like our PC’s where the common I/O’s are the keyboard and the monitor.

  • Difference of the targets either embedded system or a normal PC
  • No standard library
  • No real-time system compatibility
  • Usually there is an infinite loop (not necessary in purely interrupt driven system) which is restricted in standard C
  • Programmers have to consider memory size, stack size as embedded systems have less memory
  • Bit level accessibility of memory
  • Extra data pointers

 

 

 

I²C Protocol in microcontrollers

I²C (Inter-Integrated Circuit) (generically referred to as “two-wire interface”) is a multi-master serial single-ended computer bus invented by Philips that is used to attach low-speed peripherals to a motherboard, embedded system, or cellphone.

No licensing fees are required to implement the I²C protocol. However, fees are still required to obtain I²C slave addresses allocated by NXP.

I²C uses only two bidirectional open-drain lines, Serial Data Line (SDA) and Serial Clock (SCL), pulled up with resistors. Typical voltages used are +5 V or +3.3 V although systems with other voltages are permitted.

Maximum no of I2C UC ca be interfaced: 27=128, 16 reserved addresses, so a maximum of 112 nodes can communicate on the same bus.

Max. Communication Speed: 100 kbit/s standard mode and the 10 kbit/s low-speed mode, but arbitrarily low clock frequencies are also allowed. Recent revisions of I²C can host more nodes and run at faster speeds (400 kbit/s Fast mode, 1 Mbit/s Fast mode plus or Fm+, and 3.4Mbit/s High Speed mode). These speeds are more widely used on embedded systems than on PCs.

3 wire (SPI) Vs 2 wire (I²C):

I²C (for ‘Inter-Integrated Circuit’, protocol) and SPI (for ‘Serial Peripheral Interface’) both protocols are well-suited for communications between integrated circuits, for slow communication with on-board peripherals. At the roots of these two popular protocols we find two major companies – Philips for I²C and Motorola for SPI – and two different histories about why, when and how the protocols were created.

The I²C bus was developed in 1982; its original purpose was to provide an easy way to connect a CPU to peripherals chips in a TV set. Peripheral devices in embedded systems are often connected to the microcontroller as memory-mapped I/O devices. One common way to do this is connecting the peripherals to the microcontroller parallel address and data busses. This results in lots of wiring on the PCB (printed circuit board) and additional ‘glue logic’ to decode the address bus on which all the peripherals are connected. In order to spare microcontroller pins, additional logic and make the PCBs simpler – in order words, to lower the costs – Philips labs in Eindhoven (The Netherlands) invented the ‘Inter-Integrated Circuit’, IIC or I²C protocol that only requires 2 wires for connecting all the peripheral to a microcontroller.

It seems the Serial Peripheral Protocol (SPI) was first introduced with the first microcontroller deriving from the same architecture as the popular Motorola 68000 microprocessor, announced in 1979. SPI defined the external microcontroller bus, used to connect the microcontroller peripherals with 4 wires. Unlike I²C, it is hard to find a formal separate ‘specification’ of the SPI bus – for a detailed ‘official’ description, one has to read the microcontrollers data sheets and associated application notes.

 

Table: Advantages and Disadvantages of 3-/2-Wire Interfaces

Interface 

Advantages 

Disadvantages

3-Wire: SPI, QSPI, and MICROWIRE PLUS

1. Speed
2. No pullup resistors required
3. Full-duplex operation
4. Noise immunity

1. Larger number of bus line connections
2. Individual chip-select lines required to communicate with more than one slave at a time
3. No acknowledgment of received data

2-Wire: I²C and SMBus 

1. Fewer bus line connections
2. Multiple devices share the same bus
3. Received data is acknowledged

1. Speed: SMBus limited to 100kHz; I²C limited to 3.4MHz
2. Half-duplex operation
3.
Open-drain bus lines require pullup resistors
4. Reduced noise immunity


A master and a slave communicate through multiple bus lines over a 
serial interface. During a write cycle, the master uses its own clock and data signals to transmit data to the slave. During a read cycle, the slave transmits data to the master.

External Links:

http://www.esacademy.com/en/library/technical-articles-and-documents/miscellaneous/i2c-bus.html

http://www.eetimes.com/discussion/beginner-s-corner/4023816/Introduction-to-I2C

Measuring and analyzing I²C signals

SPI/I²C Bus Lines Control Multiple Peripherals AN4024

http://www.byteparadigm.com/kb/article/AA-00255/0/Introduction-to-SPI-and-IC-protocols.html

 

http://www.jcontrol.org/tutorials/comm_i2c/index_en.html

http://www.mikroe.com/eng/chapters/view/7/chapter-6-serial-communication-modules/

http://gsmukund.org/articles/i2c/i2c.html

 

 

Introduction to Pattern Recognition

a

“Pattern recognition is the research area that studies the operation and design of systems that recognize patterns in data. It encloses subdisciplines like discriminant analysis, feature extraction, error estimation, cluster analysis (together sometimes called statistical pattern recognition), grammatical inference and parsing (sometimes called syntactical pattern recognition).              .

… Pattern Recognition Group at Delft University of Technology

description of their research area.

“A branch of artificial intelligence concerned with the classification or description of observations. Pattern recognition aims to classify data (patterns) based on either a priori knowledge or on statistical information extracted from the patterns. The patterns to be classified are usually groups of measurements or observations, defining points in an appropriate multidimensional space.”   …. FOLDOC

Pattern recognition is the assignment of some sort of output value (or label) to a given input value (or instance), according to some specific algorithm. An example of pattern recognition is classification, which attempts to assign each input value to one of a given set of classes (for example, determine whether a given email is “spam” or “non-spam”).

Source: wikipedia

Pattern Recognition / Pattern Matching are not same.Pattern recognition algorithms generally aim to provide a reasonable answer for all possible inputs and to do “fuzzy” matching of inputs. This is opposed to pattern matching algorithms, which look for exact matches in the input with pre-existing patterns.

f