Page 3 of 5

Re: connecting pyboard to CAN BUS

Posted: Sun Sep 04, 2016 6:16 am
by dhylands
You're not allowed to allocate memory from within an interrupt handler.

recv needs to allocate a buffer to return its results.

See: http://docs.micropython.org/en/latest/p ... rules.html for more background.

Re: connecting pyboard to CAN BUS

Posted: Sun Sep 04, 2016 4:35 pm
by kamikaze
PappaPeppar wrote:Here is a skin that I know Works.
https://github.com/HenrikSolver/pybcanskin
What is a purpose of 120Ohm resistors in this scheme? I suppose they are for CAN bus termination... but I've seen that such resistors do connect CANH and CANL on the bus ends.

Re: connecting pyboard to CAN BUS

Posted: Fri Sep 16, 2016 2:07 pm
by kamikaze
finally got my PCBs for my car project. Also waiting for a version for PyBoard with two interconnected transceivers on a single board.
Image

Image

Image

Re: connecting pyboard to CAN BUS

Posted: Fri Sep 30, 2016 11:55 am
by kamikaze
With two PyBoards (one is a sender in a loop, another is a receiver in a loop) I've found that if receiver is unable to read fast enough - then sender fails with OSError 16 (device busy). Is it a correct way to do: sender should try-except and retry on fail? But what if sender sends a message with id, that is not being accepted by any of devices?

Image

Re: connecting pyboard to CAN BUS

Posted: Fri Sep 30, 2016 3:19 pm
by PappaPeppar
With CAN, all messages are received and acknowledged by all nodes on the bus. Then the filters decides if the message shall interrupt the software or the message shall be discarded. But if the bus it faulty or overloaded, you can get into a situation that messages from a node can not be sent to the bus. In that case you will get OSError 16. This will also happen when you call send() faster than the messages can be transmitted to the bus. At 1 Mbit/s you can send about one message each ms. I guess that this is what happens in your case. You can try to set the timeout argument to something sensible instead of catching the exception. It is documented here http://docs.micropython.org/en/latest/p ... b.CAN.send

Re: connecting pyboard to CAN BUS

Posted: Sat Oct 01, 2016 6:52 pm
by kamikaze
yeah. Looks like it worked ) https://youtu.be/zVPl3wx_bmI

Re: connecting pyboard to CAN BUS

Posted: Sun Oct 02, 2016 1:30 am
by kamikaze
Here is my example code (still in progress)

Re: connecting pyboard to CAN BUS

Posted: Tue Oct 11, 2016 12:27 pm
by kamikaze
in case if someone is interested in both CAN interface (1 and 2) cross-talk or even connecting to outer CAN bus - I have 10 PCBs for this. Actually 9 ) It is designed for two Microchip MCP2562 CAN transceivers

Image

Soldered all components and now testing

Re: connecting pyboard to CAN BUS

Posted: Mon Oct 31, 2016 7:41 am
by kamikaze
not tested in car yet, but there is a question... do I need to power my board from the car (OBD2 port for example) to get same ground with car`s CAN bus? Or is it just fine to connect CANH and CANL into OBD2 while having separate power supply for PyBoard? Google doesn't help so much. There are some CAN bus "hackers" that mention their arduino shield experience, but not actually saying HOW they connect them )

Re: connecting pyboard to CAN BUS

Posted: Mon Oct 31, 2016 8:32 am
by Roberthh
The CAN bus uses a diffferential signal. Given that, connecting the GND of PyBoard to the GND of the car is not mandatory, but it might help in case of noise & spikes. If you power PyBoard from the car's power network, then a common GND can be assumed anyhow. Us proper twisted & shielded cables, unless tehse are very short.