Menu

Microsoft Small BASIC remote control Microcontroller!

Anobium
2019-02-05
2019-07-25
  • Anobium

    Anobium - 2019-02-05

    I thought it was worth sharing an approach I have been using to communicate between a host computer and a microcontroller.

    I have been using Microsoft Small BASIC to create small and fast programs – this a lot easier that using a number of the more complex IDE alternatives.

    Microsoft Small Basic 'is a programming language created specially to help students transition from block-based coding to text-based coding. By teaching the fundamental elements of syntax-based languages in an approachable manner' to quote Microsoft.

    So, the little video shows how to create a simple application to communicate between a host computer and an UNO.

    Sharing: Source code and the tools are here: https://github.com/Anobium/Great-Cow-BASIC-Library-Development/tree/master/MicrosoftSmallBASIC

    Enjoy

     

    Last edit: Anobium 2019-02-05
  • Moto Geek

    Moto Geek - 2019-02-05

    Thanks for sharing this. I never even heard of small basic before. This is a great resource for us basic users to interface to a PC. I am assuming we can use a typical USB to serial for use on a PIC project. I will have to try this out for sure. There have been many times where this would have come in handy in the past as I was always a bit reluctant to try and write any code for a PC to communicate with a PIC other than using serial term, etc.

     

    Last edit: Moto Geek 2019-02-05
  • David Stephenson

    Thanks for bringing small basic to my attention. It looks very useful. I've downloaded it already and managed 3 "unrecognised statements" in 3 lines! (do loops are not supported).
    Is there a tutorial that covers serial communication (It does not feature in the introductory guide).

     
  • David Stephenson

    It's never as easy as it looks. The comport commands are "extensions" contained in the LITDEV files and need to be placed in the ...smallbasic\lib folder. There is suitable documentation in the LITDEV...rtf files (avoid the ones in German) to explain the COM options.
    Anyway it looks interesting I have been using QB64 for serial communication and sadly newer versions of QB64 do not work reliably for serial communication (older versions are ok). The problems started when they switched from SDL to openGL. The whole QB64 project has become abandonware.

     
    • Anobium

      Anobium - 2019-02-05

      The LitDEV is very cool. When create an exe the lib and the dlls are created/moved into your project folder - very cool.

      I am glad this has helped. The whole Small BASIC project is very intereting.

      :-)

       
      • David Stephenson

        I've now tried it on serial communication. Yes it works, but it is limited (it is making a virtue out of this). Maybe I prefer a "bigger" version of basic (I don't have to use all the features after all). I've found the limitation on data types (single bytes or strings) and output formatting (none) is the drawback.
        I also tried freebasic but it was not quick enough to capture the data stream from a FT201X.
        So I've gone back to QB64 (which has a new version out) and this works nicely (the data is coming in at about 200kbaud) and I can read it in as an unsigned integer and format the output with the PRINT USING.

         
  • stan cartwright

    stan cartwright - 2019-02-05

    Small basic is new to me. I must understand serial. I looked up using freebasic to open a usb uno port.
    The comport handling of FreeBasic expects a high signal on DSR line by default after opening a comport.
    You can suppress that by adding DS0 as extendet option.
    comrtn=Open Com("COM4:9600,N,8,1,DS0" AS #a)
    should do the job.
    I recommend to use:
    comrtn=Open Com("COM4:9600,N,8,1,CS0,DS0,CD0" AS #a)

    all very complicated for me. I'm suprised freebasic is never mentioned.

     
    • Anobium

      Anobium - 2019-02-06

      I use FreeBASIC when appropiate. Many of the Great Cow BASIC converters are written and compiled using FreeBASIC.

      And, of course. Great Cow BASIC is compiled using FreeBASIC.

      The IDE manager is FreeBASIC.

      Oh the list is long.

      Microsoft Small BASIC will have its use cases.

       
  • stan cartwright

    stan cartwright - 2019-02-06

    I didn't want to detract from small basic.
    fb is the only tool I can use to write a rpi app... and win, not that I use it often.
    I find rpi python too difficult.

     
  • Frank Steinberg

    Frank Steinberg - 2019-02-10

    The real >small< Basic for me is "Libert Basic Booster" (LBB). The download of 516 kB (kB - not MB, not GB!) comes with an editor incl. debugger. The syntax is compatible to Liberty Basic. LBB can easily generate windows GUIs. Support for the serial port is built in. Generated EXEs run without dependencies on special DLLs with a size from 114 kB.

    Free download :
    http://www.bbcbasic.co.uk/lbb/index.html

    Project, I've realised with LBB (german - but useful links for LBB at the bottom of the page):
    https://www.franksteinberg.de/BLHeliTV.html

    Sample code:

    '- SendToCom.BAS ------------------------------------------------ >>fst'19<< -
    ' - Send text to a serial port.
    ' - Operation via a GUI (window) with buttons.
    ' - Searches all available ComPorts.
    ' - Programming language = LB Booster  http://www.lbbooster.com 
    '- V 20190211 -------------------------------- https://www.FrankSteinberg.de -
    
     NoMainWin            'don't show console window
    
     '*** Search all available ports and put to ComboBox:
     Global Selected$     'make values available in Subs
     Dim ComboPort$(257)  'create array for ComboBox
     For i = 1 to 256     'Windows allows COM1 - COM256
      Try                 'try to open all possible ports
       'ATTENTION: The code for open a serial port is different from Liberty-Basic:
       Open "COM"+Str$(i)+": baud=9600 parity=n data=8 stop=1 odsr=off octs=off idsr=off" For Random As #ComPort
       ComboPort$(i) = "COM"+Str$(i)
       Close #ComPort
      End Try
     Next
    
    '*** Build GUI:
     WindowWidth = 230 : WindowHeight = 220   'dimensions of GUI
     StaticText  #main.staticInfo, "Choose ComPort:", 15, 20, 180, 20  
     ComboBox    #main.comboPort, ComboPort$(), ComboSelect, 15, 40, 180, 300
     Button      #main, "Send Hello", BtnHello, UL, 15, 80, 180, 25
     Button      #main, "Send line-break", BtnLineBreak, UL, 15, 120, 180, 25
     Open " SendToCom" for Window as #main    'show mainwindow
     #main "trapclose [quit]"                 '"gosub" to [quit] if user closes mainwindow
     Wait                                     'wait for events
    
    '*** Event-handling:
    
    Sub ComboSelect    'Selection from Combobox done:
        Try : Close #ComPort : End Try          'if necessary, close previously opened port
        #main.comboPort "selection? Selected$"  'put selection to string
        'Open comport; do not check statuslines:
        'ATENTION!  Syntax is different from Liberty-Basic!
        Open Selected$ + ": baud=9600 parity=n data=8 stop=1 to=off xon=off odsr=off octs=off dtr=off rts=off idsr=off" For Random As #ComPort
        Print #main.staticInfo, Selected$ + " opened; 9600 8N1"  'show info on mainwindow
    End Sub
    
    Sub BtnHello      'First Button pressed:
        If Len(Selected$) Then Print #ComPort, "Hello World!";  'Send text to port; check if port selected before
    End Sub
    
    Sub BtnLineBreak  'Second Button pressed:
        If Len(Selected$) Then Print #ComPort, CHR$(13)+CHR$(10);  'Send two bytes "line break" to port; check if port selected before
    End Sub
    
    [quit]            'User closes mainwindow:
        Try : Close #ComPort : End Try  'close ComPort; no error if none was open
        Close #main                     'close mainwindow
        End                             'end program
    
     

    Last edit: Frank Steinberg 2019-02-10
    • stan cartwright

      stan cartwright - 2019-03-07

      LBB is interesting in that I don't need liberty basic.
      Using LBB.exe I get an IDE window and I can type a simple prog to display text and it can run it or make a exe file.
      Lots to learn. references to bbc basic, just basic, qbasic.
      I wouldn't have known about LBB if not for your link. cheers

       
  • stan cartwright

    stan cartwright - 2019-02-12

    The download works..the ide appeared. bit late to try. The homepage running program looks like "gorilla bas"...I got that on my phone. remember it from win 98
    nice one, will try.

     
  • Anobium

    Anobium - 2019-03-08

    I just posted a new Small BASIC program.

    The program enumates the serial ports, creates a nice drop down menu to enable selection of the serial port, then, opens the serial port. The code then sends the entered strings to the LED Matrix (happens to be a UNO).

    See https://github.com/Anobium/Great-Cow-BASIC-Library-Development/tree/master/MicrosoftSmallBASIC/Remote_control_of_UNO_LED_Matrix this URL has all the pieces you need - Small BASIC source (and the DLLs) and Great Cow BASIC user program I am using.

    Enjoy

     
  • Hanspeter

    Hanspeter - 2019-07-16

    Many thanks for opening my parachute as I'm stuck with PowerBasic10, Bob Zale's death was a real drawback.

    What a relief for sore eyes!

    Don't get me wrong, PB10 will work for sometime to come till almighty MS pulls the plug on Win32.

    Kind regards,
    Hanspeter.

     
  • George Towler

    George Towler - 2019-07-16

    Hi Hanspeter, I also use PB10 so I'm curious to know it what way you feel that Small Basic is superior to PB?

     
  • Hanspeter

    Hanspeter - 2019-07-16

    Good day George, isn't your question rather colourful?

    Regards,
    Hanspeter.

     
  • George Towler

    George Towler - 2019-07-16

    Hi Hanspeter, I think your comment got lost in the translation. I only ask because if SmallBasic has some obvious advantage over PB then I will switch.

     
  • Randall Young

    Randall Young - 2019-07-16

    I think M$ SmallBaic is a perfect complement to the efficiency and economy of GCB programing. "Birds of a feather" I think...

     
  • Hanspeter

    Hanspeter - 2019-07-17

    Thank you Randall, need I say more?

     

Log in to post a comment.