So, I have a project I'm working on where I need a clock source that can be slow. Something that can go well below 1hz. But I would also like to be adjustable up to say 1khz at the top end. But would be ok with significantly slower. And I've been toying with the idea of using the ATTiny85 as the clock. The reason for this is that I could change the variables on the fly by use of inputs. Versus a, for example, 555 timer which would be limited by Pot selection. What I'm saying is I think that for the slower speeds I'm looking at, and availability of parts on hand, I think the ATtiny might be a better fit for this project.
But here is my problem, for what I plan on using it for, I need whatever clock I choose to use to be a clean clock. Read: as close to square wave as possible, with about a 50% duty cycle. But I don't have a scope or logic analyzer, and cannot check how clean the ATtiny is, say with a blink style program, without one of those tools. I also have failed in my searches of finding any information about this topic on the net.
Now considering it is a digital IC, I would assume it is pretty clean. Even more so with use of an external Crystal. But in the opinions of the resident experts, would an ATtiny using the internal oscillator at 8mhz be clean enough to use at the given duty cycle and frequencies I am hoping to achieve?
The duty cycle should not be a problem. Even without hardware assistance (timer...) your code can toggle the output, so that the on and off times should be fairly close.
For testing purposes you can use another Arduino, that counts or timestamps the received clock pulses or transitions. This can also help in the determination of the stability of the internal clock. The internal clock frequency may depend on the supply voltage, chip and ambient temperature, don't forget to vary these parameters in your tests.
google sound card oscilloscope
DrDiettrich:
The duty cycle should not be a problem. Even without hardware assistance (timer...) your code can toggle the output, so that the on and off times should be fairly close.
For testing purposes you can use another Arduino, that counts or timestamps the received clock pulses or transitions. This can also help in the determination of the stability of the internal clock. The internal clock frequency may depend on the supply voltage, chip and ambient temperature, don't forget to vary these parameters in your tests.
Yeah, I'm not worried about the duty cycle. I'm just curious about the signal that would be generated. It really does need to be pretty clean.
@Dave, that is pretty cool. I'll have to look into building one of those. I've also thought about getting one of those cheap $10 usb logic analyzers from China. I guess those even beat the heck out of not having anything...
I thought I would share my findings after using a cheap Fleebay Saleae clone to check how clean of a clock source the ATtiny85 is. I would assume that the rest of the AVR family will be this accurate as well. The MCU in question was using the internal 8Mhz fuse setting. And the measurement was consistent within +/-0.0200ms. This would likely be more accurate with an actual crystal. So the data tells me that for a low frequency clock source, the ATtiny does in fact show promise. Attached is a screenshot of the data pulled from the device.
Yeah - I'd just take over timer1 (ie, set the registers yourself, rather than using the arduino wrapper) and use the PWM and an appropriate prescaler setting. You should be able to set it to count up to anywhere from 2 to 255, and if you have it comparing to a number half that, you get 50% duty cycle. Should be perfectly viable