Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched.
Close
I am having some issues communicating with a barcode scanner from Sick through CANopen. Does anybody have any experience with this device?
This is what already works:
I have installed the EDS file and added the scanner to my PLC configuration. Then I mapped several values to PDO's.
Now when I write a value to the scanner I get the correct response back with the current barcode being red.
So far so good, but:
Now I want to get the read data from the scanner with a SDO packet.
Does anyone know how I can make the scanner upload the read results by SDO?
The reading result should be located at address 0x2000.
Can anyone point me in the right direction?
Thanks,
Stefan Roelofs
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i'm currently stuck with a similar problem.
A CLV431 transmits data through PDOs (e.g. "length of datastring", "type of datastring") but the result string array is always empty.
I eventually used the function: CanOpenSendSDO (from the libary: 3S_CANopenManager)
With the following parameters:
  sdoTransfer      :CanOpenSendSDO;  xSdoEnable        :BOOL;  aSdoDataBuffer      :ARRAY[0..99]OFBYTE;  aSdoAnswerBytes    :ARRAY[0..7]OFBYTE;  iSdoAnswerLength    :INT;  xSdoWaitForAnswer    :BOOL;  xSdoAnswerRec      :BOOL;  xSdoToggleUnequal    :BOOL;  xSdoAbortRec      :BOOL;  aSdoAbortRec      :ARRAY[0..3]OFBYTE;
(*Do not call this FB while the targetnode is not in state 5.*)(*Create an instance within your application for the FB, one for each node you want to communicate at the same time.*)(*There are maximum 64 instances possible.*)(*Do not change inputparameters, while the FB is waiting for an answer.*)sdoTransfer(  Enable      :=xSdoEnable,    (*Change from 0->1 will start the transmission.*)  wDrvNr      :=WORD#0,        (*Index of CanMaster, that will send the message. 0 if only one exists*)  ucNodeId    :=BYTE#9,        (*NodeId of targetnode.*)  wIndex      :=16#2000,      (*Index of ObjectDict.-entry*)  bySubIndex    :=16#04,      (*SubIndex within the index.*)  ucModus      :=16#40,      (*SDO-mode, use 16#40 for read-request, use 16#23 for 4-byte-write-request.                                          use 16#27 for 3-byte...                                         use 16#2B for 2-byte...                                         use 16#2F for 1-byte...                                     use 16#21 for downloading more than 4 bytes using the segmented transfer.*)  ucByte0      :=0,        (*The 4 possible databytes.(That's why the FB is called ...light*)  ucByte1      :=,  ucByte2      :=,  ucByte3      :=,  aAbortCode    :=,  (*Additional functionality if the segmented transfer should be used.*)  (*For this mode, use 16#41, 16#40 as an read-request and 16#21 as a write request.  In this case the following DataLength parameter and DataBuffer-address is used.*)  dwDataBufferLength:=DWORD#99,  pDataBuffer    :=ADR(aSdoDataBuffer),    (* <--- Output is here *)  bWaitForAnswer  =>xSdoWaitForAnswer,  bAnswerRec    =>xSdoAnswerRec,  (*The following are written by the CanOpenInterfaceMan.*)  ucAnswerBytes  =>aSdoAnswerBytes,  iAnswerLength  =>iSdoAnswerLength,  bToggleUnequal  =>xSdoToggleUnequal,  bAbortRec    =>xSdoAbortRec,  aAbortRec    =>aSdoAbortRec);
First set an output (over PDO) to the scanner so it starts to scan for a new barcode.
Next check if a counter (over PDO) is increased (counter will increase for each read result)
Now set 'xSdoEnable'
Wait for 'xSdoAnswerRec' is TRUE
The array aSdoDataBuffer now contains the Read Data.
I have attached a CANopen manual. Maybe it helps you.
thank you very much for your help, you saved me a lot of time!
By now I got the CLV up and running. The point was "SDO-Transfer" - I always tried PDO-Transfer, which isn't supported by the CLV43x series...
Especially the manual was helpful, because it contains information about the CAN-messages used by SICK. So I was able to monitor communication between CLV and the PLC with a CAN-Sniffer.
Best regards
Erik
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using your code for recieving SDO "swtroelofs". In CANopen analyzer the remote node/device answer read-Request for SDO, but my BUFFER is empty. Do not have a clue why the buffers are empty?
Another interesting thing is that, when the state of xSDOenable goes from TRUE to FALSE. I got Abort code 0 object SSDO, answer from remote node
There is a picture attached.
Thnx in advance,
Alex
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I call a FB within PLC_PRG when device state is 5. And the most important I wait for bWaitForAnswer and then xSDOenable=FALSE. I got no error in Analyser.
The data is not in aSDOdataBuffer but in ucAnswerBytes:ARRAY[0..7] OF BYTE. Last 4 BYTES (4..7) presents recieved SDO data.
regards,
Alex
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everybody,
I am having some issues communicating with a barcode scanner from Sick through CANopen. Does anybody have any experience with this device?
This is what already works:
I have installed the EDS file and added the scanner to my PLC configuration. Then I mapped several values to PDO's.
Now when I write a value to the scanner I get the correct response back with the current barcode being red.
So far so good, but:
Now I want to get the read data from the scanner with a SDO packet.
Does anyone know how I can make the scanner upload the read results by SDO?
The reading result should be located at address 0x2000.
Can anyone point me in the right direction?
Thanks,
Stefan Roelofs
I got it working eventually.
If anyone needs some advise on this let me know.
Stefan
Hello Stefan,
i'm currently stuck with a similar problem.
A CLV431 transmits data through PDOs (e.g. "length of datastring", "type of datastring") but the result string array is always empty.
Can you please give me a hint where to look into?
Thank you!
Erik
PLC: Moeller XC-CPU101-C128k
Scanner: Sick CLV431-2010
Hi Erik,
I eventually used the function: CanOpenSendSDO (from the libary: 3S_CANopenManager)
With the following parameters:
First set an output (over PDO) to the scanner so it starts to scan for a new barcode.
Next check if a counter (over PDO) is increased (counter will increase for each read result)
Now set 'xSdoEnable'
Wait for 'xSdoAnswerRec' is TRUE
The array aSdoDataBuffer now contains the Read Data.
I have attached a CANopen manual. Maybe it helps you.
By the way: I used a Sick CLV650 scanner.
Manual_CANopen_IDpro_V15.pdf [191.89 KiB]
Hi Stefan,
thank you very much for your help, you saved me a lot of time!
By now I got the CLV up and running. The point was "SDO-Transfer" - I always tried PDO-Transfer, which isn't supported by the CLV43x series...
Especially the manual was helpful, because it contains information about the CAN-messages used by SICK. So I was able to monitor communication between CLV and the PLC with a CAN-Sniffer.
Best regards
Erik
Hello!
I'm using your code for recieving SDO "swtroelofs". In CANopen analyzer the remote node/device answer read-Request for SDO, but my BUFFER is empty. Do not have a clue why the buffers are empty?
Another interesting thing is that, when the state of xSDOenable goes from TRUE to FALSE. I got Abort code 0 object SSDO, answer from remote node
There is a picture attached.
Thnx in advance,
Alex
No one? I really do not know where to search the answer...
please help
regards,
Alex
Solved!
I call a FB within PLC_PRG when device state is 5. And the most important I wait for bWaitForAnswer and then xSDOenable=FALSE. I got no error in Analyser.
The data is not in aSDOdataBuffer but in ucAnswerBytes:ARRAY[0..7] OF BYTE. Last 4 BYTES (4..7) presents recieved SDO data.
regards,
Alex