Data acquisition and device control with Scilab.
Desciription
Scilab is a freeware alternative to MATLAB. For low-cost data acquisition and device control a nice Arduino toolbox is available.
This site presents a Mbed port which allows to use Mbed boards (equipped with Arduino header) rather than Arduino to import real time data into Scilab and to control real equipment witch Scilab.
Installation
- Install Scilab to your PC, if not done yet.
- Launch Scilab and install the Arduino toolbox by executing the following command from the Scilab console:
--> atomsInstall("arduino")
Controlling Mbed's digital output from Scilab
- In Xcos open
examples/Arduino1.zcos
- Double click on the
Board
setup block and replace the serial port number with mbed's actual virtual serial port number.
- Double click on the
Digital WRITE
block and set Digital Pin to 13 (D13 is connected to LED1).
- Start simulation and LED1 on the Mbed board should start blinking.
Reading and displaying Mbed's analog input
- In Xcos open
examples/Arduino2.zcos
- Double click on the
Board
setup block and replace the serial port number with mbed's actual virtual serial port number.
- Double click on the
Analog READ
block and set Analog Pin to 2.
- Start simulation and a graph should appear showing the analog signal measured on Mbed's pin A2.
NOTE: Currently, there is bug in the toolbox ARDUINO_ANALOG_READ_sim function (I have reported to Scilab) so the analog readings are not correct.
PID controller
- In Xcos open
examples/Arduino9.zcos
ScilabSerial/Encoder.h@0:295b7e1c12f3, 2021-01-18 (annotated)
- Committer:
- hudakz
- Date:
- Mon Jan 18 19:51:22 2021 +0000
- Revision:
- 0:295b7e1c12f3
Data acquisition and device control with Scilab.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hudakz | 0:295b7e1c12f3 | 1 | #ifndef ENCODER_H |
hudakz | 0:295b7e1c12f3 | 2 | #define ENCODER_H |
hudakz | 0:295b7e1c12f3 | 3 | |
hudakz | 0:295b7e1c12f3 | 4 | #include "mbed.h" |
hudakz | 0:295b7e1c12f3 | 5 | |
hudakz | 0:295b7e1c12f3 | 6 | class Encoder |
hudakz | 0:295b7e1c12f3 | 7 | { |
hudakz | 0:295b7e1c12f3 | 8 | InterruptIn* _chanA; |
hudakz | 0:295b7e1c12f3 | 9 | InterruptIn* _chanB; |
hudakz | 0:295b7e1c12f3 | 10 | int8_t _position; |
hudakz | 0:295b7e1c12f3 | 11 | public: |
hudakz | 0:295b7e1c12f3 | 12 | Encoder(PinName pinA, PinName pinB, int mode); |
hudakz | 0:295b7e1c12f3 | 13 | ~Encoder(); |
hudakz | 0:295b7e1c12f3 | 14 | int8_t position() { return _position; } |
hudakz | 0:295b7e1c12f3 | 15 | void reset() { _position = 0; } |
hudakz | 0:295b7e1c12f3 | 16 | void onRiseMode1(); |
hudakz | 0:295b7e1c12f3 | 17 | void onChangeMode2(); |
hudakz | 0:295b7e1c12f3 | 18 | void onChangeMode4(); |
hudakz | 0:295b7e1c12f3 | 19 | }; |
hudakz | 0:295b7e1c12f3 | 20 | #endif // ENCODER_H |