Poging GOUD - Vrij

Learn Lisp Programming Using MCUs - Part 2: Extending µLisp with Custom Functions

Circuit Cellar

|

February 2025

In the second installment of this series, Raul delves into the world of µLisp and shows how to extend capabilities by adding custom functions such as "pulsein" and "servo-create", enabling developers to interface with ultrasonic sensors and control servomotors. In Part 1, Raul presented µLisp concepts and syntax, and extensions specific to MCUs.

- Raul Alvarez-Torrico

Learn Lisp Programming Using MCUs - Part 2: Extending µLisp with Custom Functions

μLisp is a dialect of the Lisp programming language. It is tailored to microcontrollers having limited amounts of RAM, and can be run on various platforms—from the Arduino Uno based on the ATmega328, up to the Teensy 4.0/4.1 [1]. To follow the topics discussed here, you need to be acquainted with the Arduino platform and any programming language from the Lisp family. Please see Part 1 of this article series (“Crash Course Offers Insight into Pioneering Language,” Circuit Cellar 411, October, 2024) for a brief introduction to Lisp programming and the µLisp dialect [2].

With µLisp, it is possible to add your own extension functions, such that they appear as built into the language after re-compiling and flashing the µLisp interpreter to your Arduino board. There’s an excellent tutorial on how to do this on the µLisp website [3]. I will build on that tutorial to discuss how to add custom functions. For the examples presented here, I will continue to use Seeed Studio’s Wio Terminal MCU development board; but the information discussed also can be applied to other µLisp-supported Arduino boards.

EXTENDING µLISP

In general, any function not supported by default in µLisp can possibly be added as an extension to the language—for instance, hardware access functions for servomotor control. Let’s explore a simple example to help us understand how the language extension system works.

Listing 1 shows the Arduino C code for adding the pulsein extension to µLisp, which is not available by default. This extension will make it possible to measure digital pulse widths. Five sections of the listing show the µLisp extensions structure. Like the core µLisp interpreter, extensions are also written in Arduino C language. So, any extensions to the interpreter imply basically writing C code. That makes adding them straightforward, using the Arduino C language built-in functions and external libraries.

Circuit Cellar

Dit verhaal komt uit de February 2025-editie van Circuit Cellar.

Abonneer u op Magzter GOLD voor toegang tot duizenden zorgvuldig samengestelde premiumverhalen en meer dan 9000 tijdschriften en kranten.

Bent u al abonnee?

MEER VERHALEN VAN Circuit Cellar

Circuit Cellar

Circuit Cellar

Bourns Announces New Micro Encoders Offering High Reliability in a Compact Design

Bourns, Inc., a leading manufacturer and supplier of electronic components for power, protection, and sensing solutions, announced its PEC04 Series 4mm Incremental Micro Encoder, its PEC05 Series 5mm Incremental Micro Encoder and its Model PEC06, a 6mm Incremental Micro Encoder. Bourns new micro encoders provide position and speed information essential for control functions in a broad variety of electronic applications.

time to read

1 min

September 2025

Circuit Cellar

Circuit Cellar

Harwin Brings Through-Hole Retention to Industrial Kontrol Range of Connectors

Harwin has extended its Kontrol lineup of connectors for industrial and embedded applications, adding through-hole retention to further enhance resilience and board-level reliability in harsh operational environments. Harwin has added 72 new products to the industrial connector family, extending the range by 48%.

time to read

1 min

September 2025

Circuit Cellar

Circuit Cellar

Renesas Introduces 64-bit RZ/G3E MPU for High-Performance HMI Systems Requiring AI Acceleration and Edge Computing

Renesas Electronics Corp., a premier supplier of advanced semiconductor solutions, announced the launch of its new 64-bit RZ/G3E microprocessor (MPU), a general-purpose device optimized for high-performance Human Machine Interface (HMI) applications.

time to read

1 mins

September 2025

Circuit Cellar

Circuit Cellar

Build a Follower Counter for Social Media

See Real-Time Metrics Using an Arduino Yún

time to read

20 mins

September 2025

Circuit Cellar

Circuit Cellar

Nordic Semiconductor Announces Highly Integrated nPM3104 Power Management IC With Support For Small-Size Battery Products

Nordic Semiconductor announced the new nPM1304 Power Management IC (PMIC). Building on the success formula of the well-established nPM1300, the nPM1304 offers the ideal solution for space-constrained applications that require small batteries.

time to read

2 mins

September 2025

Circuit Cellar

Circuit Cellar

Chaos on Your Desktop

Build a Color-Pulsing Light Sphere Using a PIC or Raspberry Pi Pico MCU

time to read

9 mins

September 2025

Circuit Cellar

Circuit Cellar

NXP’s New Battery Cell Control IC Family Advances New Energy Solutions

NXP Semiconductors announced its new 18-channel Li-ion battery cell controller, the BMx7318/7518 IC family, designed for electric vehicle (EV) high-voltage battery management systems (HVBMS), industrial energy storage systems (ESS) and 48V battery management systems.

time to read

1 mins

September 2025

Circuit Cellar

Circuit Cellar

Autonomous Mobile Robots

Robots Moving to Their Own Beat

time to read

12 mins

September 2025

Circuit Cellar

Circuit Cellar

The DVM on Your Wrist

A Wireless Link Between A DVM and a Smart Watch

time to read

18 mins

September 2025

Circuit Cellar

Circuit Cellar

Control Your Local IoT Network from the Cloud

Secrets of “Cloud Relaying” Revealed

time to read

5 mins

September 2025

Listen

Translate

Share

-
+

Change font size