CH32V003J4M6 Tutorial - Part 9 - Low-power modes

Поділитися
Вставка
  • Опубліковано 4 січ 2025
  • In this video, I show you the low-power modes of the CH32V003-series microcontroller using a CH32V003J4M6 chip. The device can be put into sleep mode (~600 uA) or standby mode (~10 uA). Depending on what other devices are operated and how often the microcontroller must perform a task, the standby mode can be sustained for more than a year, even with a small CR2032 battery.
    Consider becoming a channel member! / @curiousscientist
    Article: curiousscienti...
    Resources: www.wch-ic.com...
    Parts and tools: curiousscienti...

КОМЕНТАРІ • 11

  • @CuriousScientist
    @CuriousScientist  6 днів тому

    *Exploring Low Power Modes on the CH32V003 Microcontroller*
    * *0:00** Introduction:* The video demonstrates how to use the low power modes (sleep and standby) of the CH32V003 microcontroller for battery-operated or power-saving applications.
    * *0:53** Microcontroller Choice:* The 8-pin J4M6 microcontroller is selected for its balance of features and low power consumption, comparable to the ATtiny85 but with more peripherals.
    * *1:39** Low Power Modes Overview:*
    * *Sleep Mode:* CPU clock stopped, peripheral clocks active, faster wakeup, higher power consumption.
    * *Standby Mode:* More functionalities disabled, significantly lower power consumption, ideal for battery-operated projects.
    * *2:35** Code Development:* A new project is created for the J4M6 chip, which lacks an external clock source.
    * *2:48** Clock Configuration:* The default 48MHz High-Speed External (HSE) clock is disabled in favor of the 8MHz High-Speed Internal (HSI) clock to save power.
    * *4:32** Sleep Mode Implementation:* The code is structured to enter sleep mode and wake up via a button press (interrupt on pin PA2). An LED (pin PC1) is toggled to indicate wake/sleep status.
    * *5:42** GPIO Configuration:* All GPIO pins are set to internal pull-up (IPU) mode to prevent floating states and reduce unnecessary current consumption.
    * *8:56** Interrupt Setup:* An external interrupt (EXTI) is configured for pin PA2 to trigger on a falling edge (button press), waking the device from sleep mode.
    * *15:01** Initial Power Measurement:* In sleep mode with the 8MHz HSI clock, the device consumes around 600 microamps, consistent with the datasheet.
    * *18:58** Standby Mode and LSI:* The video introduces the Low-Speed Internal (LSI) oscillator (around 128kHz) which can further reduce standby current to about 10.5 microamps (with LSI on) or 9 microamps (with LSI off).
    * *20:56** Standby Mode Implementation:* Another interrupt (EXTI line 9) is configured for the auto wake-up (AWU) feature, triggered by the LSI timer.
    * *23:58** Auto Wake-Up Configuration:* The LSI is enabled, and a prescaler is set to achieve a pulse approximately every 480 milliseconds. The AWU window value is set to 25, resulting in a wake-up period of around 12 seconds (though variations are expected due to LSI frequency tolerance).
    * *29:46** Standby Power Measurement:* With the LSI enabled, the device consumes around 11 microamps in standby mode. Disabling the LSI reduces this to about 9.6 microamps.
    * *33:15** Battery Life Estimation:* With a CR2032 coin cell battery (approximately 225mAh), the device in standby mode could theoretically last over 20,000 hours (more than 2 years) at 9.6 microamps.
    * *34:36** Conclusion:* The video demonstrates the significant power savings achievable with the CH32V003's low power modes, making it suitable for various battery-powered applications like thermometers, light switches, or motion sensors.
    I used gemini-1.5-pro-exp-0827 on rocketrecap dot com to summarize the transcript.
    Cost (if I didn't use the free tier): $0.03
    Input tokens: 19258
    Output tokens: 766

  • @CorgonCorgon
    @CorgonCorgon 6 днів тому

    Perfect tutorial!
    Some time ago, when I was making my wireless dropper seat for my bike (the video’s on my UA-cam channel), I used this MCU in both the transmitter and receiver.
    I struggled with the sleep and standby modes and had a hard time figuring out that the MCU only fully enters standby mode after a power cycle. When I compared my code to yours, it’s almost the same.
    I wish I had this guide back then :)

    • @CuriousScientist
      @CuriousScientist  5 днів тому +1

      Thank you! I also spent some time digging through the datasheet and the examples provided by WCH, but after a few days of work, I think I managed to master the different sleep modes. Neat project with the dropper seat, and also a nice bike! Cheers from a fellow hardtail MTB rider.

  • @LioN-pn6zs
    @LioN-pn6zs 2 дні тому

    What happened to your transmission radiator project? Did you connect the radiator to your computer? How much electricity do Peltiers use? Did you get a big electricity bill because of the Peltier?

    • @CuriousScientist
      @CuriousScientist  2 дні тому

      What do you mean? I never intended to do anything with my computer.

  • @peterdkay
    @peterdkay 5 днів тому

    Great video and the code you write is very readable.
    I use ATTiny85 as a stimulator it has EEPROM to store parameters (Pulse level, rate and width).
    I need a UART so I have to code it with bit-banging.
    It appears the CH32V003J4M6 does not have EEPROM but does have a UART so almost compatible with ATTiny85. Also ATTiny85 can be programmed via USB via DigiSpark and Micronucleus driver.

    • @CuriousScientist
      @CuriousScientist  18 годин тому

      Thank you!
      Yes, you are right that there is no dedicated EEPROM on the chip. However, with some smart tricks, you can write the flash. So, you can kind of achieve the same as you could by using an EEPROM. Furthermore, you can buy a 1-wire EEPROM and use it as a temporary storage. I also read it in some article that someone figured out a bit-banged USB on these chips and they could put the USB protocol on the bootloader. Quite neat.

    • @peterdkay
      @peterdkay 15 годин тому

      @@CuriousScientist That would be a great topic for a video. I assume you will have to copy image to RAM, modify byte, then do a FLASH page erase and write RAM back to FLASH.
      With only 4 or 5 pins available, 1 wire EEPROM could be a problem unless you can multi-use pins.
      I would love to see an example of USB bit banging to do reprogramming.
      Keep going, I love this series!!!

    • @CuriousScientist
      @CuriousScientist  14 годин тому

      @@peterdkay Thank you, I will continue this series. There are a lot of topics to cover and once I finish with the V003-series, I will start working with the V103, V203...etc series as well. And I will definitely dedicate a video for the "flash-eeprom" topic because I think it is a very neat hack.

  • @RicardoPenders
    @RicardoPenders 6 днів тому

    Interesting and thanks for sharing this video, it almost looks like coding an Arduino.

    • @CuriousScientist
      @CuriousScientist  6 днів тому +1

      Thanks! I would say it is more similar to ST's HAL system. But at the end of the day, it is just a C language. Just different commands.