Software Drivers for Scientific Devices in the Most Common Computer Languages on All Major Operating
Total Page:16
File Type:pdf, Size:1020Kb
COMPUTER LOGICIEL — MÉTROLOGIE The Mensurasoft-System: Software Drivers for Scientific Devices in the Most Common Computer Languages on All Major Operating Systems with a Prototype API for Measurement Data Processing Applications - Practical Examples P. Dieumegard * Independent Researcher, Orléans, France Abstract For years now, although many scientific devices have a port for computer connection, the diversity of various con- nection types results in lack of software able to use the totality of them. This paper presents how to: (1) build software drivers with a prototype Application Programming Interface API for scientific devices using dynamic libraries under various combinations of connection ports, programming languages and operating systems, (2) employ these drivers in software programs capable of managing more than one device at the same time, and (3) use two specific software imple- mentations of this whole Mensura (Measurement) System to se- lect appropriate built driver, define communication set- tings, and collect-store-process-present experimental data. Keywords Mensurasoft, measurement, devices, dynamic library, pro- gramming languages, MS-Windows, Linux, driver Introduction ally through an ISA, PCI or In this paper, "scientific RS-232, but nowadays via USB devices" are mainly measure- too. ment devices: pHmeters, volt- Sometimes there is soft- meters, thermometers etc, but ware to use them, often there sometimes they are actuators: is no software. When a soft- motors, heaters, voltage-gen- ware is sold or given with a erators etc. Many scientific device, it can be used only devices can be connected to a with this device or similar computer; in the past, usu- devices from the same sup- MONDAY 14 SEPTEMBER 2015 v1—7 FUNKTECHNIKPLUS # JOURNAL P. DIEUMEGARD plier. This causes problems program for his/her aim. to professional scientists, In the present work we will as well to teachers of sci- show how to use "scientific ences, and to simple amateurs drivers" from the system Men- of sciences. Can we imagine surasoft named by the Latin programs able to manage all word mensura which means mea- of them? sure. Fig. 1 gives an illus- This problem is similar to tration of the Mensurasoft that of office software: how system architecture: separa- to make programs (spread- tion between programming for sheets, word-processors etc) devices and programming for able to manage all printers - humans is an obvious neces- not only already existing sity. printers, but also the print- ers which will appear in the The necessity of Drivers next years. The solution is The construction of scien- similar; by using device dri- tific devices is not easy. vers. There is a printer dri- Making a pHmeter is a job for ver for each printer, and we specialists, with special can make a driver for each glasses for the electrode, measurement driver. special electronics, correc- However, there are two dif- tion for temperature, etc. In ferences between office pro- the same way, building a pre- grams and scientific pro- cise scale to measure weight, grams. Scientific devices are or an accurate lux-meter are more various than printers, works of specialists. These and usually produced in small specialists can supply a pro- quantities. Scientist often gram for their devices, but must make himself/herself the not for others. Computer measurement device driver main program user Fig. 1: Mensurasoft System FUNKTECHNIKPLUS # JOURNAL v1—8 ISSUE 8 — YEAR 3 THE MENSURASOFT-SYSTEM: SOFTWARE DRIVERS FOR SCIENTIFIC DEVICES A professional scientist On the other hand, almost needs several scientific de- all programming languages can vices. For example, in eco- use dynamic libraries, inclu- logy, we must measure accu- ding office software such as rately temperature AND pH AND Openoffice/LibreOffice, or the light: there are not programs calculation specialists for from devices makers for all example FreeMat [2], Scilab them. A teacher of sciences [3] Julia [4], R [5], and needs to show to the students tools for general programing how to make an experiment. If as Basic, C/C++, Pascal, Py- there are several models of thon, Ruby, Rebol. measurement devices in the In order to use dynamic li- classroom, with different soft- braries for all scientific de- ware, the explanations will be vices, we must standardize the very difficult for the tea- functions, giving them the cher, who dreams about one same name in all the drivers. piece of software for all "Mensurasoft system" is a pro- these devices. posal for a possible stan- Drivers for measurement de- dard: the names are short and vices must be simple and easy consist of combination of let- to use, because science work- ters. ers may not have great skills in programming. They must be Fundamental functions and usable with a lot of program- additional properties ming languages, in order to Computer must receive mea- be used by many people. sures from the measurement device, and the driver needs Dynamic Libraries as a function for this input. In Drivers Mensurasoft system, the name Dynamic libraries are pie- of this input function has ces of compiled program, with the letter "e" (as "entrée" functions callable by others in French, "eingang" in Ger- programs; they are standard- man, "entrada" in Spanish, ized and available in major "entrata" in Italian and "en- operating systems: MS-Win- try" in English). This is the dows, Linux (named "shared ob- main job. jects") and Mac-OS [1]. Many If the device has an actu- programming languages can ma- ator, computer must send a ke dynamic libraries, often value to the device, in order available as free software, to change its state. In Men- but they must be compiled surasoft system, the name of ones, such as: C/C++, Pascal, this output function has the and some kinds of Basic. letter "s" (as "sortie" in MONDAY 14 SEPTEMBER 2015 v1—9 FUNKTECHNIKPLUS # JOURNAL P. DIEUMEGARD French, "salida" in Spanish). to the first channel, 1 to Inputs and outputs can be the second and so on. digital or binary if there Output functions have two are only two values as "yes/ parameters. The first is the no", "1/0", "on/off", repre- number of the channel, as for sented with the letter "b" in input functions, and the sec- Mensurasoft. They are analog ond is the value to be set by if there are a great number the device (integer or "dou- of values, for example when ble"). we measure temperature, volt- In programming languages, age or pH: in Mensurasoft, there are several ways to the letter is "a" for them. pass parameters to a function: Computers use different ty- stdcall, cdecl, pascal, and pe of numbers: integers or others. "stdcall" is more used reals ("floating"). Reals are in Windows world, "cdecl" in often coded as "double" (dou- Linux world, but this is no ble precision), using 8 bytes mandatory. In order to use (64 bits), and integers can all of them, we must put a be coded on 4 bytes (32 prefix "std" if the declared bits). When the result of an function is "stdcall" and "c" input function (or the value if the function is "cdecl". to be set by an output func- For example, in Mensura- tion) is an integer, there is soft system, the first analog no special letter, but when input channel sending a real the result or the value is a (double) is stdead(0) with "double", a letter "d" is the calling convention "std- added. call"; the second binary out- Sometimes (often) there put is stdsb(1,1) if it is are several inputs. For exam- set to "On" and stdsb(1,0) if ple, the little Arduino Uno it is set to "Off"; with has 6 analog inputs; a simple "cdecl" convention, the third thermometer only measures tem- binary input is ceb(2) and the perature at one sensor, but fourth analog output set to we could have the results ei- 3.44 is csad(3, 3.44). ther in kelvins or in Celsius That is enough for main or even in Fahrenheit system, programming languages, but thus three (3) analog inputs there are some among them are needed. So the input which want other functions. functions have one parameter Some languages accept parame- meaning the channel for mea- ters only as "double", even surement which is usually for the channel number: in- coded as integer without a stead of "d", we put "double" special letter; 0 corresponds to show that all parameters FUNKTECHNIKPLUS # JOURNAL v1—10 ISSUE 8 — YEAR 3 THE MENSURASOFT-SYSTEM: SOFTWARE DRIVERS FOR SCIENTIFIC DEVICES and results are in double pre- a. when we do not know the cision. Some languages deals channels of the device: we with parameters and results can ask cnead(0), cnead(1), only as "strings": we can add cnead(2) and so on in order "str" at the end, and then to find out them the word stdeastr (0), for example, stands for the first b for general purpose soft- analog input. Others need spe- ware with menus and dialog cial functions (R, Scilab) in boxes: to show all analog in- the dynamic library, but they puts the programmer is able are not included in the pre- to use a loop, asking the na- sent work. A detailed outline me of the analog input until of the naming procedure for this name is empty. functions in the Mensurasoft system is shown in Fig. 2. Additional string func- tions can be added for more Additional string comfortable use. A function functions "detail" could provide infor- mation about the device such In Mensurasoft system each as the company identity, the numerical function as already device name, the programmer's has been mentioned above has name, the date of programming its name, coded by a string etc.