Irvine Welsh appears to have a head cold. He sounds nasal and parched, a bit blocked up. A few years back, when he had attained a kind of infamy as the prime chronicler and, in some critics' eyes, champion of a certain kind of chemical uber-excess that has now gone mainstream, one could have safely assumed that the state of his nasal passages was directly correlated to the extent of previous night's partying. This, he tells me, is no longer the case.

'I was talking to Damien Hirst about this recently,' he says, sipping a sugar-free cappuccino in the stark and draughty surroundings of the Irish Film Institute cafe in Dublin, 'And we agreed that you get to a certain age and you think, this is not on any more. The thing about getting wasted is that it looks good on some young fucker, but it looks just daft on an old c**t. It's just not dignified.'

These days, though you wouldn't guess it from his vocabulary, Welsh seems to have embraced a degree of moderation that would have been unimaginable to his younger self. Now 47, he has belatedly settled into a relatively mellow middle-aged domesticity, having relocated to Dublin, where he lives with his American partner, about whom he is famously reticent. He still goes out on the rip, mind, but not as often, nor as doggedly. Then again, Welsh's idea of mellowness is, to say the least, relative.

'Now, if I go out carousing,' he says, sounding for a second like he might be talking about Morris dancing rather than raving, 'there's a kind of self-protective mechanism that kicks in on the third day. It's something to do with the sheer tiredness of it all, and the predictability. You can go out and do 10 pints and a couple of grams, and, because you know the journey so well, there's that ennui thing that kicks in. I realised I'd rather drive out into the hills and have a look around. You don't get jaded out in the countryside.'

These restorative rural sorties, it has to be said, do seem to have improved Welsh's pallor. He no longer looks so wan and pasty-faced, and his features have filled out somewhat. He seems, too, to have discovered a late flowering philanthropic streak as life-changing as his former nihilism. Having recently travelled to Afghanistan and Sudan on behalf of Unicef, Welsh has agreed to be interviewed in order to promote a charity called the OneCity Trust, whose aim is to 'raise awareness of issues of social inclusion' in his native Edinburgh.

Alongside fellow Scottish authors, Ian Rankin and Alexander McCall Smith, he has contributed to a collection of 'long-shorts', also entitled OneCity, which features an introduction by JK Rowling. 'It's a bit ironic given that Edinburgh is the city that invented and redefined the whole idea of social inclusion,' he elaborates. 'It's the prototype for every other western city. When they built the new town, it was the first splitting up of the professional and the manual classes, and it created the model of the suburb and the ghetto.'

Ironic, too, that Welsh is an ambassador for the cause of social inclusion given that he is a self-style outsider, whose defining subject was the city's druggy flotsam and jetsam. Indeed, he was once, in his own words, 'persona non grata' among the burghers of Edinburgh, who were none too pleased at his portrayal of the royal city as a cesspool of drug-fuelled degradation. Has he suddenly had a late attack of guilt?

'Nah, not at all,' he laughs, 'I'm as suspicious of the whole celebrity charity thing as anybody. But, you know, you have to do something rather than nothing. Whether it's a substantial something, or a token something, it's better than sitting on your arse. Also, it's my home town. It's time I did something. I've got a bit fed up with being Edinburgh's pantomime villain.'

With his hood pulled up over his balding head for the benefit of the Observer photographer, Welsh does indeed look like a malevolent middle-aged elf. More striking still is his peculiar speaking voice which seldom veers above a mumble. When he gets into his stride, though, he can be both charming and coarse, thoughtful and effortlessly obscene, often in the space of a single sentence. In this, of course, he echoes the energy of his best writing, the extravagantly nihilistic prose of Trainspotting, the linguistic richness of The Acid House, the imaginative reach of Marabou Stork Nightmares, which found an unlikely champion in Britain's best known literary scholar, Professor John Carey.

Now, Welsh says, his writing style has mellowed, too. His new novel, the wonderfully titled Bedroom Secrets of the Master Chefs, which will be published next spring, even features two protagonists who are middle class. 'It's hard to talk about it because I'm free of it now, but it does feel different in a lot of ways,' he says, after some considerable prompting. 'For a start, it's not quite so heavy on the vernacular, and the characters are kind of middle class, but more in that classless space that a lot of guys that have made good find themselves in. It's an uncomfortable space that they are trying to make their own.'

Perhaps that space is the very one that Welsh himself now occupies, and negotiates with considerable care. Having came up through the school of hard knocks in Leith, then on one of the massive Sixties-built housing schemes of Muirhouse, he had been kicking around for some time, doing all kinds of menial jobs, before finding fame, and notoriety, with his debut novel, Trainspotting, published in 1993.

His writing, which was then even heavier on the vernacular, and steeped in his own first-hand experiences of Edinburgh's hard-drug demi-monde, was initially dismissed as unreadable by what he terms 'English middle-class publishers'. Then, having caught the attention of fellow Scot, Robin Robertson at Secker & Warburg, the novel was published to unprecedented word-of-mouth success, and belatedly acclaimed for its rawness and authenticity.

In the wake of the extraordinary success of the book, and then the Danny Boyle directed film of the same name, Welsh became the undisputed literary high priest of contemporary drug-fuelled nihilism, a kind of Caledonian William Burroughs for the acid house generation. Like Burroughs before him, he was blessed by being in the right place at the right time doing all the wrong drugs, and, though the whole sick crew from Trainspotting turned up again, briefly, in Glue, and in the full-fledged sequel that was Porno, neither book had the visceral energy or verisimilitude of the first.

With hindsight, does he think his debut was a difficult act to follow? 'Nah,' he says, shrugging, 'I never saw it like that. I never saw it as an albatross round my neck. My only problem as a writer is trying to find the time to write out all the ideas I have in my head.'

As if to illustrate his dilemma, he tells me he is currently at work on a book of short stories, a stage play, and two screenplays. By next summer, Four Way Pictures, the production company he started with actor Robert Carlyle, director Antonia Bird, and film writer Mark Cousins, should be making The Meat Trade, a film based on a script he has just written. If all goes according to plan, an adaptation of Alan Warner's novel, The Man Who Walked will follow.

'I have to be disciplined,' says Welsh, 'just to get it all done. There was a time when I could sit down after two days on the powders and the pills and just bang it out, but not any more.' Is he trying to tell me he used to write best on a comedown? 'It sounds mad, but that was always a good time for me creatively, the big comedown. It was like I was writing it all out. It worked for a long while, that, but I couldn't do it now.'

I put it to him that, if even if half the stories about him are true, his powers of recovery must be easily the equal to his powers of description. Can he tell me, honestly, how much of his own life has leaked into his books? 'Aw, that's a difficult one. I mean, all writing's basically the same. You use the same devices as a middle-class writer would: the characters are all composites, and you use bits from the culture you know, and from your life experience.'

Did he understand why his particular brand of graphic realism was seen by some people as a kind of literary amoralism? He seems offended by the very notion. 'My thing was never to moralise or to judge the characters. People called me amoral, but why would I moralise? I'm a novelist. I was honestly trying to show life as I had experienced it. You can have a laugh on drugs, then you can go off the rails if you get too far into drugs, and, if you're really unlucky with drugs, you can end up in the quagmire of addiction. That's just the way it is. It's a common sense experience.'

Welsh, famously, ended up in the quagmire himself for a time, succumbing to heroin addiction in his early twenties. He describes his younger self as 'a bit too nihilistic' and, these days, seems a lot less cavalier about the downside of hard drug use. 'It wasn't any fun, that stuff. I wouldn't recommend it,' he says, sounding sombre and reflective. 'From about 18 to 25, I lost some of the good things about my life. I went to places I certainly never want to go to again.'

So, for all the reckless self-destructiveness of the characters he created in his own image, there are regrets. A pause. 'Aye. I suppose so. I had a lot of things happen to me back then, mind, family bereavements, relationship break-ups and that, which I couldn't really handle. I suppose I wasn't mature enough so I just internalised a lot of the anger until it came out in a very self-destructive way.'

Is it true he underwent the same self-inflicted cure as the Ewan McGregor character did in the film of Trainspotting: a locked room, a blanket, an empty bucket? 'Well, I never got into the whole NA (Narcotics Anonymous) thing. My attitude is that you make a contract with yourself, whether you're getting out of it, or getting straight. There's nobody standing there pouring it down your throat, or putting it in your arm, but yourself. You have to see it on that very basic level, and just stop. In a way, I've always thought that going to an NA or an AA meeting every day is a way of keeping the whole thing going. It's referencing the whole thing by omission. Really, it's up to you to decide what's at the centre of your life and what isn't.'

Towards the end of our conversation, Irvine Welsh says something as unexpected as it is revealing, and one senses that he is now on a very different journey of self-discovery than the one that almost derailed his younger self.

'I spent a lot of time chasing oblivion, that was a big thing for me, and on the more mercenary side, I've been able to make that pay through the writing. But, when I was actually doing it, I'd get up in the morning and it would be a beautiful day, and immediately I'd want to get out and get fucked up. It took me along time to realise what I was actually doing was ending that feeling, killing the beauty. I couldn't handle the beauty.'

Now that he can, it should be interesting to see where his writing goes. Having defined the culture of dissolution before it really took hold, one suspects that Welsh may yet have it in him to define the fallout of our embrace of excess, the big comedown to beat all others.

· OneCity by Alexander McCall Smith, Ian Rankin and Irvine Welsh is published nationwide on 5 January by Polygon, £5.99