The Cheapest Microcontroller? Getting started with the 10 cent Puya PY32.

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 พ.ค. 2024
  • The Puya PY32 is an amazingly cheap 32-bit microcontroller with an ARM Cortex M0+ core. These parts can be had for under 10 cents each in modest quantities, making projects requiring large numbers of microcontrollers affordable for us DIYers.
    This video gives a brief introduction to the Puya PY32F0 series of microcontrollers, starting first with the benefits and drawbacks. I’ll then discuss the four options available and their respective features and cost. Next, I’ll go over the software and hardware tools needed to develop code and program these, including details on how to set up the software. Finally, I will show two demonstration codes to prove that these microcontrollers work as advertised and are relatively straightforward to use. First, I’ll do a classic blinking LED test using the onboard LED and one of the timer peripherals. The second example will use the internal analog to digital converter (ADC) to read an analog voltage and send the result out over the serial UART peripheral.
    Check out these previous videos where I’m putting the PY32 to use:
    Programming the PY32 for the tile backsplash project: • Programming the Smart ...
    Introduction to the smart LED tile backsplash project: • LEDs, Microcontrollers...
    Chapters:
    00:00 Introduction
    01:40 Why you might want a 10 cent microcontroller
    06:12 The PY32 options
    08:43 Getting started with uVision
    13:53 Blinking an LED with a timer example
    16:55 Reading an analog voltage and sending the result over UART example
    19:42 Conclusion
    The code used in this video can be found in this repository:
    github.com/AllTradesZach/PY32...
    The microcontrollers can be procured from LCSC here:
    www.lcsc.com/products/Microco...
    The development board:
    www.lcsc.com/products/Develop...
    Some of the tools I’m using in this video can be found here:
    ST Link V2 Clone: amzn.to/4arg6u1
    Official ST Link V3: amzn.to/4auZe5G
    Quality Breadboards: amzn.to/43wJw82
    As an Amazon Associate I earn from qualifying purchases.
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 87

  • @lohikarhu734
    @lohikarhu734 10 วันที่ผ่านมา +40

    I've built stuff, and designed IC's to use in 500 million volumes... Part of the cost calculation goes to a bunch of factors, not least of which are assembly cost, passive components needed, PCB area and technology, connectors, and, believe it or not, production test.
    So, for high volumes, if you need anything outside the MCU, like capacitors, crystal, resistors, transistors (driving actuators, indicators).
    In one device case, we were able to build in quite complete self test capability, which saved almost 1/2 the price of the device, in reduced production test ( tested not just the device, but most of its connected components), and we "designed-out" current setting resistors, I2C pull-up resistors, and provided enough drive on the device to handle 95% of use cases... Sorry to blather on, just wanted to bring out some of the "stuff" that needs to get put into the "system cost" consideration.
    But, still, the amount of logic, or mechanism, that can be programmed into 10¢ !

    • @lohikarhu734
      @lohikarhu734 10 วันที่ผ่านมา +5

      As much of a whiner as I can be, your video is very nicely done ... Good style, and good pacing... the one thing that I find, in many of this kind of video, that it would be nice to "zoom in" a bit on the screen images of the development setup.
      Sonst, prima.

    • @AllTradesZach
      @AllTradesZach  9 วันที่ผ่านมา +3

      Thanks for the suggestion! I'm definitely learning here, so any constructive feedback is welcome

    • @AllTradesZach
      @AllTradesZach  9 วันที่ผ่านมา +4

      I definitely see where you're coming from. I'm one of my earlier videos I discussed the engineering tradeoffs for the project, and had a lot of the same thoughts you're alluding to.
      My day job is in a high reliability, high quality field, so BOM cost isn't something we even worry about. In my earlier video though, i mention spending more on passive components than active components, which was absolutely true! Good quality caps and resistors add up!

    • @murraymadness4674
      @murraymadness4674 9 วันที่ผ่านมา +1

      Indeed, as a DIY'r the first thing I look at is how many external components do these chips need. I really like the attiny202 because it needs NONE, and I'm using it now with its sdi to interface to a 2.4ghz radio to do very simple stuff. I previously used the msp430 back when they were new, which still needed a couple caps, but really needed a crystal for consistent timing. Although today when you can have small quantity of boards assembled in china, they can put on those external parts, which cost pennies instead of assembling yourself which is very painful for tiny smd parts, which everything is now.
      I got the ch32v parts recently to test them, real cheap and has so much more than an attiny. I have a new project to switch on/off hundreds of leds, and the ws leds are not bright enough, so the easy way isn't possible.

    • @lohikarhu734
      @lohikarhu734 7 วันที่ผ่านมา

      Cool...as I said, overall very good video!

  • @RGormanJr
    @RGormanJr 17 วันที่ผ่านมา +35

    As an older GenXer, I laughed when you said that 10¢ could buy half a GIGAbyte of storage. I can honestly remember the days when computer scrappers would pay a few bucks per MEGAbyte for non-working hard drives. (Of course an actual working drive cost hundreds of dollars per MB)

    • @AllTradesZach
      @AllTradesZach  16 วันที่ผ่านมา +8

      You know, I almost left that one out, 'cause when I calculated that I realized just how cheap flash storage is.
      But then I remembered that each of these videos takes at least a quarter terabyte of storage, so I suppose it's all relative.

    • @musiqtee
      @musiqtee 10 วันที่ผ่านมา +4

      My studio boss got mad at me for the invoice of four MB of RAM for our Atari ST. The set of four chips cost a little over $450 in 1989 - More than the actual computer… 😅

    • @lohikarhu734
      @lohikarhu734 10 วันที่ผ่านมา +3

      In about 1980, one could buy a MASSIVE "Winchester" hard disk, even including the control board, for only about USD $2200... for..
      10 Megabytes!
      $220 per Megabyte !

    • @edwardfletcher7790
      @edwardfletcher7790 9 วันที่ผ่านมา +3

      ​​@@musiqteeyeah, that's 8x the standard RAM !! LOL
      I remember getting a 16mb Ram stick for my Amiga in the late 90's for US$150. I paid the same for a secondhand 200mb HD in the early 90's👍😁

    • @eightsprites
      @eightsprites 8 วันที่ผ่านมา +1

      Had a 50mb harddrive in my Amiga 2000. No idea what that costed. Much I bet. Thanks dad ❤.

  • @edwardfletcher7790
    @edwardfletcher7790 9 วันที่ผ่านมา +11

    Cortex M0 is a powerful little chip!

  • @cpk001
    @cpk001 15 วันที่ผ่านมา +7

    Looking forward to future videos

  • @user-lx9eg4yv5p
    @user-lx9eg4yv5p หลายเดือนก่อน +3

    YES!!! Thanks for the upload Zach! Still tuned & sub'd for the whole project! (and any others you may think of in the future!)

  • @larsu1212123
    @larsu1212123 หลายเดือนก่อน +6

    Hey, I've been waiting for the follow-up, ever since your video on the "Backdrop" panels. Keep up the great work!

    • @larsu1212123
      @larsu1212123 หลายเดือนก่อน

      RP2040 is a bitt more comlex than the ~1$ controller. You still need NOR Flash, which sets you back around another dollar in small quantities. And at that pricepoint, competition of the esp32 series is getting relevant. Thus, even the more "expensive" PY32s may be worthwile, in my opinion.

    • @AllTradesZach
      @AllTradesZach  หลายเดือนก่อน +2

      Thanks! You bring up a fair point with the RP2040 also needing a flash chip. The size of the RP2040 plus a flash chip is also substantially bigger than the QFN-16 PY32. I don't know about you, but when I get charged by the square inch for boards I make them as small as I can! For the backsplash project in particular size is very important.
      I think the -F030 has a compeling feature set for general purpose use and is a steal at 30-40 cents each. If it's true that the -F002A is the same die and can be convinced it is actaully a -F030 then that would be the real bargain.

  • @mytechnotalent
    @mytechnotalent 9 วันที่ผ่านมา +2

    Incredible Zach!

  • @MrVipulLal
    @MrVipulLal 7 วันที่ผ่านมา

    Eye opener video. Many thanks

  • @WessieNC
    @WessieNC 8 วันที่ผ่านมา

    I find this chip very useful and interesting. Thank You.

  • @omar_l_p
    @omar_l_p 10 วันที่ผ่านมา +1

    Muy buen video!! Simple e informativo.

  • @stefanguiton
    @stefanguiton 9 วันที่ผ่านมา +1

    Great video

  • @mehmetkendi6067
    @mehmetkendi6067 9 วันที่ผ่านมา +1

    Thank you!

  • @manfredbogner9799
    @manfredbogner9799 11 วันที่ผ่านมา +1

    Very good

  • @andymouse
    @andymouse 10 วันที่ผ่านมา

    Interesting stuff, all the setup work is above my paygrade at the moment, fascinating nonetheless....cheers. Edit: oh yeah 'PB5' same port and pin on the Arduino Uno for the built in LED.

  • @Bianchi77
    @Bianchi77 10 วันที่ผ่านมา

    Creative video, thanks :)

  • @choppergirl
    @choppergirl 8 วันที่ผ่านมา

    I wonder if you could add input and output to convert this to the equivalent of an old mainframe.

  • @klassikkustard4828
    @klassikkustard4828 6 วันที่ผ่านมา +1

    Commented cause i loved this

  • @WallaceRoseVincent
    @WallaceRoseVincent 5 วันที่ผ่านมา

    Hey Zach, I have a useful idea for the microcontroller that fits your channel. Since you are a jack of all trades then would a controller that monitors your ac system on your house be useful? A monitor system that helps you see ac problems before the turn catastrophic. It would be mostly temp sensing.

  • @qnaman
    @qnaman 10 วันที่ผ่านมา +1

    I've bought about 58 LGT8F328P - LQFP32 Boards of different kinds and they work as regular pro mini and are faster. But initally there was serious problem with libraries for them. Once I almost burned mine programmator, because one of pins started sending singnals through pin which works as input - which lead to shortcircuit.

    • @GnuReligion
      @GnuReligion 9 วันที่ผ่านมา

      Oh, the Logic Greens? I have some of those atmega328 sorta-clones ... both the 20-pin and 32 pin. The ADC is superior on these, but still mystified that they did not make true clones, instead of these semi-compatible things, or something completely new.

  • @nguyenthinh6188
    @nguyenthinh6188 10 วันที่ผ่านมา +1

    I agree, py32f002 is cheapest arm mcu can buy at here. Yes 4600vnd for 1 unit, easy to program via dap,stlink clone,etc...

    • @nguyenthinh6188
      @nguyenthinh6188 10 วันที่ผ่านมา

      Fmd60 cheaper but programmer of that 8bit mci not cheap

  • @saddle1940
    @saddle1940 10 วันที่ผ่านมา +1

    I had to smile when you described over several minutes, thee code needed to flash a led. It reminded me of the joke about the king and the toaster design. Even with interrupts, I'd be thinking under a minute with an arduino before youd be flashing the chip. So much prewritten code and definition files, i worry about code errors made by others, but thats the cost of wanting things like USB to work from libraries.

  • @LifeGeneralist
    @LifeGeneralist 11 วันที่ผ่านมา +2

    Helpful!

  • @parthsahni8952
    @parthsahni8952 6 วันที่ผ่านมา +1

    Very good and informative vid! im ur 700th sub lol

  • @etmax1
    @etmax1 6 วันที่ผ่านมา

    RP2040 has no internal Flash and only uses SPI Flash so it has to load the program or bits of program into RAM, reducing how much RAM you actually have for data so your comparison is a non starter in my opinion. What I do really like about this device though is that it's ARM M0+ rather than the somewhat inferior RISC-V. In my opinion the only thing RISC-V really gives you is the cheap FPGA synthesis.
    What I find interesting here is check the price out of an RTC chip compared to these micros. Obviously you need to be able have low power and a low power 32 kHz crystal connection, but basically you get about 5-10 of these for 1 RTC. I used to use MSP430 family devices as RTC's because they were 1/3 the price of an RTC. We use cheap micros for all sorts of glue logic because you can replace 100 or more logic gates with one of these for a fraction of the cost and PCB area if you don't need fast logic.
    Oh one last thing, when listing all of the serial options it has, I thought I'd mention that a lot of MCUs have shared HW for the various serial engines eg. the SPI Tx register and UART Tx Register could be the same HW meaning if you use SPI you're down a UART channel. It's not exclusively so, but just something to watch out for.

    • @AllTradesZach
      @AllTradesZach  6 วันที่ผ่านมา

      I agree on the RP2040 not having flash, I probably should have mentioned that. I do still maintain that it is a powerful chip for 80c (+50c or so for a SPI flash), but needing that flash certainly makes it bigger and more expensive.
      I'm excited for RISC-V in the future, but so far I haven't seen anything that has made me make the jump. I definitely appreciate open source, but I haven't really seen RISC-V parts being drastically cheaper than ARM parts.
      This part is probably the cheapest way to get any of the peripherals! I can see using it just for the ADC, or as a GPIO expander, or as a serial translator.
      Hmm, I'd have to double check to see if there's any conflicting peripheral hardware. So far everything I've run has been fine, but I've not used all the serial peripherals simultaneously.

    • @etmax1
      @etmax1 5 วันที่ผ่านมา

      @@AllTradesZach I agree, the pico chip is a great bundle, and the PIO engine is really something. The biggest issue is knowing what the real-time performance is going to be for any given implementation once programs exceed the available RAM. PCB footprint with external Flash is also a factor.
      On the peripherals sharing pins front, that is half of it, and I had a quick look at the Puya and the block diagram "Suggests" the peripherals themselves are separate (I didn't check for pin clashes). The thing I meant was eg. Infineon has not got I2C, SPI, UART, it instead has USIC0 and USIC1 which means that the registers are shared and they have a switchable state machine to make each USIC (only 2 of them) either I2C, SPI or UART. I got stuck with this where I needed 2 UARTs and 1 I2C. Another gotcha was that I couldn't get the SPI to work fast enough to do WS2812 because I couldn't reload the SPI register quick enough to do a 840bit stream without gaps. I could with a PIC.

  • @marsrocket
    @marsrocket 6 วันที่ผ่านมา

    How long until there is compute power in EVERYTHING and it all meshes together?

    • @AllTradesZach
      @AllTradesZach  6 วันที่ผ่านมา

      Well, we've got smart toasters, so I'd say that time is now.

  • @RWBHere
    @RWBHere 6 วันที่ผ่านมา

    Ten cents for all of that capability? I remember paying £100 for a megabyte of RAM and thinking that it was a bargain price. How times have changed.

  • @ChandrashekarCN
    @ChandrashekarCN 10 วันที่ผ่านมา

    💖💖💖💖

  • @TheRainHarvester
    @TheRainHarvester 7 วันที่ผ่านมา

    😮"wait 11:26 for it to update" oh yank-ware which may stop at any time? Is there a way to download everything to not depend on a company?

    • @AllTradesZach
      @AllTradesZach  6 วันที่ผ่านมา

      I know, this can be frustrating. Puya revised their website when I was making this video and now some of the documentation is gone. Luckily I did download all of it locally. The packs, datasheets, and some of the tools are available right from GitHub for download though. As far as the IDE's, fingers crossed I guess...

  • @yigitozen
    @yigitozen 2 วันที่ผ่านมา

    well done YT recommendations.

  • @voidpointmedia853
    @voidpointmedia853 18 วันที่ผ่านมา +3

    Weird fact: these can be found for free inside geek bar vapes. I recently decided to start disassembling these and found this micro controller in them which is wild being that these are DISPOSABLE VAPES. Such e-waste for no reason

    • @charlieRcarter
      @charlieRcarter 17 วันที่ผ่านมา +1

      So hyped for fossilized computer chips in 1 million years

    • @AllTradesZach
      @AllTradesZach  16 วันที่ผ่านมา +1

      That's quite interesting, I'd be curious to know what other products use them. They're in a bit of a weird place I think, because they're flash based and not the absolute cheapest, but also don't have the heritage/support/options of more expensive chips from STM, TI, Renesas, etc.
      But yes, quite a shame that the proliferation of cheap electronics has allowed society to make disposable electronics.

    • @andymouse
      @andymouse 10 วันที่ผ่านมา +1

      Awesome, I have been collecting a stock of 3.7v cells from these 'disposable' vapes that litter my town ! I shall take a closer look at the controller now...cheers.

    • @PainterVierax
      @PainterVierax 9 วันที่ผ่านมา +1

      most of the time, those cheap devices embed label-sanded chips that can come from any PRC manufacturer so it's not worth salvaging.
      most of the time they look like PIC pinouts but the programming is very different. And of course, those could be useless one-time-programming chips.

  • @murraymadness4674
    @murraymadness4674 9 วันที่ผ่านมา

    I get the sense you reading from a teleprompter?

  • @Ed19601
    @Ed19601 9 วันที่ผ่านมา

    The development board is about 5 USD, which is lunacy compared to and ESP32 board

    • @AllTradesZach
      @AllTradesZach  9 วันที่ผ่านมา +1

      Completely agree, they were $18 at one point which is absolutely absurd. These only make sense if you're spinning your own boards, and lots of them. Otherwise I'll personally grab a nucleo.

    • @Ed19601
      @Ed19601 9 วันที่ผ่านมา

      @@AllTradesZach I have no experience with the Nucleo but they seem like pretty decent boards

  • @usrrsr
    @usrrsr 6 วันที่ผ่านมา

    Gr8 video and +1 subriber

  • @jayneatkinson2747
    @jayneatkinson2747 9 วันที่ผ่านมา

    I found datasheets in Chinese a few days ago, but even they've disappeared. I'll stick with STM32

    • @AllTradesZach
      @AllTradesZach  9 วันที่ผ่านมา

      In Chinese here: www.py32.org/mcu/PY32F002Axx.html
      They redid their website while I was making this video, there used to be English versions there that were quite good.

    • @bikkelchiefwizard1681
      @bikkelchiefwizard1681 6 วันที่ผ่านมา

      at EEBLOG they mention an repository with all data sheets (also English)

  • @No-mq5lw
    @No-mq5lw 12 วันที่ผ่านมา +3

    I honestly thought this was a new RISC-V chip. My disappointment was palpable when the reveal dropped.

    • @isoslow
      @isoslow 9 วันที่ผ่านมา

      What's so good about RISC-V??! To me currently nothing. ARM has a huge codebase or ready-made opensource libraries for literally everything, RISC support on the other hand is nonexistent.

    • @No-mq5lw
      @No-mq5lw 9 วันที่ผ่านมา

      @@isoslow FOSS isa lends itself to completely free resources, Verilog. Also newer ESP32 chips are RISC-V.

    • @LimbaZero
      @LimbaZero 9 วันที่ผ่านมา +2

      @@isoslow With ARM cores manufacturer have to pay license to ARM. With those cheap mcu:s it can be risk if it's not paid by manufacturer. Basically all arm cores are from arm. Some have custom core using expanded instruction set but still they pay arm to use instruction set.
      Edit: STM and others who use ARM cores one reason why those cost more than chinese clones is that they pay that ARM license. For hobby user it can be ok to use those but to use in real product it can be problematic.

    • @No-mq5lw
      @No-mq5lw 9 วันที่ผ่านมา

      @@isoslow Free ISA under Creative Commons lends itself nicely to free simulators, free Verilog/VHDL/etc soft cores, and the ISA itself can be customized to whatever specification you want including custom Instructions. This makes embedding a RISC-V processor in whatever you want pretty much free. For the moment though, the mid to high end performance tier RISC-V options definitely do have a lot of work ahead of them in order to get them production ready.
      Espressif is basically jumping ship from Xtensa to RISC-V with their next generation designs like the ESP32 -P4, C6, C3. And imagine how many devices have been shipped utilizing the *proprietary* Xtensa ISA. Just because it's not ARM doesn't mean that's stopping products from being shipped.

  • @TheOpticalFreak
    @TheOpticalFreak 9 วันที่ผ่านมา

    Wait whut 😳😲 is that like an AT Mega?!😮

    • @isoslow
      @isoslow 9 วันที่ผ่านมา +1

      AVR stuff is 30 years old overpriced joke compared to modern micros at 1/20 of the price.

  • @AI-Doom-
    @AI-Doom- 9 วันที่ผ่านมา

    Not available in my country (India) and import costs makes them expensive.

  • @amandioreal2293
    @amandioreal2293 9 วันที่ผ่านมา +3

    This a clone of stm32f0 and use the same documentation.

    • @bikkelchiefwizard1681
      @bikkelchiefwizard1681 6 วันที่ผ่านมา

      No the PY32F0 can run on 5V something the new ST micros lack

  • @stepannovotny4291
    @stepannovotny4291 8 วันที่ผ่านมา

    Why do you need a HAL for something like this? The code is on bare metal isn't it? Doesn't the HAL just get in the way of actual hardware capabilities and introduce someone else's bugs?

  • @lohikarhu734
    @lohikarhu734 10 วันที่ผ่านมา +1

    "if we're really being *pedantic*..."
    Or, am I being too pedantic?

  • @Kysen10
    @Kysen10 3 วันที่ผ่านมา

    This looks like a clone chip of STM.

  • @nyeleskettes
    @nyeleskettes 8 วันที่ผ่านมา

    This looks like a cortex clone along with the debug interface and all the drivers.

  • @tcurdt
    @tcurdt 9 วันที่ผ่านมา

    Is there platformio support? otherwise I'll pass

  • @pacsmile
    @pacsmile 19 วันที่ผ่านมา +1

    everytime you said 10 cent i thought you were saying "tencent", the chinese company

  • @hitension7
    @hitension7 8 วันที่ผ่านมา +3

    You buy cheap, you buy twice! This video looks like paid ad.