How to use the function block of CANOpenDevice?

yue-qi-qi
2013-02-28
2013-04-15
  • yue-qi-qi - 2013-02-28

    In the 3S CANopenDevice library,there is a function block of CANOpenDevice.
    When I define a instance of this function block like bellow:
    PLC_PRG
    fbCanOpenDevice:CANOpenDevice;
    END_VAR

    and do nothing to fbCanOpenDevice.
    then rebuild the project,no problem.
    but when download the project to the target, the target die, and the communication between the target to CoDeSys IDE will break.
    Our target is Wachendorrf A3.

    But if I define the instance as global variables:
    VAR_Global
    fbCanOpenDevice:CANOpenDevice;
    END_VAR
    and do nothing to fbCanOpenDevice.
    The problem disappear.
    But if add a call to the instance's method of fbCanOpenDevice.SwitchToOp() in the project. again the problem rise.

     
  • TimvH

    TimvH - 2013-02-28

    Don't define a CanOpenDevice in your application !!!
    The CAN configurator and driver uses this library.
    When you add the CANbus and add a CAN device in the device configuration, this FB is implicitly called.

     
  • yue-qi-qi - 2013-02-28

    OK.
    But is there some way to enable the slave self-startup?that is to enable the slave node to switch to the operation mode automaticly when the PLC is used in a nonCanopen network where there is no canopen master to issue the NMT command?

     
  • TimvH

    TimvH - 2013-03-01

    I'm not sure what you mean. Do you mean the CAN device you want to connect to is a "non CANopen device".
    Should the CODESYS PLC act as a master?

    If is it not CANopen you could use the CAN low level library to connect to any CAN device.
    For this you have to add the "CANbus" library, but this is not easy to use without a really good knowledge of the CAN protocol and CODESYS V3.

     
  • ScottJones - 2013-04-15

    I am working on a an CodeSys program for a Wachendorff A1 and need to use CAN, but not neccessarily using a Protocol like CANOpen. I just want to set the Message ID, RTR, Extended/Standard, etc and transmit the message either cyclically or when requested. I have used CAN extensively in another proprietary program (Sauer-Danfoss Plus1)that uses FBD to program and know CANOpen, Devicenet and J1939 protocols pretty well, but this my first time in CodeSys (Visulation). Usually when I am doing the sending and receiving for all of the devices. I just stuff the data into each message and use as many messages that are needed, don't write or use an actual protocol.

    If Anyone has any examples on setting up just generic CAN messages it would be helpful. If anyone has questions specific to CAN protocols, ask me especially CANOpen and J1939. Thanks

    Scott

     

Log in to post a comment.