B4R Question How many Variables can be declared in B4R?

Gerardo Tenreiro

Active Member
Licensed User
Hello again
I am starting a new project which will use many variables and processor time will be very tight, as always for me.

Well, I'm creating this program to see how long it takes for the processor to execute an instruction depending on the type of variable to estimate if I will be able to carry out all the instructions to be carried out in the established times, but the problem is not in this program but rather from time to time I define many variables. An error is generated from the WIFI.h library that has nothing to do with it.

If I change in the program
Public FR05(700) as Float a Public FR05(600) as Float

It compiles correctly and tells me that I use 35% of the variables.

Why is this error generated?
B4R can't manage all the variables?

Log
Utilizando archivo previamente compilado: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D\sketch\B4RArduino.cpp.o
Compilando librerías...
Compilando librería "WiFi"
Utilizando archivo previamente compilado: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D\libraries\WiFi\WiFiServer.cpp.o
Utilizando archivo previamente compilado: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D\libraries\WiFi\WiFiGeneric.cpp.o
Utilizando archivo previamente compilado: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D\libraries\WiFi\WiFi.cpp.o
Utilizando archivo previamente compilado: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D\libraries\WiFi\WiFiAP.cpp.o
Utilizando archivo previamente compilado: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D\libraries\WiFi\WiFiMulti.cpp.o
Utilizando archivo previamente compilado: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D\libraries\WiFi\WiFiClient.cpp.o
Utilizando archivo previamente compilado: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D\libraries\WiFi\WiFiSTA.cpp.o
Utilizando archivo previamente compilado: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D\libraries\WiFi\WiFiScan.cpp.o
Utilizando archivo previamente compilado: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D\libraries\WiFi\WiFiUdp.cpp.o
Compilando librería "WiFiClientSecure"
Utilizando archivo previamente compilado: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D\libraries\WiFiClientSecure\esp_crt_bundle.c.o
Utilizando archivo previamente compilado: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D\libraries\WiFiClientSecure\ssl_client.cpp.o
Utilizando archivo previamente compilado: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D\libraries\WiFiClientSecure\WiFiClientSecure.cpp.o
Compilando el núcleo...
cmd /c echo -DARDUINO_CORE_BUILD > "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D/file_opts"
Using precompiled core: C:\Users\Gerardo\AppData\Local\Temp\arduino\cores\4a7d7b954ca99fd3fc22051a0dee36cb\core.a
cmd /c type nul > "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D/file_opts"
Linking everything together...
"C:\\Users\\Gerardo\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\esp-2021r2-patch5-8.4.0/bin/xtensa-esp32-elf-g++" "-Wl,--Map=C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D/src.ino.map" "-LC:\\Users\\Gerardo\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.13/tools/sdk/esp32/lib" "-LC:\\Users\\Gerardo\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.13/tools/sdk/esp32/ld" "-LC:\\Users\\Gerardo\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.13/tools/sdk/esp32/qio_qspi" -T esp32.rom.redefined.ld -T memory.ld -T sections.ld -T esp32.rom.ld -T esp32.rom.api.ld -T esp32.rom.libgcc.ld -T esp32.rom.newlib-data.ld -T esp32.rom.syscalls.ld -T esp32.peripherals.ld -mlongcalls -Wno-frame-address -Wl,--cref -Wl,--gc-sections -fno-rtti -fno-lto -Wl,--wrap=esp_log_write -Wl,--wrap=esp_log_writev -Wl,--wrap=log_printf -u ld_include_hli_vectors_bt -u _Z5setupv -u _Z4loopv -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u pthread_include_pthread_rwlock_impl -u include_esp_phy_override -u ld_include_highint_hdl -u start_app -u start_app_other_cores -u __ubsan_include -Wl,--wrap=longjmp -u __assert_func -u vfs_include_syscalls_impl -Wl,--undefined=uxTopUsedPriority -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u newlib_include_assert_impl -u __cxa_guard_dummy -DESP32 -DCORE_DEBUG_LEVEL=0 -DARDUINO_USB_CDC_ON_BOOT=0 -Wl,--start-group "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\sketch\\B4RArduino.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\sketch\\B4RCore.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\sketch\\B4RStream.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\sketch\\BufferedWiFiClient.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\sketch\\Scheduler.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\sketch\\b4r_main.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\sketch\\rESP8266WiFi.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\sketch\\src.ino.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\libraries\\WiFi\\WiFi.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\libraries\\WiFi\\WiFiAP.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\libraries\\WiFi\\WiFiClient.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\libraries\\WiFi\\WiFiGeneric.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\libraries\\WiFi\\WiFiMulti.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\libraries\\WiFi\\WiFiSTA.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\libraries\\WiFi\\WiFiScan.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\libraries\\WiFi\\WiFiServer.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\libraries\\WiFi\\WiFiUdp.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\libraries\\WiFiClientSecure\\WiFiClientSecure.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\libraries\\WiFiClientSecure\\esp_crt_bundle.c.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D\\libraries\\WiFiClientSecure\\ssl_client.cpp.o" "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\cores\\4a7d7b954ca99fd3fc22051a0dee36cb\\core.a" -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lbt -lcbor -lunity -lcmock -lcoap -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lperfmon -lspiffs -lulp -lwifi_provisioning -lrmaker_common -lesp_diagnostics -lrtc_store -lesp_insights -ljson_parser -ljson_generator -lesp_schedule -lespressif__esp_secure_cert_mgr -lesp_rainmaker -lgpio_button -lqrcode -lws2812_led -lesp32-camera -lesp_littlefs -lespressif__esp-dsp -lfb_gfx -lasio -lcmock -lunity -lcoap -lesp_lcd -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lperfmon -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lspiffs -lesp_insights -lcbor -lesp_diagnostics -lrtc_store -lesp_rainmaker -lesp_local_ctrl -lesp_https_server -lwifi_provisioning -lprotocomm -lbt -lbtdm_app -lprotobuf-c -lmdns -ljson -ljson_parser -ljson_generator -lesp_schedule -lespressif__esp_secure_cert_mgr -lqrcode -lrmaker_common -lmqtt -lcat_face_detect -lhuman_face_detect -lcolor_detect -lmfn -ldl -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lrtc -lesp_phy -lphy -lrtc -lesp_phy -lphy -lrtc -lxt_hal -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc -Wl,--end-group -Wl,-EL -o "C:\\Users\\Gerardo\\AppData\\Local\\Temp\\arduino\\sketches\\1825E9DE2A07EA1C6BE382088478E57D/src.ino.elf"
c:/users/gerardo/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Gerardo\AppData\Local\Temp\arduino\sketches\1825E9DE2A07EA1C6BE382088478E57D/src.ino.elf section `.dram0.bss' will not fit in region `dram0_0_seg'
c:/users/gerardo/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: DRAM segment data does not fit.
c:/users/gerardo/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: DRAM segment data does not fit.
c:/users/gerardo/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: region `dram0_0_seg' overflowed by 200 bytes
collect2.exe: error: ld returned 1 exit status
Se encontraron varias bibliotecas para "WiFi.h"
Usado: C:\Users\Gerardo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.13\libraries\WiFi
No utilizado: C:\Users\Gerardo\OneDrive\Documentos\Arduino\libraries\WiFiNINA
Usando librería WiFi con versión 2.0.0 en la carpeta: C:\Users\Gerardo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.13\libraries\WiFi
Usando librería WiFiClientSecure con versión 2.0.0 en la carpeta: C:\Users\Gerardo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.13\libraries\WiFiClientSecure
Error during build: exit status 1
[92mUsed library[0m [92mVersion[0m [90mPath[0m
[93mWiFi[0m 2.0.0 [90mC:\Users\Gerardo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.13\libraries\WiFi[0m
[93mWiFiClientSecure[0m 2.0.0 [90mC:\Users\Gerardo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.13\libraries\WiFiClientSecure[0m
[92mUsed platform[0m [92mVersion[0m [90mPath[0m
[93mesp32:esp32[0m 2.0.13 [90mC:\Users\Gerardo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.13[0m


Program
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 600
#End Region
'
' Medida de Velocidad de ejecucion de Instrucciones
'

Sub Process_Globals
Public Serial1 As Serial
Private wifi As ESP8266WiFi
Public T_Inicio As ULong = 0
Public T_Final As ULong = 0
Public DT As ULong = 0
Public CT As Float = 0.0
Public C As ULong = 0

Public Tiempo01 As Timer

Public E1 As Pin
Public A1 As Pin
Public Estado_E1 As Boolean
Public Estado_A1 As Boolean

Dim B As Long = 1
Dim BB As Float = 0.1


Public M00(1000) As Float
Public M01(1000) As Float
Public M02(1000) As Float
Public M03(1000) As Float
Public M04(1000) As Float
Public M05(1000) As Float
Public M06(1000) As Float
Public M07(1000) As Float
Public M08(1000) As Float
Public M09(1000) As Float
Public M10(1000) As Float
Public M11(1000) As Float
Public M12(1000) As Float
Public M13(1000) As Float
Public M14(1000) As Float
Public M15(1000) As Float
Public M16(1000) As Float
Public M17(1000) As Float
Public M18(1000) As Float
Public M19(1000) As Float

Public Fr00(1000) As Float
Public Fr01(1000) As Float
Public Fr02(1000) As Float
Public Fr03(1000) As Float
Public Fr04(1000) As Float
Public Fr05(700) As Float
' Public Fr06(1000) As Float
' Public Fr07(1000) As Float
' Public Fr08(1000) As Float
' Public Fr09(1000) As Float
' Public Fr10(1000) As Float
' Public Fr11(1000) As Float
' Public Fr12(1000) As Float
' Public Fr13(1000) As Float
' Public Fr14(1000) As Float
' Public Fr15(1000) As Float
' Public Fr16(1000) As Float
' Public Fr17(1000) As Float
' Public Fr18(1000) As Float
' Public Fr19(1000) As Float

End Sub

Private Sub AppStart

Serial1.Initialize(115200)
Log("................")
Log("... ARRANQUE ...")
Log("................")


'example of connecting to a local network
'If wifi.Connect2("SSID", "PASSWORD") Then
' Log("Connected to network")
'Else
' Log("Failed to connect to network")
'End If




' Define Entradas
E1.Initialize(36,E1.MODE_INPUT)
A1.Initialize(25,A1.MODE_INPUT)

Tiempo01.Initialize("Tarea",1000)
Tiempo01.Enabled = True



End Sub


Sub Tarea()
Dim A As Float = 0.0
Dim AA As Float = 0.0

T_Inicio = Micros ' Momento Inicial
For C = 0 To 999999
A = Rnd(-1000,1000)
A = A / 7
AA = Rnd(-1000,1000)
AA = AA / 7
AA = A / AA
Next



T_Final = Micros ' Momento Final
DT = T_Final - T_Inicio
CT = DT / C
Log("Tardo=", NumberFormat(DT,5,0), " us en Ejecutar ",C," Instruciones. ",CT ," ... ",A," ... ",AA )

End Sub
Thank you very much for the help
 

Cableguy

Expert
Licensed User
Longtime User
B4R can't manage all the variables?
If you try running windows 11 on a 386DX2 processor and it fails, is it the software's fault or an hardware limitation?
The same applies to B4R!
B4R can compile code to target many different hardware configurations, being it processor, coms, or memory.
There should be a sticky post on the B4R Questions forum, asking users to specify the board they're targeting, and any breakouts they're connecting to.

Now, your question...
Wrong question, so not the answer you need!
B4R can manage any variable you want and need.
The real question is, does your board have the right specs for the task you are trying to give to it?

So, in order for anyone to be able to help you, start by describing what is it your need your device to do, which board have you chosen as the heart of you device, and which, if any, breakout boards you are using.

As a side note...
The ESP32, as many of the ESP family boards, has built-in Wi-Fi and BLE capabilities, so when compiling to those boards, all the boards built-in hardware libs get compiled too.

2nd side note...
Different boards have different memory and memory buffers. First establish your board memory buffer and set it in your code accordingly.
 
Upvote 0

Gerardo Tenreiro

Active Member
Licensed User
Thanks for your reply.

But I still don't understand the problem

I understand that B4R is the one who manages the compilation and who manages how it is done, therefore, and from what I have seen, I observe that when the number of variables reaches a value, an error is generated for a library that is not even being used.
That is why I asked the question in the forum within the B4R section without having more knowledge of the solution and above all with the aim of helping and alerting that this is happening.

If I compile with a lower value and B4R indicates that 35% of its capacity is being used with more than 20K variables and I add 100 variables and the error is generated, I cannot think or imagine that it is a board capacity problem. Either the indication of using 35% of the capacity is wrong or I don't know what is happening.

I tested with different board models and the problem repeats itself, even with an ESP32 with 16Mb memory.

As always, thank you very much and I hope for some response or suggestion that will allow me to address the problem.

Note: Someone tried this with some type of board and it worked.

Thank you so much
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
If I compile with a lower value and B4R indicates that 35% of its capacity is being used
With a lower value of what exactly? 35% of what? processor or memory?
with more than 20K variables
Dham that's a lot of variables!

and I add 100 variables and the error is generated
then it's 20k1 variables or only 100?

Please, don't think I am being petty or unpolite... I'm really trying to understand your problem... but you are giving misleading info, and not even a description of what you are aiming to accomplish...

Have you tried to up the buffer value in your project attribs?

The fact of the WIFI lib is getting compiled even though its not used, to me, is only due to the presence of such hardware in the chosen board.
You can try to see if it's possible to "remove" that lib from compilation... but that is an Arduino IDE thing, not a B4R. (B4R relies on the Arduino compiler to... well... compile)
 
Upvote 0

Gerardo Tenreiro

Active Member
Licensed User
The occupation is 38% of the global variables of the dynamic memory, this is indicated when compiling with Variables.25821
Las variables Globales usan 124576 bytes (38%) de la memoria dinámica, dejando 203104 bytes para las variables locales. El máximo es 327680 bytes.
If more than 25821 FLOAT variables are declared, the error is generated, it's that simple

Increasing or decreasing the size of the "#StackBufferSize" does not modify the number of variables to generate the error

To verify the problem I leave two programs, one generates the error and the other does not
This generates the error
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 600
#End Region
'Ctrl+Click to open the C code folder: ide://run?File=%WINDIR%\System32\explorer.exe&Args=%PROJECT%\Objects\Src

Sub Process_Globals
Public M00(25822) As Float
End Sub

Private Sub AppStart

End Sub

and this one doesn't
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 600
#End Region
'Ctrl+Click to open the C code folder: ide://run?File=%WINDIR%\System32\explorer.exe&Args=%PROJECT%\Objects\Src

Sub Process_Globals
Public M00(25821) As Float
End Sub

Private Sub AppStart

End Sub

That's why I put the title "How Many Variables can be declared in B4R?" .
I think the question is correct, or not?


The current project is a data logger with 20 analog voltage and current channels that takes samples every 1uS from an external converter. Every second I need to store the waveforms, their values, frequency and other parameters to later perform analysis. That is why it is necessary to store so many variables.
I also understand that if the processor has this amount of dynamic memory for variables, they can be used.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I still don't understand... how many variables do you need?
Are you storing all the read values into memory? why? can't you store them to sd and then read them back when needed?
 
Upvote 0

Gerardo Tenreiro

Active Member
Licensed User
If the answer is 25821, who limits it B4R or Arduino?
Can this limitation be solved?

In the application I need about 37,000 dynamic variables
Due to processing speed, I don't think you can use SD memory, and why use another processor when the processor has its own RAM and is the fastest and most direct?
You could put an external RAM memory via SPI or an SD but why not use the processor's own memory? I don't understand
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
B4R or Arduino?

B4R is just transpiller over Arduino. It wraps B4X language around C-code of all MCUs families supported by Arduino.

IMHO, you stuck up the ESP32 family architecture limitation.
 
Last edited:
Upvote 0
Top