ESP32 PWM!

For general Flowcode discussion that does not belong in the other sections.
Post Reply
jgu1
Posts: 798
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 688 times
Been thanked: 177 times

Flowcode v10 ESP32 PWM!

Post by jgu1 »

HI all!

I need to control a PWM via potentiameter in anothe project. First I test it in a simple testprogram. When I simulate the program it doesn´t work, I don´t see the PWM on the Graph. I have not test in real word yet, so I don´t know if it work,

What am I do wrong, please?

Br Jorgen
Attachments
PWM_ESP.fcfx
(11.34 KiB) Downloaded 539 times

chipfryer27
Valued Contributor
Posts: 1616
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 358 times
Been thanked: 565 times

Re: ESP32 PWM!

Post by chipfryer27 »

Hi Jorgen

The PWM component needs to have a PWM Timer selected and has a period overflow of 255 for 8-bit devices and 65535 for 16-bit devices which also needs to be set according to your device.

I see your slider has a range of 0-4095 so you could perhaps use the Map component to scale to 0-255 for your Duty?

Hope this helps.

Regards

jgu1
Posts: 798
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 688 times
Been thanked: 177 times

Re: ESP32 PWM!

Post by jgu1 »

Hi chipfryer27

Many thank´s for your help. Yes I managed to get it work in simulation after your advice. I have compile to chip, no uotput

I use theanalog (warm ) Analog 4 = pin 32 and for the PWM out I use CH4 with pin B3 = D11

Do you have any advice? ;)
Attachments
PWM_ESP.fcfx
(11.53 KiB) Downloaded 520 times

chipfryer27
Valued Contributor
Posts: 1616
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 358 times
Been thanked: 565 times

Re: ESP32 PWM!

Post by chipfryer27 »

Hi Jorgen

I don't use the ESP32 that much but from what I see with View > Target (showing pins)

I agree that the Slider is connected to IO32 / ADC4 PortB.0 but I'm unsure where you get D11 for the PWM. Is that a typing error?

How are you measuring the output? You will need a scope or an analyser on the pin to see the duty change.

Regards

jgu1
Posts: 798
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 688 times
Been thanked: 177 times

Re: ESP32 PWM!

Post by jgu1 »

Hi again!

I disvoverd that if I change the channel I saw that Pin was changing Timer A and B so I try to use Channel 1 and pin A15 then I get fine PWM out :)

I not managed it by any of the BPins. But anyway, by help from you I can continue my project. ;)

I think it is tricky with pinnumbers with ESP32, no logig :lol:

Again thank´s

Br Jorgen
Attachments
PWM_ESP.fcfx
(11.53 KiB) Downloaded 608 times

chipfryer27
Valued Contributor
Posts: 1616
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 358 times
Been thanked: 565 times

Re: ESP32 PWM!

Post by chipfryer27 »

Hi
I think it is tricky with pinnumbers with ESP32, no logig :lol:
It certainly seems that way :)

Glad you have it working now.

Regards

MJU20
Posts: 349
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 99 times
Been thanked: 69 times

Re: ESP32 PWM!

Post by MJU20 »

I've downloaded the file in https://flowcode.co.uk/forums/viewtopic ... 423#p15423 and changed the target to the ESP32C3_super-mini (compiled it using EDF5.3x).

This gives an error.
According to the schematic and specifications: https://www.sudo.is/docs/esphome/boards ... supermini/ the GPIO's all have PWM capabilities.
But when I compile it I get this error..

Code: Select all

[3/7] Linking C static library esp-idf\main\libmain.a
[4/7] Generating ld/sections.ld
[5/7] Linking CXX executable esp-project.elf
FAILED: esp-project.elf 
cmd.exe /C "cd . && C:\Espressif\tools\riscv32-esp-elf\esp-13.2.0_20240530\riscv32-esp-elf\bin\riscv32-esp-elf-g++.exe -march=rv32imc_zicsr_zifencei -nostartfiles -march=rv32imc_zicsr_zifencei --specs=nosys.specs    -Wl,--cref -Wl,--defsym=IDF_TARGET_ESP32C3=0 -Wl,--Map=D:/FC10/ESP/SuperminiPWM/PWM_ESP/build/esp-project.map -Wl,--no-warn-rwx-segments -fno-rtti -fno-lto -Wl,--gc-sections -Wl,--warn-common -T rom.api.ld -T esp32c3.peripherals.ld -T esp32c3.rom.ld -T esp32c3.rom.api.ld -T esp32c3.rom.libgcc.ld -T esp32c3.rom.version.ld -T esp32c3.rom.eco3.ld -T esp32c3.rom.newlib.ld -T memory.ld -T sections.ld @CMakeFiles\esp-project.elf.rsp -o esp-project.elf  && cd ."
C:/Espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: esp-idf/main/libmain.a(esp-project.c.obj): in function `FC_CAL_PWM_Enable_1':
C:\ProgramData\MatrixTSL\FlowcodeV10\CAL\ESP/ESP_CAL_PWM.c:221:(.text.FC_CAL_PWM_Enable_1+0x26): undefined reference to `mcpwm_gpio_init'
C:/Espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\ProgramData\MatrixTSL\FlowcodeV10\CAL\ESP/ESP_CAL_PWM.c:223:(.text.FC_CAL_PWM_Enable_1+0x3a): undefined reference to `mcpwm_init'
C:/Espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\ProgramData\MatrixTSL\FlowcodeV10\CAL\ESP/ESP_CAL_PWM.c:225:(.text.FC_CAL_PWM_Enable_1+0x46): undefined reference to `mcpwm_start'
C:/Espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld.exe: esp-idf/main/libmain.a(esp-project.c.obj): in function `FC_CAL_PWM_SetDuty8Bit_1':
C:\ProgramData\MatrixTSL\FlowcodeV10\CAL\ESP/ESP_CAL_PWM.c:268:(.text.FC_CAL_PWM_SetDuty8Bit_1+0x40): undefined reference to `mcpwm_set_duty'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
Executing action: all (aliases: build)
Running ninja in directory D:\FC10\ESP\SuperminiPWM\PWM_ESP\build
Executing "ninja all"...

Build Failed


Autoclose turned off
What am I doing wrong? Use the wrong pin? Need to choose another pint in the PWM settings?

This example uses the PWM channel 1 component, I don't find that in my component library.
How can I make pin 9 (or any other pin), work as a PWM signal?

At this moment the board is flashing a LED on pin 9 so I know it works and compiles..

MJU20
Posts: 349
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 99 times
Been thanked: 69 times

Re: ESP32 PWM!

Post by MJU20 »

Bump

BenR
Matrix Staff
Posts: 1945
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 509 times
Been thanked: 692 times

Re: ESP32 PWM!

Post by BenR »

Hello,

Thanks for letting us know. I'll upgrade my IPE to v5.3 and see if I can solve the problem for you. Likely the PWM API has changed slightly in the latest version of the IPE.

MJU20
Posts: 349
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 99 times
Been thanked: 69 times

Re: ESP32 PWM!

Post by MJU20 »

Bump...

Any news on this yet?

Post Reply