CanOpen communication with Qt on udoo Neo

Discussion in 'UDOO NEO' started by Sassus-Bourda, Mar 17, 2016.

  1. Sassus-Bourda

    Sassus-Bourda Member

    Joined:
    Dec 21, 2015
    Messages:
    42
    Likes Received:
    4
    Hello udoo community,

    I'm currently develop an application with Qt langage. I use a virtual machine linux. I have to export this application to the udoo board with the cross compilation then I have to connect an other extern board with the canOpen.

    I would like to try the canCommunication between my PC and the udoo board because i don't have the other board now. I know that i need a canOpen usb adapter to connect these two elements but how can I set up this kind of connection, what are the manipulation that I have to two on my Pc and on my board?

    Thanks in advance for your help.

    Regards,
    Pierre
     
  2. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
    Qt 5.6 implement a new class QtserialBus (technologie preview) to use CAN BUS. You can download now qt5.6 to test it from your pc (in my case i use a peak can usb). Neo side is more complicated for the moment because udunbuntu don't have qt5.6, they have a solution with yocto and meta-udoo master (not jethro branch). We are trying to build the qtserialbus modules with yocto (qt 5.6 is already build, but metaqt5 not include this module), but we are stuck for the moment with an issue with master branch ... I let you know if we make some progress. Otherwise you can activate CAN on neo with the device tree editor and test it with linux tool elinux.org/Can-utils , flexcan ...

     
    Ayeed Shaikh likes this.
  3. Sassus-Bourda

    Sassus-Bourda Member

    Joined:
    Dec 21, 2015
    Messages:
    42
    Likes Received:
    4
    Hi,
    Thank you for your response.

    Yes i have download the qserialbus example with the librairie. But my problem is that the program don't detect device if I have understand I need to have a can Usb adapter on my PC and connect this one to my board is that exact? If it's correct does i need to do some manipulation or the Qt example do all the work?

    I follow your link but have an error with the command line ./autogen.sh the console display that the commande autoreconf line 20 is not found..

    Thanks in advance for your help,
    Pierre
     
  4. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
  5. Sassus-Bourda

    Sassus-Bourda Member

    Joined:
    Dec 21, 2015
    Messages:
    42
    Likes Received:
    4
    I use the 5.5 version but I have also download the 5.6 I get the two compiler.

    Ok no problem let me know thanks.

    Could you give me your point of view about what is the best solution for Can communication between two board with a Qt program? If you have a tutorial that i can follow to succeed this big part of the program it could be helpful.

    Regards,
    Pierre
     
  6. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
    At first you need to understand how CAN protocols works (very important), after that to use can with Qt you have three solutions :
    - Use the new qserialbus of Qt
    - Use the api of you pc adapter (include .lib in your Qt app), for exemple (http://www.peak-system.com/fileadmin/media/linux/index.htm)
    - If you are under linux, implement your own class to use socketCan ...
    Important, don't forget to use a CAN transceiver on neo, for example http://www.microchip.com/wwwproducts/en/en010405
    and add the 120 ohm resistor termination (not necessary on Sa62 board)

    [​IMG]
     
  7. Sassus-Bourda

    Sassus-Bourda Member

    Joined:
    Dec 21, 2015
    Messages:
    42
    Likes Received:
    4
    Hi,

    Thanks for the links.

    The socketCan seems to be the best way for me because I have to try on the NEO board, and in final it's my NEO board who send messages.

    When you says that I have to implement my own socketClass could you please explain to me how can I do that?

    Thanks again,
    Pierre
     
  8. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
    @Sassus-Bourda
    For the creation of the class it depend of your need and is the base of c++ ... i can't do it for you.
    Otherwise, i make a test with a pc under windows7 and qt5.6 running CAN bus example. I use a peak can usb to link with the pc. Neo side i use a MCP2551 chip. The OS in neo is udoobuntu, important you need to enable CAN with the device tree editor and reboot the card to enable the can --> ifconfig -a show you if is enable

    see the pictures under for the details (the important instructions are in red) :

    upload_2016-3-19_12-36-8.png

    upload_2016-3-19_12-43-2.png

    can.png

    you can find informations in this post
    next step is to test the can with yocto (Qt5.6 with qtserialbus compiled :D), i let you know ...
     
    Last edited: Mar 19, 2016
    graugans likes this.
  9. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
    @graugans , @Francesco

    Hi, i have compiled the master branch of meta udoo (yocto) with qtserialbus (with the help of my best friend here ... Graugans -->i let you some issue on github after the complete test of can ...) . After a test on udoobuntu (work fine) i started the test on yocto. To do this i copied the folder dts-overlay and uEnv.txt (from udoobuntu with can and uart6 enabled, see above) on my sdcard (boot partition). Start the card :

    ifconfig -a --> can not appear !

    see the logs of the boot here :
    flexcan error

    boot log

    Sometimes the card boot and sometimes it stuck (see flexcan error). If i use the standard dtb files the card boot normally ! Do you have an idea about the issue ?

    Otherwise, qtserialbus compil fine from my host to the card :) , just need to correct the problem of dtb file ...
     
    Last edited: Mar 19, 2016
  10. graugans

    graugans Administrator Staff Member

    Joined:
    Sep 17, 2015
    Messages:
    328
    Likes Received:
    141
    @modjo Can you please provide the DTS files?
     
  11. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
  12. graugans

    graugans Administrator Staff Member

    Joined:
    Sep 17, 2015
    Messages:
    328
    Likes Received:
    141
    Thx, at the moment it looks like you have to disable the M4 to have CAN. This is also written in the post you've mentioned:
    I have to check the manual about possible PIN muxings. Maybe there is an updated M4 firmware available with not touching those PINS... Maybe @Andrea Rovai or @Francesco have more details...
     
    modjo likes this.
  13. jas-mx

    jas-mx Active Member

    Joined:
    Dec 31, 2013
    Messages:
    407
    Likes Received:
    118
    The changes I made aren't really to do with the M4, they are to do with hogging pins in the dts which can't make sense if they want to be reassigned to a peripheral. Unfortunately its a lack of understanding of what these features mean and how correctly use them in a dts file.
     
    modjo and graugans like this.
  14. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
    It strange, i hope @Francesco or @Andrea Rovai can help to resolve this point !
    Otherwise if i disable m4 CAN appears (not necessary on ubuntu) ! and qtserialSerial bus is working on neo :cool: see under :

    P1150466.JPG

    P1150468.JPG
     
    graugans likes this.
  15. graugans

    graugans Administrator Staff Member

    Joined:
    Sep 17, 2015
    Messages:
    328
    Likes Received:
    141
    I agree with @jas-mx I have some lack in understanding why the CAN PINs are defined in multiple groups and why UDOOBuntu behaves different than the Yocto build. The last time I've checked both of them use the same kernel version....
     
  16. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
    @graugans , @jas-mx do you try to compil the dtb files without the external.dtsi files, configure directly the dts file (example for neo full + m4 + lvds7) and make dtbs ?
     
  17. graugans

    graugans Administrator Staff Member

    Joined:
    Sep 17, 2015
    Messages:
    328
    Likes Received:
    141
    I use the dts files from kernel source and build with the kernel Makefiles

    Gesendet von meinem FP2 mit Tapatalk
     
  18. graugans

    graugans Administrator Staff Member

    Joined:
    Sep 17, 2015
    Messages:
    328
    Likes Received:
    141
    For me CAN is not working on latest Kernel of UDOObuntu and latest dtweb edition same issue like on Yocto
     
  19. graugans

    graugans Administrator Staff Member

    Joined:
    Sep 17, 2015
    Messages:
    328
    Likes Received:
    141
    @modjo You may have to check the levels on the MCP2551, it is a 5V CAN Tranceiver and the NEO is 3.3V logic Level, Maybe the CAN Input is 5V tolerant but I am not sure.
     
  20. jas-mx

    jas-mx Active Member

    Joined:
    Dec 31, 2013
    Messages:
    407
    Likes Received:
    118
    If the MCP2551 VDD is 4.5-.5V then it shouldn't be connected to the NEO without a series resistor on the CRX pin. Its easier to use a 3.3v CAN transceiver.
     

Share This Page