THIS IS THE TEST SITE OF EUROBRICKS!
Search the Community
Showing results for tags 'qbasic'.
-
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. 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 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 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 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\; 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 …): 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”.
- 8 replies
-
- control lab
- 9751
-
(and 2 more)
Tagged with: