Author Topic: Lightweight Scripting Language for MCUs  (Read 28236 times)

0 Members and 1 Guest are viewing this topic.

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6514
  • Country: fi
    • My home page and email address
Re: Lightweight Scripting Language for MCUs
« Reply #125 on: May 24, 2024, 02:11:06 pm »
My requirements would be
  • access to local variables, e.g. to get/set control parameters "visible" on the front panel or over GPIB
  • no if-then-else statements, nor anything equivalent
  • no procedures/functions/macros
Yep.  Depending on the use case, one might also wish to disable redefinition of user-defined variables (read-only global/local context), too.

As a practical example, consider some stepper motor motion controller configuration:

To convert between steps and human length units, you need something like
    STEP_SIZE = 0.1 ; mm per step

However, if the user happens to have a belt drive, it would make things much better documented if they could use
    belt_pitch = 2 ; mm, using GT2 belt
    pulley_teeth = 20
    pulses_per_turn = 400 ; half-stepping
    STEP_SIZE = belt_pitch * pulley_teeth / pulses_per_turn
where for illustration only, I've used uppercase for the actual configuration item, and lowercase for user-defined variables.

After switching to a ball screw, users might use
    thread_pitch = 8 ; mm, using T8x8
    pulses_per_turn = 400 ; half-stepping
    STEP_SIZE = thread_pitch / pulses_per_turn

The "standard" solution is to split the step size into two or more parameters, so that instead of specifying the STEP_SIZE directly, you specify some terms (typically a numerator and a denominator).  I don't like that AT ALL, because it hides what is actually important to the firmware, and instead tries to force some kind of pattern or way the device is to be used.
 

Offline nimish

  • Regular Contributor
  • *
  • Posts: 175
  • Country: us
Re: Lightweight Scripting Language for MCUs
« Reply #126 on: June 06, 2024, 02:29:12 am »
It's 1000x faster to bring up a sensor board with micropython/circuitpython than to write and flash compiled firmware

i wouldn't use it for anything at the extremes of performance but it's a great little tool for interactively messing with i2c/spi devices
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 20027
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Lightweight Scripting Language for MCUs
« Reply #127 on: June 06, 2024, 08:18:31 am »
i wouldn't use it for anything at the extremes of performance but it's a great little tool for interactively messing with i2c/spi devices

There are other tools that can be considered for that, e.g. a BusPirate5.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1020
  • Country: es
    • Picuino web
Re: Lightweight Scripting Language for MCUs
« Reply #128 on: June 07, 2024, 01:35:32 pm »
https://github.com/totalspectrum/tinyscript

Quote
Introduction

This is tinyscript, a scripting language designed for very tiny machines. The initial target is boards using the Parallax Propeller, which has 32KB of RAM, but the code is written in ANSI C so it should work on any platform (e.g. testing is done on x86-64 Linux).

On the propeller, the interpreter code needs about 3K of memory in CMM mode or 5K in LMM. On the x86-64 the interpreter code is 6K. The size of the workspace you give to the interpreter is up to you, although in practice it would not be very useful to use less than 2K of RAM. The processor stack is used as well, so it will need some space.

tinyscript is copyright 2016-2021 Total Spectrum Software Inc. and released under the MIT license. See the COPYING file for details.
 

Offline nimish

  • Regular Contributor
  • *
  • Posts: 175
  • Country: us
Re: Lightweight Scripting Language for MCUs
« Reply #129 on: June 07, 2024, 10:40:45 pm »
i wouldn't use it for anything at the extremes of performance but it's a great little tool for interactively messing with i2c/spi devices

There are other tools that can be considered for that, e.g. a BusPirate5.

That's a lot more work than simply loading a different firmware image once not to mention it cannot replicate how the specific MCU you are using would actually communicate
 

Offline Sal AmmoniacTopic starter

  • Super Contributor
  • ***
  • Posts: 1741
  • Country: us
Re: Lightweight Scripting Language for MCUs
« Reply #130 on: June 12, 2024, 07:40:29 pm »
@Sal: I've been messing with your dilemma for 40years already. The only "really interactive and complete" MCU tool fully running on a target is Forth, imho.  Well, you have to overcome the initial mental barrier first.
Btw, I read a guy from NZ is claiming his Forth can do Basic - ABCForth..

I didn't realize this thread, which I created nearly 8 years ago was still alive.

Personal update: I ended up implementing Forth for the STM32. It's about 1200 lines of ARM assembly code plus Forth code to implement more complex words. I don't use it very often, but when I need it it does come in handy.
"That's not even wrong" -- Wolfgang Pauli
 

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2247
  • Country: pr
Re: Lightweight Scripting Language for MCUs
« Reply #131 on: June 16, 2024, 09:38:15 pm »
@Sal: I've been messing with your dilemma for 40years already. The only "really interactive and complete" MCU tool fully running on a target is Forth, imho.  Well, you have to overcome the initial mental barrier first.
Btw, I read a guy from NZ is claiming his Forth can do Basic - ABCForth..

I didn't realize this thread, which I created nearly 8 years ago was still alive.

Personal update: I ended up implementing Forth for the STM32. It's about 1200 lines of ARM assembly code plus Forth code to implement more complex words. I don't use it very often, but when I need it it does come in handy.

What forth did you use?  I know there are many which run on ARMs.
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf