Edinburgh Castle's ''Tam the Gun'' aims to stage a millennium exhibition telling the history of the one o'clock gun that has been heard resounding throughout the capital every day since 1861.

Staff Sergeant Tam McKay, who has fired the gun for 20 years, has become an authority on the world-famous time signal. He has joined forces with Historic Scotland, owners of the castle, and applied for a lottery grant.

Sergeant McKay MBE, district gunner of 52 Lowland Brigade, is a constant source of information to curious tourists fascinated by the tradition. He believes it is now time to make his knowledge official.

The exhibition, to be housed at the castle, will feature the original copy of the 1861 book, the History of the Time Gun, by Charles Piazzi Smyth, about how the gun came into being. Diagrams will be laid out to show how the gun was linked to the time ball on Calton Hill, by what was then the longest electric cable in Europe, to ensure they were set off simultaneously.

Sergeant McKay, 53, from Lochgelly, Fife, said: ''Most of the locals come to see the gun once in their life, usually when they are only six or seven and they never come back again. That is too young to appreciate the history of the gun.''

Edinburgh businessman John Hewitt campaigned for a time gun after a visit to Paris in 1846, when he was astonished to hear a gun firing and see people checking their watches.

He pressed for something similar in Scotland's capital and eventually, in 1852, the time ball was erected on the Nelson Monument on Calton Hill. It was another nine years before the time ball was accompanied by gunfire from Edinburgh Castle.

The gun was fired at one o'clock for the first time in June 1861 and the tradition has continued ever since, interrupted only by the two world wars.

The original gun was a 64lb muzzle-loader which took four men to fire. The present gun, which was used in the North African Campaign in the Second World War, is fired by just one man.

The exhibition, which is to run from December next year until February 2000, will tell the story of the gun and its gunners from 1861 until the present day.

A spokesman for Historic Scotland said the heritage body was keen to back Sergeant McKay but added that plans for the exhibition were still at an early stage.