0

I have a question about serial communication with a CP6606 from beckhoff. I'm working with Twincat 3 version 4022.16 in combination with Windows CE 7 compact on the HMI. I've all licenses installed.

For school I have to program a pick and place with integration of a Sick CLV 610 barcode scanner.(RS232) First I need to trigger the scanner with the string "K". Then the scanner will scan and return the scanned result. For stopping the scan, I write the string "I" to the device.

I connect my scanner on the Onboard Com1 on the CP6606. I use the following configuration in twincat 3:Config scanner. Is it fine to use RS232 or should I use RS485 to do the job? Is my emulation mode right?

I make use of 2 tasks. 1 standard task and a Fast task. The fast task places the data from the hardware in the Buffer. The standard Task processes the data from the buffer. The configuration of the fast task can be found here : FastTask

In my program for the fast task, I use this function block :FB_SerialLineControl

For sending my trigger "K" I use the following 2 function blocks:SendReceive. sSerial_SendText contains the string "K" and after the timeout of 2sec, it will take the string "I" for stopping the process.

I don't get any errors in my program. The trigger just doesn't arrive on the scanner. I cant find any Com port analyzers for Windows CE 7.0 (only 5.0 and 6.0.) It seems something is wrong with my IO config with the Com Device.

Does the runtime version affect this problem? On my PC I use twincat 3 v4022.16 (newest) and on the CP 6606 is running version 4022.2.

I tested the hardware with a program called "putty". When I press "K" on my keyboard the scanner works and displays the code in the terminal.

I did the same test with a program called "Terminal CE" (same as putty but for Windows CE"). The test was also successful, so I think that the problem is not in the hardware but rather in the software.

You can find the source files of this project on this link. https://drive.google.com/file/d/1UjvCwl1u3sF9GF553zxO4dvl6VLIRLQx/view?usp=sharing

I hope someone can help me. Thanks in advance!

  • You need to produce a Minimal Complete Verifiable Example https://www.stackoverflow.com/mcve and edit this code into your question. All it has to do is send K (or not send K) – DisappointedByUnaccountableMod May 30 '18 at 21:04
  • It is possible to get virtual serial port software which will let you see what your program sends - try that. – DisappointedByUnaccountableMod May 30 '18 at 22:26
  • Oke first I will make a example where the program stops working and post it here. I found a virtual com spy software for windows ce. The only thing I've to do is to test it. Thanks for the tip! – Jens Vanhulst May 31 '18 at 05:06
  • Just checking, when you use SendString255 FB, your "_STARTSCAN" is only TRUE for one cycle, right? If _STARTSCAN is TRUE for many cycles, "K" is sent too many times and it may flood the transmit buffer. – Stucky Jun 04 '18 at 01:57
  • Yeah it's only true for 1 cycle. But when the cycle is over the output of the FB SendString255 is still "true" . This is why I think, it is something to do with my IO. – Jens Vanhulst Jun 04 '18 at 04:58
  • Yes you are right. It's only active for 1 cycle. – Jens Vanhulst Jun 04 '18 at 04:59
  • Not sure if this is the cause, but you have a bug in the code. SendString255 and ReceiveString255 (https://i.stack.imgur.com/x1plB.png) should be getting input from "GVL_RS232.g_mSerial_TxBuffer" instead of only "g_mSerial_TxBuffer". You have another variable with the same name "g_mSerial_TxBuffer" declared in your PRG_Serial. Right now you're using the local variable, but that is not correct. – Stucky Jun 04 '18 at 06:35
  • Hi Stucky I wanna thank you for your solution. This was indead wrong, after I changed it to a global variable it worked. Now everything is working fine. Thanks man ! – Jens Vanhulst Jun 04 '18 at 14:03

0 Answers0