“Instead of an Arduino, he could have done that with a 555 timer.” “Instead of a 555 he could have done that with two transistors.” “Instead of a few transistors, he could have done that with butterflies.” These are quotes from various Hackaday comment threads throughout the years. It seems simplicity is the name of the game here, and if you need a timer chip, how about an 8-pin DIP? This, of course, means an I2C programmable oscillator in the form of an LPC810.
[kodera2t] built this circuit after reaching for a 555 timer a few too many times. It’s a one-chip solution with an ARM core that’s able to generate square waves with 1Hz resolution up to 65536Hz.
The source for this chip is a lot of C, but once it’s in the Flash of the LPC810, this chip becomes a programmable oscillator with an I2C interface. Yes, it’s a one-component solution, no, it’s not a twenty cent chip, but try programming a 555 over I2C.
The videos below show [kodera] playing around with this I2C oscillator, sweeping the frequency from zero to inaudible teenage angst.
He could have done that with 8 bit processor core…
he could have done that with a 64 bit Intel workstation
Or a server with 64Gig Ram and 4 quad core processors.
Eh, He could have made it cloud based with an iOS app.
He could have done that with a chunk of raw silicon.
He could have done that with a programmable unijunction. Just a 3 pin TO92 package, and the least amount of transistors involved: https://en.wikipedia.org/wiki/Unijunction_transistor#Programmable_unijunction_transistor
These work very well as 1 Bit SPI RAM.
[quote] The source for this chip is a lot of C, but once it’s in the Flash … [/quote]
Can someone please translate?
Nevermind — I figured out he is talking about source code, not source for the component.
The LPC810 is actually an ARM microcontroller in an 8 pin DIP package. kodera2t wrote some code for it in C that listens as an I2C slave device and sets the onboard PWM peripheral based on that. The compiled code is stored in flash so you only need to program the code once and then the LP810 just acts like a I2C controlled oscillator.
“fish, plankton, seagreens and protein from the C”
I think that means the chips come from the future, probably in logan’s run time.
just watch out for the blinking lifeclock. there IS no santuary!
The comment system needs a method for upvoting Logan’s Run references.
Don’t get Mike started on the upvote rant again!
Not many people would get that reference. And even fewer can claim to have been an extra in the film. Lot’s of fun days at the Dallas Word Tradecenter.
+1 for remembering logan’s run , now check your palm.
Also, not noisy or power-gobbling.
This is what I use the Picaxe 08m2 for. far easier to program for and is only slightly more expensive at $2.80 each.
+100 for PICAXE. I love those things.
And you can reach +- 2 Mhz with the 08M2+ :
setfreq m32
pwmout 2,3,8
do:loop
Noice.
Hm. That makes me think… there’s a dude who used an Arduino for a clock controller *and* its timing source. Too lazy to ferret up the link right now, if I can even find it, but IIRC he basically used a PWM pin off a timer, wired to an input, as the clock timing source.
I wonder if something similar is doable with PICAXE…? (I actually doubt it, but I’ve been wrong before…)
$6 will get you 10 attiny13a dip-8 or 20 soic on aliexpress.
$2.18 gets you an arduino pro mini on Ebay… Things are getting so cheap nowadays!
The pro minis are 188c, or 168c for a mega168 pro mini on aliexpress. And unlike EBay, every payment is escrow until you confirm receipt.
Congrats looks good!
Any chance we can get more info on the case, an the rest of the parts??
I was going to use a 555 for a project but the frequency would constantly change with temperature. Ended up using a ATTiny85 and added a bunch of nifty features. https://github.com/mkotyk/c128power/
The ATTiny85 internal oscillator will also change depending on the temperature. The factory calibration accuracy is +/-10% and only valid for 25C exactly. You can calibrate it yourself to within +/-1% but it again has to be a fixed temperature.
He could have done that with assembler.
He could have done that with a watch, some string, freshly shaved Peruvian coconut, chloroform, that actor from Mr. Belvedere who became the lead singer of Garbage, more string and duck tape, not duct but actual tape made from ducks. Square waves, all damn day.
What oscilloscope is that?
SeeedStudio DSO Nano V3 Pocket 1MHz Digital Storage Oscilloscope
http://www.seeedstudio.com/wiki/DSO_Nano_v3
These guys are listing A**uino Uno for $89? Either their currency converter is off, they have some interesting definitions of value or the value of my workbench just soared.
I meant $29.90…but still…
I assume you’re comparing it to one of the many clones which are dirt cheap in comparison. A real Arduino Uno R3 isn’t cheap. Adafruit and Sparkfun both sell it for $24.95 so Seeed selling it for $29.90 is a bit more expensive but not wildly so.
Search ebay for dso201 – not sure on the model but cheap ones are on ebay
Anyone know the brand/model of the oscilloscope?
using the internal RC Oscillator for a waveform generator :\\\
For running a site about (mostly) electronics hacks, HaD spends a lot of time wasting time on spending too much money on over powered chips for simplistic operations. There are only about 100,000,000,000,000,000 8 pin, dip package microcontrollers that can do this that don’t have the overhead and expensive price tag that this ARM chip has that have been around since like 1980 or something. PICs for example. How is this a hack, and a good one at that?
I’ll go to the grocery store down the street in my Lambo, while I wait on an answer….
Most people on here only need single items, or low quantities. A few bucks extra for the price of the controller is pretty much irrelevant.
Hack (n) (src:Wiktionary
—–
10.(computing) An interesting technical achievement, particularly in computer programming.
11.(computing) A small code change meant to patch a problem as quickly as possible.
12.(computing) An expedient, temporary solution, meant to be replaced with a more elegant solution at a later date.
13.(colloquial) A trick, shortcut, skill, or novelty method to increase productivity, efficiency or ease.
—-
This is 10 because it is 13 used as a 12 that enumerates 11 at the hardware level
I wouldn’t call that an oscilloscope. Its name is DSO Nano v3.
The clock seems very stable… not! He could’ve just used a timer of the chip from the i2c master. Oh, I forgot he only has arduino skills.
Oh wow, what an epic burn. And that way you say something like you mean it, and then add a “not” in the end… Amazing.
I’m not up with all the sick new snark you kids have today, am I safe to assume your “Amazing” is said in the negative format?
Yes.
Not.
“[…] These are quotes from various Hackaday comment threads throughout the years.”
That’s why it HAVE to be called Trollspace® !
Can someone tell me how he gets 1Hz resolution in a microprocessor?
According to the datasheet, the micro runs at up to 30MHz, which for a 30KHz signal would be a PWM counter divided by 1000. Taking the next larger divisor (1001) results in a difference of 30Hz.
(And that assumes a full square wave with each count. More likely, each count is one transition, so the divisor would actually be 500, and the difference in resolution is about 60.)
In other words, is the cited resolution just the API interface, with the actual output mapping many frequencies into one? Or is he actually getting 1Hz resolution?
I would *love* to be able to run my transducer from a micro with 1Hz resolution – if it can be done. My analysis (“Design Question 3” from the link below) suggests that it can’t be done.
https://hackaday.io/project/4689-improve-the-haber-process/log/16065-measuring-resonant-frequency-the-easier-way
You can do far better than 1Hz resolution even with the elder AVR family and that’s sine wave too.
http://www.myplace.nu/avr/minidds/
>In my case with a 11.059200 MHz crystal, the resolution is 0.073242188 Hz.
google for the theory for DDS.
Ok, let’s say you want 29,999hz. Divide by 1,000. Also trigger an interrupt each time a pulse is generated, an MCU can handle 30K interrupts per second no problem. Count the pulses, and on every 30th pulse, set the divisor to 1,001; then reset it back to 1,000 on the next pulse. And voila, you have 29,999hz.
To put it a more general way, you’re accumulating the error caused by being limited to an integer divisor, until it becomes large enough to temporarily select the next higher or lower divisor.
You can also reduce the number of interrupts needed. For the 29,999hz example, feed the PWM pulses into a counter. Sometimes you can do this completely in-chip, other times you just externally connect two pins. Set the counter to trigger an interrupt every 30 pulses. This first interrupt sets the divisor to 1,001, and enables a second interrupt that triggers on the next pulse. The second interrupt sets the divisor back to 1,000. Now instead of 30K interrupts/sec, you only have 2K interrupts/sec.
Sure, not all pulses will be of exactly equal length this way. You get a “jitter” in the signal of 16.5us average and 33us max, but in most cases that’s not important. Probably not in yours, since resonant circuits average over many pulses.
But let’s go accuracy crazy, and say any jitter is unacceptable. I recall one NTSC video signal generator that used a really neat trick, and I hope I can accurately recount how it worked. It used an external crystal to clock the MCU. You’re supposed bypass each side of the crystal to ground with a capacitor, usually in the 12-18pF range, for stability. But by altering the cap values, you can also subtly tweak the crystal frequency. This generator replaced one of the caps with a varactor diode, ie an electronically variable capacitor. A PWM was output into a filter to generate an analog bias voltage for the diode. By using a second clock as a fixed reference, it was able to measure its main clock frequency and *alter* it, just enough that it was capable of producing the exact signal frequency required – despite the limitation of an integer divisor.
It most definitely CAN be done… just a matter how how fancy you want to get. ;)
That’s not “jitter”, that’s you actually getting two different frequency signals out of it if you look at it in a spectrum analyzer.
You’re just generating a 30,000 Hz signal most of the time and interrupting it every 30 cycles, which produces a 1,000 Hz spike in the spectrum on the side. There is no energy at 29,999 Hz in your signal, just like two people singing equally loud in C and E doesn’t make it sound like one person signing in D.
If you put that through an extremely narrow bandpass filter at 29,999 Hz you get nothing out. A resonant circuit would be excited to some degree, but you lose signal amplitude. If you try to clock another circuit with it you get timing glitches.
“There is no energy at 29,999 Hz in your signal, just like two people singing equally loud in C and E doesn’t make it sound like one person signing in D.”
Imagine taking a 1khz square wave, and digitally sampling it at 44.1khz. 44.1khz isn’t an integer multiple of 1khz, and therefore pulse lengths would alternate between two values; which would only produce 1khz when averaged over time, not when examined on a pulse-by-pulse basis.
Yet you obviously don’t hear two notes when playing back the digital audio. So I have to assume you’ve misunderstood something.
I wonder why it was not done with ESP8266. Network controllable 555!
Soon !
But does it play Crysis?
I2C !!!
Please, USB
No offence, but in what circumstances would you want something like this controled by USB? I2C is far more convenient with any embedded system, as it’s easier to implement.
he could have done that with a handfull of vaccum tubes and a rubidium check source to get much more accuracy
+1, if only because you made me actually laugh.
Hackaday needs more projects using butterflies. How about a contest?
These?
http://www.digikey.com/product-search/en?KeyWords=avr%20butterfly&WT.z_header=search_go
I have one of those! They were gimmies at an ESC West back in the ’00’s. Been thinking of doing a badge or something with that thing.
I once read a Don Lancaster post that a Microchip PIC can be used to replace a 555 and be more flexible Sounds to me.
I’m not sure how valuable an I2C controlled 555-replacement is, because any MCU that can drive an I2C bus probably has a spare PWM output somewhere.
More generally, though, I’ve been thinking that a project that had a library of common utility functions implemented as firmware for a common MCU like the ATTiny range could be really helpful. Want an IO expander, or a boost controller, or a counter? Sure, just flash this premade firmware onto a device you already have and check out the datasheet.
Am I so behind-the-times that a 32-bit ARM in an 8pin DIP is … shocking?
You have to wonder what’s so complex as to need so many MIPS, yet so simple it only needs 8 pins. But somebody must be buying ’em.
I’m imagining there’s something to be said for the learning/devel overhead… there’s a programmer necessary, toolchain, etc. I can definitely see sticking with what you’re familiar and have the tools for… And, from the other side, there’s the fact that something like this is a bit of an appeal to AVR/PIC users to attempt ARM programming, knowing there’re options for small projects.
The thing that I find appealing is that with that few pins it can’t possibly require all the complicated power/decoupling of ‘some other’ DIP-factor 32-bit chips I’ve run into. Start small, and work your way up, in this case…?
But, like you’re suggesting, it is hard for me to imagine a case where this would be used in any sort of product, it’s like they’re aiming it directly at the educational/hobbiest/hacker market(?)
Lots of contemplations… Kinda cool to know it’s out there. Maybe some day…
On a modern process, the ARM Cortex M0+ core is only 0.0066 mm2, whereas an older 555 is more than 0.5 mm2.
You also need to factor in the die size of the other parts than just the core… RAM, FLASH, I/O cells, I/O pads, peripherals, the usual system stuff: oscillator/PLL, regulator for the core voltage, brownout detector, bus interface, debugger etc.
You CAN program a 555 with i2c…it’s called an i2c interfaced digital pot. I’ve done it.
The problem being that now you need a programming device and a computer to interface to your simple project that is designed to blink a LED or generate a simple servo signal etc.
The point of the “you can do it with a 555” argument is usually that the device is doing something exceedingly trivial that doesn’t warrant digital access, and is actually made more cumbersome by the requirement to program it instead of just soldering in a resistor or turning a knob.
Often you see people then add the potentiometer to make the thing stand-alone from the computer, and then spend hours and hours puzzling over how to read analog values, debugging their code, dealing with glitches and special considerations like brown-out-detection and how to prevent the chip from corrupting itself when the battery runs out…
So-on and so forth, when they could have just started with a 555/556 reference circuit and be done in 5 minutes.
Work hard once so you don’t need to work hard every time.
I don’t count the effort required to initially develop the code unless you are intending to use the device exactly once.
There are good objections to this hack, but I don’t think that is one of them. JMO
How many LED flashers or halloween props with servos are you going to make over the years?
Curiously enough, I see this mentality a lot with hackers. It’s the mentality of, “I’ll spend two hours writing a shell script to do this one specific thing that I’m probably never going to do twice, that would take me one hour to do manually. Isn’t command line powerful!”
I doesn’t have to be same project. I’ve done dozens of microcontroller projects, and a lot of code snippets and knowledge can be carried from one to the other.
Not many. Which is why I didn’t make this hack. When or/if I do, then I will.
Hacking is a hobby, so the free time costs nothing.
Well I’d rather just use a cheap Attiny13. Less than $2.
The LPC810 is only $3.50 at single quantities. Difference isn’t really worth worrying about.
I have no idea, why this device is so cool. If the one have a ARM32 M0 with 30 MHz, he definitely can reach high frequency at least 1 MHz, not 65 KHz. Algorithm is simple as it is in description: get a frequency, fill the memory with pre-calculated samples. send values from a memory cell one-by-one to a GPIO. If you’re smart enough, you will get high frequency and complex signal shape at the same time. Jitter will be minimal, while the number of ticks required for a loop is absolutely predictable if interrupts are disabled.
But anyway, last time I see, that ARMs are more and more preferable than ATxxx, AVR, PIC, MSP430 or STM8. Thanks to the author for a discovering new chip for me. BTW.
Butterflies??? You had butterflies??? We only had a handful of pebbles!
I tried it with moths! No damned good at all! There is no conversion, the moth buss protocol is so complicated!
I’ve found anything with a club antenna works, if it’s feathered, forget it!
Oh, and use a knife for the duck tape or you’ll be spitting feathers all weak!
On a similar vein, years back I programmed up some motor speed controllers, using PIC 8pin devices for RC cars etc. Made life so easy! Many parameters could be set on start-up with a press button ;)