SmallBASIC was ported to the Teensy 4.0 and 4.1. Have fun using SB on this fast and easy to use microcontroller. For details see our Teensy guide.
What is the size of the Tx and Rx buffers for serial Comms? Is there a road-map for this development (features, capabilities, etc)? I’m gonna have to get one ![]()
![]()
I don’t have a real roadmap, but I would like to implement the following features (in this order, somehow)
- LittleFS for storing the SmallBASIC program and data in flash memory. Run the stored SB program at Teensy startup
- Accessing SD card from your SB program
- SPI → many displays
- OneWire → i.e. Dallas temperature sensor DS18B20
- Examples for more I2C devices
Here are some information about Rx and Tx buffer:
- USB serial: in principal a huge buffer managed by the operating system and the Teensy usb core: Teensyduino: Using USB Serial with Teensy on the Arduino IDE
- Hardware UARTS (serial 1 to 8): 64 Bytes software buffer. Can be increased with
Increasing buffer size for Teensy 4.1 | Teensy ForumSerial6.addMemoryForRead(serial6RXbuffer, SERIAL6_RX_BUFFER_SIZE)); Serial6.addMemoryForWrite(serial6TXbuffer, SERIAL6_TX_BUFFER_SIZE);
Let me know if you really need this feature.
If you have other ideas what to implement, let us know.
64 bytes/port is good for me.
Presumably, changing the PWM resolution is already planned?
There is a library; HardwareQuadratureDecoder which handles multiple high speed encoders without CPU overhead. I don’t suppose it would be a simple matter of creating a wrapper?
I see that the 4.1 can handle ethernet. Any plans for this?
Will there be a hardware (deterministic) timer interrupt?
This is gonna be awesome
![]()
- PWM and changing PWM resolution is already implemented: SmallBASIC | teensy
- I can implement: Encoder Library, for Measuring Quadarature Encoded Position or Rotation Signals
- No plans for Ethernet yet.
Oh fantastic, can we also include:
We will have the basis of a full blown CNC that uses servo motors as opposed to steppers ![]()
![]()
![]()
The 1ms minimum loop time is OK but if we could get shorter than that, we will be with the big boys ![]()
Oh wait. That isn’t the high speed library, it uses interrupts.
This is the one that I was referring to:
#include <HardwareQuadratureDecoder.h>
HardwareQuadratureDecoder encoder1;
HardwareQuadratureDecoder encoder2;void setup() {
Serial.begin(115200);// Initialize two encoders on different pins encoder1.begin(2, 3); // Encoder 1 A and B pins encoder2.begin(4, 5); // Encoder 2 A and B pins}
void loop() {
int32_t count1 = encoder1.getCount();
int32_t count2 = encoder2.getCount();Serial.print("Encoder 1 Count: "); Serial.println(count1); Serial.print("Encoder 2 Count: "); Serial.println(count2); // Additional logic...}
It even supports Index and trigger signals…. Perfect ![]()
![]()
![]()
Interactive mode: Meaning that it’s possible to do things like interrogate and/or change the value of a variable during program execution? ![]()
![]()
oh, maybe the name is misleading. Interactive modes means, that you can upload a new program via serial whenever you want. SmallBASIC will detect the upload, stop the current program and start the newly uploaded one.
Any updates to come, maybe SPI support?
no updates so far. Currently I’m working on the improved console version of SmallBASIC. Linux is running quite nice now. I started to get also Windows working. After finishing this I will get back to Teensy. Most probably I will start with SPI and storing several programs in Flash memory.
Sounds great. I haven’t pulled the trigger on buying a Teensy until I am sure that I can make use of it but I wonder if you could give me a couple of benchmarks?
Floating point
dim x as single
x=1000000
while x>1
x=x/1.0001
i=i+1 ' -- count iterations -- about 138K
loop
Integer
i=1000000
while i
i=i-1
loop
Don’t go out of your way, only if it is convenient
![]()
Here are the benchmarks you asked for. I additionally added a pin toggle benchmark.
What kind of MCU/BASIC you are using? Do you have benchmark results for comparison?
x = 1000000
a = ticks()
while x > 1
x=x / 1.0001
i=i+1 ' -- count iterations -- about 138K
wend
b = ticks()
print "Time: "; b - a; "ms Loops: "; i
Time: 443ms Loops: 138163
x = 1000000
a = ticks()
while x
x = x - 1
wend
b = ticks()
print "Time: "; b - a; "ms"
Time: 1628ms
OUT = teensy.OPENDIGITALOUTPUT(13)
state = 0
a = ticks()
for x = 1 to 1000000
OUT.WRITE(state)
state = !state
next
b = ticks()
print "Time: "; b - a; "-> "; round(1000000/(b-a)); "kHz"
Time: 3294ms → 303kHz
I am currently evaluating the very new ARMbasic on the Pico 2 (RP2350 @150MHz150MHz)
Time for float BM: 45ms
Time for integer BM: 80ms
I/O toggle:
main:
Output(PICO2_LED) ' sets pin direction
a=timer
while X<1000000
x=x+1
Out(PICO2_LED) = x and 1 'sets pin state
loop
b=timer
ms_time = (b-a)/1000 'timer is microseconds
print "Time: "; ms_time; "-> "; 1000000/ms_time; "kHz"
end
Time: 270-> 3703kHz
Coridium ARMbasic (BUT THIS IS A COMPILER
)
However, I was more interested in a comparison with what I actually use which is MMBasic on the “PicoMite” (RP2350). I am overclocked to 378MHz:
Float BM: 805ms (your Teensy: 443ms)
Integer BM: 3191ms (your Teensy: 1628ms)
Output toggle BM: 6203ms (your Teensy: 3294ms)
Many thanks. Teensy is exciting
![]()