||This article needs additional citations for verification. (December 2009)|
The contraction of heart (cardiac) muscle in all animals with hearts is initiated by electrical impulses. The rate at which these impulses fire controls the heart rate. The cells that create these rhythmical impulses are called pacemaker cells, and they directly control the heart rate.
In humans, and occasionally in other animals, a mechanical device called an artificial pacemaker (or simply "pacemaker") may be used after damage to the body's intrinsic conduction system to produce these impulses synthetically.
Primary (SA node) 
One percent of the Cardiomyocytes in the myocardium possess the ability to generate electrical impulses (or action potentials).
A specialized portion of the heart, called the sinoatrial node, is responsible for atrial propagation of this potential.
The sinoatrial node (SA node) is a group of cells positioned on the wall of the right atrium, near the entrance of the superior vena cava. These cells are modified cardiomyocyte. They possess rudimentary contractile filaments, but contract relatively weakly.
Cells in the SA node spontaneously depolarize, resulting in contraction, approximately 100 times per minute. This native rate is constantly modified by the activity of sympathetic and parasympathetic nerve fibers, so that the average resting cardiac rate in adult humans is about 70 beats per minute. Because the sinoatrial node is responsible for the rest of the heart's electrical activity, it is sometimes called the primary pacemaker.
Secondary (AV junction & Bundle of His) 
If the SA node does not function, a group of cells further down the heart will become the ectopic pacemaker of the heart. These cells form the atrioventricular node (AV node), which is an area between the left atrium and the right ventricle, within the atrial septum.
The cells of the AV node normally discharge at about 40-60 beats per minute, and are called the secondary pacemaker.
Further down the electrical conducting system of the heart is the Bundle of His. The left and right branches of this bundle, and the Purkinje fibres, will also produce a spontaneous action potential at a rate of 30-40 beats per minute, if the SA and AV node both do not function. The reason the SA node controls the whole heart is that its action potentials are released most often to the heart's muscle cells; this will produce contraction. The action potential generated by the SA node passes down the cardiac conduction system, and arrives before the other cells have had a chance to generate their own spontaneous action potential. This is the normal conduction of electrical activity in the heart.
Generation of action potentials 
There are three main stages in the generation of an action potential in a pacemaker cell. Since the stages are analogous to contraction of cardiac muscle cells, they have the same naming system. This can lead to some confusion. There is no phase one or two, just phases zero, three and four.
Phase 4 - Pacemaker potential 
As in all other cells, the resting potential of a pacemaker cell (-60mV to -70mV) is caused by a continuous outflow or "leak" of potassium ions through ion channel proteins in the membrane that surrounds the cells. The difference is that this potassium permeability decreases as time goes on, partly causing the slow depolarization. As well as this, there is a slow inward flow of sodium, called the funny current, as well as an inward flow of calcium. This all serves to make the cell more positive.
This relatively slow depolarization continues until the threshold potential is reached. Threshold is between -40mV and -50mV. When threshold is reached, the cells enter phase 0.
Phase 0 - Upstroke 
Though much faster than the depolarization caused by the funny current and decrease in potassium permeability above, the upstroke in a pacemaker cell is slow compared to that in an axon.
The SA and AV node do not have fast sodium channels like neurons, and the depolarization is mainly caused by a slow influx of calcium ions. (The funny current also increases). The calcium is let into the cell by voltage-sensitive calcium channels that open when the threshold is reached.
Phase 3 - Repolarization 
The calcium channels are rapidly inactivated, soon after they open. Sodium permeability is also decreased. Potassium permeability is increased, and the efflux of potassium (loss of positive ions) slowly repolarises the cell.
See also