CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Fri Jul 28, 2017 4:03 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Apr 28, 2017 7:41 pm 
Offline

Joined: Thu Jan 26, 2017 5:00 pm
Posts: 16
First time using codesys and CAN here. I can't seem to read anything off our CAN network. I know for certain that the baudrate and CAN-IDs are correct because I used PCAN View to verify they were correct. I'm using the CANAPI 1.0.0.2 library in codesys to read the CAN messages on a display.

Below I have snap shots of the driver configuration, code for receiving CAN messages, the implementation of ProcessMessage() method, and the driver29bit.ReceiveMessage() method. All snap shots were taken while connected to the device from a laptop. The communication port on the CAN hub is what I connected to with both the device and PCAN adapter so I know it isn't a wiring issue.

My code is based off the CANAPI example found at the codesys store. If I understand the process in the example correctly, the driver is configured, msgProcessor is configured with the driver, and then the singleID receiver is configured into the driver. The singleIDreceiver and msgProcessor are both passed to the ReceiveMessage() method in which the internal function processes the single CAN ID and passes the message to msgProcessor. From there, the CAN message should be passed to the internal variable "message" in msgProcessor, where I can then implement the message in the ProcessMessage() method.

What I've noticed is that ProcessMessage() is never called, I set a break point in there during the live test and the break point was never hit. I also have noticed that ReceiveMessage() returns "FALSE" every time. Could someone with more knowledge about CAN networks explain what I am doing wrong or what the problem is? I'm very green when it comes to CAN stuff.

List of things I have tried or noticed:

I've tried changing the usiNetwork from 0 - > 1 - > 2 and if I change the Network to 2 then the generated receiverIDs return '0' but 0 and 1 usiNetworks work for generating IDs.

I've tried changing the g_tTimeLimit anywhere from 0 to 100 and tried matching them to the cycle times of the CAN messages.

If you look at the ReceiveMessage picture below, you'll notice that the itfMsgProcessor has a value of "16#307FC25C". When checking for that value using PCAN View, that message is no where on the network. What does that mean?

My driver configurations and singleIDReceivers show "NO_ERROR".

I don't recall what else I have tried at the moment but if I remember I will come back and post them here.

Attachment:
BusConfig.PNG


Attachment:
Can_Recieve.PNG


Attachment:
ProcessMessage.PNG


Attachment:
ReceiveMessage.PNG


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Tue May 02, 2017 5:23 pm 
Offline

Joined: Thu Jan 26, 2017 5:00 pm
Posts: 16
I decided to try out the CFC side of the CAN-API using an area receiver instead, since the CAN message addresses are pretty close. I still can't read anything off of the CAN and now the area receivers and driver configurations won't "configure". I'm getting Errors such as NO_CANBUSS_DRIVER, WRONG_BAUDRATE, and INVALID_DRIVER_HANDLE.

Between the way I have my drivers and receivers configured in ST and CFC, they are the exact same except ST is 29bitDriver (singleIDreceiver) and CFC is 11bitDriver (areaReceiver). The message coming over the CAN are 16#??? which means they are 11 bit so both 11bit and 29bit drivers should work.

The 29bitdrivers (ST) are able to generate singleIDreceiver handles but the 11bitDriver (CFC) is not able to generate the areaReceiver handle.

Below I have the pictures of how CFC is set up for the areaReceiver and a snapshot of the CANDriver_11bit's internal data. Under _CANBus in DriverConfig, the uiBaudrate, usiNetwork, and ctMessages are all set to "0" (Forgot to click down the list for the screen shot). I don't know how that is possible considering that I set-up driver configuration in my CFC.

I'm really at loss of what I'm doing wrong here...

Attachment:
AreaReceiver.JPG

Attachment:
ErrorPage.PNG


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Tue May 02, 2017 8:17 pm 
Offline

Joined: Thu Jan 26, 2017 5:00 pm
Posts: 16
Nevermind, I fixed it.

EDIT: My CAN-High/Low wires were backwards going into the hub. For anyone else who happens to come across this thread, the CAN-API example in the codesys store works and you can use the 29bitDrivers to receive 11 bit messages but you need to configure the singleIDConfig as shown below.

Attachment:
config.JPG


You do not have the required permissions to view the files attached to this post.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited