Jump to content
THIS IS THE TEST SITE OF EUROBRICKS! ×
THIS IS THE TEST SITE OF EUROBRICKS!

Recommended Posts

Posted

Dear All,

this post was originally focused more on getting QBASIC (or QuickBASIC, TurboPascal, TurboC, VisualBasic for DOS, and whatever DOS video game you ever played back in the days, and of course all the LEGO DOS software, for e.g. #9750 and #9751), rather than controlling Control Lab with QBASIC, but I turned it around, as getting DOS running on (e.g.) Win11/64 bit is really straight forward, so I made that the second part of this post.

1.) Controlling #9751 with QBASIC

This has been posted already briefly in the dedicated EB “Dacta Control Lab Software” thread, however, it very quickly drowned there, as two experienced people (@Bliss and @Gunners TekZone) are discussing/developing some very exciting, really powerful up-to date software that can handle multiple #9751 boxes, and so much more! After 5 pages of discussion, I have totally lost it in that thread, but it all sounds absolutely cool to me.

This contribution is more for the ssimple-minded people = me. Some of you may have noticed that I am a very BASIC person. It began in 1982 with the Sinclair ZX81 … and never stopped. Well, if you count VisualBasic6.0 as BASIC. But I am back to the roots; as said, even VB is essentially above my head, I am using it as if it were – well – QBASIC.

Here is the QBASIC program I made for #9751 control; either manually or via QBASIC program control. There are a couple of convenience subroutines such as “SetPower O.A + O.B + O.F”, which – guess what – sets the power for outputs A, B, F. It is all for my personal use, but maybe some diehards want to play with is as well – and maybe not.

Q9751_3%20in%20DOSbox-X.jpg
 

https://bricksafe.com/files/Toastie/lego-interface-b-9751/Q9751_3.BAS

https://bricksafe.com/files/Toastie/lego-interface-b-9751/Q9751_3.EXE

These may >slightly< change, but the name/link will remain the same. For example, I have no temperature sensor, so I can’t test it, so it is not in the code, but that is a matter of two or so code lines.

Here is a (crappy as usual) YT video demonstrating a bit how it works:

The list of “convenience subs” is small, but sufficient for my purposes (simple robotics). As all sensor/input data are pre-processed within #9751 and sent 50 times/second encoded as a 19 byte word [16 x 2 bytes composed as 16 bit word: 10 bit A/D value, 2 bit #transitions (high/low or low/high = 1 count), 1 bit open/close, 3 bits rotation clicks/direction + 2 leading bytes and one trailing checksum byte for each sensor – regardless of type attached (none, touch, light, temperature, rotation], there is one array in the program carrying these data all the time: IDproc (Input Data processed). Note that each analog value change may also generate transition and rotation click counts; the latter make only sense when the sensor connected to the input port is “suitable” for such counting. In other words: A touch sensor may generate meaningful transition counts but certainly useless rotation click counts and so on. Output data are stored as well in the array OStatus, but that is usually irrelevant when making user programs.

Convenience sub routines for outputs:

OutputFwd O.A + … O.H
OutputRev O.A [+ … O.H]
OutputOn O.A [+ … O.H]
OutputStop O.A [+ … O.H], O.BREAK/O.COAST
OutputPower O.A + … O.H, 0 … 7 (0 = lowest power level, but not stopped)

Inputs:

(int) X = IDproc(1 … 8, ANALOG/TRANSITIONS/ROTCLICKS)
ClearCounter 1 … 8

(The latter resets the accumulated transition counts and rotation clicks for sensor 1 … 8)

Program interaction:

UPWaitForAnyKey
UPMessage(“Text”)

Other than that, the full suite of QBASIC commands and functions is available :pir-stareyes:

Here is a short "user program" (something like this is what I use for my robotics stuff = TC robot arms, the dinosaur, LEGO camera stand, and so on):

SUB UserProgramB

  OutputPower O.C + O.D, 0 	‘set lowest output power
  UPWaitForAnyKey
  OutputOn O.C + O.D 		‘turn outputs on at lowest power level
  Delay .1 					‘seconds
  FOR i% = 1 TO 7 			‘ramping up power
    OutputPower O.C + O.D, i%
    Delay .1
  NEXT i%
  ClearCounter 8   			‘sensor generating rotation clicks needs to be present on input 8
  UPMessage ("Turn rotation sensor until clicks > 20 (or any key)")
  ‘loop here until rot clicks > 20 or any key is pressed
  DO: LOOP UNTIL (IDProc(8, ROTCLICKS) > 20) OR LEN(INKEY$)
  ‘stop motors with coasting motors (outputs are not shorted)
  OutputStop O.C + O.D, O.COAST

END SUB

 

2.) Getting DOS to run on your modern computer

There are many solutions, but one very convenient route is: “Install” (=unzip) DOSBox-X to any folder on your hard disk. At the time of this writing, the latest version is 01.01.2025 – rather current, I’d say. There is a Windows, Linux, MacOS, and DOS version (one can emulate “another” DOS within DOS …):

https://dosbox-x.com/

(Links on that webpage point to GitHub direct downloads)

Then open the configuration file “dosbox-x.conf” with a text editor (none of the other .conf files) – it is a sheer endless list of configuration entries. I do ignore them all but

  1. the serial port settings (around line 900) to change the port mapping; in my case I have USB2Serial/USB2TTL adapters and serial-over-Bluetooth devices  mapped to real com ports 1,7,8 (=COM1,2,3 in QBASIC; Windows: The “realports” are those appearing in device manager under COM&LPT):
    [serial]
    serial1       = directserial realport:COM1
    serial2       = directserial realport:COM7
    serial3       = directserial realport:COM9

     
  2. Change the config.sys equivalents in the [config] = second last section – I only added paths(s) to the existing entry, which are relative to your mounting point:
    set path = Z:\;Z:\SYSTEM;Z:\BIN;Z:\DOS;Z:\4DOS;Z:\DEBUG;Z:\TEXTUTIL;C:\QB45\LIB\;C:\QB71\BINB;C:\QB71\LIB\;

     
  3. And lastly, change the mounting point for your hard drive in the [autoexec] section; I am just mounting a logical drive C at C:\_DOSBox-X\
    [autoexec]
    # Lines in this section will be run at startup.
    # You can put your MOUNT lines here.
    mount C C:\_DOSBox-X\
    c:

The mounted C drive has DOSBox-X in its own subdirectory, as QBASIC, QuickBASIC, Turbo Pascal and so on and so forth, have. The entire directories listed in Windows explorer are also available in the DOS window that shows up when starting “dosbox-x.exe”; copying/pasting files is just a matter of using Win explorer (or using DOS …):

DOSbox-X%20in%20explorer.jpg

That was it. Deinstallation = deleting the DOSBox-X folder … but why would you want to do that!

All the best,

Thorsten

P.S.: All the programming languages and LEGO programs mentioned and so much more DOS stuff is freely available on the net. These are generally everything else but memory monsters – QBASIC.EXE for example is less than 200 kByte “long”.

 

 

Posted (edited)
18 hours ago, Toastie said:

This has been posted already briefly in the dedicated EB “Dacta Control Lab Software” thread, however, it very quickly drowned there, as two experienced people (@Bliss and @Gunners TekZone) are discussing/developing some very exciting, really powerful up-to date software that can handle multiple #9751 boxes, and so much more! After 5 pages of discussion, I have totally lost it in that thread, but it all sounds absolutely cool to me.

Sooo sorry to have overwritten your posts.  

BTW... Thanks, but I am hardly "experienced" I am merely riding on the coattails of @Bliss 's much more advanced work. 

But I can agree, it is often better to keep a topic consistent.  So I am glad you are re-doing this one.  Easier for me as well to keep track of as well :laugh:

I will have to give this a slower and more thorough read... I find I miss way too many details if I rush myself with info-overload.

Edited by Gunners TekZone
Posted (edited)

BTW... It was many a years ago, but I actually tried out a version of BASIC that ran on an ESP32, if memory serves correctly (and now I need to find that again, both the memory and code). 

UPDATE, Is is actually a ROM-based BASIC interpreter already in the SoC.

Now wouldn't that be an interesting combo with the Interface B... And possibly the Interface-A as well?

 

 

 

Edited by Gunners TekZone
Posted
34 minutes ago, Gunners TekZone said:

Sooo sorry to have overwritten your posts.

No, no, no, please don't be - that is entirely OK!!! This is naturally the case in an active conversation/development in a forum thread! And it should be like that. I truly enjoyed all the energy and dedication - and the best part: success :pir-stareyes:

I will closely follow what you guy come up with in the future - it will be exciting.

All the best and have a nice day (OK, relative to UTC+1),
Thorsten

Posted (edited)
13 hours ago, Gunners TekZone said:

Now wouldn't that be an interesting combo with the Interface B... And possibly the Interface-A as well?

For sure!!!

However, regarding Interface A there are ... these rules, you know, carved in stone. And I am obeying @evank :pir-laugh: (You know about his challenge and rules going with it, right?)

An ESP32 board will certainly handle #9751 (I am using Devkit 1's for all PoweredUp stuff running around here - oh as well as for Tenka's circuit cubes running my Pantasy monorail). I have no clue how to get BASIC onto such a board ... that would be nice to know! So far, I am using either the Arduino IDE or the VS Code environment along with C++, without really knowing how C++ works. Trial and error, copy/paste and a little extrapolation of my BASIC knowledge seems to work so far :pir-huzzah2:. Arduino's can do that as well, of course: https://www.eurobricks.com/forum/index.php?/forums/topic/192941-lego-interface-a-97509771-–-lego-technic-control-1-tc1-referenceideas-thread/&amp;do=findComment&amp;comment=3580886

Oh man, back in the days (the late 1980s), when I began working on my PhD thesis, I was allowed to use Intel 8052 MCU's, which had floating point BASIC interpreters on board - man, that was fun! These little thingies calculated gas concentrations in flow tubes from pressure drops in known volumes for me ... yeah, calculators could also do that, but it was usually late in the night and much more fun to have someone working for me ;)

Can you direct me to ESP32 BASIC?

All the best,
Thorsten

Edited by Toastie
Posted
4 hours ago, Toastie said:

regarding Interface A there are ... these rules, you know, carved in stone

Scratched into plastic, anyhow. :laugh:

BTW here is my new feline. We adopted him last weekend. I insisted on naming him "Floppy Diskatte" and my wife went along with it.

 

floppy.jpg

Posted

How nice is this? He looks beautiful!

Say hello from our two cats (brother and sister, we found them 10 years ago during a trash cleaning type thing - "adopt a recreation area" - I shall find a picture ...)

But be aware - when he is allowed to move freely in the neighborhood - and you call him for dinner. Just imagine Hard Discharlie shows up :pir-wink:

Have fun with the new family member!

Best,
Thorsten 

Posted
On 1/10/2025 at 12:38 AM, Toastie said:

I am using Devkit 1's for all PoweredUp stuff running around here

Does that mean that you've written some Arduino code to control PUP motors with an ESP32 ? I mean not only to power them, but also to read their sensors' data ?

PUP has quite a sophisticated serial link which uses 2 out of 6 wires in the PUP plug. And while LEGO has opened it's wireless protocol for Bluetooth communication with modern Technic's hubs, the wired serial link with motors/sensors is not officially documented. As I have some interest in developing a DIY RC-controller for LEGO motors, the best materials I've found yet are 1) reverse engineering by Philo (link 1) 2) pybricks sources (link 2). I guess BuWizz developers also have a good understanding of that, but their firmware is not opensource.

Posted
20 hours ago, LabManager said:

Does that mean that you've written some Arduino code to control PUP motors with an ESP32 ?

Oh no, none of that! I am using ESP32's simply as clients for the LEGO PUp servers (predominantly the 2-port and the 4-port hubs). I simply plugged in Cornelius Munz' Legonio, did minor changes to it, and that's all.

What you want to accomplish is wayyyy over my head!

All the best,
Thorsten 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...