Hello again!
I continue to describe my development shDRO. In this part, I will describe the device polling algorithm and the format of the console commands.
First part.Firmware')
Since the number of channels / ports to which reader 12 can be connected, and each channel can theoretically be set to interrupt, two PCINT interrupt handlers are used (for ports D and C). One connection restriction follows from this: all device pins that are configured for input must be connected to channels of the same group. If the channel is configured to exit, then for the current device, no matter which group it belongs to. Groups: group 1 (channels 0-5), group 2 (channels 6-11).
For interrupt handlers, two circular buffers are involved, 256 bytes each.
The interrupt handler code is:
buf[pos] = DATA_N; pos++;
Where DATA_N is one of the ports: PIND, PINC.
Data processing is as follows:
- an interrupt occurs, a new port value is written to the buffer;
- periodically the buffer is polled, and the data that appeared after the last poll is read from it (the position of the last poll buffer is stored in the device structure);
- in the process of reading the new data, the interrupt levels set for the channels are compared with the current port data. If the interrupt level does not match, then the data is ignored.
- it checks that all data has been received for processing (for example, for the BIN6 protocol, 24 bits must be taken);
- the data is processed into a “readable” view and the processed data is displayed on the screen;
- then the process is repeated;
To implement the above logic, the following logic modules are implemented in the firmware:
- Device: the module contains all the information about one connected device. For each connected device, such a module is created;
- Protocol: the module contains information about the protocol and how to handle incoming signals on the ports in accordance with this exchange protocol;
- Function: module contains information on how to convert data received from the Protocol module. For example, there is a Protocol module that supports a quadrature signal, but devices that produce a quadrature signal can be different: it can be an optical ruler, or a speed sensor. Those. in one case, the data must be converted to mm or inches, and in the other rpm. This module just does it;
- Led: a module that displays information on indicators. shDRO contains 4 indicators, and the desired display indicator is set for each device;
As a result, to connect the device, in the console you need:
- configure the desired channels;
- add device;
- for device, set protocol, function and led;
- add / bind the desired channels to the device;
ConsoleAt the moment, I checked the console in the monitor port ArduinoIDE and in Terminal v.1.9b. For terminals like Putty you need to implement an echo mode (not implemented).
Command format:
<> </1> <_1> </N> <_N>
Maximum number of arguments per line 5.
Register does not matter, command parsing occurs after converting a string to lower case (exception: the value of the argument in quotes).
All commands are executed only after issuing the Setup command (exception, Help command, which lists all available commands).
All commands are described in the attached archive, as well as the first version of the firmware in hex format.
shDRO.zip (.hex + command description)To be continued.
Thank!
PS
Commands related to configuring devices and channels can be sent to the “bare” arduinka without strapping.
PS1
Please those who live in Kazan.
If you have:
- digital calliper protocols: 24BIT, BCD7;
- iGaging digital lines (21BIT protocol);
then could you give them to me for a couple of days to write and debug protocols for them?
I promise to keep them safe and sound!
But this is in a personal. Thank you in advance.
PS2
I forgot to add two commands to the command description file:
- save: saves channel and device settings to EEPROM;
- load: unloads the settings of channels and devices from the EEPROM (load is performed by the machine during initialization);
I will not upload the file, just keep in mind. But “help” displays these commands.