antBASIC is a modernized version of Tiny BASIC, with the addition of I/O manipulation instructions specifically designed for the Raspberry Pi. Although the language specification is minimal, beginners can learn the basics of programming, and a wide range of I/O controls through antBASIC.
antBASIC is a product of the BMH project. BMH is an abbreviation for Bare Metal Hacking, which aims to teach the basics of system programming by controlling bare LEDs, LCDs, ICs, MCUs, etc., on a breadboard. I designed antBASIC as an introductory computer language for I/O control running on the Raspberry Pi. It is the 21st-century version of Tiny BASIC for beginners.
The Raspberry Pi has a 40-pin external header which holds 27 GPIO pins. Since the order of the original PINs (https://pinout.xyz/#) is irregular, it is easy to make mistakes when wiring. From an educational perspective, BMH has assigned new consecutive numbers (BMH1 to BMH14) to the GPIO pins. Although the number of pins is about half, 14, you can enjoy almost any I/O control!
BMH provides an easy-to-understand BMH GPIO card for beginners (bmh-gpio-cards.pdf in the DOCUMENTS ๐ directory).
You need to pre-install libreadline-dev, atp and ghostscript (includes ps2pdf) packages before
make std
ormake max
.
$ make
๐ antbasic and antcalib
$ make std
๐ antbasic, antcalib, antbasic.pdf, and src.pdf
$ make max
๐ antbasic, antcalib, antbasic.pdf, src.pdf, test_token, test_bcode, test_prog, test_eval, test_assign
You require ROOT privilege
$ sudo make install
๐ ๐ /usr/local/bin/antbasic, ๐ /usr/local/bin/antcalib, ๐ /usr/local/share/man/man1/antbasic.1
$ make clean
๐ delete applications in the source tree
You require ROOT privilege
$ sudo make dist-clean
๐ purge all created files
Default Makefile builds an antBASIC binary linked with the GNU Readline library. Readline makes editing commands and programs much more effortless. In addition, the filename completion is very powerful. For more information on editing and history functions, see rluserman.pdf in the DOCUMENTS ๐ directory.
There are two types of wait functions, MSLEEP() and USLEEP(), in antBASIC. The former is a delay in seconds, while the latter is in micro-seconds. By default, both functions use the usleep system call internally, but a delay in the order of micro-seconds can lead to time variability.
If more precise control in micro-seconds is required, set the ANT_MICROWAIT environment variable. Then the USLEEP() function does not use the usleep system call but uses a simple loop for the number of times specified by ANT_MICROWAIT.
antcalib is a utility for estimating the number of loops required for a ฮผsec delay. The first argument specifies the number of loops, and the second argument specifies the number of loop calls.
$ ./antcalib 220 10000000
Loopcount = 220
Number of loops = 10000000
Elapsed time --> 10 sec 9327 usec
Mean time --> 1.000933 usec/loop
On a Raspberry pi 400, the loop count is around 220. Once the loop count is determined, add the export command to the ~/.bashrc.
export ANT_MICROWAIT=220
You can find the usage and grammar of antBASIC in the man file. Enter the command
$ man antbasic
in a terminal or open antbasic.pdf in the DOCUMENTS ๐ directory of the source tree.
Initial release 1.0.0 released on Apr 26th, 2022 Revised version 1.0.3 released on Nov 27th, 2022
Doctor BMH ๐ฏ๐ต
Wataru Nishida, M.D.๐ฉบ, Ph.D. ๐
๐ BMH Home Page
๐ antBASIC GitHub Repository
๐บ BMH YouTube Channel
๐ฃ DoctorBMH Twitter