EmbeddedRelated.com
Forums

I/O-ing Frequencies on ATMega8

Started by forTe November 6, 2005
So I recently acquired some ATMega8's for a project. My biggest need
right now is for somebody to point me in the direction of some guides
and code for specific programming on the ATMega8. Most specifically I
am using these to output a frequency (Highs and lows and 5 and 0 Volts)
using a circuit to process the signal and send it back to the
microcontroller where the incoming frequency will be sent out again.
The main purpose is to deteriorate the frequency's integrity/accuracy
as much as possible through doing this process multiple times. It
sounds strange, I know, but if you have any links or references to some
pre-written codes or explanations on how to do this, I'd be very
appreciative.

Thanks a bunch,

ForTe

On 6 Nov 2005 12:56:40 -0800, "forTe" <ivan.carzy@gmail.com> wrote:

>So I recently acquired some ATMega8's for a project. My biggest need >right now is for somebody to point me in the direction of some guides >and code for specific programming on the ATMega8. Most specifically I >am using these to output a frequency (Highs and lows and 5 and 0 Volts) >using a circuit to process the signal and send it back to the >microcontroller where the incoming frequency will be sent out again. >The main purpose is to deteriorate the frequency's integrity/accuracy >as much as possible through doing this process multiple times. It >sounds strange, I know, but if you have any links or references to some >pre-written codes or explanations on how to do this, I'd be very >appreciative.
I doubt very much that there's pre-written code. You set bits and then you read bits. You could use one of the timers to wiggle an OC bit or use a PWM or just loop and do and SBI/CBI. Read with an IN and write with an OUT, or perhaps use an interrupt pin. Are you going into/out of of a single AVR or a chain of multiple? What are you trying to do? -- Rich Webb Norfolk, VA
forTe wrote:
> So I recently acquired some ATMega8's for a project. My biggest need > right now is for somebody to point me in the direction of some guides > and code for specific programming on the ATMega8. Most specifically I > am using these to output a frequency (Highs and lows and 5 and 0 Volts) > using a circuit to process the signal and send it back to the > microcontroller where the incoming frequency will be sent out again.
I don't have a clear understanding of what you are trying to do. Are you toggling an output line to generate a square wave, driving a D/A, programming a frequency synthesizer. or something else? What kind of processing are you doing externally? Are you then attempting to measure the frequency with same processor? If so, why would it be different? How are you capturing the modified signal? How long are you maintaining your output frequency?
> The main purpose is to deteriorate the frequency's integrity/accuracy > as much as possible through doing this process multiple times.
Why would you expect the signal's frequency to change? -- Thad
On 6 Nov 2005 12:56:40 -0800, "forTe" <ivan.carzy@gmail.com> wrote:

>So I recently acquired some ATMega8's for a project. My biggest need >right now is for somebody to point me in the direction of some guides >and code for specific programming on the ATMega8. Most specifically I >am using these to output a frequency (Highs and lows and 5 and 0 Volts) >using a circuit to process the signal and send it back to the >microcontroller where the incoming frequency will be sent out again. >The main purpose is to deteriorate the frequency's integrity/accuracy >as much as possible through doing this process multiple times. It >sounds strange, I know, but if you have any links or references to some >pre-written codes or explanations on how to do this, I'd be very >appreciative. > >Thanks a bunch, > >ForTe
Depending on the ferquencies involved, you might want to look at the imput capture and PWM peripherals
Ok, so I now realize that I need to be a bit more specific.

So let me clarify the purpose. Basically what I am trying to do is have
the ATMega8 output a square wave from two pins at a frequency (the
frequency does not matter as I'll explain in a minute). One pin needs
to output a low and one pin a high (Low being 0 Volts, High being 5
Volts) so that I have at each time a single pin giving a high and a
low. Both signals are sent to an IC that will process the signal (the
way it processes it does not matter) and send a signal back to the
microcontroller hopefully at the same frequency (thats what I am
testing). I will then need this signal coming from the IC to be used as
input to the microcontroller via one pin and output yet again via
another pin to another IC. This will happen for 3-4 ICs, and I will
analyze the frequency at certain points at calculate signal loss as a
percentage (assuming there is signal loss, since that is the point of
doing this test) compared to the number of ICs. If perhaps I run out of
room on my single 28 pin ATMega8, then I will have to move to another
ATMega, but I am hoping to keep it on one ATMega.

So basically here is what has to happen on the Microcontroller:
I generate an identical original signal from two different pins on the
controller.
I then have to receive a signal and output the received signal from a
different pin.

Hopefully that clarifies the purpose/procedure.

Rich Webb:
>I doubt very much that there's pre-written code.
I was afraid of that since my google searches turned up very little. I need to go back and look more closely at the AVRFreaks website and forums and see If I can turn up something. However now that I've explained it a little better perhaps somebody can point me towards some pre-written code that has bits and pieces of what I am trying to do. I really need some good sources to some Assembly or C code that contain things like input output and generating with PWM or internal clocks. And just so nobody worries- I have the IC/analog portion of my circuit already planned out so I don't think I need much help there. Its just in the coding of the uC that I need a little push in the right direction. Thanks ForTe
>(the chip under test will) send a signal back to the > microcontroller hopefully at the same frequency (thats what I am > testing).
...
> I will > analyze the frequency at certain points at calculate signal loss as a > percentage (assuming there is signal loss, since that is the point of > doing this test) compared to the number of ICs.
So, it woulds like you will be testing for frequency deviations or 'jitter' created by the ICs under test. If this is correct, and you want to measure this linearly, then you can't use one microcontroller and loop the signal in and out several times, because the outputs will all be synchronised with the uC clock. You also mention signal loss. If you are interested in amplitude, note that the uC will always output 0 and 5V, no matter what level it gets on the input. Maybe you mean modulated signal distortion? So far it's not sounding to me like the AT megas are what you need to do this project. Try using a simple function generator and a spectrum analyzer.
>So, it woulds like you will be testing for frequency deviations or >'jitter' created by the ICs under test. If this is correct, and you >want to measure this linearly, then you can't use one microcontroller >and loop the signal in and out several times, because the outputs will >all be synchronised with the uC clock.
Yes, thats pretty much what I would like to do. Luckily I have extra uCs so this should not be a problem. The frequency deviation is really what I was trying to convey in the above post. This is for a demonstration for people who won't necessarily know what a 'frequency deviation' would be (uCs are will be like magic boxes to some people reviewing this) so I have been using 'signal integrity' as a blanket term for it, though I recognize that it is not the same thing. So now it occurs to me that what I really need to do is use one uC to generate the signal and send it to the IC, which sends it to another uC whose internal clock will be determined by the incoming signal and then output the signal, which outputs to another IC, and repeat over and over. My other issue is budget in that I can't do this project too excessively, though I will recycle the components. So any expensive equipment is out the window at this point. Also, I am trying to recreate 'real world' conditions with this project, so using things that are not necessarily used in consumer electronic products would make this project moot. Thanks, and if you still have some resources on ways to do this, I'd be much appreciative.
So that I make sure, I should use PWM for this task correct?

Unless I'm missing something about what you're trying to do, I really don't 
see the point of using the microcontroller as a repeater.  It will introduce 
lots of error which will mask the effects you are trying to measure.  Just 
stick with a simple digital or analog buffer.  I suppose you could use a 
microcontroller to generate the initial signal but that is still overkill.

Henry


"forTe" <ivan.carzy@gmail.com> wrote in message 
news:1131409522.166099.204670@f14g2000cwb.googlegroups.com...
> So that I make sure, I should use PWM for this task correct? >
forTe wrote:
> > So that I make sure, I should use PWM for this task correct?
the pwm would be the easiest way to generate a fixed or oscillating frequency square wave from the uC. But If you want to show people what frequency deviation is, here's an idea. I don't know what chip you are using to skew the clock (the chip under test), but if it can handle clock I/O frequencies of around 3 MHz, you could use an audio coax s/pdif signal as the clock source and run that through your chip(s) and run the resulting signal back to a s/pdif to analog converter (like in most modern stereo amps). Then you could HEAR the frequcncy deviations in noise. the a->d http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=5827971697