First steps - example file doesn't work - no attribute 'interface' #382
-
Hi all, I hope someone can help me to get this code running. Outline I have a Raspberry Pi 4 and I use a RS485_CAN_HAT from waveshare with an MCP2515 IC. The Hat documentation is very basic. When I use a basic CAN script to send data via CAN or when I use However, as I want to use CANopen and make use of the application layer functionality I tried the script provided in the README and also the example. However, in both cases I perceive the error
I tried to cut down the provided From reading CANopen 301 I did not get the impression, that there is some crucia device-specific setup that would make the network.connect() function fail due to incorrect values. Maybe I am wrong. Also, I tried to use @bggardner So in both cases I try to talk via a bus, which is not yet configured. I have some questions:
I am looking forward to your reply, please don't hesitate to ask for further details for debugging. Thank you in advance! spaceKelan |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
I can't speak to First, can you run the python-can example (using
|
Beta Was this translation helpful? Give feedback.
-
a) The best way to recover from b/c) The output of
|
Beta Was this translation helpful? Give feedback.
-
It's not wrong to look at the differential signals, but not ideal. When you connect the scope probes, it creates a long "stub", which alters the topology/impedance of the bus, which can lead to reflections and bit errors. Ideally all transceivers are connected directly (with a stub as short as possible) to the bus. CAN likes an end-to-end "bus" topology, not radial, star, mesh, or otherwise. |
Beta Was this translation helpful? Give feedback.
-
I suggest you simplify until you reach milestones…
first, just send one raw message without CANopen library… just bare CAN.
- your logic analyser seems like Logic from saleaé. The decoder need
threshold voltages and this would easily explain your can-h/l not being
mirrored.
- the Can errors ar because there is a single device and no receiving the
‘ACK’ bit from a secondary not… so the hardware can module automatically
retransmits the message.
If yours are using the MCP2515 as can controller, there is a possible
setting to ‘send-once’ but would only do that if I were you to validate
that you know how to change this setting. When multiple nodes on the bus,
I do not know to which extent does the mcp2515 would repeat in case the
message sent is of lower priority.
Once you can reliably send and receive a message ( get a second node on the
bus to help you out)!you can go to step 2-> start messing with CANopen or
j1939
Otherwise, you are questioning the CANopen stack when the “interface” with
the BUS class is what your are struggling with.
Get any second CAN node on the bus and use you logic analyser to figure out
it’s transmit baud and try configuring the PI for RX and check if received
message matches your logic analyser.
Once your baud rate is ok, you can transmit anything and the other node
will “ACK” even if it doesn’t mean anything (j1939 vs CO)
Goodluck
…On Fri, Jun 23, 2023 at 07:05 Andy ***@***.***> wrote:
thank you!
—
Reply to this email directly, view it on GitHub
<#382 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADFFTRSBT4YSFDCL4LSRLJ3XMV2ATANCNFSM6AAAAAAZGPBZAM>
.
You are receiving this because you are subscribed to this thread.Message
ID: <christiansandberg/canopen/repo-discussions/382/comments/6261158@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
@andy,
Thresholds: voltage level at which the logic analyser will report a 0 or 1.
CAN low will be either 2.5V for “1” or idle, and ~1.5v for 0’s. Which is
still considered a ‘1’ in TTL/CMOS logic.
If using an analog input , check if you can set the threshold voltage
where the ‘decoder’ will return a 0 or 1.
Most likely not avail on digital only inputs devices.
4.Vendor ID —> yes if you plan on selling a commercial product. Otherwise,
make something up
====
I did the same as you do…. Using the Python library to learn and practice
and validate my “c” version running on embedded CPU and even if for Codesys
St code where I did not like the limitations of codesys in regards to their
parameter manager.
Eric
…On Wed, Aug 9, 2023 at 07:02 Andy ***@***.***> wrote:
Hi @ericbaril72 <https://github.com/ericbaril72>,
thank you for your response.
1. Yes my logic analyser is from salea, may you please elaborate on
the threshold explains it?
2. Two nodes are the minimum, figured that out by now, too.
3. I did add the second device after receival of that CAN interface
and CAN 2.0B is supported and works well.
I'm sorry if this is the wrong space to ask this:
I plan to move from
Device Name Computer OS
A Pi Raspbian
B Desktop older Fedora Linux
to other hardware. The pi is therefore just for testing purposes. I am
currently organising myself a second pi so I can use this repository here
without interfacing with other frameworks focussing on OD and simple
implementation of it.
Device Name Computer OS
A something exotic RTEMS
B Desktop older Fedora Linux
When I tried to make CANopen run with a self-created minimum feasible OD,
I also looked into CANopenLinux for device B, which turns out to create
issues in the 309 ASCII Gateway.
Next I used their template OD.eds and generated OD.h and OD.c files,
which did not built the code due to errors! After adding elements to a
similar level as my personal minimum feasible OD, I could built but would
get the same error when executing.
I know this is a different repository, I stalled working with this for
now, as it seems too complex to strip, as I won't need 309 in my final
implementation anyways. However, I am even more confused now.
1. Is it possible to take two CAN devices and implement CANopen
protocol on them even though they did not offer that functionality before?
( I assume yes, but 301 reads like there would have to be a Vendor ID
noted at CiA for this to work, which I doubt.)
My current plan is to implement
- SDO block upload and download for example frames
- some PDOs and go from there.
The only CANopen ICD I was able to get does not go into detail regarding
NMT etc. , but only contains TPDO and RPDO. Therefore the whole CANopen
complexity is still a bit confusing.
The implementation of NMT seems complex and unfortunately since this
repository is based on python and my target language must be C++, I can
only learn from this, but not implement this directly. However, I will
definitely check how I can inspire myself by this work as this seems way
more straight-forward than CANopenLinux.
Looking forward to hear your thoughts!
Thank you for your time!
—
Reply to this email directly, view it on GitHub
<#382 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADFFTRTHCC3QKP7GLUHBNE3XUNU4DANCNFSM6AAAAAAZGPBZAM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
a) The best way to recover from
BUS_OFF
is to restart thecan0
interface, especially at this point in debugging. It should eventually recover automatically if there is non-error traffic on the bus when its internal error counters fall below thresholds.b/c) The output of
example_python_can.py
doesn't seem right, probably due to the error frames on the bus. You shouldn't use the logic analyzer to look at CANH/CANL individually, but after a transceiver, like at the CAN_RXD signal on your CAN HAT schematic. There should always be another CAN node on the bus, as it will set the ACK bit when another node is transmitting a frame, preventing error frames. Note that a CAN node means a CAN control…