It was so close to programming in raw assembly code that you might have been able to bit-bash your I2C functionality. Even on the smaller chip. The watchdog was the first thing that came to mind when I saw the way the LED was behaving. Every time you move to a new microcontroller there's a bit of a learning curve.
@@ChimpyChamp if you know how the i2c protocol works on the signal level, all you have to do is reproduce those signals by turning on and off the pins yourself
@@ChimpyChamp nah, you just need an input pin, output pin and enough program space to save all the packets you need to communicate with the slave. Simplest i2c bit basnging program is around 1kb.
@@ChimpyChamp Usually you start by looking up timing diagrams and protocol definition. The first tells you what lines carry a signal for what time. The latter tells you what the signals need to contain in information so that another device can make sense of it. Having HW interrupts in your uC helps a lot but you can manage without. One thing that is critical though is that you either have HW timers or that your architecture can produce repeatable timings when given the same set of instructions (unlike complex platforms like computers, where that timing would break as soon as the CPU gets a little too busy) From there it is just writing functions and abstract your way upwards to a level where you can simply receive and send data like you are used to on Arduino. It is a lot of work, though. But it is not outside the scope of a beginner with a scope (see what i did there? 🙂)
Watchdog timers are brilliant when used properly - deserving of a video of their own. Basically, inside your loops you reset the timer. If your program crashes, it won't reset the timer and the watchdog circuit will reset the whole device. Absolutely fantastic for circuits that aren't easily accessible in particular.
Yeah, I was watching this video thinking how not fully explaining the watchdog timer can lead lots of people down the road of bad coding practices. I have no problems with disabling it for such simple code, but if you have a project that does anything more advanced (like wireless communication or has a display), you definitely should consider learning how to properly use it. Watchdog timers are great for error handling. Nice video in general, though!
@@realdragon Because watchdog timers run independently of the ALU. Your ALU can deadlock, but the watchdog can still keep counting down and reset your ALU
The premise of the video is a bit off. If you are only making 14 boards, then the 2€ difference in price for the MCU doesn't justify the cost of buying a new programmer and spending a week worth of extra engineering time. On the other hand, if you are making thousands of these boards, then something like missing hardware support for an I2C master interface isn't going to stop you from buying the less expensive controller. That's a very easy fix in software, and you can find countless reference implementations online going back at least 30 years. Of course, if the goal is to make an entertaining and educational video, the incentives look very different. The cost for a new programmer is negligible, if you get a successful video out of it. And for me as a viewer, this is certainly more entertaining than yet another video showing how to program an Arduino.
If you are going to do a 'proper' job of bitbanging the master, it's not so trivial. You have to deal with corner cases such as when the SCLK pin is an input (from master perspective). For only 1 device, if it's well-behaved -- then yes, the code for master can be simpler. But I2C edge cases are a pain. I *hate* I2C when I have a better option (e.g. SPI, and if you are pin limited, use, say, 74LV8153 which can be driven by a spare uart TX pin, bitbanged, and has output OC or push-pull, separate Vcc for the 8 output pins, and can drive 40 ma --- one pin from the uC neeced to get 8 out! With a simple SPI setup, you have the 'selects' you need with the expander. SPI -- always SPI.
I feel like a little RISCV chip makes a lot of sense here, like the CH32V003. It’s even cheaper than your $0.20 part and can work as an I2C controller.
Upvote for the CH32V003. The SOP-8 version can be obtained for about 10 eurocents and the TSSOP-20 for about 20 eurocents. It has a functioning Arduino core that does the basics but needs some further development to support its peripherals. When using the Arduino IDE v2.x it even supports regular debugging (i.e. stepping through code, watching variables, etc),
CH32V003F4P6 - $0.21 per piece 48 MHz, 16k flash, 2k RAM, 18 GPIO, SPI, i2c, USART...etc. You are welcome! If you need less hardware and want to have an even smaller form factor, then CH32V003J4M6 comes in a SOP-8 package. It beats ATTiny85 in specs.
I think he would have to use the 84 to get the extra GPIO, ofcause depending on the project, though the AT are usually a few bucks for a SOC, but still pretty cheap in small batches, depending if you want to pay wages or chips. But in 10x productions i would go for less time working vs higher price SOC, he spent 3 days on it and where i live that would cover about 500 pcs of ATTiny84
I use the ATTiny85 MCUs which can be programmed using an Arduino and works great with the Arduino IDE. Once programmed in a DIY ZIF Arduino programming shield require no additional components. The V models run on 1.8V/300uA @ 1 MHz in low power mode with 0.1uA in standby and you can boost the clock to 10Mhz with 2.7V. I only use Arduinos for prototyping and then design my production boards using an ATTiny instead. I keep a tube around they are super handy. They cost $13 per 100 or $1.30ish each. Not as cheap for mass production but the hassle for under 1000 units isn’t worth the time or effort of a custom MCU and IDE.
The ATtiny's have excellent Arduino cores available. For small projects that need a few more pins than the ATtiny85 I've enjoyed using the ATtiny44A and ATtiny84A, which are often somewhat cheaper than the '85. For really small things I find the ATtiny13A interesting, but the limited memory can also be a bit of a challenge.
@@JanKluiver - I've read they have better features indeed, but I still have some stock to empty first. As for new cheap tiny MCU's I'm looking into the CH32V003, which is cheaper, has more memory and even supports debugging.
There is a tomm of stm32f103 chip`s, which cost less then $1, sometimes $0.5. Or you can find chineese clone for even less price. And STM32 have a tonn of features, like USB or advanced timers. And they can be programmed through Arduino IDE or CubeIDE and there are a lot of examples.
NOT a pointless video at all! Ive been following the channel for a few years now and I always appreciate the ones like this! The ones where you put in the hard tedious work to show us something *new/not well known. Cheers from Texas!
The programming pin names OCDSDA and OCDCLK do hint at On Chip Debugging, the IDE even has a Debug menu. It might support breakpoints, much better than using Serial.print
Debugging is only possible for their "special" development boards. I was sadly not able to use it with their normal uC. But maybe I was also just too stupid.
@@greatscottlab Yes you need the HT66V rather than HT66F part to debug. You can get them from a Holtek rep, from Bestmodules or from dev boards and just hot air gun them off. They do it to reduce the cost of the production parts
I came across the Attiny85 recently after many years of projects with atmega328s and it certainly has made a difference for smaller projects for both cost and size.
Yeah, that was my first thought, too. For a project like this, why not just switch to an ATtiny? The CPU is substantially similar to that used on the ATmega Arduino boards, and I believe that there are even folks selling ATtiny boards that have added the appropriate tweaks to the Arduino ecosystem (IDE and libraries) to be able to use that to program and run the ATtiny.
@@Curt_Sampson you have development boards like the digistump which runs micronucleus bootloader, only problem is that if you use them in-circuit you want to disconnect some of the pins while uploading because they are used for the usb function too... :/ Also not sure if it has enough pins for what he is trying and probably the price is still too high: around 1.41 eur / piece for 25 pieces on mouser... is not that different from the arduino microcontroller he mentions in his video costs around 2dollar ~ 1.8 eur / piece for 20 pieces
Same. I’ve found few 8bit MCU projects I couldn’t substitute a tiny for. I’m more likely to go to a 32-bit MCU when I need more for the kinds of projects I do anyway.
in our microcontroller programming course we had to program like first few weeks in assembly language - it really made people appropriate how much higher level languages with proper libraries enable people to do with much less effort
Great to see you're using my Instructables guide! To be honest I never thought anyone would read it 😂 I've been using Holtek for years mostly on commercial products and always found them great for the price. Keep up the great videos! On another point, maybe you could bit-bash the I2C, but it will be a difficult task.
If you have GPIOs and are using PWM through a timer, it's not too difficult to implement i2c master in SW, much less simple to implement slave which is probably why they have it on some versions.
Nice vid! Not sure why you didnt mention that you can implement a bit banged i2c master! No need to have it as a hardware module, specially at lower speeds
@@greatscottlab no worries! And the development + troubleshooting time is not free either 😅 unless you plan to make thousands of these, its probably cheaper overall to go with a slightly bigger micro with the features that you need
@@greatscottlab Long story short, you can practically bit bang anything as long as you can generate and/or read signals fast (often) enough. That essentially programs your general purpose processor core to do the specific application, which the usual hardware bus processor is meant to do. They can be functionally identical, although it does obviously pose some limitations in terms of speed, as well as efficiency on power and processing capacity. If your module/sensor supports SPI or UART, they are much easier to bit-bang. Bit banging will be pretty much the same for any platform, give or take the I/O or timer specific functions which you've already explored!
bit banging I2C is so simple you'll regret not implementing it, especially when you have a oscilloscope and an arduino for testing your code. You can clock I2C at any speed even with a CPU running at 32khz. No timing is required (a clock cycle can be 1hz and the next one 1Mhz in the same byte, it doesn't matter). Master or slave, with minimal error processing, would take about 10 lines of C code. Funny thing is master is much simpler to program than slave.
I have always run with ESP-01 I bought for $0.5 a pop off aliexpress for cheap Arduino replacement but good to know there are even cheaper alternatives. Everything suggested in the comments is useful as well. It's good that you made this video.
Yep. Right on schedule: Exactly at 6:45 of a 13m30s video (50.0%) the 'Blink' is finally working. I've said this for years: Getting 'Blink' (or 'Hello World') to work is typically the *halfway* point of any small project in any new µC ecosystem. Not usually so precise. That's why Arduino, which includes 'Blink' from the start, has such an easy learning curve. Everyone should understand this point; it's important for planning and scheduling.
What? This is a video. The pacing of a video has nothing to do with the pacing of the learning process and everything to do with the creator's directorial intent. I also think that the Arduino Blink sketch is VERY simple and mostly is an intro to digitalwrite. Sure, there is timing involved, but I'd hardly call it an intro to scheduling since there is only one thing happening.
@@MarioPL989 Except notice this: Our channel host spent "3 days" (he mentioned it) in this new-to-him ecosystem, just to get a few 'simple' routines up and running. I expect that another several days would be more than sufficient for what you describe. Keep in mind that primary point, and it's not an argument about "50%" versus 20% or anything else. It's that it can be time well spent in a new ecosystem getting as far as ''Blink'. If you're managing coders, direct them (firmly) to go get 'Blink' (or 'Helllo World') running first. They might not be back for several days, no matter how smart they think they are. It's a valid point and ignored at your peril.
@@MarioPL989 You may not understand the purpose of a blink program. It's not about precision or accuracy. It's about taking a chip you've never used before, and getting code into it, and having that code do something you can easily verify is working.
Absolutely. Blink or Hello is the absolute hardest thing to get working. Or the equivalent for any other hardware. I just spent 3 days getting a SPI LCD panel to show anything other than a solid white screen. And then I spent another couple of hours the next day getting eight other (different models) LCDs hello worlding me. It also took me about 2 days to get my first Blink going on one of the new AVR 0 series chips, using the new UPDI interface. But that's because there was a lot of almost-right information out there on RUclips.
8 cent : PY32F002/PY32F003 from PUYA for microcontrollers with an ARM Cortex M0+ core clocked at 24/32MHz. PY32F002 20kB FLASH, 3kB RAM, SPI, USART, I2C, ADC, timer... nothing to complain about. PY32F003 additionally DMA and a few more timers, there is also an additional memory selection. It is an SWD interface that does not require a special exotic programmer. Power supply 1.7V...5.5V, TSSOP, to small QFNs or DFNs.
Actually this video demonstrates nicely why Arduino was such a game changer. The time for learning and debugging will never justify the price savings in an hobbyist environment.
This type of thing is NEVER a waste! And, instead of three days, or hours for other issues, you've well detailed the process, saving the rest of us all that time you spent on it! (For some of us, it convinces us not to bother, or visualize the system a bit differently, maybe multiplexing or another solution depending on the need and context.) Watching your process alone taught me some general things, plus, you gave an update on JLCPCB offering more colors soon, so, yeah: another GREAT video!!!
The MCU of air001 produced by a Chinese company named hezhou is only sold for $0.1, supporting Arduino, with the following performance: - Adopts the MO+ core of ARM 32-bit, and the main frequency can reach 48MHz; - 4K RAM + 32K Flash; - Ultra-wide power supply range of 1.7~5.5V, which can be powered directly by USB or battery; - Built-in configurable RC oscillators of 4/8/16/22.12/24MHz, which can run at 48MHz without external crystals; - A 12-bit ADC, supporting 9 input channels; - 9 timers, 2 USARTs, 2 SPIs, 1 I12C, 2 comparators, very rich peripherals; - 3-channel DMA, efficient data processing; - Standby power consumption as low as 2μA.
Go for the enhanced family of PIC, the newest versions feature many useful peripherals, larger program memories and the IDE supports a GUI for setting up configurations instead of manipulating registers!
I never advise my students to use the delay() statement, given that it kills the program for the time they've set and it's a waste of resources. On Arduino it is preferable to use the "millis()" function and for the HT66F002 it is easy to implement an interrupt handler and build a similar "millis()" function for the HT66F002. Especially in robotics we should avoid using "delay()" instructions.
@@greatscottlab would it not be possible to use something like a raspberry pi pico as a programmer using software ? (offcourse there will need to be decent documentation about the programming protocol and probably allot of time)
@@ChristopheVerdonck Something I've noticed is that many microcontroller makers don't document the programming process. They just say, "use our programmer and our free software". I was very unhappy when I decided to use one of the newer-generation AVR 0 chips, only to discover that 1) they don't program like the older AVRs, and 2) they did not specify how programming was done. Fortunately there are enough hackers out there that it has been reverse engineered well enough that I was able to get it working, but to me it's inexcusable that they would sell me chips and then require me to use their software. If you could get the programming specs for the Holtek chips, it's likely it would be in Chinese and would not translate well. I suspect that the reason Scott bit the bullet and bought the programmer was that he intends to make at least a limited production run, and the 110 € expense was justifiable. Last time I priced ATmega328P, 110 € would only have bought about thirty of them.
Ben Eater has an EXCELLENT series about building a PC from scratch, including the evolution from code bytes to assembly instructions, all the way up to C code which is a great complement to this info.
While you spent some time learning the syntax to code these chips, the good news is you can create your own reusable wrapper libraries that are compatible with Arduino code and make future projects easier and faster to build. Arduino was originally based on Atmel microcontrollers, which have had really nice opensource tools for a long time. You can easily build your own programmer for them as well. You can still buy these chips independently and use them in your projects. Fun project and demonstration of the power of more generic microcontrollers. Thanks for sharing!
I did the halfway version of this project.. I bought an Arduino trinket which is powered by an 8pin dip attiny85 processor and programmed it using the Arduino environment, I then bought a USB Tiny programmer for ~$6 and some bare ATTiny85 chips at $1 to prototype my project. My programming was all done in the Arduino software for the trinket, and with code from the ATTiny Datasheet. but for my final pieces I bought boards fully populated by PCBway, and used an SMD chip clip to finally program the ATTiny chips on the boards.
Personally, I'm a big fan of the CH32V003 (it's 32 bit, RISC-V, way more capable and even cheaper). I believe it even has pretty good Arduino support as of right now.
I commend you for making this video, especially for exploring an unfamiliar MCU. There are so many makers who are reluctant to go beyond the Arduino and Arduino "IDE" - I think your explorations here will give some the added push to go out and venture beyond the ATmega328 + bootloader + Arduino "IDE" environment. The Arduino ecosystem has injected a lot of interest in electronics, but the community needs makers who aren't afraid of datasheets and getting their hands dirty with new hardware and software.
At some point this make you love Audrino more. This remind me of my project of adding midi to a vintage 3 manual and full peddle Rogers organ with single ground bus and need to find a cost effective way to expand ardrino to have hundreds of digits in gpio to generate serial midi signal for virtual organ software.
I go back and forth on this. My first Atmel AVR project I did bare-metal, using the gcc-avr tools and buying an Arduino Nano just to use as a programmer, because I really didn't like the Arduino way of doing things, hiding all kinds of stuff from the user. And I would have been in serious trouble had I not found an example project on Adafruit that included a Makefile and a header file for pin definitions. With that, I had no use for the Arduino IDE, or for that matter, any other IDE. BUT, the second time I used an AVR was to modify the code on a hobby radio called the ATS-20, which used an Arduino Nano to control the radio-on-a-chip and an OLED display, so I was very thankful that the developer of this radio released the code as an Arduino sketch, since this made it easy to understand the interface to the I2C-connected display. So it's love/hate for me, and now I fully understand that if I want to make a microcontroller-based project for others to build on, this is the way to make that easy.
But it requires external flash and a lot of passives and a crystal, and is not easy to manually solder / build your project without a better tooling - they have a place, sure, but they are too complex to implement in many use cases
Very nice! I'm so glad you documented this process! Learning that the process ultimately did not achieve what was hoped makes is just as valuable as learning a process that does achieve this.
A great alternative could be the attiny series (not the 85 but their newer attiny chips). They are available in 8 to 24 pin packages, with 2 to 16kB memory and come with SPI, I2C, UART, multiple timers with either 16Bit or 8 Bit pwm, and adc and much more. Im pretty sure you can also programm them with the arduino ide and an arduino nano if you dont want to fork over 160€ for microchips own programmer.
Hello GS, I started watching your videos 10 years ago while I was in Highschool (Electronics Major) today I came across again with your videos and I really miss your Led backlight leds intro 😢 I am glad you are still this active.
Even if I play the old intro with no sound I still have that sound in my head. Today I am 28, and feel old because I saw your first videos and noticed they were uploaded few years back 😅 (I am sure it was only some months back but not this long. I always have admired your work 👏🏼👏🏼👏🏼
You should be able to use the programmer to debug as well, just like an Arduino. Usually there are functions that allow you to write to the serial bus, which should even show up in your Arduino IDE if you pick the right port.
@@lifeai1889 I know what you mean. It's incredible to have reliable step debugging/breakpoints and access to the stack. It ruins any platform that doesn't support them. Some bugs just can't be fixed without it!
I've used both debuggers and "print" on many, many projects, and have found the debuggers had a much higher learning curve. I can get a lot of debugging done just by sending a single character to a serial port or even blink codes to an LED.
Haven't understand almost anything (I don't have any engeneering background whatsoever), yet I always watch your videos and feel happy new ones show up in my feed... I kept wondering why. And it hit me a moment ago - you seem to me to be very precise and very honest, balanced in your opinions. I find your materials well thought thru, well prepared and deep into the topic. All of theese factors lead me to one conclusion - it seems I TRUST YOU, and that's the main reason for me - a complete amateur in yoir field - to watch your stuff and keep coming back. You have build a trust in me by keeping up to noble standards in the field of your craft and - what is also important - in the way of comunication across that field. Therefore I wanted to thank you for sharing your passion, your way of thought, your skills in a way which not only does not DISCOURAGE noobs, but rather INVITE them into the topics you present. And this habit of yours - to use pen and paper... as a motion graphics solution :) - this constantly blow my mind as a remedy so simple yet still so effective in our modern overstimulating times! (plus, I find it part of your "signature", your style, identity). Overall - Kudos and big thanks!❤ Greetings from Poland.
Yeah, depending on how much communication you actually need, it's definitely possible to bit-bang the i2c commands. The limitation will be the memory though, it'll take a fair bit of space to manually code in the timing
@@NewtoRah Only very few I2C Slave devices have actual lower bound timing requirement. So by dropping the speed low enough you can just ignore the timing all together using I2C. That's why implicitly, all MCUs with atleast one Input/Output pin support I2C Master-Mode. The Code isn't even complicated if you don't care for the MCU being blocked during this time. The Adafruit OLED Library actually has that code in it. It's ~15 lines.
@@NewtoRah This HT66F0176 has 2Kx16 of Flash and 128x8 RAM. So yes, I agree that memory is a limitation, but it's possible. One thing he should take care of is timer interrupts, which can mess up communication timing.
Embedded hardware engineer here. "w95 interface" is mostly an industry standard. It wont lag and will run on any crappy pc anyone could have. For an i2c - you can always make soft-i2c through bit-banging. Thats always worth the time spend, because it allows our clients to pay us once for making it possible, than to spend lots(+20-40%) of money on every device they'll need.
It's not exactly "standard", it's just Keil and IAR do not want to invest in updating their ancient IDEs look-and-feel because it's a small market, much smaller than, say, web dev. General purpose Eclipse or VSCode are modern enough.
I love that you covered the topic and shared it regardless of it not being what you can use for your project. We were able to see the process of learning which I and probably others also learned from.
My go-to controller series these days is the STM32G030 series. There is a 20 pin version from about 0.5$ and it has all the goodies that its bigger package brothers have. I use it with ST's IDE which certainly has a steep learning curve after Arduino but the raw amount of hardware features is worth it for me. The only downside is that division and floating point math are basically non existent on the controller but it's easy to get by them. E.g. I can do integer divide by power of 2 by right shifting, if I don't need to be super precise.
I feel like something from ST probably would fit the bill pretty well they have some really low cost small boards and the HAL and arduino compatibility make it easy to start things up
Great video! It is important to show failures sometimes to highlight the thinking and work involved with solving novel problems. I also liked it because I came across the same family of controllers while adding wireless control to a toilet seat warmer recently, so I could turn it on as soon as someone walked toward the bathroom.
Was about to comment about the ATTiny Microcontroller It may not be as cheap as the MC's in the video, but it has nice interface, easy programming and lots of tutorials, so they can get the job done Nice video as always
Nice to see a much less clickbaity title! Nice vid. BTW the DeArrow title for this is 'Trying out the Holyek HT66F002 Microcontroller'. I reckon something in between would be ideal so people researching the chip can find it and those looking for alternatives can too. But it's not financially viable to title for maximum viewer usefulness I guess. Still a big improvement over the usual thanks
It is easy to implement I²C Master in Software. Maybe a little bit slower and consuming more CPU time. But not a problem like I²C Slave. Does it not fit into the limited memory?
Exactly my thought too. I2C is not hard at all to implement as master. Sometimes even easier than trying to interface the hardware peripheral if just wanting to hack together and reading out a simple value, without bothering with DMA and such
The only way I know about Holtek was when I took apart a laminator machine. I was planning on taking it apart and reprogramming it to have a "slow" mode for thermal transfer toner of PCB images. Unfortuantely there wasn't much to dump the firmware or to re-program it, and within months Holtek locked down their documentation archive. I also needed to reverse how the heater was modulated, temperature was measured, and how the AC motor was being controlled. It was far easier for me to just run the PCB through the laminator 20 times than to reprogram the machine.
110 Euro isn't that bad... I'd think that their IDE being limited to Windows is more of the issue... I wonder if WINE (et al) would be able to utilize the USB device properly for programming in Linux.
Arduino encompasses the atmega chip which... Is the core of it and is a microprocessor... So yes it can be considered an alternative. Or simply, it's "another possibility"
I mean they are. Merriam-Webster dictionary definition 2 of alternative "different from the usual or conventional" technically a toaster can be an alternative to an Arduino.
FYI Depending on the storage space that the microcontroller has, you can implement the I2C bus in software. I have done this in the past on two occasions, and it works well.
@@greatscottlab You propbably seen Andreas Spiess' Video about the new ATtinys. Is there a reason you seem to use the ATiny402 (13:09) and not the newer 412 or even newer ones from the TinyAVR 2 Familiy?
I've been looking at the ATTiny 10 for a micro project that I have in mind but suspect that the 85's would be best to buy given the range of things I can try to make it do.
It seems my comment got nuked as it contained a link to my guide setting up a arduino nano as a programmer for the Attiny412.. but yeah it would have been perfect for your application as it should support all of your features, keep it up, love these videos!
What's the problem with implementing i2c in software?! At least, i2c master mode is totally straightforward and it takes only about 50 lines or so... Just stop being obsessed with that libraries and h/w implementations.
Always interesting to see the process of learning about microcontrollers. An avid RC Plane enthusiast, I am always interested in learning possible ways to bring my projects to the next level. Thanks.
As someone whose interest in microcontrollers predates the Arduino, I'm always worried about how that "easy mode" could affect the collective skill level of this field. I'm glad you're shining some light on other options. Also worth noting, it is entirely possible to write your own I2C code. Not _quite _ as trivial as SPI, but still well within reach of a hobbyist.
Very cool video. i may not need one of these in a project personally but found it very interesting to know there are alternatives that cost almost nothing if you willing to buy the not so cheap programmer.
This is reminiscent of how I learned Arduino, manually setting all of the control register values because I heard that the IDE's helper functions were bloated. I ended up doing the same for learning ARM M microcontrollers too
As you are a complete beginner then I suggest to google "Arduino kit" and buy it. You'll get Arduino board (chip), some cables, some LEDs, some sensors, etc. Then google "Arduino beginner tutorial" to get the most simplest things up and working. What he did in the video is more advanced.
I agree, 8 bit these days is toast. I still use the TI MSP430 16-bit stuff because it's cheap, but the CH32V003 is cheaper still and you can use the Arduino dev environment, and it already has the dreaded I2C controller. I think the days of 8-bit and 16-bit are over; the 'war' at the low end is now between cheap Cortex M0+ devices and low-cost RISC-V chips. 32 bits forever!
I appreciate this look into developing for a more "product component" microcontroller, and seeing what its like beyond the garden of Arduino-compatible boards! Especially since, just this week, I was tempted by the allure of super-cheap micros. Seeing the hassle to save a few bucks, and not producing anything at scale, Ill stick with the ATtiny for my super const-sensitive applications, and bite the bullet on the rest.
Nice! I believe you could've gotten i2c to work by using a bitbang library, esentially just doing what the i2c hardware would do in software using GPIO. Since your MCU is acting as the master in this situation, this can be as slow and intermitten as you need it to be to allow it to run its other functions. There's not really any strict timing requirements here.
I think the video is quite inspiring. In schools, education is generally provided with expensive microcontrollers. I think cheap microcontroller should be used for simple applications.
I have been using Holtek MCU for decades. It was the most popular MCU for DIY and electronic enthusiasts before Arduino was launched. The downside of Holtek MCU is the price of their emulator. Holtek MCU is ideal for project that involve mass production, but not for end user who only need one or two MCU for their circuit design. And for the e-link emulator, a bare board version will only cost around USD20 if you can find it in Taobao. Hope this info will help for those who would like to know more about this MCU.
If you don't feel like dealing with Chinese micros, Microchip makes a PIC16F15213 (8 pin) which is well under $1 (the SOIC pkg is under 50c qty 1) and covers your list. There are also pin upgrades to increase pin count, memory, etc in the same and other families. Edit: The ATTiny402 is another good choice (and also made by Microchip).
Doing I²C in software is very straightforward, especially for master. You probably have some serial peripheral that can do the job or most of it as well.
Nice video. That's how life used to be (and is) with proprietary controllers and near-zero libraries. Lawyering with the datasheet and register descriptions, debugging with blinking LEDs and oscilloscopes and maybe a display or UART once you got one running. First time I saw the led blink, I was thinking "running or bootloop?" :-D
Omg, this came out perfectly at the time i wanted. Im trying to figure out how to make a kpop lightstick but an arduino takes too much space for it and i need multiple microcontrollers for controlling stuff. Thank u
I really love this video. I have been looking for some videos on how to make cheap market solutions for arduinos without just selling things with expensive dev boards.
Try an attiny402. Costs €0.38 here, should be available in germany but price may vary. Upto 20mhz@5v 2x uart ports 1x i2c 1x spi 2x interrupts 4x pwms 5x gpio(all can do analog or digital readings) Can use at once : 1 uart + spi 1uart + i2c 2 uart ports 5 gpios Edit:added reasons.
Nice video. I started using ATtiny 412 and 1614 a couple of weeks ago. Lots of searching to get the board libraries installed. But with that working, the chip(s) are easy to program using an Arduino Nano as the UPDI programmer. Use an FT232 board for serial.Print commands. Thanks again for all your videos.
I looked at the Nano-based UPDI programmers last summer when I did my first tiny412 project, but in the end I used a USB/serial interface and avrdude. The "programmer" costs about $3 that way, and you just need a 4kohm resistor tying TXD and RXD together to connect to the programming/reset pin.
6:12 the correct term is actually Download, as it is to a "lower lovel device". You can search the web and discover multible poeple have asked on the Arduino Forums for a reason to why their termonoligy is revers, and unly find the answer "IDK". In PLC's a download always referes to a data being downloaded to the PLC and an Upload being when data is uploaded from the PLC. SO in conclusion Download is the correct term, even though in arduino it is called Upload.
You can still do this project with this micro, if you use operations with registers and disconnect the output by hardware you can achieve high impedance and write a library to communicate this micro through I2C. I did it with a pic 12f615.
But you can add software I2C - "Bit Bang" and it's very common. I've used it with 8051 for communicating with 24CXX I2C EEPROMs and with ATtiny85 for driving SSD1306 I2C OLED module.
It was so close to programming in raw assembly code that you might have been able to bit-bash your I2C functionality. Even on the smaller chip.
The watchdog was the first thing that came to mind when I saw the way the LED was behaving. Every time you move to a new microcontroller there's a bit of a learning curve.
How would to typically go about doing that? I always assumed I2c has dedicated hardware
@@ChimpyChamp if you know how the i2c protocol works on the signal level, all you have to do is reproduce those signals by turning on and off the pins yourself
oh hi there :)
@@ChimpyChamp nah, you just need an input pin, output pin and enough program space to save all the packets you need to communicate with the slave. Simplest i2c bit basnging program is around 1kb.
@@ChimpyChamp Usually you start by looking up timing diagrams and protocol definition. The first tells you what lines carry a signal for what time. The latter tells you what the signals need to contain in information so that another device can make sense of it. Having HW interrupts in your uC helps a lot but you can manage without. One thing that is critical though is that you either have HW timers or that your architecture can produce repeatable timings when given the same set of instructions (unlike complex platforms like computers, where that timing would break as soon as the CPU gets a little too busy)
From there it is just writing functions and abstract your way upwards to a level where you can simply receive and send data like you are used to on Arduino.
It is a lot of work, though. But it is not outside the scope of a beginner with a scope (see what i did there? 🙂)
Watchdog timers are brilliant when used properly - deserving of a video of their own.
Basically, inside your loops you reset the timer. If your program crashes, it won't reset the timer and the watchdog circuit will reset the whole device. Absolutely fantastic for circuits that aren't easily accessible in particular.
Thanks for the feedback. Nicely summarized :-)
Yeah, I was watching this video thinking how not fully explaining the watchdog timer can lead lots of people down the road of bad coding practices. I have no problems with disabling it for such simple code, but if you have a project that does anything more advanced (like wireless communication or has a display), you definitely should consider learning how to properly use it. Watchdog timers are great for error handling.
Nice video in general, though!
How this timer is different than any other? It's seems just like a timer
thanks.
Another hole in the rabbithole of microcontroller.
@@realdragon Because watchdog timers run independently of the ALU. Your ALU can deadlock, but the watchdog can still keep counting down and reset your ALU
I2C master is trivially simple to bit-bash, no need for a hardware peripheral
That's what I was thinking!
Yep, I thought he was going to do that
The premise of the video is a bit off. If you are only making 14 boards, then the 2€ difference in price for the MCU doesn't justify the cost of buying a new programmer and spending a week worth of extra engineering time. On the other hand, if you are making thousands of these boards, then something like missing hardware support for an I2C master interface isn't going to stop you from buying the less expensive controller. That's a very easy fix in software, and you can find countless reference implementations online going back at least 30 years.
Of course, if the goal is to make an entertaining and educational video, the incentives look very different. The cost for a new programmer is negligible, if you get a successful video out of it. And for me as a viewer, this is certainly more entertaining than yet another video showing how to program an Arduino.
If you are going to do a 'proper' job of bitbanging the master, it's not so trivial. You have to deal with corner cases such as when the SCLK pin is an input (from master perspective). For only 1 device, if it's well-behaved -- then yes, the code for master can be simpler. But I2C edge cases are a pain. I *hate* I2C when I have a better option (e.g. SPI, and if you are pin limited, use, say, 74LV8153 which can be driven by a spare uart TX pin, bitbanged, and has output OC or push-pull, separate Vcc for the 8 output pins, and can drive 40 ma --- one pin from the uC neeced to get 8 out! With a simple SPI setup, you have the 'selects' you need with the expander. SPI -- always SPI.
Agreed. A slave is a bit more tricky but a master is easy.
I feel like a little RISCV chip makes a lot of sense here, like the CH32V003. It’s even cheaper than your $0.20 part and can work as an I2C controller.
I can put it on my to do list for next time :-)
Upvote for the CH32V003. The SOP-8 version can be obtained for about 10 eurocents and the TSSOP-20 for about 20 eurocents. It has a functioning Arduino core that does the basics but needs some further development to support its peripherals. When using the Arduino IDE v2.x it even supports regular debugging (i.e. stepping through code, watching variables, etc),
Yeah another vote for the WCH CH32V003. I use them for everything and the programming is easy. Either Mounriver Studio or CH32V003FUN.
and ch32x035, which is really not so much expensive, compared to ch32v003, but have usb and PD controller, and lot of extra features
have a few ch3v003 in breakout boards sat in my bench right now trying to figure out to use them for
CH32V003F4P6 - $0.21 per piece
48 MHz, 16k flash, 2k RAM, 18 GPIO, SPI, i2c, USART...etc.
You are welcome!
If you need less hardware and want to have an even smaller form factor, then CH32V003J4M6 comes in a SOP-8 package. It beats ATTiny85 in specs.
If you still need all the pins but also want it smaller, it also comes in a QFN-20 package, 3mm square.
Nice. I had been usint ATTiny85 but will now look at the CH32V003F4P6 family so see if I can substitute.
I think he would have to use the 84 to get the extra GPIO, ofcause depending on the project, though the AT are usually a few bucks for a SOC, but still pretty cheap in small batches, depending if you want to pay wages or chips. But in 10x productions i would go for less time working vs higher price SOC, he spent 3 days on it and where i live that would cover about 500 pcs of ATTiny84
WCH has some good stuff, he should absolutely look into it
The flash usage is higher for 32-bit RISC-V compared to 8-bit Attiny, more than 2x. Other than that, it beats Attiny on price/performance.
I use the ATTiny85 MCUs which can be programmed using an Arduino and works great with the Arduino IDE. Once programmed in a DIY ZIF Arduino programming shield require no additional components. The V models run on 1.8V/300uA @ 1 MHz in low power mode with 0.1uA in standby and you can boost the clock to 10Mhz with 2.7V.
I only use Arduinos for prototyping and then design my production boards using an ATTiny instead. I keep a tube around they are super handy. They cost $13 per 100 or $1.30ish each. Not as cheap for mass production but the hassle for under 1000 units isn’t worth the time or effort of a custom MCU and IDE.
The ATtiny's have excellent Arduino cores available. For small projects that need a few more pins than the ATtiny85 I've enjoyed using the ATtiny44A and ATtiny84A, which are often somewhat cheaper than the '85. For really small things I find the ATtiny13A interesting, but the limited memory can also be a bit of a challenge.
$13/100 is $0.13 each, even cheaper.
Better use the new generation ATTiny. I used ATTiny1616 in a project. Programmable in Arduino IDE. Only 1 pin needed for programming.
@@JanKluiver - I've read they have better features indeed, but I still have some stock to empty first. As for new cheap tiny MCU's I'm looking into the CH32V003, which is cheaper, has more memory and even supports debugging.
There is a tomm of stm32f103 chip`s, which cost less then $1, sometimes $0.5. Or you can find chineese clone for even less price. And STM32 have a tonn of features, like USB or advanced timers. And they can be programmed through Arduino IDE or CubeIDE and there are a lot of examples.
NOT a pointless video at all! Ive been following the channel for a few years now and I always appreciate the ones like this! The ones where you put in the hard tedious work to show us something *new/not well known. Cheers from Texas!
I agree 100%. This is a great help! Can't wait to see similar videos featuring CH32V003 and ATTiny85.
The programming pin names OCDSDA and OCDCLK do hint at On Chip Debugging, the IDE even has a Debug menu. It might support breakpoints, much better than using Serial.print
Debugging is only possible for their "special" development boards. I was sadly not able to use it with their normal uC. But maybe I was also just too stupid.
@@greatscottlab Yes you need the HT66V rather than HT66F part to debug. You can get them from a Holtek rep, from Bestmodules or from dev boards and just hot air gun them off. They do it to reduce the cost of the production parts
@@pyromaniac303always an expert in the comments! Good on ya
yes it does have on chip debug
I came here to say the same. Weird the basic part does not have the debug functionality built-in ...@@pyromaniac303
I came across the Attiny85 recently after many years of projects with atmega328s and it certainly has made a difference for smaller projects for both cost and size.
Yeah, that was my first thought, too. For a project like this, why not just switch to an ATtiny? The CPU is substantially similar to that used on the ATmega Arduino boards, and I believe that there are even folks selling ATtiny boards that have added the appropriate tweaks to the Arduino ecosystem (IDE and libraries) to be able to use that to program and run the ATtiny.
@@Curt_Sampson you have development boards like the digistump which runs micronucleus bootloader, only problem is that if you use them in-circuit you want to disconnect some of the pins while uploading because they are used for the usb function too... :/
Also not sure if it has enough pins for what he is trying and probably the price is still too high: around 1.41 eur / piece for 25 pieces on mouser... is not that different from the arduino microcontroller he mentions in his video costs around 2dollar ~ 1.8 eur / piece for 20 pieces
Same thought here. We use the AtTiny85 for a number of small control projects.
Dont use Attiny85. Its such an old chip and is frankly crap compared to modern 2-series attiny chips.
Same. I’ve found few 8bit MCU projects I couldn’t substitute a tiny for. I’m more likely to go to a 32-bit MCU when I need more for the kinds of projects I do anyway.
in our microcontroller programming course we had to program like first few weeks in assembly language - it really made people appropriate how much higher level languages with proper libraries enable people to do with much less effort
You've confused me. You are trying to save 14 x €2 on your project but then purchase a €100 programmer 🤔
Yes
I wonder why he didn't use a Padauk microcontroller. It has an open source programmer.
Well, in fairness, the programmer can be used in other projects.
I did not know you can still buy people nowadays
@@turolretar wait, you don't?
You are truly an inspiration for me. You gave me the courage to start in electronics in my late 30's as a hobby and I really enjoy it. Thank you 😊
Great to see you're using my Instructables guide! To be honest I never thought anyone would read it 😂 I've been using Holtek for years mostly on commercial products and always found them great for the price. Keep up the great videos!
On another point, maybe you could bit-bash the I2C, but it will be a difficult task.
hey! do you need PCB supplier? i can help you.
If you have GPIOs and are using PWM through a timer, it's not too difficult to implement i2c master in SW, much less simple to implement slave which is probably why they have it on some versions.
Nice vid! Not sure why you didnt mention that you can implement a bit banged i2c master! No need to have it as a hardware module, specially at lower speeds
I am really not a software guy. What you see in the video was the max I could do. So I had not idea that you could bit bang i2c master. Sorry.
@@greatscottlab no worries! And the development + troubleshooting time is not free either 😅 unless you plan to make thousands of these, its probably cheaper overall to go with a slightly bigger micro with the features that you need
@@greatscottlab Long story short, you can practically bit bang anything as long as you can generate and/or read signals fast (often) enough. That essentially programs your general purpose processor core to do the specific application, which the usual hardware bus processor is meant to do. They can be functionally identical, although it does obviously pose some limitations in terms of speed, as well as efficiency on power and processing capacity.
If your module/sensor supports SPI or UART, they are much easier to bit-bang. Bit banging will be pretty much the same for any platform, give or take the I/O or timer specific functions which you've already explored!
bit banging I2C is so simple you'll regret not implementing it, especially when you have a oscilloscope and an arduino for testing your code.
You can clock I2C at any speed even with a CPU running at 32khz. No timing is required (a clock cycle can be 1hz and the next one 1Mhz in the same byte, it doesn't matter). Master or slave, with minimal error processing, would take about 10 lines of C code. Funny thing is master is much simpler to program than slave.
you can bang everything if there's a desire
I have always run with ESP-01 I bought for $0.5 a pop off aliexpress for cheap Arduino replacement but good to know there are even cheaper alternatives. Everything suggested in the comments is useful as well. It's good that you made this video.
CH32V003 would be a good fit - there is an 8 pin version, £0.18 at LCSC. very cheap programmer, 1 pin for programming.
I2C can use DI/DO pin with software coding to create one, please see the protocol of I2C, hardware I2C pins are not necessary.
for the Arduino generation this is something like rocket science, although even on “dinosaurs” like the 16F84 it worked without digging into assembler
@@VDLab1and it could be the 16f84 assembler runs directly on this chip, it seams like a good copy
For low end ICs that may take up a lot of instruction cycles, no?
Yep. Right on schedule: Exactly at 6:45 of a 13m30s video (50.0%) the 'Blink' is finally working.
I've said this for years: Getting 'Blink' (or 'Hello World') to work is typically the *halfway* point of any small project in any new µC ecosystem. Not usually so precise.
That's why Arduino, which includes 'Blink' from the start, has such an easy learning curve.
Everyone should understand this point; it's important for planning and scheduling.
What? This is a video. The pacing of a video has nothing to do with the pacing of the learning process and everything to do with the creator's directorial intent. I also think that the Arduino Blink sketch is VERY simple and mostly is an intro to digitalwrite. Sure, there is timing involved, but I'd hardly call it an intro to scheduling since there is only one thing happening.
Unless your blink is done in non-blocking way, using timers and proper interrupts it's nowhere near the 50%.
@@MarioPL989 Except notice this: Our channel host spent "3 days" (he mentioned it) in this new-to-him ecosystem, just to get a few 'simple' routines up and running. I expect that another several days would be more than sufficient for what you describe. Keep in mind that primary point, and it's not an argument about "50%" versus 20% or anything else. It's that it can be time well spent in a new ecosystem getting as far as ''Blink'. If you're managing coders, direct them (firmly) to go get 'Blink' (or 'Helllo World') running first. They might not be back for several days, no matter how smart they think they are. It's a valid point and ignored at your peril.
@@MarioPL989 You may not understand the purpose of a blink program. It's not about precision or accuracy. It's about taking a chip you've never used before, and getting code into it, and having that code do something you can easily verify is working.
Absolutely. Blink or Hello is the absolute hardest thing to get working. Or the equivalent for any other hardware. I just spent 3 days getting a SPI LCD panel to show anything other than a solid white screen. And then I spent another couple of hours the next day getting eight other (different models) LCDs hello worlding me. It also took me about 2 days to get my first Blink going on one of the new AVR 0 series chips, using the new UPDI interface. But that's because there was a lot of almost-right information out there on RUclips.
8 cent : PY32F002/PY32F003 from PUYA for microcontrollers with an ARM Cortex M0+ core clocked at 24/32MHz.
PY32F002 20kB FLASH, 3kB RAM, SPI, USART, I2C, ADC, timer... nothing to complain about.
PY32F003 additionally DMA and a few more timers, there is also an additional memory selection.
It is an SWD interface that does not require a special exotic programmer.
Power supply 1.7V...5.5V, TSSOP, to small QFNs or DFNs.
agreed, puya is amazing value and doesn't require a 100€ programmer... swd is enough.
The py32f002 actually has the full py32f030 stuff, including memory and peripherals
Came here to suggest a Puya. Glad to see I wasn't the only one to think about that.
Actually this video demonstrates nicely why Arduino was such a game changer. The time for learning and debugging will never justify the price savings in an hobbyist environment.
Also, 100$ for a programmer? No, thank you very much
This type of thing is NEVER a waste! And, instead of three days, or hours for other issues, you've well detailed the process, saving the rest of us all that time you spent on it! (For some of us, it convinces us not to bother, or visualize the system a bit differently, maybe multiplexing or another solution depending on the need and context.) Watching your process alone taught me some general things, plus, you gave an update on JLCPCB offering more colors soon, so, yeah: another GREAT video!!!
The MCU of air001 produced by a Chinese company named hezhou is only sold for $0.1, supporting Arduino, with the following performance:
- Adopts the MO+ core of ARM 32-bit, and the main frequency can reach 48MHz;
- 4K RAM + 32K Flash;
- Ultra-wide power supply range of 1.7~5.5V, which can be powered directly by USB or battery;
- Built-in configurable RC oscillators of 4/8/16/22.12/24MHz, which can run at 48MHz without external crystals;
- A 12-bit ADC, supporting 9 input channels;
- 9 timers, 2 USARTs, 2 SPIs, 1 I12C, 2 comparators, very rich peripherals;
- 3-channel DMA, efficient data processing;
- Standby power consumption as low as 2μA.
Looks interesting, but it doesn't look like there is English documentation
Go for the enhanced family of PIC, the newest versions feature many useful peripherals, larger program memories and the IDE supports a GUI for setting up configurations instead of manipulating registers!
I never advise my students to use the delay() statement, given that it kills the program for the time they've set and it's a waste of resources. On Arduino it is preferable to use the "millis()" function and for the HT66F002 it is easy to implement an interrupt handler and build a similar "millis()" function for the HT66F002. Especially in robotics we should avoid using "delay()" instructions.
CH32V003 8 pin arduino compatible, 20 cents or cheaper, seems like a better alternative?
16 and 20 pin versions are around the same price too.
Sounds like fun. I put it on my to do list :-)
@@greatscottlabit is a RISC-V MCU from WCH, but has a proprietary programming port too.
There's also a company called puya producing the py32 line of microcontroller
That was my first thought too, the programmer and dev board are also much cheaper (about $10 for the combo).
For 110 € you can buy a lot of Atmega 328P microcontrollers. I like your videos!
Haha true :-)
35 of them in (SP)DIP.
@@greatscottlab would it not be possible to use something like a raspberry pi pico as a programmer using software ? (offcourse there will need to be decent documentation about the programming protocol and probably allot of time)
@@ChristopheVerdonck Something I've noticed is that many microcontroller makers don't document the programming process. They just say, "use our programmer and our free software". I was very unhappy when I decided to use one of the newer-generation AVR 0 chips, only to discover that 1) they don't program like the older AVRs, and 2) they did not specify how programming was done. Fortunately there are enough hackers out there that it has been reverse engineered well enough that I was able to get it working, but to me it's inexcusable that they would sell me chips and then require me to use their software. If you could get the programming specs for the Holtek chips, it's likely it would be in Chinese and would not translate well.
I suspect that the reason Scott bit the bullet and bought the programmer was that he intends to make at least a limited production run, and the 110 € expense was justifiable. Last time I priced ATmega328P, 110 € would only have bought about thirty of them.
@@ChristopheVerdonck everything is possible if your time has no worth
Ben Eater has an EXCELLENT series about building a PC from scratch, including the evolution from code bytes to assembly instructions, all the way up to C code which is a great complement to this info.
This little microcontroller is quite awesome for the price. Thanks for the video!
You're welcome :-)
Yeah....But the programmer costs about 60 bucks.....Hardly "cheaper" than using Arduino's.....
@@muppetpaster That's true, but of course, if you use them a lot, it will eventually get cheaper than using arduinos.
While you spent some time learning the syntax to code these chips, the good news is you can create your own reusable wrapper libraries that are compatible with Arduino code and make future projects easier and faster to build.
Arduino was originally based on Atmel microcontrollers, which have had really nice opensource tools for a long time. You can easily build your own programmer for them as well. You can still buy these chips independently and use them in your projects.
Fun project and demonstration of the power of more generic microcontrollers. Thanks for sharing!
Thank you so much for videos like this, Ive built so many projects with my school counselor and saved my school a lot of money this way.
Great to hear!
I did the halfway version of this project.. I bought an Arduino trinket which is powered by an 8pin dip attiny85 processor and programmed it using the Arduino environment, I then bought a USB Tiny programmer for ~$6 and some bare ATTiny85 chips at $1 to prototype my project. My programming was all done in the Arduino software for the trinket, and with code from the ATTiny Datasheet. but for my final pieces I bought boards fully populated by PCBway, and used an SMD chip clip to finally program the ATTiny chips on the boards.
Personally, I'm a big fan of the CH32V003 (it's 32 bit, RISC-V, way more capable and even cheaper).
I believe it even has pretty good Arduino support as of right now.
I commend you for making this video, especially for exploring an unfamiliar MCU. There are so many makers who are reluctant to go beyond the Arduino and Arduino "IDE" - I think your explorations here will give some the added push to go out and venture beyond the ATmega328 + bootloader + Arduino "IDE" environment. The Arduino ecosystem has injected a lot of interest in electronics, but the community needs makers who aren't afraid of datasheets and getting their hands dirty with new hardware and software.
At some point this make you love Audrino more. This remind me of my project of adding midi to a vintage 3 manual and full peddle Rogers organ with single ground bus and need to find a cost effective way to expand ardrino to have hundreds of digits in gpio to generate serial midi signal for virtual organ software.
I go back and forth on this. My first Atmel AVR project I did bare-metal, using the gcc-avr tools and buying an Arduino Nano just to use as a programmer, because I really didn't like the Arduino way of doing things, hiding all kinds of stuff from the user. And I would have been in serious trouble had I not found an example project on Adafruit that included a Makefile and a header file for pin definitions. With that, I had no use for the Arduino IDE, or for that matter, any other IDE.
BUT, the second time I used an AVR was to modify the code on a hobby radio called the ATS-20, which used an Arduino Nano to control the radio-on-a-chip and an OLED display, so I was very thankful that the developer of this radio released the code as an Arduino sketch, since this made it easy to understand the interface to the I2C-connected display. So it's love/hate for me, and now I fully understand that if I want to make a microcontroller-based project for others to build on, this is the way to make that easy.
You are thinking outside of the Box, and IT IS INCREDIBLE!
Excelent video Senior Scott!!!
This just makes me appreciate the rp2040 even more. They work with all standard stuff and what they deliver for below 1$ is just absolutely crazy.
for $1 per chip i think the rp2040 a a very powerful controller (so much has been done with already)
But it requires external flash and a lot of passives and a crystal, and is not easy to manually solder / build your project without a better tooling - they have a place, sure, but they are too complex to implement in many use cases
Very nice! I'm so glad you documented this process! Learning that the process ultimately did not achieve what was hoped makes is just as valuable as learning a process that does achieve this.
A great alternative could be the attiny series (not the 85 but their newer attiny chips). They are available in 8 to 24 pin packages, with 2 to 16kB memory and come with SPI, I2C, UART, multiple timers with either 16Bit or 8 Bit pwm, and adc and much more. Im pretty sure you can also programm them with the arduino ide and an arduino nano if you dont want to fork over 160€ for microchips own programmer.
Yep. ATtiny comes next. Don't worry :-)
Hello GS, I started watching your videos 10 years ago while I was in Highschool (Electronics Major) today I came across again with your videos and I really miss your Led backlight leds intro 😢 I am glad you are still this active.
Even if I play the old intro with no sound I still have that sound in my head. Today I am 28, and feel old because I saw your first videos and noticed they were uploaded few years back 😅 (I am sure it was only some months back but not this long. I always have admired your work 👏🏼👏🏼👏🏼
You should be able to use the programmer to debug as well, just like an Arduino. Usually there are functions that allow you to write to the serial bus, which should even show up in your Arduino IDE if you pick the right port.
after using cortex m0 stm32 clones that you can debug with breakpoint it is so good im not going back to stone age using serial lol
@@lifeai1889 I know what you mean. It's incredible to have reliable step debugging/breakpoints and access to the stack. It ruins any platform that doesn't support them. Some bugs just can't be fixed without it!
I've used both debuggers and "print" on many, many projects, and have found the debuggers had a much higher learning curve. I can get a lot of debugging done just by sending a single character to a serial port or even blink codes to an LED.
Haven't understand almost anything (I don't have any engeneering background whatsoever), yet I always watch your videos and feel happy new ones show up in my feed... I kept wondering why. And it hit me a moment ago - you seem to me to be very precise and very honest, balanced in your opinions. I find your materials well thought thru, well prepared and deep into the topic. All of theese factors lead me to one conclusion - it seems I TRUST YOU, and that's the main reason for me - a complete amateur in yoir field - to watch your stuff and keep coming back. You have build a trust in me by keeping up to noble standards in the field of your craft and - what is also important - in the way of comunication across that field.
Therefore I wanted to thank you for sharing your passion, your way of thought, your skills in a way which not only does not DISCOURAGE noobs, but rather INVITE them into the topics you present.
And this habit of yours - to use pen and paper... as a motion graphics solution :) - this constantly blow my mind as a remedy so simple yet still so effective in our modern overstimulating times! (plus, I find it part of your "signature", your style, identity).
Overall - Kudos and big thanks!❤ Greetings from Poland.
You can emulate I2C functions in software. Greetings from Croatia.
Yeah, depending on how much communication you actually need, it's definitely possible to bit-bang the i2c commands. The limitation will be the memory though, it'll take a fair bit of space to manually code in the timing
@@NewtoRah Only very few I2C Slave devices have actual lower bound timing requirement. So by dropping the speed low enough you can just ignore the timing all together using I2C. That's why implicitly, all MCUs with atleast one Input/Output pin support I2C Master-Mode. The Code isn't even complicated if you don't care for the MCU being blocked during this time.
The Adafruit OLED Library actually has that code in it. It's ~15 lines.
@@NewtoRah This HT66F0176 has 2Kx16 of Flash and 128x8 RAM. So yes, I agree that memory is a limitation, but it's possible. One thing he should take care of is timer interrupts, which can mess up communication timing.
It's nice that there are many
Embedded hardware engineer here.
"w95 interface" is mostly an industry standard. It wont lag and will run on any crappy pc anyone could have.
For an i2c - you can always make soft-i2c through bit-banging. Thats always worth the time spend, because it allows our clients to pay us once for making it possible, than to spend lots(+20-40%) of money on every device they'll need.
It's not exactly "standard", it's just Keil and IAR do not want to invest in updating their ancient IDEs look-and-feel because it's a small market, much smaller than, say, web dev. General purpose Eclipse or VSCode are modern enough.
I love that you covered the topic and shared it regardless of it not being what you can use for your project. We were able to see the process of learning which I and probably others also learned from.
Nice story.....BUT......The programmer cost you about 60 euro/dollar....How is this cheaper then, if you need to make 14/15???
and having the opportunity to make a interesting video about it give him more than the cost of the programer. heis a smart boy.
You know you can use programmer for several projects and don't buy it every time?
Well… not if you are programmer yourself 😂
My go-to controller series these days is the STM32G030 series. There is a 20 pin version from about 0.5$ and it has all the goodies that its bigger package brothers have. I use it with ST's IDE which certainly has a steep learning curve after Arduino but the raw amount of hardware features is worth it for me. The only downside is that division and floating point math are basically non existent on the controller but it's easy to get by them. E.g. I can do integer divide by power of 2 by right shifting, if I don't need to be super precise.
0:16 Casually flexes £5000 oscilloscope
I feel like something from ST probably would fit the bill pretty well they have some really low cost small boards and the HAL and arduino compatibility make it easy to start things up
Great video! It is important to show failures sometimes to highlight the thinking and work involved with solving novel problems.
I also liked it because I came across the same family of controllers while adding wireless control to a toilet seat warmer recently, so I could turn it on as soon as someone walked toward the bathroom.
Was about to comment about the ATTiny Microcontroller
It may not be as cheap as the MC's in the video, but it has nice interface, easy programming and lots of tutorials, so they can get the job done
Nice video as always
Bitbanging I²C isn't that hard. I suggest you give it another shot by implementing it yourself.
Nice to see a much less clickbaity title! Nice vid.
BTW the DeArrow title for this is 'Trying out the Holyek HT66F002 Microcontroller'. I reckon something in between would be ideal so people researching the chip can find it and those looking for alternatives can too. But it's not financially viable to title for maximum viewer usefulness I guess. Still a big improvement over the usual thanks
It is easy to implement I²C Master in Software. Maybe a little bit slower and consuming more CPU time. But not a problem like I²C Slave.
Does it not fit into the limited memory?
Exactly my thought too. I2C is not hard at all to implement as master. Sometimes even easier than trying to interface the hardware peripheral if just wanting to hack together and reading out a simple value, without bothering with DMA and such
Ich liebe dieses Deutscher versucht Englisch zu sprechen, die Betonungen sind Gold...
5:16 How German do you want to be? Scott: Blurs out the path of the code ;)
The only way I know about Holtek was when I took apart a laminator machine.
I was planning on taking it apart and reprogramming it to have a "slow" mode for thermal transfer toner of PCB images.
Unfortuantely there wasn't much to dump the firmware or to re-program it, and within months Holtek locked down their documentation archive. I also needed to reverse how the heater was modulated, temperature was measured, and how the AC motor was being controlled.
It was far easier for me to just run the PCB through the laminator 20 times than to reprogram the machine.
110 Euro isn't that bad... I'd think that their IDE being limited to Windows is more of the issue... I wonder if WINE (et al) would be able to utilize the USB device properly for programming in Linux.
Microcontrollers are now called "Arduino Alternatives"? *sigh*
Arduino encompasses the atmega chip which... Is the core of it and is a microprocessor... So yes it can be considered an alternative. Or simply, it's "another possibility"
Let me fix. Microcontroller alternatives to a microcontroller. In this case an alternative to an Arduino (Microcontroller).
For the purposes of making beginner EE available to a wider audience, yes.
Arduinio is not a microcontroller. It’s a platform that can run on atmega among others (stm32 for instance).
I mean they are. Merriam-Webster dictionary definition 2 of alternative "different from the usual or conventional" technically a toaster can be an alternative to an Arduino.
FYI
Depending on the storage space that the microcontroller has, you can implement the I2C bus in software.
I have done this in the past on two occasions, and it works well.
looking foward to the ATTiny video
;-)
@@greatscottlab You propbably seen Andreas Spiess' Video about the new ATtinys. Is there a reason you seem to use the ATiny402 (13:09) and not the newer 412 or even newer ones from the TinyAVR 2 Familiy?
32BIT MCUS ARE THE FUTURE
I've been looking at the ATTiny 10 for a micro project that I have in mind but suspect that the 85's would be best to buy given the range of things I can try to make it do.
@@ragesmirk This is true, but I will miss 8-bit MCUs.
I like that the software that handles uploading is called “HOPE”
I'm pretty sure you can do I2C in software.
You can. But I am stupid.
I like the new style you're putting on your videos, more homely feeling, and good to see your face Great Scott!
And I don't even have to watch the video. I already know it's gonna be 5star😃
Well, I do not want to spoil the verdict of the video. But let's just say, it was not what I expected ;-)
Learning is never pointless. Excellent video. It gives us electronics plebs some courage to try other solutions.
I found the CH32V003 in another (better?) corner
In 3 days of such working I could have made a microcontroller from scratch 😂, but thank you for sharing valuable information with us
Try STM8 - also costs nothing and is supported by arduino ide
I can put it on my to do list :-)
It seems my comment got nuked as it contained a link to my guide setting up a arduino nano as a programmer for the Attiny412.. but yeah it would have been perfect for your application as it should support all of your features, keep it up, love these videos!
Did you look at chips like PY32F002A ?
Did you ever test it? Should have a SWD like all ARM cpus. Not sure if it is correctly licensed and sounds a lot like a STM32 copy :-)
I can have a look at them in the future ;-)
Do love your style of presenting and writing the points of interest and then marking success and failure - paper and pen really is useful.
Couldn't you have implemented i2c by yourself?
Isn't only data and clock
Is bitluni better than you?
Regarding programming? Yes, definitely. He is a programmer. I am an electrical power engineer.
@@greatscottlab Sorry for the teasing, I really like your content anyway
wow good job. $0.20 mc + $110 programmer. Much cheaper than $2.
What's the problem with implementing i2c in software?! At least, i2c master mode is totally straightforward and it takes only about 50 lines or so... Just stop being obsessed with that libraries and h/w implementations.
Always interesting to see the process of learning about microcontrollers. An avid RC Plane enthusiast, I am always interested in learning possible ways to bring my projects to the next level. Thanks.
Arduino costs $2? Really?
on AliExpress
Only the bare Microcontroller on the Arduino ;-)
The ATmega328P itself, is on the more expensive side.
As someone whose interest in microcontrollers predates the Arduino, I'm always worried about how that "easy mode" could affect the collective skill level of this field. I'm glad you're shining some light on other options.
Also worth noting, it is entirely possible to write your own I2C code. Not _quite _ as trivial as SPI, but still well within reach of a hobbyist.
Very cool video. i may not need one of these in a project personally but found it very interesting to know there are alternatives that cost almost nothing if you willing to buy the not so cheap programmer.
I'm making a peoduct that im currently using a nano for that ivolves WS2812B LEDs. Would something like this be able to control them?
I heavily appreciate time you put into trial and error in getting it to work.
This is reminiscent of how I learned Arduino, manually setting all of the control register values because I heard that the IDE's helper functions were bloated. I ended up doing the same for learning ARM M microcontrollers too
idk a thing about programming or whatever this is, but I still watched the whole video 😭this looks so fun, I might look more into it
As you are a complete beginner then I suggest to google "Arduino kit" and buy it. You'll get Arduino board (chip), some cables, some LEDs, some sensors, etc. Then google "Arduino beginner tutorial" to get the most simplest things up and working.
What he did in the video is more advanced.
I agree, 8 bit these days is toast. I still use the TI MSP430 16-bit stuff because it's cheap, but the CH32V003 is cheaper still and you can use the Arduino dev environment, and it already has the dreaded I2C controller. I think the days of 8-bit and 16-bit are over; the 'war' at the low end is now between cheap Cortex M0+ devices and low-cost RISC-V chips. 32 bits forever!
I appreciate this look into developing for a more "product component" microcontroller, and seeing what its like beyond the garden of Arduino-compatible boards! Especially since, just this week, I was tempted by the allure of super-cheap micros. Seeing the hassle to save a few bucks, and not producing anything at scale, Ill stick with the ATtiny for my super const-sensitive applications, and bite the bullet on the rest.
Nice! I believe you could've gotten i2c to work by using a bitbang library, esentially just doing what the i2c hardware would do in software using GPIO. Since your MCU is acting as the master in this situation, this can be as slow and intermitten as you need it to be to allow it to run its other functions. There's not really any strict timing requirements here.
Good point on the timing requirements!
I think the video is quite inspiring. In schools, education is generally provided with expensive microcontrollers. I think cheap microcontroller should be used for simple applications.
I have been using Holtek MCU for decades. It was the most popular MCU for DIY and electronic enthusiasts before Arduino was launched. The downside of Holtek MCU is the price of their emulator. Holtek MCU is ideal for project that involve mass production, but not for end user who only need one or two MCU for their circuit design. And for the e-link emulator, a bare board version will only cost around USD20 if you can find it in Taobao. Hope this info will help for those who would like to know more about this MCU.
Is it possible to program them without spending $100 on a programmer? Looks like a deal-breaker for DIYers.
If you don't feel like dealing with Chinese micros, Microchip makes a PIC16F15213 (8 pin) which is well under $1 (the SOIC pkg is under 50c qty 1) and covers your list. There are also pin upgrades to increase pin count, memory, etc in the same and other families. Edit: The ATTiny402 is another good choice (and also made by Microchip).
Doing I²C in software is very straightforward, especially for master. You probably have some serial peripheral that can do the job or most of it as well.
Nice video. That's how life used to be (and is) with proprietary controllers and near-zero libraries. Lawyering with the datasheet and register descriptions, debugging with blinking LEDs and oscilloscopes and maybe a display or UART once you got one running. First time I saw the led blink, I was thinking "running or bootloop?" :-D
Omg, this came out perfectly at the time i wanted. Im trying to figure out how to make a kpop lightstick but an arduino takes too much space for it and i need multiple microcontrollers for controlling stuff. Thank u
you could also try other cheap controllers that have arduino support e.g. attiny.
I really love this video. I have been looking for some videos on how to make cheap market solutions for arduinos without just selling things with expensive dev boards.
Try an attiny402.
Costs €0.38 here, should be available in germany but price may vary.
Upto 20mhz@5v
2x uart ports
1x i2c
1x spi
2x interrupts
4x pwms
5x gpio(all can do analog or digital readings)
Can use at once :
1 uart + spi
1uart + i2c
2 uart ports
5 gpios
Edit:added reasons.
Nice video. I started using ATtiny 412 and 1614 a couple of weeks ago. Lots of searching to get the board libraries installed. But with that working, the chip(s) are easy to program using an Arduino Nano as the UPDI programmer. Use an FT232 board for serial.Print commands. Thanks again for all your videos.
I looked at the Nano-based UPDI programmers last summer when I did my first tiny412 project, but in the end I used a USB/serial interface and avrdude. The "programmer" costs about $3 that way, and you just need a 4kohm resistor tying TXD and RXD together to connect to the programming/reset pin.
This is the kind of video I like to see here, along with the aliexpress hidden gems or garbages for my consumer instinct.
6:12 the correct term is actually Download, as it is to a "lower lovel device". You can search the web and discover multible poeple have asked on the Arduino Forums for a reason to why their termonoligy is revers, and unly find the answer "IDK". In PLC's a download always referes to a data being downloaded to the PLC and an Upload being when data is uploaded from the PLC. SO in conclusion Download is the correct term, even though in arduino it is called Upload.
You can still do this project with this micro, if you use operations with registers and disconnect the output by hardware you can achieve high impedance and write a library to communicate this micro through I2C. I did it with a pic 12f615.
Cool integrated circuits, very often found in cheap devices, but in the OTP version. I checked the price of the debugger and definitely not!
But you can add software I2C - "Bit Bang" and it's very common. I've used it with 8051 for communicating with 24CXX I2C EEPROMs and with ATtiny85 for driving SSD1306 I2C OLED module.