atmega328 glitching on and off

The meter won't show everything. An oscilloscope might.

Try some decoupling capacitors.

http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

some of the componenets will not work as they need higher voltages

If the 328 works with a separate 5V on it, but not when running off the 7805,
then it sounds like some of the other components in the circuit may be crowbarring
the 7805.

Just a thought about voltages in your circuit.
Your transformer will give a peak voltage of 1.414 x 24 volts ( 33.936 ) at the rated output. If you are drawing less current, which seems likely, the peak voltage will be higher. The spec for a 7805 is maximum input 35 volts, your rectifier will drop a few volts but it might still output more than 35 volts so it might keep shutting down.

The meter won't show everything. An oscilloscope might.

Try some decoupling capacitors.

De-coupling

thanks for that information just tryed that and still seems to make no apparent difference

If the 328 works with a separate 5V on it, but not when running off the 7805,
then it sounds like some of the other components in the circuit may be crowbarring
the 7805.

disconnected them from circuit no difference unfortunatly

Just a thought about voltages in your circuit.
Your transformer will give a peak voltage of 1.414 x 24 volts ( 33.936 ) at the rated output. If you are drawing less current, which seems likely, the peak voltage will be higher. The spec for a 7805 is maximum input 35 volts, your rectifier will drop a few volts but it might still output more than 35 volts so it might keep shutting down.

oh yes with no load i have 40v off the bridge rectifier so yeah your probably correct that the voltge regulator is shutting down due to over voltage does anybody have any recommendations for a regulator what will handle the higher input voltages?

Use a switching supply, or lower the voltage, or add your own winding for a low voltae tap

or add your own winding for a low voltae tap

what so add an external winding? any information on this?

Well it would depend on the type of transformer you have and if you can take it apart to add a winding, its not too hard if there's space and if the transformer comes apart, toriodal transformers are the easiest, other really depend on how well its assembled, sometimes the EI transformers are just two pieces of core together, other times its a whole lot of individual laminated layers, which is. Real pain and I wouldn't try, did one and cut myself, not so fun
but if there's room wrap enamel wire around the other wires basically until you getthe voltage you need, which I would suggest testing that while its under a similiar sized load

o ok i understand what you meen now unfortunatly the transformer is molded into a plastic case so can not get to the windings
i did have a look for voltage regulators with higher input voltages but the only ones i found were variable ones was looking at this LM317AHVT for a quick fix what do you think?
but for future boards i think i will have to pick just the one 12v output from the transformer and run two rectifiers one for atmega328 and the other for the other components on the board

Unfortunetly dropping from 40 to 5v means wasting 8times the power and 8x the heat
so a 30ma draw at 5v would have the regulator dropping the 35v and using 1W of power(maximum without a heatsink assuming a cool surrounding), where only .15W is actually doing work the rest is heat
you need a switching power supply to effectively drop that within practicality
so unless your drawing less than 30ma you'd need a largish heatsink, which will get you a little farther but not too much

This is a "No-Brainer", Really simple. However remember that an 8VA transformer has a secondary current capability of .3A and 300 mA can quickly be used if the transformer supplies other things.
One other thought is that If the transformer is used for other control it's secondary must not be common to your ground or negative PSU terminal.

Solution #1 use a 150 ohm 10 watt resistor from the HV to ground... Load it down to the equivalent RMS voltage.
Solution #2 use a half wave rectifier and 2200uF cap on the output of the diode. 1/2 of 24 V
Solution #3 is the transformer Center Tapped? if so use a halfwave bridge or tweo diodes cathodes common and + output... - output is the CT.
or connect the bridge rectifier from one side of the secondary and the center tap... 12V Ac... now 1/2 of the transformer secondary is used
Solution #4 Connect a 12Volt 1 watt or better Zener diode in Series with the HV PSU cathode pointed to the HV side of the PSU... anode to the regulator.
Polarity of the diode is important here the diode will work connected either way however only the way I mentioned will give you more than the
nominal .6V diode drop. The Zener is used as a level shifter.
Solution #5 Get a 12V transformer... or see Solution #3 and find a 24V transformer with a center tap.

Doc

I believe the half wave idea wouldn't work effectively unless it was a constant predictable load, the halfwave rectifier would simply make it a larger ramp up time of the capacitor, if there's no load it will go up to the full voltage
I think a switching regulator is the best option, the rest re kinda wasteful, they actually make drop in switching replacements for the to220 7805 tho they are a few bucks

Winner you are DEAD WRONG the half wave rectifier has been successfully used without the strange effects you describe for nearly a hundred years, it's only drawback is the requirement for a large input filter.
I've used it for 50 years my self... Very successffully... When I was a WORKING PROFESSIONAL ENGINEER, You?

Docedison

Im sorry I haven't that experience nor tried it, I just never heard about that and thought that it would only cause alot more ripple because it only charges the capacitor half of the cycle, still it would charge it so long as the capacitor is at a lower voltage than the ac peak voltage, which if there was no load would charge it to the ac peak
If it was only ac output then I could see it effectively cutting the rms voltage in half, but then again im not that experienced and there's a million things I don't know yet

It does cause more ripple that's why I pointed out that the input filter had to be bigger and in this case since there is a linear regulator the added ripple makes no difference . Even with a 470uF instead if the 2200 uF min I had mentioned the ripple could Never be big enough to cause the regulator to even be close to it's dropout voltage. You will remember that the original issue was the reg shutting down because of overvoltage... So I listed several different workable strategies to fix that problem.

Doc

As far as I understand a common 7805 has no 'automatic' shutdown due to input voltage being too high. There is automatic shutdown for output over current draw and for maximum heat dissipation, but over voltage of the input would just subject the chip to damage, not any kind of automatic response.

Lefty

thanks all for your help think i will pick it off the centre tap
just one more question as im here anybody know a good website to explain the correct way of working out the correct va transformer for your application?

Calculate or Measure the current drawn and double it... Just for luck and multiply that by the voltage realizing that control/signal transformers come in standard values. A 24 V transformer, a 10 ohm resistor and a single diode with a 2200 uF - 4700 uF input filter is the simplest method to deal with 24V transformers... Because of the required high value of the input filter for a single diode (half wave) it is recommended to use a 5 to 10 ohm 'Surge' protection resistor in series with and before the diode to reduce the inrush current to the diode.
It is also recommended to use a diode of 3A forward current, typically a 1N5407 and the input filter after the diode.
This is for a supply for a 5V regulator and a low current load. This is from memory and I am certain of it's validity, It's just that right now I am too busy to go find the text and quote it here and for that I apologize...
However the loaded voltage should be about 11-13V which, while being a little high for heat considerations in the regulator should be OK.
The Best method was already mentioned and that was to use a switcher to begin with.
The methods I outlined earlier were only "Fixes" for the immediate issue which was the regulator shutting down for an over-voltage condition.
There was a comment about "Not Believing???" that a regulator would shut down... YES VERY MUCH SO...
Read the Data Sheet before you consider yourself enough an expert to quote opinions here.
The Shut down is done for several reasons primarily to control the device Power dissipation.
Ex. 1. 50 V in 5 V out @ 1 A = 5W load to the regulator and 45 Watts wasted as heat... 50W total device dissipation
Ex. 2. 35 V in 5 V out @ 1 A = 5W load to the regulator and 35 Watts wasted as heat... 40W total device dissipation
50W/40W = 1.25~ X increase in power dissipation for a 15V increase in supply voltage or simply by making the Max voltage 35 V instead of 50 V makes a 25% decrease in required power dissipation.
Under any circumstances the final shutdown is due to heat and limiting the input voltage to a 'reasonable level' increases the available current at high voltage inputs because the final control in the regulator is it's internal temperature... Not current as much as heat.
Internal to the regulator is a comparator that measures the supply voltage against a reference voltage and if high merely shuts down the drive to the pass transistor to prevent exceeding the total device dissipation.

Doc

thankyou for that information
so if i have my boubled load at 1A at 24V i should have a 24VA transformer? sounds a bit high
could you do a quick drawing on what you describe to give me and others a better understanding
thanks

All of what I wrote in my last post is I believe correct... for a device that needs 200 - 300 mA Max current from a 24VA transformer and yes you do need a 24VA transformer to supply 24 VAC @ 1A load current. A "Half Wave Rectifier will give you 1/2 (approx) of the 24V ac or about 12 Vdc. I suggested a large enough diode that the surge resistor might not be needed and that there would be 9 to 10 Vdc available for the regulator.
The best method (IMO) is a switcher and I had very good results with the part i mention next... I made about 100 of them (Not me I just did the design and PCB layout) but they were really quiet and trouble free.
I built a lot of 24Vac based switchers in 2003 - 2006 I used an LT1170 because I needed about 3A for 10 - 15 seconds to power a 10W transmitter. It was an easy device to use... all the information you will need is in the data sheet. There are three varieties of this device, LT1170 - 1 - 2 for 5A @60 V max input voltage (LT1170 2.5 A (LT1171 and 1.25 A for the LT1172 I used the 5 lead TO-220 and the 5 Lead SMT package and all worked very well. This is the link to the data sheet.
http://www.stanford.edu/class/ee122/Parts_Info/datasheets/LT1170.pdf
an ac transformer and a bridge rectifier work very well with this device for a stable and adjustable buck mode power supply. If you need a lot of current. If you are just doing a small control device then my last post should have more than enough information. I would add that a Tranzorb should be included for transient protection on the secondary of the transformer to protect the diodes. I also included poly fuses to prevent fires in case of component malfunction. I also used tranzorbs on the rectifier output as these were used in Kansas on a Rural Power Grid where KV level spikes were common and some of long duration... 1/2 second spikes were measured... Usually though when the Power company did a "Load Drop", A frequent nightly occurrence as most of the big Agricultural companies used power at night when rates per KW were cheaper.

Doc

Whats a load drop?