Which 10 Cent Microcontroller is Right for You? Comparing the CH32V003 to the PY32F002A.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
a little while back I made a video about this the 10-cent Pua py 32 microcontroller in that video I mentioned that the py 32 wasn't the only Ultra cheap flash-based microcontroller but there's also the wch ch32 v003 which also comes in around 10 cents and it seems to be far more popular many of you left comments on that video discussing the merits of the ch32 and that got me wondering did I make the right choice when I bought 500 of the p32 for my latest project well there's really only one way to find out this is a development board for the ch32 v003 which is the cheapest of the ch32 V series and it's the most comparable to the p32 f002 a that I talked about previously I'm going to put this through its paces and determine which of these you should use if you only have 10 cents and you ignore the cost of passives and the circuit board and everything else you need to get started let's get into it I'm Zach and you're watching Zack of all [Music] trades I'm going to get started by discussing the biggest and probably most controversial difference between the py 32 and the ch32 the pro processor core specifically the differences between the risk 5 Core in the ch32 and the arm cortex m0 plus core in the p32 risk 5 which stands for reduced instruction set computer five is a free and open-source instruction set architecture for background an instruction set architecture defines how the processor should behave with respect to software by outlining the things like in instructions registers and memory handling binary code that is written for One processor should work on any processor that follows the exact same Isa now let's contrast this to the cortex m0 plus core the MZ plus is intellectual property from arm which is a for-profit company and it's more than just an Isa but it also includes things like Hardware models physical IP and stuff that gets you much closer to actually building the ship on Silicon you also are going to get software tools and simulation tools now when you buy a cortex part a fraction of what you spend goes back to arm in royalties okay I am assuming here that whoever makes the chip has properly licensed from arm there have been instances where foreign companies have stolen the IP while I can't be 100% sure that puya is licensing the devices correctly they do show up in Keel microvision which is a IDE that's released by arm it seems a little unlikely to me that arm would knowingly add microcontrollers to their software if they weren't properly licensing them so then what do the makers of risk 5 chips do for their Hardware Designs well most commonly it would seem that they develop their own proprietary implementations which is what wch has done here with the ch32 and their shinky core hope I'm pronouncing that right there are other open- source implementations including verilog descriptions and that's pretty cool in all honesty though I don't know that this matters for the majority of hobbyists we're not likely to be making our own silicon although that day is approaching you can Implement these verilog descriptions on fpgas but that's probably more of a learning exercise than something You' regularly do another point I'd like to make is that microcontrollers are far more than just their processor cores they also have memory peripherals power system systems clocks and so on and those can actually be more important than the core itself the arm versus risk 5 debate doesn't actually tell us anything about these peripherals and the majority of time these aren't going to be open the differences in peripherals also means that programming various risk five or arm parts even with the same core can be very difficult as there's not really any standardization of these finally I don't believe the underlying C core makes all that big of a difference from a programming perspective since most of us are probably writing our code in C or a higher level language if you want to multiply two numbers you're probably not worrying about loading values into registers finding the right instructions you're just going to type Cals a * B semicolon and move on with your life the compiler handles the rest and it's going to abstract away many of the differences in the underlying Hardware now don't get me wrong I'm a huge fan of Open Source I definitely prefer not to pay corporations for software that hasn't really changed functionality in decades looking at you Microsoft Office and I refuse subscription based software much of the software I use on a daily basis is open source and I contribute when I can I also believe risk 5 is an important development that will have a really positive impact on the industry but from what I've seen so far I don't believe that risk 5 microc controllers have a really substantial Edge over arm devices at least not yet for one the ch32 is different enough that you'll need different software and different programmers and that adds to the cost and it can have a fairly steep learning curve and despite not requiring royalties risk five parts don't seem cheaper at least not for the parts I'm comparing here but I'll get to cost in a second what I do think is awesome about risk 5 and one of the reasons I'm really excited about it is that it will allow companies researchers and even hobbyists to freely Implement processors where they probably wouldn't have otherwise bothered I foresee companies making more ic's smart as adding a processing core to a ADC an IMU or a radio whatever that'll no longer require that company to involve their lawyers and write contracts and pay fees just to license that Core Design the benefits for Academia will also be huge not just research purposes but also because students now have an actual open-source Isa to study when they're learning how processors operate I think there are also benefits on the 64-bit processor side for application processors as well as personal Computing but I'm not as familiar with that and it's outside the scope of this discussion that's all I'm going to say right now about core differences but at the end I'll bring this full circle and give you my thoughts when choosing a microcontroller or any other component for that matter cost is only one part of the broad picture ease of use availability support tool chains total bomb cost ease of assembly part Lifetime and so on are all things you need to consider so when might you actually want to use one of these 10-cent microcontrollers versus one of the more expensive options first I personally believe that these chips only make sense if you're using them on your own circuit boards if you're looking to just buy a development board for a one-off project then I couldn't recommend either of these for reference I got this development board as part of a larger package on Amazon it came with this a ch32 v203 development board a wch link e programmer and five each of the chips from both of these boards and this was all $27 I put a link down in the description if you're interested and I can attest that these work fine at least to the extent I've tested them now while I wouldn't say this is a terrible deal and there are certainly cheaper options especially if you go from overseas vendors there are lots of options from other more reputable companies in this price range and they're certainly easier to use and they're going to have more features the stm32 blue pill or the new cleos the esp32s any of the arduinos the Raspberry Pi Pico I think that these and really any of the popular development boards are going to be better choices so one use case for these 10-cent Parts could be to save money when you're building a product you're going to sell although honestly I'm not sure I'd feel that comfortable doing that either I would worry that one of these manufacturers might suddenly stop making these which would invalidate much of the non-recurring engineering You' done also if I opened up some product I'd bought especially something I expected to have a long life and I saw one of these Ultra sheep chips in there I'd be a little put off personally if I were making something I planned on selling I'd spend a little more money from a part from St or Texas Instruments or Renu one of the parts I could just buy from digy and be reasonably assured it'd be around for the next decade now where I do think these microcontrollers are really useful is for projects where you need a lot of microcontrollers that are doing pretty basic tasks this is what I'm doing with the p y32 in my tile backsplash project here I'm using the inter ADC on the py 32 to digitize a microphone signal and communicate the peak value back to a main processor I need about 250 of these so for a personal project I just really can't afford to use anything more expensive check out the video on that project if you haven't And subscribe so you can be sure to catch the rest of it these types of projects things like making an analog sensor into a smart one doing at the sensor processing or event detection heck even making your own personal Computing cluster these are the cases where these Ultra cheap microcontrollers shine so I've called these both 10-cent microcontrollers but how accurate is that for comparison I'm only looking at the lowest spec cheapest Parts which are the ch32 v003 and the py 32 f002 and these prices are as of mid 2024 on LCSC which I considered to be a reliable vendor you can buy the py 32 for between 13.2 C and 17.5 cents if you buy only 5 and 8 cents to a smidge over 11 cents if you buy 500 depending on the package the ch32 in comparison is on the order of 19 to 23.5 cents for five and 12 to 14 1.2 cents for 500 additionally as of right now you can't even order 500 of a single type of ch32 because there are only 415 sop 8s in stock and 100 qfm 20s for the py 32 on the other hand all five options are in stock and the scarcest one has over 4500 now I know that you can buy the ch32 on AliExpress from the official wch store in fact you can apparently get 50 of the8 pin ch32 v003 chips for a single dollar shipped which is absurd but that's a onetime deal and you don't have much control over quantity I am also personally far less comfortable ordering from AliExpress but you could feel differently about that so from a cost and availability perspective on bare chips I have to give the advantage to the py 32 if you're looking for development boards though then the exact opposite is true there is this board for the py 32 f003 on LCS CX right now it costs about $14.5 which is a bit high for what you're getting and I've noticed that the price fluctuates considerably there are a couple other options for the p32 but they have no reviews and probably no documentation the C32 though like I said I got this on Amazon delivered in two days with the spare chips it was a little pricey at $27 but very easy to order check out the description for the link there's also plenty of other cheaper options for the ch32 particularly from overseas just Googling ch32 v003 will turn up lots of options so for development boards I've got to give the edge to the ch32 taking a look at the data sheets you'll find that there's really no clear winner as the p32 f002 and the ch32 v003 trade blows in different areas now allegedly the py 32 f2a uses the same die as some of the higher end parts and you can unlock additional features if you know what you're doing but that's not guaranteed that might not always be true so for this comparison I'm sticking strictly to what is advertised to start the ch32 can run up to 48 MHz and it has a PLL that can make that frequency from the 24 MHz internal oscillator the py 32 though runs at half that 24 MHz it has no PLL the p32 does have the edge for Ram and Flash with 3 kilobytes of RAM and 20 kilobytes of flash whereas the ch32 has 2 kiloby of RAM and 16 kiloby of flash both parts have one Advanced timer and one basic timer but the p32 has an additional low power timer both have adcs however the py 32s is 12 bits and the CH 32s is only 10 if you're sampling that data really quickly though you don't want to load up the process then you're going to find the dma on the ch32 very useful but you don't get on the p32 the ch32 also has a built-in op amp which if you need it could reduce your build of materials in comparison with the p32 for connectivity they both have one uart one spy and one i2c but there's a caveat for the ch32 the Spy is only broken out on the 20 pin packages there's no spy on the 16 and eight pin options compare that to the py 32 where you get the option for all three regardless of package if you have an application in mind though you should probably check out the multiplexing on those really small packages as some of those functions overlap other than that these two parts are really similar they can both operate at 5 volts they both have comparable package options and number of IO and they have similar low power modes as you can probably see it is hard to declare one of these better than the other without knowing your exact application on one hand the ch32 is faster and has dma and that built-in op amp but the py 32 has more Flash and RAM and a higher resolution ADC the data sheets one thing but how did these chips actually perform in the real world and how easy are they to use for the py 32 go back and check out my previous video where I walked through setting up the IDE and then did two coding examples now the p32 has pretty much no information online and there really aren't any tutorials which is definitely a drawback so in the previous video I went into quite a bit of detail on how to use them there is much more information for the ch32 though so I'm not going to walk through this step by step like I did before what I am going to do is replicate the two test codes I did in the last video first I'm going to Blink an LED using a timer and interrupts and then secondly I'm going to read an analog voltage with the internal ADC and report it to computer over serial I'll then compare the experience on the ch32 with that of the p32 for ID I'm going to be using Mound River this is what is recommended by wch which is why I'm choosing it similar to what I did for the p32 there are other IDE options probably better options there's even support for the Arduino IDE so don't be too scared away by this mound river is Eclipse based so it's going to feel pretty familiar if you're coming from some something like the stm32 cube IDE as mentioned the boards I'm testing this with came from Amazon and included two development boards one for the ch32 v003 and one for the v203 as well as 10 bear chips and the wch link e which is this comically bulky USB programmer that you can't actually push the buttons on without removing the case there's also a GitHub repository I've linked that has lots of information on this ship and this board things like the schematics example code some how-to PDFs I recommend you poke through that before you get started when you open Mound River and go to create a project you basically just need to provide a name and select the chip you're using click okay and that's it all the start code and the how drivers are there and ready to use the start code sends the system clock rate and the chip ID over uart as well as has some uart Echo functionality without making any changes to the start code I compiled and flashed it just to verify that this at least worked I used the serial adapter built into the link e as well as MOA xterm on a PC all I had to do was connect 3.3 volts from the debugger to VCC on the board ground to ground s swdi to pd1 and RX to pd5 this would have worked great except my link e firmware was ever so slightly out of date so M River refused to use it and it forced me to update it which I tried to do itself halfway through the update process though the link e disconnected from my computer and didn't come back now those of you that deal with these things regularly know that this can be a bad situation a little searching though led me to the wch link utility which is available straight from WC's website this luckily recognized the link e and I was able to update it without much trouble back over in Mound River the program now flashed directly and the serial communication to my PC worked as it should I then got started modifying the code to Blink an LED with a timer this is pretty straightforward and honestly pretty similar to the p32 or any other arm part you configure the timer start it in the appropriate mode configure the LED GPO pin write an interrupt Handler where the pin is actually flipped and then you call the initialization functions from the main function and enter an infinite Loop interrupts will do the rest interestingly the ch32 development board doesn't actually connect the led to a pin unlike what you would usually see so you get to choose where it goes the downside though is that this does require a wire on the development board which might not be desirable for your final application I did have one issue and a couple of complaints the issue I ran into is in regards to attributes on the interrupt Handler function prototype I'm not going to go into great detail here as I wouldn't say that I fully understand it myself but the Crux is that if you create an interrupt Handler and the wch interrupt fast attribute is applied to the other interrupt handlers then you should go ahead and apply it to the one you create as well I didn't and my initial code ended up in the hard fault Handler luckily since this microcontroller is fairly widely used I actually found a discussion and a solution for this issue online line my complaints are in regards to the documentation the data sheet the reference manual there's a core manual and a bunch of other how-to guides they're really well written and they're written in English unlike what you get for the p32 but I could not find any documentation for the hardware drivers despite the fact that they're used by default in Mound River now to be fair poya also does not have documentation for the drivers on the p32 but those drivers are BAS basically just copied from STM 32s so st's 2000ish page Hal manual is directly applicable for the ch32 I basically didn't have any guidance other than the reference code and reading through the drivers in the IDE now I know roughly what I'm doing and the drivers behave pretty similarly to the arm devices they mostly just differ in syntax so I was able to stumble through this by just using the ide's autocomplete functionality and kind of just guessing what the function should be but still it would have been really nice to have a manual if anyone knows that one exists please let me know now this brings me to another minor complaint this is regarding the reference code the reference code provided on GitHub is quite complete it covers every peripheral but I found that it only covers more complicated use cases take the timers for instance there's an example code for dma for encoder counting for output compare one pulse modee Etc but there's not an example that just covers setting up a timer to generate an interrupt the ADC is another good example there is no code that just covers a single software start conversion which is probably what most beginners the ones who are reading the example code anyway are trying to do you can certainly piece together what you need from some of the more complicated examples but I found this a bit odd regardless I worked through this Blinky example reasonably quickly and I got the board to Blink its LED 500 milliseconds on 500 millisecs off without much trouble this was certainly faster than getting the py 32 running even when you take into account updating the link e on to the more complicated example reading a voltage with the ADC and sending it over serial to a computer setting up the uart here couldn't have been easier literally because it's already done for you in the start code there is a debug file included you can go through and check out the exact functionality but one thing it does is redirects print F to ur1 all you need to do is know the pins pd5 for TX and pd6 for RX hook them up to the link e appropriately and then print F just works compare this to the p32 where I still haven't gotten print F to redirect correctly I'm compiling messages and then sending them over to Art the manual way the other main thing that needs to be done here is configuring the ADC this took a little bit of playing around because of the aformentioned lack of documentation on the how drivers pretty simple stuff like should this field be zero indexed or one indexed and how do I do a single conversion since all the example codes or multiple or injected conversions overall though I would say that this example took me a similar amount of time to what it did on the p32 with my lack of familiarity with the drivers being offset by the fact that the uart was already set up so here's the circuit setup I've just run VCC to one side of a potentiometer ground to the other side and the center tap of the pot to pd3 which is ADC Channel 4 on this chip this makes an adjustable voltage divider and you can see here that as I rotate the pot the ADC values respond logically I'll be at only to 1023 as this is only a 10 bit ADC the ADC noise seems quite small only an LSB or so at 43 cycle sampling time and I ran this for many hours and I didn't observe any drift so now that I've had the chance to test out both the p32 and the ch32 including their functionality native software environment and ease of writing and flashing code which chip is the winner well I hate to reiterate what I've already said but it really does depend on what your final application is for this chip as they both have pros and cons and they could make break a particular project but if they both have the features you need then well I have to give the edge to the ch32 it comes down to four things first when you download mountain river and you select the ch32 V3 it pretty much just works there's no messing around with configuration no trying to load the right Hardware libraries really nothing other than needing to update the link e after that I literally hooked up the debug probe compil loaded the start code and that was it it just worked second and you might not personally care about this but risk 5 is kind of cool right now and by using the ch32 you're helping to support that movement third I think I have to give the hardware Edge to the ch32 it runs at twice the speed it has a dma controller and I feel like that's probably a little more useful than what the py 32 has has which is additional Flash and RAM the higher resolution ADC and an additional timer you could debate this point though so take that with a grain of salt and finally there's a lot of online help for the ch32 not necessarily directly from wch but in online discussion and even a lot of tutorials now the p32 is very very similar to the stm32 so stm's documentation even for stuff like the how drivers is very use use ful but there's essentially no online help specifically for the p32 that said I did find the lack of driver documentation on the ch32 to be quite frustrating so did I make the wrong choice when I bought these 500 p32 chips for my tile backsplash project I don't think so and it all comes down to availability remember when I said that for the ch32 v003 there were only 415 of one package and 100 of another package in stock well I wrote that a couple days ago and before filming this I went back and checked again now there is not a single ch32 v003 in stock at LCSC and that's the problem if you want 10 50 maybe even 100 CH 32s then sure you can probably order them on AliExpress you'll probably get what you need but if you need a whole spool of these even just 500 of them then you're out of look with the p32 though I've never had to worry about stock plus it's not like one of these existing negates the usefulness of the other one you can have and use both of them I think that they're both fantastically useful microcontrollers they're not all that different to program they're both an insane value and now that I've got an experience with both of them I'm going to keep them both in mind for future projects that's all I've got today in the next videos I'll be getting back to some of the projects so please like subscribe and check those out thanks for watching
Info
Channel: Zach of All Trades
Views: 33,096
Rating: undefined out of 5
Keywords: Ch32, CH32V003, PY32, Puya, WCH, PY32V002, Cheap microcontroller, cheapest microcontroller, linke
Id: Y-n7vXHAqm8
Channel Id: undefined
Length: 27min 33sec (1653 seconds)
Published: Sun Jun 09 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.