03 - 10 - 2024

Controllers library

Block FTDI

License: Hobby, Industrial


The block works with the next FTDI chips:

  • FT245BL, FT245BM: Every of 8 IO pins of the device can be set as digital input or digital output. The device works well in Asynchronous mode, so please set the parameter Mode of the block to Asynchronous.

FT245BL Data Sheet:
http://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT245BL.pdf

Compatible devices:
http://denkovi.com/usb-relay-board-four-channels-for-home-automation-v2

  • FT245RL: The chip has 8 IO pins, which can be set as digital input ot output, but works well with Synchronous mode, in case we use Asynchronous mode, the device will work too, but every reading of digital inputs will be slowly, because TimeOut of 1 sec will appear.

FT245RL Data Sheet:
http://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT245R.pdf

FTDI chip is very fast, it allows more than 50 Read/Write commands per second to send.

Block's parameters:

 

 

  • CommunicatePerSec - the seconds per which the commands for Read/Write operations will be send to device. If this parameter is 0, the commands will be send per every DiscreteTime interval described in block Process.
  • FTDI_Device - this is a ComboBox with enumerated all the FTDI devices available on the current computer. The user has to select one of available FTDI devices.
  • Disable - If the diagram is started without connected device to computer, the process will be stopped automaticaly, because the device is not accessable. In this case if Disable parameter is checked, the process will be started without the device.
  • InvertOuts - the digital outputs of the device are presented as block's inputs. If the hardware after FTDI chip inverts the digital outputs, then it is more easy to invert all the signals, which enter into the block than to use NOT digital block to invert every input signal.
  • Mode - this parameter is very important, because some of the FTDI devices work well in different modes. Please read the difference between FT245BL and FT245RL chips above;
  • Purge -if the parameter is checked, then on every I/O operation, a SCADA software will purge the communication port and this will ensure that every command to device is processed. "Purge" decreases the communication speed with device. If the parameter is unchecked, the communication speed can be increased up to 1000 commands to device per second.

 

Block outputs:

  • CommunicationError - becomes to high level if the device does now respond to the computer's command;
  • OnRead - bocomes to high level when a data is received from the device;

The important output of the block is CommunicationError. Is case the device USB cable is very long, cable is disconnected or for other reason, some of the commands between computer and device can be not processed from device, then the described output will become to high value for 3 sec.

Demo - FTDI.nsm file:

 

Block SerialPortUni:

License: Hobby, Industrial

The idea:
The block allows work with devices with different TEXT communication protocols. Unlimited number of inputs / outputs can be added to the block. Then, the commands are created, which consist of text to be sent to the device and a response received as one-line or multi-line text. The sent text is a composition of the values of the blocks' inputs. The received text response from the device is analyzed by the block and the corresponding outputs of the block are set according to the values in the received text response.

Example (pelase, load SerialUni.nsm from the Demos):

The block description is explained over an example of controlling the Numato 2 Channel USB Powered Relay Module. The following commands will be used in the example:

  • ver - returns the software version of the device;
  • relay on 0 - switchs ON relay 0;
  • relay off 0 - switchs OFF relay 0;
  • relay on 1 - switchs ON relay 1;
  • relay off 1 - switchs OFF relay 1;
  • adc read 0 - reads the value of the Analog to digital convertor 0;

Each command sent to the device ends with CR (dec 13). The received text response is two-line and each line ends with the CR too. The first row always repeats the sent command, the second row contains the response data.

The communication parameters of the block are:

  • ComPort - the com port of the device;
  • BaudRate - the communication speed;
  • ByteSize - may be one of listed: 5, 6, 7, 8. The default value is 8;
  • Parity - None, Odd, Even, Mark, Space. The default value is Note;
  • StopBits - 1, 2;

 

Additional parameters:
  • DebugInfo - when the parameter is checked and the diagram is started, information is generated during the operation of the block, which is displayed in the blue text screen on the right of the diagram;
  • Disable - if the diagram is started without a connected device to the computer, the process will be stopped automaticaly, because the device is not accessable. In this case if Disable parameter is checked, the process will be started without the device.

The main parameter of the block is Settings, which contains the entire universal conception of communication to any device. The parameter opens the following interface:

The main interface of the parameter Settings consists of three areas:

 

  • Area 1 - In this area, the user can add unlimited inputs and outputs, from different data types - analogue, digital, integer, string, datetime. Each row added adds a new input/output to the block;

  • Area 2 - Some devices require the communication text to end with special characters, for example - cartridge return (often shortened to CR), is defined as 13 (or hexadecimal 0D). We can add a sequence of characters to be added at the end of each sent text, the same symbols will be expected to be contained as the end of the received text response from the device. At the edit End byte we can add decimal byte, with the edit End char we can add character. With button Add CR+LF we can add CR (cartridge return) byte and LF (line feed) byte;
  • Area 3 - In this area, we add the commands to the device;

Commands (means description of send and received text):

The interface of the command is shown below:

The settings of every command are:

  • Command Name - for every added command, a new digital input and a new digital output of the block will appear. The names of input/output are formed in the following way:
  • Name of the new digital input - command name + SendCommand;
  • Name of the new digital output - command name + OnCommand;

For example, for the command named GetVersion, a new digital input will be added to the block with Name GetVersion + SendCommand=GetVersionSendCommand, and a new digital output will be added with name GetVersion+OnCommand = GetVersionOnCommand. When the input GetVersionSendCommand becomes to high level, the command will be send to the device. when the device responds, the received text is analyzed and the block outputs are set with parsed values, then the output GetVersionOnCommand will become to a high level for short time.

  • Scan rate[ms] - if the corresponding input of the command (in the example GetVersionSendCommand) is not connected, the block will use this setting for time interval for sending the command to the device in milliseconds. If the corresponding input of the command is connected, the command will be send only when the input becomes at high level;
  • Wait between commands[ms] - if the commands are too frequent, the time between two commands will be no less than this parameter;

Example: we want to switch ON/OFF the two relays on the board. We have to use the commands:
relay on 0
relay off 0
relay on 1
relay off 1

This commands are similar and we can decompose them to three parts:

  • part 1: simple text relay
  • part 2: on or off text. For this purpose we use digital input of the block RelayValue. If the input is at low level, it is represented as off text, at high value is represented with on text;
  • part 3: just one space char;
  • part 3: index of relay: 0 or 1. The value of block's input RelayIndex is represented with text 0 or 1;

So at Send data area we will describe the Send text composition as:

 

 

 

The respond of the device at this command is not interesting, so we define the respond as <UnDef>, means UnDefined.

The next example is with adc read 0 command. The sending text is simple, we just send a simple text: adc read 0. The received text from the device contains two lines, each of them ends with CR. The first received text line repeat the sent text and is not interesting, this is the reason it is defined as <UnDef>. The second received line contains the value of the ADC. The block will parse it and to set the parsed value to block's output ADC0.

 

 

Block GeigerCounterRH

License: Hobby, Industrial

Geiger Counter DIY Dosimeter Nuclear Radiation Detector DIY Kit from Radio Hobby Store:

http://radiohobbystore.com/geiger-counter-dosimeter-nuclear-radiation-detector-diy-kit-with-lcd.html

Parameters:

  •  ComPort - index between 1 and 99 of PC COM Port on which the counter is connected

Outputs:

  • CPM - Count per minute

 

Block SAAFShield

License: Industrial

The block is used to communicate with the SAAFShield Real-time Reactivity Monitor device.

 

The full device documentation and communication protocol:

The block has settings for alarms: CumCu, CumAg, IncCU, IncAg. Input of the block is 4..20mA measured from some device with mA analog input.