29 Ekim 2007 Pazartesi

Pseudo-coherent Radar



A requirement for any Doppler radar is cohenrence; that is, some definite phase relationship must exist between the transmitted frequency and the reference frequency, which is used to detect the Doppler shift of the receiver signal. Moving objects are detected by the phase difference between the target signal and background clutter and noise components. Phase detection of this type relies on coherence between the transmitter frequency and the receiver reference frequency.

If the transmitter output stage is a self oscillating device, the pulse to pulse phase is random on transmission. In coherent detection, a stable cw reference oscillator signal, which is locked in phase with the transmitter during each transmitted pulse, is mixed with the echo signal to produce a beat or difference signal. Since the reference oscillator and the transmitter are locked in phase, the echoes are effectively compared with the transmitter in frequency and phase. This phase reference must be maintained from the transmitted pulse to the return pulse picked up by the receiver.

Pseudo-coherent Radar sets are sometimes called: „coherent-on-receive”

Duplexer
The duplexer alternately switches the antenna between the transmitter and receiver so that only one antenna need be used. This switching is necessary because the high-power pulses of the transmitter would destroy the receiver if energy were allowed to enter the receiver.

Mixer Stage
The function of the mixer stage is to convert the received rf energy to a lower, intermediate frequency (IF) that is easier to amplify and manipulate electronically. The intermediate frequency is usually 30 op to 74 megahertz. It is obtained by heterodyning the received signal with a local-oscillator signal in the mixer stage. The mixer stage converts the received signal to the lower IF signal without distorting the data on the received signal.

IF-Amplifier
After conversion to the intermediate frequency, the signal is amplified in several IF-amplifier stages. Most of the gain of the receiver is developed in the IF-amplifier stages. The overall bandwidth of the receiver is often determined by the bandwidth of the IF-stages.

Automatic Frequency Control
As in all superheterodyne receivers, controlling the frequency of the local oscillator keeps the receiver tuned. Since this tuning is critical, some form of automatic frequency control (afc) is essential to avoid constant manual tuning. Automatic frequency control circuits mix an attenuated portion of the transmitted signal with the local oscillator signal to form an IF signal. This signal is applied to a frequency-sensitive discriminator that produces an output voltage proportional in amplitude and polarity to any change in IF-frequency. If the IF signal is at the discriminator center frequency, no discriminator output occurs. The center frequency of the discriminator is essentially a reference frequency for the IF-signal.

The output of the discriminator provides a control voltage to maintain the local oscillator at the correct frequency.

Stable Local Oscillator
As the receiver is normally a super heterodyne, a stable local oscillator known as the StaLO down converts the signal to intermediate frequency.

Most radar receivers use a 30 up to 74 megahertz intermediate frequency. The IF is produced by mixing a local oscillator signal with the incoming signal. The local oscillator is, therefore, essential to efficient operation and must be both tunable and very stable. For example, if the local oscillator frequency is 3,000 megahertz, a frequency change of 0.1 percent will produce a frequency shift of 3 megahertz. This is equal to the bandwidth of most receivers and would greatly decrease receiver gain.

The power output requirement for most local oscillators is small (20 to 50 milliwatts) because most receivers use crystal mixers that require very little power.

The local oscillator output frequency must be tunable over a range of several megahertz in the 4,000-megahertz region. The local oscillator must compensate for any changes in the transmitted frequency and maintain a constant 30 up to 74 megahertz difference between the oscillator and the transmitter frequency. A local oscillator that can be tuned by varying the applied voltage is most desirable.

Phase-sensitive Detector
The IF-signal is passed to a phase sensitive detector (PSD) which converts the signal to base band, while faithfully retaining the full phase and quadrature information of the Doppler signal. This means, the phase-sensitive detector produces a video signal. The amplitude of the video signal is determined by the phase difference between the coho reference signal and the IF echo signals. This phase difference is the same as that between the actual transmitted pulse and its echo. The resultant video signal may be either positive or negative.

Signal Processor
The signal processor is that part of the system which separates targets from clutter on the basis of Doppler content and amplitude characteristics.

Directional Coupler
The directional coupler provides a sample of the transmitter output on every pulse. This signal adjusts the STALO frequency via the AFC but more importantly, it adjusts the phase of the COHO, locking it to the phase reference from the magnetron. The phase synchronization of the COHO by means of a sample of the magnetron output is mandatory because there is no phase correlation between two successive RF pulses of the magnetron.

Mixer Stage
The function of this mixer stage is to convert the sample of the transmitter output to the intermediate frequency. This coho lock pulse synchronize the coho to a fixed phase relationship with the transmitted frequency at each transmitted pulse.

Coherent Oscillator
The second local oscillator known as the coherent oscillator (COHO) enables the down conversion process into the phase sensitive detector, whilst maintaining an accurate phase reference. The coho lock pulse is originated by the transmitted pulse. It is used to synchronize the coho to a fixed phase relationship with the transmitted frequency at each transmitted pulse.

The COHO takes over the phase of the transmitter tube and provides it to the receiver part of the system. This is the reason why the pseudo-coherent radar is also called „coherent on receive”.

Modulator
The oscillator tube of the transmitter is keyed by a high-power dc pulse of energy generated by this separate unit called the modulator.

Disadvantages of the pseudo-coherent radar
The pseudo-coherent radar is a retired one today, but some older radar sets are still operational. The disadvantages of the pseudo-coherent radar can be summarised as follows:

The phase locking process is not as accurate as a fully coherent system, which reduces the MTI Improvement factor.
This technique cannot be applied to a frequency agile radar. Frequency change in a magnetron relies on the mechanical tuning of a cavity and it is essentially a narrow band device.
It is not flexible and cannot easily accommodate changes in the PRF, pulsewidth or other parameters of the transmitted signal. Such changes are straightforward in a fully coherent radar because they can be performed at low level. It is also impossible to perform FM modulation (which is mandatory for a pulse compression radar) with this type of system.
Second time around echoes are returns from large fixed clutter areas located a long distance from the radar. Because they originate from a large distance, such echoes are returned after a second magnetron pulse has been transmitted. However, they pertain to the first pulse transmitted by the magnetron. Such echoes are range ambiguous but, in addition, second time around clutter will not cancel. This is due to the fact that the phase locking of the COHO applies only to the last transmitted pulse.

29 Ağustos 2007 Çarşamba

Microcontrollers

Introduction - It is all Faraday's fault
In the beginning there was an electricity... People lived in an ignorant bliss, having no idea that energy was everywhere around them and that it could be tamed. It was good... And then came Faraday, and the ball started to roll, picking up the speed slowly but surely...

Eventually, first machines using the new energy source were built, and with these came the first people who could "understand the electricity". Time passed on and just about the time civilized world got used to this new concept and let the self-proclaimed experts toy with it, somebody came up with an idea to put electrons in a glass tube. At the first glance, it seemed like a good idea... but there was no turning back as electronics was born and the ball kept on rolling faster...

New science called for new scientists. White collars took the place of blue collars and there came the people who could "understand the electronics". And while the world stared in awe, the conspirators split up in two factions: those who specialized in software and those who specialized in hardware. Younger and more enthusiastic than their teachers, both groups carried on their efforts, but following the different paths. While the first advanced steadily to this day, those dedicated to hardware got carried away by their success and eventually discovered a transistor.

Up to that crucial moment, the situation could have been controlled to a certain extent - but the public underestimated the importance of this breakthrough and made a grave mistake! In a naive attempt to slow down the technological revolution, world market opened itself for a flood of electronic products, thus closing the circle. Market value of components rapidly decreased, electronics making its way to the younger populace. The ball started to fall freely...

Discovery of the integrated circuits and the processors only sped up the things, making the computers as available as ever. Computers started to upgrade themselves. The resulting deflation brought electronics new wave of devotees, making it omnipresent nowadays. Yet another circle closed - computers fell into the hands of the masses and their rule supreme had begun...

While this drama took place, nameless hobbyists and professionals across the world kept working on their projects, although still divided into two large factions.

And then somebody came up with another great idea: why not create an all-purpose component? A cheap and universal integrated circuit that could be programmed and used in any device, anywhere. Technology was up to the task, there was an interested market... why not? Soul and body were united into one powerful MICROCONTROLLER.

What are microcontrollers and what are they for?
As with everything that is good, this powerful component is actually very simple in its essence. It was built using the tested solutions and ingredients by the following recipe:

Processor was removed from the simplest of computers to be used as the "brain" for the upcoming system.

Depending on the manufacturers' taste, some memory was added, a few A/D converters, timers, I/O communication lines, etc.

It was all placed in a standard casing.

Simple software that everybody could learn was developed for controlling the thing.

A variety of microcontrollers has been constructed in this manner, becoming a man's subtle yet indispensable companion in everyday life. Their incredible simplicity and flexibility has earned our trust awhile ago - if you have an idea of utilizing a microcontroller for the most trivial of tasks, know that somebody has already been there...

There are three decisive facts responsible for such a success of microcontrollers:

Their powerful, cleverly chosen electronics is able to control a variety of processes and devices (industrial automatics, voltage, temperature, engines, etc) independently or by means of I/O instruments such as switches, buttons, sensors, LCD screens, relays...

Their low cost makes them suitable for installing in places which attracted no such interest in the past. This is the fact accountable for today's market being swamped with cheap automatons and "intelligent" toys.

Writing and loading a program into microcontroller requires practically no previous schooling. All that is required is: any PC (software is very friendly and intuitive) and one simple device (programmer) for loading a written program into microcontroller.

So if you are into electronics, you will undoubtedly want to master the great potential of microcontrollers and put it to good use.

How does microcontroller work
Although there are plenty of different microcontrollers and programs available, they all share a lot in common between them. This means that if you master one model, you will be able to handle them all eventually.

Typical scenario goes something like this:

Power is off and all is still... Program is loaded, everything is set, with no indications of what is about to take place...

As soon as the power is on, it all happens too quickly to follow! First one to register the change is the control logic. It halts all the circuits except the quartz oscillator. First few milliseconds pass in hurried preparations and loading of parasitic capacitances...

As voltage reaches its maximum, oscillator frequency stabilizes. SFR registers are loaded with bits indicating the states of the subsystems, and all the pins are designated as input. Impulse sequence starts dictating the pace and the electronics is now fully operational. From this point on, time is measured in microseconds and nanoseconds.

Program counter is reset to zero address of the program memory. Instruction is sent from this address to the instruction decoder where it is interpreted and executed promptly.

Program counter is incremented by one as the whole process plays out again... (several millions of times per second)

Obviously, it all works at tremendous speeds, and is also pretty simple. But it would not be especially useful if it was not for additional systems which round out the MCU:

Read Only Memory (ROM)
ROM is the memory which stores the program to be executed. Apparently, its size dictates the maximal program length. It can be internal or external with respect to the microcontroller. Both options have their pros and cons; external memory chip makes the microcontroller cheaper and allows for longer programs. At the same time, number of available free pins is reduced as external ROM uses MCU's I/O ports. Internal ROM is usually smaller and more costly but it provides more possibilities for connecting to the outside world. ROM spans from 512 bytes to 64kB, which is an equivalent to the number of possible program instructions.

Random Access Memory (RAM)
RAM is used for temporary storage of data during runtime. RAM memory does not retain its stored information when the power is interrupted. RAM spans from tens of bytes to several kilobytes.

EEPROM Memory
EEPROM is a special kind of memory not available with all MCUs. Its contents can be changed during runtime (as with RAM), but is also saved after the power is off (as with ROM).

SFR Registers
Special Function Registers are special elements of RAM, their purpose predefined by the manufacturer. Each of these registers is named and controls a certain subsystem of MCU. For example: by writing zeros and ones to the SFR register which controls an I/O port, each of these pins can be designated as input or output (each register bit corresponds to one of the port pins).

Program Counter
This is the "engine" which starts the program and points to the memory address of the instruction to be executed. Immediately upon its execution, value of counter increments by 1. Due to this automatic increase, program executes one instruction at a time, just the way it was written. However... value of a counter can be changed anytime with a "jump" to a new program memory location as a result. This is how routines and branch instructions are carried out. Upon performing a jump to the specified destination, Program Counter increase carries on steadily, +1, +1, +1...

In case you forgot...
Bit is the term often found to be confusing by those starting out in electronics. In practice (and in practice only) bit determines if voltage exists between two points of a circuit. If it does, we say that logic level is 1, i.e. bit is 1. If not, logic level is 0, i.e. bit is 0.

In theory, things are a little bit more complicated - bit actually represents a digit of binary system. As such, it can still have only one of two values - zero or one, set or clear (unlike the decimal system we are used to).

Control Logic
As the name implies, this is the "Big Brother" which supervises and controls every aspect of operations within MCU, and it cannot be manipulated. It comprises several parts, the most important ones including:

Instructions Decoder – part of the electronics which "recognizes" different program instructions and directs the other circuits accordingly.

Arithmetical Logical Unit (ALU) – is in charge of all mathematical and logical operations over data. Capabilities of this circuit are represented through the so called "instruction set" which is different for every MCU.

Accumulator – a special SFR register highly interconnected with ALU. It can be described as a working desk for performing operations on data (adding, shifting, etc). Also, this is the register which holds the result of the operation. Of SFR registers, Status Register is specifically associated with the accumulator. It monitors the status of the accumulator's content at all times (is zero, is greater than zero, etc).

In case you forgot...
Byte is a set of 8 adjacent bits. As bit represents a digit, it is logical to assume that byte represents a number. All standard mathematical operations that can be applied to decimal numbers can be applied to bytes. These are carried out by ALU.

It is important to note that byte has "two sides", i.e. not all positions are of the same significance. The leftmost bit is the Most Significant Bit (MSb). The rightmost bit is the Least Significant Bit (LSb). As there are 256 possible variations of 8 bits, the greatest decimal number byte can represent is 255 (zero is included!) .

A/D Converter
Another convenient instrument not available with all MCUs. Usually there are several separate channels so that multiple analog values can be measured simultaneously. Commonly, converters are 8, 10, or 12-bit and this is sufficient for most tasks.

As shown on the image below, A/D conversion (converting analog value to a numeral) starts with changing the bit in the appropriate SFR register. Hence, voltage on input pin is measured (this sampling takes a few microseconds) and stored in another SFR register as a numeral.

In our example, 8-bit A/D converter is used and the default voltage is 5V. This divides the scale in 256 units, with the smallest voltage range that can be represented of 19.53mV (5V / 256 = 19.53mV). On such a "crude" scale, voltage of 2.204V is represented by numeral 113 (113 x 19.53mV = 2.207V).

Converters of higher resolutions (10 and 12-bit) have much finer scales of 1024 or 4096 units, respectively. Using one of these instruments under the same conditions from the previous example would significantly reduce the inaccuracy (as shown on the image below).

In case you forgot...
Register is a byte physically realized as electronic component, and represents a basic memory cell. Beside the 8 bits available to the user, there is also an address part not readily accessible.

ROM and RAM registers are nameless and are usually peers.

SFR registers are named (differently with different MCUs) and each has its role.

When writing a code for MCU in one of the higher programming languages, each register can be given an arbitrary name, which proved to be useful.

I/O Ports
To be of any practical use, microcontroller needs to be connected to other electronics and to the environs. For this purpose, every MCU has one or more registers (also known as ports) which are connected to the pins on its case. Why I/O? Because every pin can be designated as eiher input or output to suit user's needs.

Oscillator
This is the rhythm section of the miniature orchestra. Stable pace provided by this instrument allows harmonious and synchronous functioning of all other parts of MCU. Commonly, oscillator frequency is stabilized using a quartz-crystal or a ceramic resonator. It can also work without an element for stabilizing frequency (as RC oscillator). Note that instructions are executed at a rate several times slower than the pace dictated by the oscillator. This happens because instructions take several steps to be accomplished (execution period of different instructions may vary on different MCUs). Therefore, if your system uses 20MHz quartz-crystal, execution period of one program instruction will not be 50 ns, but more likely 200, 400 or a "whole" 800 ns.

Timers
Majority of programs utilizes these miniature electronic "stopwatches". Commonly, timers are 8 or 16-bit registers whose value automatically increases upon an impulse. If timer is stimulated by an internal MCU oscillator, it can be used for measuring time between two occurrences (register value at the start of measuring = T1, register value at the end of measuring = T2, elapsed time = T2-T1). If timer is triggered by impulses from an external source, instrument behaves like a counter.

In both cases, filling the register resets the counter and the occurrence is recorded in a particular bit of SFR register (Overflow flag). This makes possible to measure longer time periods. Also, if enabled, this flag can cause an interrupt for breaking the program and carrying out a designated routine (see the image).

Watchdog Timer
The name itself implies the role of this instrument. It is a timer with input connected to an independent MCU RC oscillator. If Watchdog is enabled, MCU is reset every time it overflows, and the program execution starts anew (much as if the power had just been turned on). The idea is to prevent that from happening by means of special instruction. Whole concept is based upon a fact that every program technically "goes around", i.e. executes within a number of simpler or more complex loops. If, beside the regular instructions, key places in the program were added an instruction for resetting the Watchdog, its safeguard function would pass unnoticed. If, for some reason, (in industrial environment, electrical interference is common) Program Counter "gets stuck" at a memory location with no return, the ever-increasing Watchdog Timer eventually overflows and voila - MCU is reset.

In case you forgot...
Interrupt ; electronics is generally way faster than physical processes in the environment it controls. Therefore, microcontroller spends most of its time in expecting an occurrence or waiting for tasks to be accomplished. To avoid the repeated checks of input pins and internal registers, interrupt was introduced. It is a signal which breaks the standard order of program execution. In case of an interrupt, MCU comes to a halt, and determines the source of interrupt. If certain action is required, current value of Program Counter is set aside to Stack and the appropriate routine (interrupt routine) is executed.

Stack is a special part of RAM for storing the current value of Program Counter, so that program could "know" where to pick up after the interrupt routine. It can be multi-leveled, i.e. routines can be executed within other routines.

Power Supply Circuit
Two features of the MCU power supply circuit deserve your attention:

Brown out – this is a potentially dangerous state which occurs during the shutdown or in situations when voltage "oscillates" on the edge of the allowed range due to strong interference. Since microcontroller comprises a number of elements with various voltage ranges, this can cause their uncontrolled behavior. To prevent this from happening, brown out reset circuit is included within MCU. If voltage drops below the specified value for high-voltage elements of MCU, brown out promptly resets the entire electronics.

Reset pin – frequently marked as MCLR (Master Clear Reset) is used for "external" reset of microcontroller by bringing the logical zero or one (depending on the MCU). If not preinstalled, a simple external brown out reset circuit can be connected to this pin.

26 Ağustos 2007 Pazar

POWER TRANSFORMERS

power transformers
State-of-the-Art Electrical Power Transformer SalesWith experience in electrical power distribution products since 1968, AAA Acme General Electrical Power Transformer Distribution started as a family owned and run company. Today we have grown to be a National Supplier of quality brand name single and three phase electric power transformers including Acme Transformers, Marcus Transformers, TEMCo Transformers, Hammond Transformers, Sola Transformers and GE Transformers. We specify and distribute a wide variety of high quality electrical transformers daily from regional warehouses at wholesale prices. Models include step up, step down, single and three phase, isolation, buck boost, distribution transformers and others. Our experienced power transformer specialists work closely with electrical contractors, electricians, and manufacturers who use transformers to help specify the very best power transformer to best meet the need.
Highest Quality Brand Power TransformersNo matter what your power transformer needs are we can help you select the very best brand and model power transformers. We have a full range of the very best electrical transformers constructed to the strictest UL, European and Canadian electrical code requirements. Enjoy the security of using the best power transformer products from leading brands such as TEMCo, Marcus, Hammond, GE and Acme.
Knowledgeable & Friendly Electrical Power Transformer Selection AssistanceWe built our business and reputation by helping customers with friendly and knowledgeable electrical transformer selection assistance. Put our years of experience with various electrical applications to work for you. Give us a call to help select the power transformer to meet your application's specific needs.
Custom Power Transformers Built To Your SpecificationIf you need a transformer that is not manufactured stock by any of the power transformer manufacturers, just let us know - we can help. We can help you get custom power transformers built to meet your electrical needs. Our specialists can help you determine your need and get it built. We can even get custom transformers built with one of the fastest turnaround times in the transformer industry. With our manufacturers, most custom power transformers can be built and ready to ship in 5 days or less!
Need Power Transformers Fast? We Offer Quick Nationwide and International Shipping from Regional WarehousesWith warehouses stocking a wide variety of power transformers throughout the country we can ship your order to you ASAP. We understand that fast, reliable power transformer supplies can help you meet your construction and replacement time deadlines. Let us know what your time needs are and we will work hard to help you meet them.
Contact our experienced electrical power transformer specialists at AAA Acme General Electrical Power Transformer Distribution & our distribution partner Tower at 510-490-2187 to get your quote, place your order and arrange for shipping. Our electrical specialists are standing by and ready to help.

25 Ağustos 2007 Cumartesi

Development of an integrated robotic laser welding head - Ir. D. Iakovou

Project Description

The advancement of laser technology allows welding procedures to be implemented with high velocities (up to 250 mm/sec). Industrial robots can be used to perform such high velocity laser welding processes. Still, the positioning accuracy of the industrial robots is insufficient for open-loop (first teach then weld) laser welding. Therefore, additional sensor systems must be used to overcome the positioning accuracy problem by measuring and correcting the position of the welding tool in real time.

Systems already in existence, make use of “of the self” sensor that are mounted on the welding head to perform a certain operation. The addition of separate sensor systems onto the welding head increases its volume and restricts its usability. Therefore there is need for laser welding heads that have sensors integrated in them, and that can perform all the required processes like seam tracking, seam inspection and laser welding process control.

Objectives

The aim of this research project is to develop a prototype welding head with integrated optical sensory systems (optical sensors, structured light, etc) that will enable it to:

-
Assist and teach an industrial robot to track a weld joint (butt, corner, overlap, etc.) in 3-dimensional space.

-
Correct in real time any positioning errors

-
Monitor and control the laser welding process.

-
Inspect the welded seam and provide information about the weld surface quality.


The final integrated head must be designed for compactness which will improve the accessibility of complicated products and avoid deterioration of the dynamic performance of the robot.

Experimental Setup

The first prototype laser welding head (Fig.1) was designed to provide the ability to easily mount and test each of the required processes.

The setup consists of:

-
a collimator lens system and holder

-
a fiber link

-
a coaxial mirror with a mirror holder

-
a hexagonal shaped main body

-
the main body side plates

-
a high power laser focus lens holder

-
cooling rings

-
three adjustable holders for structured light laser diodes


The purpose of the coaxial mirror is to provide a camera system with a coaxial view to the high power laser. The purpose of the mirror holder is to enable the mirror to rotate towards each of the six sides of the main body where sensory systems can be integrated.

The camera with a coaxial view to the welding laser is to monitor the changes of the structured light shape on the seam and the joint plates. It can be easily understood that changes of the orientation or distance of the joint plates result in changes of the shape of the structured light. By processing the images that are captured by the camera it is possible to measure the features of the projected structured light. Thus, it is possible calculate the actual orientation and position of the welding head towards the work piece as well as the position of the seam

The prototype is designed so that the size, shape and position of the structured light are adjustable, because the influence of the process illumination is yet to be determined.

Currently, the laser structured light projectors used are 3mW line projectors. The structured light shape is projected around the tool center point of the laser head.

Sensor-guided robotic laser welding for 3-D seam welding (CRAFT project SenseLasBot) - Ir. M.W. de Graaf

Project background

Current laser welding techniques put high demands on the manipulator that is used. For most applications, accuracies in the order of 100 µm have to be reached at velocities up to 250 mm/s. It is not feasible to program industrial robots that accurate in a production environment. Sensors are needed to increase the positional accuracy and ease-of-use of a robotic welding cell.


OBJECTİVES
The main objective of this research project is the development of a fully automated robotic laser welding cell by integrating a Nd:YAG laser, an industrial 6-axis robot, laser welding optics, an optical seam-tracking sensor and process sensors (Figure 1). Both a commercial seam-tracking sensor (Falldorf GmbH) and the developed integrated welding head of Iakovou will be considered. The system uses sensor information for teaching of the welding trajectory. Furthermore it measures the seam trajectory in real-time during the robot motion and compensates for positioning errors, hereby making robot programming easier and faster.

Seam tracking
An optical seam-tracking sensor is used to accurately measure the seam trajectory in the product to be welded. The commercial sensor uses the principle of optical triangulation (Figure 2) to measure four coordinates (3D position and 1 rotation angle) of the weld joint with respect to its coordinate frame. The integrated welding head of Iakovou can even measure six coordinates (3D position and complete orientation). To be able to use the seam-tracking sensor while the robot is moving, the sensor measurements and the robot joint position measurements have to be synchronized. Algorithms are being developed that can teach an unknown seam trajectory while the robot is moving and track an approximately known seam trajectory during laser welding. For this development and subsequent testing, a simulation environment has been realized, where the effect of non-ideal behavior like sensor errors, robot geometric errors etc can be simulated.

System architecture

The system components are shown in Figure 3. There is a separation between tasks that have to be carried out in real-time (hardware control during welding, seam tracking) and tasks that don’t necessarily have to be in real-time (seam teaching, tool calibration, product frame calibration). The software framework is designed in such a way that it is independent of the hardware used. Different robots and sensors can therefore be used

LASER
A Graphical User Interface, called 24-Laser has been developed. With this GUI the robot can be programmed and welding jobs can be carried out. Furthermore a number of dedicated tasks have been implemented
·
Laser and sensor tool calibration

·
Manual robot motion control

·
Sensor-guided seam-teaching using point-to-point movements

·
Real-time seam-tracking

·
Product frame calibration



24-Laser communicates with the robot and sensor through commonly used Ethernet-sockets. Only a part of the software, necessary for communication and real-time control of the hardware, is located at the robot controller, making this GUI robot and sensor independent.

Research objectives

·
Development of intelligent seam-teaching algorithms for easy robot-programming.

·
Development of real-time seam-tracking algorithms for faster robot-programming and to compensate for product clamping errors, etc.

·
Development of a Graphical User Interface for work-preparation and job-processing

·
Implementation of easy and reliable calibration procedures for the calibration of laser and sensor tool center point

·
Integration of the software framework on multiple robot and sensor platforms

PLC controller

Architecture of specific PLC controller

Introduction
4.1 Why OMRON?
4.2 CPM1A PLC controller
4.3 PLC controller input lines
4.4 PLC controller output lines
4.5 How PLC controller works
4.6 CPM1A PLC controller memory map
4.7 Timers and counters


Introduction

This book could deal with a general overview of some supposed PLC controller. Author has had an opportunity to look over plenty of books published up till now, and this approach is not the most suitable to the purposes of this book in his opinion. Idea of this book is to work through one specific PLC controller where someone can get a real feeling on this subject and its weight. Our desire was to write a book based on whose reading you can earn some money. After all, money is the end goal of every business!

4.1 Why OMRON?

Why not? It is a huge company which has high quality and by our standards inexpensive controllers. Today we can say almost with surety that PLC controllers by manufacturers round the world are excellent devices, and altogether similar. Nevertheless, for specific application we need to know specific information about a PLC controller being used. Therefore, the choice fell on OMRON company and its PLC of micro class CPM1A. Adjective "micro" itself implies the smallest models from the viewpoint of a number of attached lines or possible options. Still, this PLC controller is ideal for the purposes of this book, and that is to introduce a PLC controller philosophy to its readers.

4.2 CPM1A PLC controller

Each PLC is basically a microcontroller system (CPU of PLC controller is based on one of the microcontrollers, and in more recent times on one of the PC processors) with peripherals that can be digital inputs, digital outputs or relays as in our case. However, this is not an "ordinary" microcontroller system. Large teams have worked on it, and a checkup of its function has been performed in real world under all possible circumstances. Software itself is entirely different from assemblers used thus far, such as BASIC or C. This specialized software is called "ladder" (name came about by an association of program's configuration which resembles a ladder, and from the way program is written out).

Specific look of CPM1A PLC controller can be seen in the following picture. On the upper surface, there are 4 LED indicators and a connection port with an RS232 module which is interface to a PC computer. Aside from this, screw terminals and light indicators of activity of each input or output are visible on upper and lower sides. Screw terminals serve to manually connect to a real system. Hookups L1 and L2 serve as supply which is 220V~ in this case. PLC controllers that work on power grid voltage usually have a source of direct supply of 24 VDC for supplying sensors and such (with a CPM1A source of direct supply is found on the bottom left hand side and is represented with two screw terminals. Controller can be mounted to industrial "track" along with other automated elements, but also by a screw to the machine wall or control panel.

Controller is 8cm high and divided vertically into two areas: a lower one with a converter of 220V~ at 24VDC and other voltages needed for running a CPU unit; and, upper area with a CPU and memory, relays and digital inputs.
When you lift the small plastic cover you'll see a connector to which an RS232 module is hooked up for serial interface with a computer. This module is used when programming a PLC controller to change programs or execution follow-up. When installing a PLC it isn't necessary to install this module, but it is recommended because of possible changes in software during operation.
better inform programmers on PLC controller status, maker has provided for four light indicators in the form of LED's. Beside these indicators, there are status indicators for each individual input and output. These LED's are found by the screw terminals and with their status are showing input or output state. If input/output is active, diode is lit and vice versa.


4.3 PLC controller output lines

Aside from transistor outputs in PNP and NPN connections, PLC can also have relays as outputs. Existence of relays as outputs makes it easier to connect with external devices. Model CPM1A contains exactly these relays as outputs. There a 4 relays whose functional contacts are taken out on a PLC controller housing in the form of screw terminals. In reality this looks as in picture below.


4.4 PLC controller input lines

Different sensors, keys, switches and other elements that can change status of a joined bit at PLC input can be hooked up to the PLC controller inputs. In order to realize a change, we need a voltage source to incite an input. The simplest possible input would be a common key. As CPM1A PLC has a source of direct voltage of 24V, the same source can be used to incite input (problem with this source is its maximum current which it can give continually and which in our case amounts to 0.2A). Since inputs to a PLC are not big consumers (unlike some sensor where a stronger external supply must be used) it is possible to take advantage of the existing source of direct supply to incite all six keys.


4.5 How PLC controller works

Basis of a PLC function is continual scanning of a program. Under scanning we mean running through all conditions within a guaranteed period. Scanning process has three basic steps:

Step 1.
Testing input status. First, a PLC checks each of the inputs with intention to see which one of them has status ON or OFF. In other words, it checks whether a sensor, or a switch etc. connected with an input is activated or not. Information that processor thus obtains through this step is stored in memory in order to be used in the following step.

Step 2.
Program execution. Here a PLC executes a program, instruction by instruction. Based on a program and based on the status of that input as obtained in the preceding step, an appropriate action is taken. This reaction can be defined as activation of a certain output, or results can be put off and stored in memory to be retrieved later in the following step.

Step 3.
Checkup and correction of output status. Finally, a PLC checks up output status and adjusts it as needed. Change is performed based on the input status that had been read during the first step, and based on the results of program execution in step two. Following the execution of step 3 PLC returns to the beginning of this cycle and continually repeats these steps. Scanning time is defined by the time needed to perform these three steps, and sometimes it is an important program feature.
4.6 CPM1A PLC controller memory map

By memory map we mean memory structure for a PLC controller. Simply said, certain parts of memory have specific roles. If you look at the picture below, you can see that memory for CPM1A is structured into 16-bit words. A cluster of several such words makes up a region. All the regions make up the memory for a PLC controller.

Unlike microcontroller systems where only some memory locations have had their purpose clearly defined (ex. register that contains counter value), a memory of PLC controller is completely defined, and more importantly almost entire memory is addressable in bits. Addressability in bits means that it is enough to write the address of the memory location and a number of bits after it in order to manipulate with it. In short, that would mean that something like this could be written: "201.7=1" which would clearly indicate a word 201 and its bit 7 which is set to one.

IR region

Memory locations intended for PLC input and output. Some bits are directly connected to PLC controller inputs and outputs (screw terminal). In our case, we have 6 input lines at address IR000. One bit corresponds to each line, so the first line has the address IR000.0, and the sixth IR000.5. When you obtain a signal at the input, this immediately affects the status of a corresponding bit. There are also words with work bits in this region, and these work bits are used in a program as flags or certain conditional bits.

SR region

Special memory region for control bits and flags. It is intended first and foremost for counters and interrupts. For example, SR250 is memory location which contains an adjustable value, adjusted by potentiometer no.0 (in other words, value of this location can be adjusted manually by turning a potentiometer no.0.

TR region

When you move to a subprogram during program execution, all relevant data is stored in this region up to the return from a subprogram.

HR region

It is of great importance to keep certain information even when supply stops. This part of the memory is battery supported, so even when supply has stopped it will keep all data found therein before supply stopped.

AR region

This is one more region with control bits and flags. This region contains information on PLC status, errors, system time, and the like. Like HR region, this one is also battery supported.

LR region

In case of connection with another PLC, this region is used for exchange of data.

Timer and counter region

This region contains timer and counter values. There are 128 values. Since we will consider examples with timers and counters, we will discus this region more later on.

DM region

Contains data related to setting up communication with a PC computer, and data on errors.

Each region can be broken down to single words and meanings of its bits. In order to keep the clarity of the book, this part is dealt with in Attachments and we will deal with those regions here whose bits are mostly used for writing.

.7 Timers and counters

Timers and counters are indispensable in PLC programming. Industry has to number its products, determine a needed action in time, etc. Timing functions is very important, and cycle periods are critical in many processes.

There are two types of timers delay-off and delay-on. First is late with turn off and the other runs late in turning on in relation to a signal that activated timers. Example of a delay-off timer would be staircase lighting. Following its activation, it simply turns off after few minutes.

Each timer has a time basis, or more precisely has several timer basis. Typical values are: 1 second, 0.1 second, and 0,01 second. If programmer has entered .1 as time basis and 50 as a number for delay increase, timer will have a delay of 5 seconds (50 x 0.1 second = 5 seconds).

Timers also have to have value SV set in advance. Value set in advance or ahead of time is a number of increments that timer has to calculate before it changes the output status. Values set in advance can be constants or variables. If a variable is used, timer will use a real time value of the variable to determine a delay. This enables delays to vary depending on the conditions during function. Example is a system that has produced two different products, each requiring different timing during process itself. Product A requires a period of 10 seconds, so number 10 would be assigned to the variable. When product B appears, a variable can change value to what is required by product B.

Typically, timers have two inputs. First is timer enable, or conditional input (when this input is activated, timer will start counting). Second input is a reset input. This input has to be in OFF status in order for a timer to be active, or the whole function would be repeated over again. Some PLC models require this input to be low for a timer to be active, other makers require high status (all of them function in the same way basically). However, if reset line changes status, timer erases accumulated value.

With a PLC controller by Omron there are two types of timers: TIM and TIMH. TIM timer measures in increments of 0.1 seconds. It can measure from 0 to 999.9 seconds with precision of 0.1 seconds more or less.

Quick timer (TIMH) measures in increments of 0.01 seconds. Both timers are "delay-on" timers of a lessening-style. They require assignment of a timer number and a set value (SV). When SV runs out, timer output turns on. Numbers of a timing counter refer to specific address in memory and must not be duplicated (same number can not be used for a timer and a counter).

CHAPTER 6 Examples for subsystems within microcontroller

Examples for subsystems within microcontroller

Introduction

6.1 Writing to and reading from EEPROM
6.2 Processing interrupt caused by changes on pins RB4-RB7
6.3 Processing interrupt caused by change on pin RB0
6.4 Processing interrupt caused by overflow on timer TMR0
6.5 Processing interrupt caused by overflow on TMR0 connected to external input (TOCKI)



Introduction

Every microcontroller comprises a number of subsystems allowing for flexibility and wide range of applications. These include internal EEPROM memory, AD converters, serial or other form of communication, timers, interrupts, etc. Two most commonly utilized elements are interrupts and timers. One of these or several in combination can create a basis for useful and practical programs.

6.1 Writing to and reading from EEPROM

Program "eeprom.asm" uses EEPROM memory for storing certain microcontroller parameters. Transfer of data between RAM and EEPROM has two steps - calling macros eewrite and eeread. Macro eewrite writes certain variable to a given address, while eeread reads the given address of EEPROM and stores the value to a variable.

Macro eewrite writes the address to EEADR register and the variable to EEDATA register. It then calls the subprogram which executes the standard procedure for initialization of writing data (setting WREN bit in EECON1 register and writing control bytes 0x55 and 0xAA to EECON2).



For data to be actually stored in EEPROM, 10ms delay is necessary. This is achieved by using macro pausems. In case that this pause is unacceptable for any reason, problem can be solved by using an interrupt for signaling that data is written to EEPROM.



eewrite macro addr, var

addr Destination address. With PIC16F84, there are 68 bytes
of EEPROM for a total address range of 0x00 - 0x44.
var Name of the variable to be stored to EPROM

eeread macro addr, var

addr Destination address. With PIC16F84, there are 68 bytes
of EEPROM for a total address range of 0x00 - 0x44.
var Name of the variable into which data read from EPROM will be stored.



Example: Variable volume, which is set via buttons RA0 and RA1, will be stored to the address 0 of EEPROM. After reboot, when the program is started, it first loads the last known value of variable volume from EEPROM

6.2 Processing interrupt caused by changes on pins RB4-RB7

Program "intportb.asm" illustrates how interrupt can be employed for indicating changes on pins RB4-RB7. Upon pushing any of the buttons, program enters the interrupt routine and determines which pin caused an interrupt. This program could be utilized in systems with battery power supply, where power consumption plays an important role. It is useful to set microcontroller to low consumption mode with a sleep instruction. Microcontroller is practically on stand-by, saving energy until the occurrence of interrupt


Example of processing interrupt caused by changes on pins RB4-RB7


6.3 Processing interrupt caused by change on pin RB0

Example "intrb0.asm" demonstrates use of interrupt RB0/INT. Upon falling edge of the impulse coming to RB0/INT pin, program jumps to subprogram for processing interrupt. This routine then performs a certain operation, in our case it blinks the LED diode on PORTB, 7.



Example of processing interrupt caused by changes on pin RB0


6.4 Processing interrupt caused by overflow on timer TMR0

Program "inttmr0.asm" illustrates how interrupt TMR0 can be employed for generating specific periods of time. Diodes on port B are switched on and off alternately every second. Interrupt is generated every 5.088ms; in interrupt routine variable cnt is incremented to the cap of 196, thus generating approx. 1 second pause (5.088ms*196 is actually 0.99248s). Pay attention to initialization of OPTION register which enables this mode of work for timer TMR0.




19 Ağustos 2007 Pazar

Industrial computers

Industrial Computer, Industrial PC, Industrial System, Industrial Motherboard

Industrial computers are intended for use on factory floors in the originally and extend to operate in other harsh environments. Unlike office and personal computers, these systems are designed to withstand shock, vibration, humidity, EMI, RFI, dust, mist, and splash. Industrial computers are available in many configurations with a variety of CPUs, displays, and I/O interfaces and have the longevity service support. Configuration or mounting style, processor type, memory, storage, and display are the most important factors to consider when searching for industrial computers. Additional specifications that are important to consider include I/O interfaces, expansion, power supply, features, and environmental parameters.
Advantech provides industrial computers to enable our partners and customers to easily and quickly leverage commercial computing technology according to their needs. In addition to our complete product selections with leading technology and features for mission-critical applications, Advantech provides streamlined global integration services to ensure our customers have a complete, flexible, and fast time-to-market industrial computing solution.
Our industrial grade reliability, long product life cycles and localized customization services are all adapted to closely meet customers' needs. Advantech services offer business advantages with faster time-to-market response, high quality products, global logistics, service and manufacturing support. Advantech provides cost effective solutions and a stream of embedded CPU and system platforms for the most critical and demanding applications to system integrators. Advantech offers a full diverse range of single board computers, for entertainment, communications, military, automation, medical, transportation and computer telephony.

17 Ağustos 2007 Cuma

Macros and subprograms chapter6

Introduction

5.1 Macros
5.2 Subprograms
5.3 Macros used in the examples

Introduction

Same or similar sequence of instructions is frequently used during programming. Assembly language is very demanding. Programmer is required to take care of every single detail when writing a program, because just one incorrect instruction or label can bring about wrong results or make the program doesn't work at all. Solution to this problem is to use already tested program parts repeatedly. For this kind of programming logic, macros and subprograms are used.

5.1 Macros

Macro is defined with directive macro containing the name of macro and parameters if needed. In program, definition of macro has to be placed before the instruction line where macro is called upon. When during program execution macro is encountered, it is replaced with an appropriate set of instructions stated in the macro's definition.

macro_name
macro par1, par2,..
set of instructions
set of instructions
endm

The simplest use of macro could be naming a set of repetitive instructions to avoid errors during retyping. As an example, we could use a macro for selecting a bank of SFR registers or for a global permission of interrupts. It is much easier to have a macro BANK1 in a program than having to memorize which status bit defines the mentioned bank. This is illustrated below: banks 0 and 1 are selected by setting or clearing bit 5 (RP0) of status register, while interrupts are enabled by bit 7 of INTCON register. First two macros are used for selecting a bank, while other two enable and disable interrupts.



bank0 macro ; Macro bank0
bcf STATUS, RP0 ; Reset RP0 bit = Bank0
endm ; End of macro

bank1 macro ; Macro bank1
bsf STATUS, RP0 ; Set RP0 bit = Bank1
endm ; End of macro

enableint macro ; Interrupts are globally enabled
bsf INTCON, 7 ; Set the bit
endm ; End of macro

disableint macro ; Interrupts are globally disabled
bcf INTCON, 7 ; Reset the bit
endm ; End of macro



These macros are to be saved in a special file with extension INC (abbrev. for INCLUDE file). The following image shows the file bank.inc which contains two macros, bank0 and bank1.


Macros Bank0 and Bank1 are given for illustrational purposes more than practical, since directive BANKSEL NameSFR does the same job. Just write BANKSEL TRISB and the bank containing the TRISB register will be selected.

As can be seen above, first four macros do not have parameters. However, parameters can be used if needed. This will be illustrated with the following macros, used for changing direction of pins on ports. Pin is designated as input if the appropriate bit is set (with the position matching the appropriate pin of TRISB register, bank1) , otherwise it's output.



input macro par1, par2 ; Macro input
bank1 ; In order to access TRIS registers
bsf par1, par2 ; Set the given bit - 1 = input
bank0 ; Macro for selecting bank0
endm ; End of macro

output macro par1, par2 ; Macro output
bank1 ; In order to access TRIS registers
bcf par1, par2 ; Reset the given bit - 0 = output
bank0 ; Macro for selecting bank0
endm ; End of macro



Macro with parameters can be called upon in following way:

output TRISB, 7 ; pin RB7 is output

When calling macro first parameter TRISB takes place of the first parameter, par1, in macro's definition. Parameter 7 takes place of parameter par2, thus generating the following code:



output TRISB, 7 ; Macro output
bsf STATUS, RP0 ; Set RP0 bit = BANK1
bcf TRISB, 7 ; Designate RB7 as output
bcf STATUS, RP0 ; Reset RP0 bit = BANK0
endm ; End of macro



Apparently, programs that use macros are much more legible and flexible. Main drawback of macros is the amount of memory used - every time macro name is encountered in the program, the appropriate code from the definition is inserted. This doesn't necessarily have to be a problem, but be warned if you plan to use sizeable macros frequently in your program.

In case that macro uses labels, they have to be defined as local using the directive local. As an example, below is the macro for calling certain function if carry bit in STATUS register is set. If this is not the case, next instruction in order is executed.



callc macro label ; Macro callc
local Exit ; Defining local label within macro
bnc Exit ; If C=0 jump to Exit and exit macro
call label ; If C=1 call subprogram at the
; address label outside macro
Exit ; Local label within macro
endm ; End of macro



5.2 Subprograms

Subprogram represents a set of instructions beginning with a label and ending with the instruction return or retlw. Its main advantage over macro is that this set of instructions is placed in only one location of program memory. These will be executed every time instruction call subprogram_name is encountered in program. Upon reaching return instruction, program execution continues at the line succeeding the one subprogram was called from. Definition of subprogram can be located anywhere in the program, regardless of the lines in which it is called.



Label ; subprogram is called with "call Label"
set of instructions
set of instructions
set of instructions
return or retlw



With macros, use of input and output parameters is very significant. With subprograms, it is not possible to define parameters within the subprogram as can be done with macros. Still, subprogram can use predefined variables from the main program as its parameters.

Common course of events would be: defining variables, calling the subprogram that uses them, and then reading the variables which may have been changed by the subprogram.

The following example, addition.asm adds two variables, PAR1 and PAR2, and stores the result to variable RES. As 2-byte variables are in question, lower and higher byte has to be defined for each of these. The program itself is quite simple; it first adds lower bytes of variables PAR1 and PAR2, then it adds higher bytes. If two lower bytes total exceeds 255 (maximum for a byte) carry is added to variable RESH.


Basic difference between macro and subprogram is that the macro stands for its definition code (sparing the programmer from additional typing) and can have its own parameters while subprogram saves memory, but cannot have its own parameters.


5.3 Macros used in the examples

Examples given in chapter 6 frequently use macros ifbit, ifnotbit, digbyte, and pausems, so these will be explained in detail. The most important thing is to comprehend the function of the following macros and the way to use them, without unnecessary bothering with the algorithms itself. All macros are included in the file mikroel84.inc for easier reference.

5.3.1 Jump to label if bit is set

ifbit macro par1, par2, par3
btfsc par1, par2
goto par3
endm

Macro is called with : ifbit Register, bit, label

5.3.2 Jump to label if bit is cleared

ifnotbit macro par1, par2, par3
btfss par1, par2
goto par3
endm

Macro is called with : ifnotbit Register, bit, label

Next example shows how to use a macro. Pin 0 on port A is checked and if set, program jumps to label ledoff, otherwise macro ifnotbit executes, directing the program to label ledon.



5.3.3 Extracting ones, tens and hundreds from variable

Typical use for this macro is displaying variables on LCD or 7seg display.

digbyte macro par0
local Pon0
local Exit1
local Exit2
local Positive
local Negative
clrf Dig1
clrf Dig2
clrf Dig3
Positive
movf par0, w
movwf Digtemp
movlw .100
Pon0 incf Dig1 ;computing hundreds digit
subwf Digtemp
btfsc STATUS, C
goto Pon0
decf Dig1, w
addwf Digtemp, f
Exit1 movlw .10 ;computing tens digit
incf Dig2, f
subwf Digtemp, f
btfsc STATUS, C
goto Exit1
decf Dig2, f
addwf Digtemp, f
Exit2 movf Digtemp, w ;computing ones digit
movwf Dig3
endm


Macro is called with :

movlw .156 ; w = 156
movwf RES ; RES = w
digbyte RES ; now Dec1<-1, Dec2<-5, Dec3<-6

The following example shows how to use macro digbyte in program. At the beginning, we have to define variables for storing the result, Dig1, Dig2, Dig3, as well as auxiliary variable Digtemp.

5.3.4 Generating pause in miliseconds (1~65535ms)

Purpose of this macro is to provide exact time delays in program.

pausems macro par1
local Loop1
local dechi
local Delay1ms
local Loop2
local End
movlw high par1 ; Higher byte of parameter 1 goes to HIcnt
movwf HIcnt
movlw low par1 ; Lower byte of parameter 1 goes to LOcnt
movwf LOcnt
Loop1
movf LOcnt, f ; Decrease HIcnt and LOcnt necessary
btfsc STATUS, Z ; number of times and call subprogram Delay1ms
goto dechi
call Delay1ms
decf LOcnt, f
goto Loop1
dechi
movf HIcnt, f
btfsc STATUS, Z
goto End
call Delay1ms
decf HIcnt, f
decf LOcnt, f
goto Loop1
Delay1ms: ; Delay1ms produces a one milisecond delay
movlw .100 ; 100*10us=1ms
movwf LOOPcnt ; LOOPcnt<-100
Loop2:
nop
nop
nop
nop
nop
nop
nop
decfsz LOOPcnt, f
goto Loop2 ; Time period necessary to execute loop Loop2
return ; equals 10us
End
endm

This macro is written for an 4MHz oscillator. For instance, with 8MHz oscillator, pause will be halved. It has very wide range of applications, from simple code such as blinking diodes to highly complicated programs that demand accurate timing. Following example demonstrates use of macro pausems in a program. At the beginning of the program we have to define auxiliary variables HIcnt, LOcnt, and LOPcnt.

15 Ağustos 2007 Çarşamba

4.2 Program package MPLAB chapter 4

4.2 Program package MPLAB

Following the installation procedure, you can launch MPLAB by double-clicking the desktop icon. As you can see, MPLAB has the familiar look of Windows programs: a drop menu (uppermost line with standard options - File, Edit..etc.), toolbar (illustrated shortcuts for common actions) and a status line below the working area. There is a rule of thumb in Windows of taking the most frequently used program options and placing them below the menu, too. Thus, we can access them more quickly and speed up the work. In other words, what you have in the toolbar you also have in the menu.

14 Ağustos 2007 Salı

Assembly Language Programming CHAPTER 3

Introduction

3.1 Representing numbers in assembler
3.2 Assembly language elements
3.3 Writing a sample program
3.4 Control directives

define
include
constant
variable
set
equ
org
end
if
else
endif
while
endw
ifdef
ifndef
cblock
endc
db
de
dt
CONFIG
Processor
3.5 Files created as a result of program translation



Introduction

The ability to communicate is of great importance in any field. However, it is only possible if both communication partners know the same language, i.e follow the same rules during communication. Using these principles as a starting point, we can also define communication that occurs between microcontrollers and man . Language that microcontroller and man use to communicate is called "assembly language". The title itself has no deeper meaning, and is analogue to names of other languages , ex. English or French. More precisely, "assembly language" is just a passing solution. Programs written in assembly language must be translated into a "language of zeros and ones" in order for a microcontroller to understand it. "Assembly language" and "assembler" are two different notions. The first represents a set of rules used in writing a program for a microcontroller, and the other is a program on the personal computer which translates assembly language into a language of zeros and ones. A program that is translated into "zeros" and "ones" is also called "machine language"

Physically, "Program" represents a file on the computer disc (or in the memory if it is read in a microcontroller), and is written according to the rules of assembler or some other language for microcontroller programming. Man can understand assembler language as it consists of alphabet signs and words. When writing a program, certain rules must be followed in order to reach a desired effect. A Translator interprets each instruction written in assembly language as a series of zeros and ones which have a meaning for the internal logic of the microcontroller.
Lets take for instance the instruction "RETURN" that a microcontroller uses to return from a sub-program.
When the assembler translates it, we get a 14-bit series of zeros and ones which the microcontroller knows how to interpret.

Example: RETURN 00 0000 0000 1000

Similar to the above instance, each assembler instruction is interpreted as corresponding to a series of zeros and ones.
The place where this translation of assembly language is found, is called an "execution" file. We will often meet the name "HEX" file. This name comes from a hexadecimal representation of that file, as well as from the suffix "hex" in the title, ex. "test.hex". Once it is generated, the execution file is read in a microcontroller through a programmer.

An Assembly Language program is written in a program for text processing (editor) and is capable of producing an ASCII file on the computer disc or in specialized surroundings such as MPLAB,which will be explained in the next chapter.

3.1 Representing numbers in assembler

In assembly language MPLAB, numbers can be represented in decimal, hexadecimal or binary form. We will illustrate this with a number 240:

.240 decimal
0xF0 hexadecimal
b'11110000' binary

Decimal numbers start with a dot, hexadecimal with 0x, and binary start with b with the number itself under quotes '.


3.2 Assembly language elements


Basic elements of assembly language are:

Labels
Instructions
Operands
Directives
Comments
Labels

A Label is a textual designation (generally an easy-to-read word) for a line in a program, or section of a program where the micro can jump to - or even the beginning of set of lines of a program. It can also be used to execute program branching (such as Goto .......) and the program can even have a condition that must be met for the Goto instruction to be executed. It is important for a label to start with a letter of the alphabet or with an underline "_". The length of the label can be up to 32 characters. It is also important that a label starts in the first clumn.


Instructions

Instructions are already defined by the use of a specific microcontroller, so it only remains for us to follow the instructions for their use in assembly language. The way we write an instruction is also called instruction "syntax". In the following example, we can recognize a mistake in writing because instructions movlp and gotto do not exist for the PIC16F84 microcontroller.

Operands

Operands are the instruction elements for the instruction is being executed. They are usually registers or variables or constants.


Comments

Comment is a series of words that a programmer writes to make the program more clear and legible. It is placed after an instruction, and must start with a semicolon ";".

Directives

A directive is similar to an instruction, but unlike an instruction it is independent on the microcontroller model, and represents a characteristic of the assembly language itself. Directives are usually given purposeful meanings via variables or registers. For example, LEVEL can be a designation for a variable in RAM memory at address 0Dh. In this way, the variable at that address can be accessed via LEVEL designation. This is far easier for a programmer to understand than for him to try to remember address 0Dh contains information about LEVEL.



3.3 Writing a sample program

The following example illustrates a simple program written in assembly language respecting the basic rules.

When writing a program, beside mandatory rules, there are also some rules that are not written down but need to be followed. One of them is to write the name of the program at the beginning, what the program does, its version, date when it was written, type of microcontroller it was written for, and the programmer's name.

Since this data isn't important for the assembly translator, it is written as comments. It should be noted that a comment always begins with a semicolon and it can be placed in a new row or it can follow an instruction.
After the opening comment has been written, the directive must be included. This is shown in the example above.

In order to function properly, we must define several microcontroller parameters such as: - type of oscillator,
- whether watchdog timer is turned on, and
- whether internal reset circuit is enabled.
All this is defined by the following directive:

_CONFIG _CP_OFF&_WDT_OFF&PWRTE_ON&XT_OSC

When all the needed elements have been defined, we can start writing a program.
First, it is necessary to determine an address from which the microcontroller starts, following a power supply start-up. This is (org 0x00).
The address from which the program starts if an interrupt occurs is (org 0x04).
Since this is a simple program, it will be enough to direct the microcontroller to the beginning of a program with a "goto Main" instruction.

The instructions found in the Main select memory bank1 (BANK1) in order to access TRISB register, so that port B can be declared as an output (movlw 0x00, movwf TRISB).

The next step is to select memory bank 0 and place status of logic one on port B (movlw 0xFF, movwf PORTB), and thus the main program is finished.
We need to make another loop where the micro will be held so it doesn't "wander" if an error occurs. For that purpose, one infinite loop is made where the micro is retained while power is connected. The necessary "end" at the end of each program informs the assembly translator that no more instructions are in the program.

3.4 Control directives

3.1 #DEFINE Exchanges one part of text for another

Syntax:
#define []

Description:
Each time appears in the program , it will be exchanged for .

Example:

#define turned_on 1
#define turned_off 0

Similar directives: #UNDEFINE, IFDEF,IFNDEF


3.2 INCLUDE Include an additional file in a program

Syntax:
#include
#include "file_name"

Description:
An application of this directive has the effect as though the entire file was copied to a place where the "include" directive was found. If the file name is in the square brackets, we are dealing with a system file, and if it is inside quotation marks, we are dealing with a user file. The directive "include" contributes to a better layout of the main program.

Example:
#include
#include "subprog.asm"


3.3 CONSTANT Gives a constant numeric value to the textual designation

Syntax:
Constant =

Description:
Each time that appears in program, it will be replaced with .

Example:
Constant MAXIMUM=100
Constant Length=30

Similar directives: SET, VARIABLE

3.4 VARIABLE Gives a variable numeric value to textual designation

Syntax:
Variable=

Description:
By using this directive, textual designation changes with particular value.
It differs from CONSTANT directive in that after applying the directive, the value of textual designation can be changed.

Example:
variable level=20
variable time=13

Similar directives: SET, CONSTANT


3.5 SET Defining assembler variable

Syntax:
set

Description:
To the variable is added expression . SET directive is similar to EQU, but with SET directive name of the variable can be redefined following a definition.

Example:
level set 0
length set 12
level set 45

Similar directives: EQU, VARIABLE

3.6 EQU Defining assembler constant

Syntax:
equ

Description:
To the name of a constant is added value

Example:
five equ 5
six equ 6
seven equ 7

Similar instructions: SET

3.7 ORG Defines an address from which the program is stored in microcontroller memory

Syntax:
Cascode stage
or “collector follower”
Jean-Paul Brodier
All microprocessors from the 8051 family have inputs and outputs that are ‘quasi-bidirectional’. This means that when power is first applied, the ports behave as inputs with a logic high level and a weak pull-up.,

Glitch
a relay or some other load such as When driving an optocou-pler or LED, there is a problem
at power on: the NPN transistor in the common emitter connec­tion (Figure 1) causes an unde­sirable excitation of the load from the moment power is applied until the microprocessor has had the chance to turn the output low. In addition, logic high outputs are seldom able to deliver enough current to drive the transistor into saturation because they have been designed to be active low.
Figure 1. An NPN transistor drives a load.
To solve both of these problems in one hit, we have to make the active level logic low. This can be done in three different ways: use an emitter follower as a buffer stage (Figure 2a), an inverter in a common emit­ter circuit (Figure 2b) or an inverter/open collector circuit (Figure 2c). The disadvantage of solution 2a is the fact that the voltage to the load is reduced. In the case of a relay with a 5-V coil there is the risk that the resulting voltage is too low. The disadvantage of examples 2b and 2c is that they require more parts.
Collector follower
That leaves the open collector buffer in the form of an IC type 7404. This solution, however, also has a few disadvantages. You do not always need all of the 6 buffers in one IC. Also, the SMD version can only handle 12 V. This is too low and dan­gerous if we happen to supply the load from an unregulated voltage.
The solution presented here com­bines in one transistor the advan­tages of the emitter follower (inactive when power is first applied) and open collector (higher power supply voltage, lower current). This circuit has been known since the valve era by the name cascode (drive via the cathode). The goal was to reduce the Miller-effect of the internal (parasitic) capacitances. Not having the option of reduc­ing the capacitance between the internal electrodes, a lower volt­age was used instead. The cas-code circuit is often used in pow­erful transmitters (tens of kW) to minimise the Miller-effect. This circuit was also used to limit tran­sistor conduction and to keep the dissipation within bounds, which increased the life of bipolar tran­sistors. This was in the IGBT and VMOS era.
The transistor conducts only when the output from the micro­processor is low (refer Fig­ure 3). The base current is lim­ited by resistor R. This current is determined by the current flow­ing through the load. When the power is switched on, both the base and emitter see the same potential, VCC, so the transistor remains blocked. One thing we have to keep in mind: we may not exceed the current rating of the microprocessor output because it has to cope with all the current flowing in the emitter of the transistor.
In the case of the quite common 80C51, this maximum current is typically 3.2 mA (two LS TTL loads). This is sufficient to drive an LED without overloading the 5-V regulator, or for driving a PNP power stage at the high side (Figure 3b). The parallel Philips PCF88574 I2C interfaces can handle 25 mA. For the Atmel AT89Cx051 as well as for the Philips P89LPC9xx the limit is 20 mA. For the latter type the cascode circuit or ‘collector fol­lower’ is even more interesting when the outputs are configured as open-drain because the nom­inal voltage is only 3.6 V. In all cases we have to make sure that the maximum dissipation of the
Figure 3. Cascode driver stage with discrete transistor.
package is not exceeded. 24 V is sufficient to energise its are determined by the power
Should this be the case, then the half Watt relay coil, which in PNP (or VMOS) transistor.
number of open collectors turn can drive a load of 16 A at The cascode transistor can be a required will probably justify 230V. ‘digital’ type with integrated resorting to a 7404. For loads driven from the positive base and emitter resistors.A current of around 20 mA at side, the voltage and current lim-


pot as interrupt generator

In battery-powered, microcon­troller driven circuits, as well as with microcontrollers operating in cars, it is desirable to switch the micro into power-down mode once a task has been completed. An interrupt request is then required to wake up the micro. This circuit allows an interrupt to be generated in a simple way using a common potentiometer. In the example circuit, the pot may also copy its spindle position to the ADC. This enables the pot to be used for continuously variable settings (like volume) as well for getting the micro out of its power-down mode.
IC1A is configured as a differen­tiator with R3 preventing oscillation by keeping the gain down to 10 times. Because the opamp oper­ates off a single-rail supply voltage, an 18k/10k potential divider (R1/R2) is able to create a virtual ground level at +1.75 V. This can be done because the LM358 can handle input levels of up to 3.5 V when supplied at 5.0 volts. IC1A supplies a brief High pulse at a falling input voltage, and a similar Low pulse when the input voltage rises. In order to get a High pulse when the potentiome­ter spindle is turned cw or ccw, IC1B is set up as an inverter. Next, each opamp output drives the base of a BC547 transistor. The 5 V-to-0 V transitions at both collector outputs are shaped and combined into a usable interrupt pulse by three NOR gates IC2A, IC2B and IC2C.If the potentiometer spindle is turned very slowly, it is possible that the circuit does not respond
That is why an LED has been added that lights briefly when a pulse is generated. Finally, a tip: a 100-pF capacitor may be connected in parallel with R5 for additional suppres­sion of self-oscillation.

elektor time standart


Elektor Time standard (1988)
Jan Buiting

The Elektor Time Standard and associated Slave Unit were spin-offs of another hugely successful project, the DCF77 Receiver / Locked Frequency Standard. The receiver was published in the January 1988 issue, the Time Standard and Slave display in the next two issues. All units were housed in then very fash­ionable and (expensive!) Ver-obox two-part ABS enclosures which had also been used for a number of Elektor test instrument designs published between 1984 and 1987. The Time Standard box was designed to process seconds pulses received from the VLF (77.5 kHz) DCF77 time standard transmitter in Mainflingen, Ger­many, and display time (with atomic accuracy) and date on an LC display. The circuit was based on then extremely popular 8052AH-BASIC microcontroller from Intel, a device, we can safely claim, that made it to fame & glory thanks to Elektor Electron-
ics. The 40-way DIL chip con­tained a BASIC interpreter capa­ble of executing ‘tokenised’ code from an external EPROM. This, we were told by our resident designer Peter Theunissen, made writing the DCF77 time signal decoding routines ‘a doddle’ using his specially adapted BASIC computer and interpreter. For example, when concerns were raised (by myself) that not all of Europe was in the time zone served by DCF77 (i.e., CET or GMT+1h), a menu option was quickly added to allow users to select between UTC and GMT+1h. As a relative novelty, a ready-made self-adhesive front panel foil with built-in membrane keys was designed into the proj­ect. This expensive item had been produced specially for Elektor. However, when the article went into print (using a rather glum page layout and black & white print), there were yet other con­cerns regarding the range of the DCF77 transmitter. This is offi­cially claimed as “approximately 1,000 km by groundwave propa-

gation”. A quick use of a com­pass and a map of Europe sug­gested that the signal would only cover the south-eastern part of the UK, possibly including Greater London. For a couple of months we waited with baited breath for readers’ responses, only to receive two enthusiastic reception reports, one from the East coast of Ireland and another from Riyadh, Saudi Arabia! The latter report came from a reader work­ing at a chemical laboratory. I remember he wrote that DCF77 could be received for a few min­utes a day only, synchronising the clock, usually around nightfall despite heavy ‘static’. A huge wire antenna was used (nothing like the 1-inch ferrite rods we used in our lab, which is less than 100 km away from Mainflingen). Although the BASIC program list-
ing for the Time Standard was freely distributed to interested readers (on paper, in an enve­lope, by snail mail!), only very advanced readers were able to compile the program into tokenised code and burn it into an EPROM. Most other readers had to rely on a ready-pro­grammed 27C64 supplied through our Readers Services. Apart from displaying time and date at atomic accuracy, the Time Standard was also capable of outputting time/date information

in the form of ASCII character strings for other (intelligent) equip­ment to use, for example, a timer or switching clock. Although sales figures of the PCB and EPROM were in the hundreds, I never heard from anyone actually hav­ing enjoyed the wonders of the ASCII output so extensively described in the article. The Slave unit published in March 1988 was connected to the Time Standard via screened (micro­phone) cable, the idea being that one or more Slave units could be installed on walls in rooms at some distance from the main clock unit. Central timekeeping deluxe for offices, labs, schools and workshops, but at what an expense and design effort! Not too many PCBs were sold for this extension of the Time Standard.