Examples here demonstrate how to acquire data in both ascii and binary modes
Prerequisites:
-
Install Python
-
Install Pyserial and Keyboard (from command prompt if you are using Window)
- python -m pip install -U pyserial --user
- python -m pip install -U keyboard --user
- If you are in Linux, and keyboard is not available, you will have to modify the codes reference to it
-
Firmware 1.35 or higher is recommended https://github.com/dataq-instruments/Firmware_Upgrade. Earlier version of firmware may not work properly in binary mode
-
Understand the protocol, please refer to https://www.dataq.com/resources/pdfs/misc/Dataq-Instruments-Protocol.pdf
-
Turn 2xxx/1xxx/4xxx (except 2008) into CDC mode: plug the device to USB port, if the LED already blinks Yellow, stop, you are already in CDC mode. If not, once the LED turns blinking Green, push and hold the button immediately (within 5 second time frame), the LED should turn white, hold until LED turns Red, then release the button, now the LED will blink yellow to indicate CDC mode. If you need to exit CDC mode, repeate the same action and a green blinking LED will indicate LibUSB mode.
-
Find out the COM port in use
Other Examples
Note:
-
If you see error message complaining “failed "import serial module" or "seial doesn't have the attribue of serial", You may have multiple installations of Pythons on your PC, if that's case, please unstall all first before reinstall
-
To single step through PY codes, follow https://stackoverflow.com/questions/4929251/how-to-step-through-python-code-to-help-debug-issues
-
If you have trouble using Python, you can use any serial terminal program (such as TeraTerm) to connect to your device (DI-2108 in the following example) and type in the commands manually, as following