ctrlX SICK CAMERA connection

Vision - Integrate ctrlX AUTOMATION with a SICK InspectorP camera and MongoDB

MauroRiboniMX
Contributor
Disclaimer

The goal is to integrate a sick camera with a ctrlX CORE or a ctrlX OS installation in order to be able to manage with flexibility the implementation of a quality inspection application. 

ctrlX SICK CAMERA connectionctrlX SICK CAMERA connection

Requirements:
  • ctrlX CORE - x3 or x7 or a ctrlX OS installation
  • A Sick inspectorP camera
  • Node-Red with some 3rd party nodes.
STEP1: install Node-RED and the needed nodes

To achieve our result we need node-red and some external nodes. You can check here how to install nodes Or here. To setup the camera we need:

  • node-red-contrib-buffer-parser : the camera accepts commands trough tcp/ip. We need to bufferize the commands correctly.
  • node-red-contrib-ftp-server: the cameras can push the image on a ftp server. it's cool to show on a dashboard what the camera sees.
  • node-red-contrib-image-output: we would like to see what the camera sees right on the flow editor, this node does it!
  • node-red-node-base64: we need this node to parse the image coming from the camera!
     

Be careful: anytime that we restart the node-red flow we need to restart the camera: the ftp server is restarted and the camera gets angry! 😎

STEP2: setup the camera 

Preliminary steps: setup camera IP address, by suggestion of Sick guys i used the dedicated tool: sick App Manager. It's super easy but please refer to Sick documentation.
In order to setup the camera we need to:

  1. Setup the communication protocol and the command channel
  2. Setup the jobs
  3. setup the feedback: image and string!
1: Setup the communication protocol.

We need to connect to the cameras webInterface, set the camera in "Configuration" mode. Add TCP server as a communication interface and select the port. in our case 12121.FTP Server ConfigurationFTP Server Configuration

Ok, once we set up the communication protocol we need to setup a "Command channel" in our case we would like to use the TCP server as command source. So the setting will be something like this:Command Channel ConfigurationCommand Channel Configuration

2: Setup the jobs.

please refer to SICK documentation for this. It depends on what and how you want to do the test.

3: Setup the feedbacks

In result we need to add a "Result String" output. We can configure the string in the way we prefer on the right.Result String FormattingResult String Formatting

In the communication part we need to select the TCPServer:0 as interface and the string as output!Feedback stringFeedback string

If we want to display the Image we need to add the "Image Collection" in communication as well. We need to use as ip address the ctrlX CORE address an setup as username and password the ones we would like to use.Image Collection FTPImage Collection FTP

Ok save and set the Camera in "RUN" mode.


STEP3: build it!

Ok now we need to set it up from node-red side!

Send commands to the camera/ The trigger command.

In order to send commands to the camera we need to use correctly the buffer node! To send the command we need to connect to the TCP server of the camera first. Here is the code:

Command with buffer codeCommand with buffer code

The content of the buffer maker node is the following:

Command bufferizedCommand bufferized

In this way we can send the trigger command and any other command. 

Get the image from the camera!

FTP server and other nodesFTP server and other nodes

The code is very simple: we need to setup correctly the ftp server:FTP settingsFTP settings

Once the FTP server is ok we can then use the Encode node, Image Preview node and write a template to show the image itself. Anything is contained in the code attached. The result is the following:

Node-red Code resultNode-red Code result

HMI ResultHMI Result

STEP4: save the pictures with MongoDB! (optional)

Another classic request for customer is to be able to store images someway. If we want to save them like a file it's super easy and it is a widely answered question online E.g: Save multiple images question. Sometime could be better to save the images in a "centralized" database like MongoDB (we can also use other DBs) in order to better organize the data. Here you can find the code, to use it we need to install the node: node-red-contrib-mongodb4. 

Code with node-red-contrib-mongodb4 integrationCode with node-red-contrib-mongodb4 integration

 
In order to upload correctly the images we need to adopt a specific formatted data structure (in json). To documentation. The conversion is contained in the "upload Formatter" function.
You can find the example attached. Have Fun 😎

MauroRiboniMX
MauroRiboniMX
Hello, I am Mauro a ctrlX DEVELOPR at night and an Application Engineer during the day 😎 . Ask me anything about ctrlX AUTOMATION but my best topics are IoT, AI, SDK and Communication!
Must Read
Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist