4 ms·
i feel like the ch32v003 might plausibly be the right chip for these jobs, even though it's risc-v, because it's so much cheaper than the avrs. as a bonus, it's
by kragen 2y ago
i feel like the ch32v003 might plausibly be the right chip for these jobs, even though it's risc-v, because it's so much cheaper than the avrs. as a bonus, it's made by a chinese company, so you can use it even in contexts where foreign hardware isn't allowed (this has become a big deal as the usa has started ramping up its sanctions)
in theory it's 12¢ each at lcsc, but it's out of stock, so that's only theoretical: https://www.lcsc.com/product-detail/Microcontroller-Units-MCUs-MPUs-SOCs_WCH-Jiangsu-Qin-Heng-CH32V003J4M6_C5346354.html https://www.lcsc.com/product-detail/Microcontroller-Units-MC...
it's not competitive with the expensive avrs when it comes to mixed-signal peripherals and 1.8-volt support, but it does have some tasty stuff. you get 3.3 to 5 volts, a 10-bit adc (1.7 megasamples per second with a ±2% bandgap reference), and an op-amp (so you can do differential input to the adc and set its gain), a basic set of digital peripherals, and that's about it. that's still better than an atmega328 or an stm32f103 but not in the same league as the stuff you're talking about
i haven't actually tried the chips myself, so i don't know if they're all they're cracked up to be, but except for a fatal problem with the spi peripheral in the smaller packages, other people seem to report good success, even without speaking chinese: https://hackaday.com/tag/ch32v003/ https://hackaday.com/tag/ch32v003/
in this price range, there's also the arm puya py32, and of course the padauk chips with their redoubtable multithreading so you can do your i/o from a separate hardware thread instead of from interrupt handlers
- dragontamer 2y ago> it's not competitive with the expensive avrs when it comes to mixed-signal peripherals and 1.8-volt support. you get 3.3 to 5 volts, a 10-bit adc (1.7 megasamples per second with a ±2% bandgap reference), and an op-amp (so you can do differential input to the adc and set its gain), a basic set of digital peripherals, and that's about it. that's still better than an atmega328 or an stm32f103 but not in the same league as the stuff you're talking about Yeah, the features you just talked about are definitely more akin to what AVR Dx or Ex have to offer (albeit the ch32v003 is cheaper and has less features). I do like this modern trend of making incredibly powerful peripherals that most mixed-signal designs need (ex: adding OpAmps to a device, or in the AVR case, adding Differential ADCs to explicitly support more use cases). This design trend didn't exist back in the day when ATMega328pb was designed however, so you don't get it with the old chip. ----------- OpAmps seem to be one magic device that really should be in more of these designs. There's so much you can add with one OpAmp (or a team of 3x OpAmps). So I love it when people point out chips with an OpAmp (or two or three) that come with a uC. I've seen some pretty silly designs, like using the OpAmps to sense Voltage (or current), hooking up the output of those OpAmps to the Analog Comparator that triggers an interrupt + internal state, and that state controls a Timer-waveform / PWM output that controls a Voltage-Controlled Current-Controlled battery charger that's feeding a MOSFET + inductor to create effectively a software-controlled buck-boost converter. I doubt its as good as any "real" solution, but if you've got a bunch of these uCs lying around, it might be a better solution than adding more SKUs of the specialized power chips. Just a hobbyist here btw. Not a real engineer. The real engineers might look at my previous paragraph with horror!
- kragen 2y agoyeah, i think software control of buck and boost converters is a mainstream thing to do at this point, and if you think about it, that's what you're doing every time you control a motor with a pwm signal, even if the motor's windings are the only inductor. building discrete dc-dc converters turns out to be the main purpose for the 184-picosecond-resolution high-resolution timer included in chips like the stm32g484. i was reading this appnote yesterday: https://www.st.com/resource/en/application_note/an4539-hrtim-cookbook-stmicroelectronics.pdf https://www.st.com/resource/en/application_note/an4539-hrtim... incidentally, even the old attiny chips that don't have adcs at all do have analog comparators, so you can do tricks like that with them too i'd be happier with the on-chip op-amps if they also included on-chip analog multiplexers, resistors, and capacitors sufficient to build something like a sallen–key filter in software, but so far only the cypress psoc line seems to be doing that, and it's probably a lot of chip real estate to sacrifice for an inferior version of a couple of 0.3¢ external components i'm not an ee either, i just play one in ngspice