Jump to content

CAN bus Layer 2 scan issue on V130


Recommended Posts

I'm having trouble getting the scan function to work for CANbus Layer 2 functions with a V130. I have gotten the Send function to work (device functions), so I think my configuration is fine. When I run the scan function, the received data appears at the location vector (MI 37) but the data is never stored at MI 30. This is likely because MB 3 is never ON. When I run Online Test it shows MB 3 temporarily ON (as it should) but I'm skeptical if this is truly working. The CAN ID is correct.

Am using the scan function correctly? Are there any examples of how to use the CANbus Layer 2 functions on the V130? Could there be any hardware problems? I have 120 ohm resistors at each end of the bus.

canbus_send_issue.png

Link to comment
Share on other sites

  • MVP 2023

I initially feel that it might be a buffer issue, unless something else is over-riding the MI30 write.  (To check this do a "Find MI 30" search and see what the program has that relates to it).   It all depends on how you are timing the various calls.  Test this theory by separating things out a bit, using a quick count to run things instead of  elements directly related to the Scan block.    Base the count around using the 1.25mS Interrupt Routine, using Cnt = 4 do this, Cnt = 10 do that etc. and use MIs for the count numbers/triggers so that you can easily vary the timings whilst in online mode.  Start with large time separations of at least a second, if they work then go backwards from there.

cheers,

Aus

Link to comment
Share on other sites

I forgot to mention that the Send function is on a 20 ms timer.

The program is small, but I checked to make sure MI 30 isn't being written anywhere else and it is not.

I tried replacing the CAN data received (MB 3) condition with a system timer and works correctly

canbus_send_issue3.png.996da2c264f7ccfd43dc5899e7c8540a.png

so it seems the CAN Data Arrived bit is never HIGH, but it still populates the MI 37 vector. I've also tried stepping through the program and it does indicate that MB 3 is high, though MI 37 is never stored in MI 30.

canbus_send_issue2.png.33fa4fb97d90a0a3c94cd17ff7d5b089.png

I would like to use MB 3 as the condition to store the CAN data though, I'm not sure why it isn't working?

Edited by schafbo
extra images
Link to comment
Share on other sites

  • MVP 2023

I have just noticed that MI30 is labelled "Can FB status".   Are you sure you haven't got 2 things addressing this?   It still looks like you have 2 things addressing MI30, occuring in the same scan or next.  Change MI30 to an MI that you definitely haven't used as yet, just in those rungs....don't use the replace function.

If this isn't the issue,  make the 20ms call longer.  On intial setting up of any comms, I always start from heaps of time giving the buffer plenty of room, and then shorten timings to suit the job.

I still don't like that you are using CAN "flags" to directly run things without any time intervals added to them, this has always given me buffer issues.

cheers,

Aus 

Link to comment
Share on other sites

Making sure MI 30 wasn't being written by anything was one of the first thing I checked. I changed it to a different integer value and still had the same issue.

I put a 20ms delay on the scan function and it looks like this fixed it. Maybe I am not understanding how the buffer works? Any way, I will be sure to put a small delay on any CAN Send/Scan functions from now on.

Link to comment
Share on other sites

  • MVP 2023

That's great Schafbo.  The rule of thumb I have learnt and work under for anything that might use a buffer is that I need to allow at least a few scans for it to be cleared after the PLC says that everything is ok.  Don't ask me the mechanics of this, it just seems to be needed. Perhaps it is simply that the PLC flags change as soon as the stuff is sent to the buffer, and then the buffer system itself has to do the operation.  Instead of the flags being told to change by the buffer actions themselves.  Edit:  And if this is really the case, could this be changed, Creators?  Would make things much simpler.

cheers,

Aus

Link to comment
Share on other sites

  • 6 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.