-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FR] CAN bus #7735
Comments
CAN is great, I love it! It might be good for remote displays, but onboard it adds a lot of cost but presents little benefit. Trinamic 2130 can not be interfaced to CAN with a CAN-SPI bridge, it needs an MCU to handle CAN. To get the best out of CAN, it really needs to be native to the MCU, going via an external CAN controller over SPI kills the performance advantage. Personally I would stick with SPI/I2C for everything on the main controller board and use RS485 or CAN for comms to remote devices such as LCD, smart toolheads etc. Cortex-M3 MCUs often have CAN, Anyway, we can blue sky as much as we like, but what you are proposing is a new hardware platform that does not exist. Perhaps if someone builds the hardware, we could consider adapting Marlin for it. |
Yes, have had a quick chat with Trinamic, and they don't (yet) have a driver that as inbuilt CAN support. I reckon that to have a future proof plan, which would then lead to silicon designers to integrate CAN is the best move. |
Some projects for can controlled closed loop steppers already exist. |
I'am really interested on this feature. I've been struggling with poor performance of SPI on medium range cable (over 2,5~3meters). |
Another possible protocol for can bus https://uavcan.org/ |
It is based on CAN FB by the looks of it.
Still waiting for some CAN bus firmware support
|
Ananas are now launching a new board: https://www.ogadget.com/x/ananasstepper3 |
Is CAN or RS485 already supported by Marlin? |
No, CAN or RS485 is currently not supported in Marlin 2.0 It is already implemented on the Duet 3 boards, which are not yet in production. |
You have info of CAN or RS485 in Marlin? Our board "VAkE" is already supporting Marlin 2. But we want a new board with one of the two buses ... |
Best to go for CAN then. CAN bus protocol is currently not supported in Marlin. |
There is a lot of work underway to get new 32bit boards set up and working. It sounds like this is something which needs to be implemented soon @thinkyhead might know more |
I think another problem is that enabling can bus in Arduino like frameworks not a good idea. With can bus you can build some distributed system (network of uC) in which each uC can control for example one stepper or one heater or one endstop. But it requres some kind of RTOS and huge redesing in MarlinFW |
Is this something that will likely come in Marlin 2.1? Several people I have talked to, want to use Marlin, but due to lack of support for CAN Bus, they have since moved onto using RepRap firmware on the Duet3D. |
Hey guys, anyone is still interested in canbus? I just made a board to test it out. Anyone that could help to integrate this into marlin would be alot of fun! I have a ton of canbus experience but would still need some help. |
Teaching Tech did a review on a new affordable option for tool changing. |
Yes, I've wanted this for months. I tried to implement it myself, but it was way over my head. It would be great to use for end-stops. Actual position reporting (using Chinese calipers com protocol on a slave cheap) or even motors. It would simplify electronics, but this approach would increase costs if you did everything over can. Not sure if the 1Mbps of can bus is fast enough even the new standard that allows faster speeds is 5Mbps. (is called Variable speed or something) Also that way we could have a Mainboard with complete USB C connectors. to power daughter boards and supply them with 12/24V I have build a few USB C breakout boards, but they don't have enough pins. (and yes i know 24V is out of spec for c. |
Although it migh be better to fork the base code of Marlin and do a rewrite, because it would probably be impossible to intergrade it while support the centralized approach for other boards. |
@Atanasovgoran If you can work with that i can go ahead and try and help you in organizing the canbus data and or make hardware for "heads" or something for example. |
Yeah, we could give it a try. How do we start? Do we create a Repo fot that? I am planning to buy some canbus boards arduino boards just to experiment and try moving some Motors for testing. |
@Atanasovgoran start out with another fork of Marlin I think is easiest. Though in the distant future, mainboards would no longer require dedicated circuits. Though a 6 pin interface will be required |
Yeah, that's why i thought USB - C could work. out of the 12 (there are 24 but it's reversable) 2 are ground and 2 are VCC (say 12-24V (although out of spec) The middle USB 2.0 should be thicker so 5V (shared ground with VCC) that leaves 6 conductores. I was thinking CAN Main, i2c and CAN aux. just in case the speed is not enough for everything. CAN main for motors and rest is CAN aux. And still i2c for display. so even display could use the same cable |
This one area that appears to be a hurdle, but isn't, as optimizations between controller and node can be introduced A naive approach could be to parse only extruder moves (extruders are used in tis example, however a myriad of other effectors can be optimized as well), and every say 3 extruder moves, set if necessary temperature and fan PWM values |
May I suggest you to use can-fd? You can find Dev boards for Arduino and
RPI, plus you get all those sweets add-ons and potentially 8 Mbit/s, given
how simple are 3d printers noise wise compared to automotive applications.
Can is already being replaced by CAN 2.0, so it makes no sense to start
with an old standard.
…On Sun, 27 Dec 2020, 23:41 Grogyan, ***@***.***> wrote:
"Not sure if the 1Mbps of can bus is fast enough even the new standard
that allows faster speeds is 5Mbps. (is called Variable speed or something)"
This one area that appears to be a hurdle, but isn't, as optimizations
between controller and node can be introduced
A naive approach could be to parse only extruder moves (extruders are used
in tis example, however a myriad of other effectors can be optimized as
well), and every say 3 extruder moves, set if necessary temperature and fan
PWM values
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7735 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACWD5UDOKWJ753WEEIYWRU3SW6ZYBANCNFSM4D4I4CAA>
.
|
USB C, must ensure that the cable itself has twisted pairs, as required by the CAN standard |
Hello i have interest on this for my re-arm + ramps board. the re-arm expose the CAN1 port (Rx:P0.0 and Tx:P0.1) in the I2C port greetings |
Here a project that connects a tool head via CAN bus. I want to do something similar with a MKS Monster8 (STM32F407) and a MKS THR42 tool head (RP2040 based). I've been looking into the issues with softwareserial on the rp2040 of a MKS THR42. There seems to be a resource conflict with the timers I guess. With the following code I managed to send some commands to the TMC2209, but reading still fails, all received data is 0. I use this softwareserial: https://github.com/pkElectronics/SoftwareSerialM#master
|
Thank you for the info! I expect we'll get CAN bus into shape for the next release following Marlin 2.2, which should be out soon. Just working through some issues in FT Motion and cleaning up scattered bugs. |
This is fantastic news Scott. Thanks for the update. |
That would be great, let me know if I can help in any way. I have MKS Monster8 V1 and V2 motherboards with integrated CAN interface and MKS THR42 (CAN bus tool head). The MKS THR36 and MKS THR42 are electrically identical, only the form factor is different. I managed to get the TMC2209 UART communication going on the THR42, it needs a low baud rate of 12K-32K, I recommend 22222 baud, which gives accurate timing numbers.
Still in Marlin there seems to be a hardware conflict with the timers used by SoftwareSerial.
|
I managed to get the CAN bus working in Marlin between a MKS Monster8 (bxCAN, STM32F407) and a BTT EBB42 V1.2 (fdCAN, STM32G0). The code on the 2 platforms is quite different because of the different CAN support. |
Hi rondlh, I have not contributed to Marlin before, but i do have some experience writing for canbus. i ordered a BTT EBB42 V1.2 and the U2C. Does anyone know what the feasability would be to support adding CAN onto an existing controller by connecting a U2C CAN_OUT to a supported marlin controller USB? |
The issue with using the USB on the control board is that, that port is often used by a host computer such as a Raspberry PI Ideally, and it should be easier, to use hardware SPI instead of software SPI. As for synchronization, this has been a core issue for a while, as Marlin needs to have a rewrite of the timing loop. |
The 8Mhz oscillator on these toolboards are generally use for a RTC, not for the CPU clock So that shouldn't be an issue with timing errors that come up |
That sounds a bit complicated to me. I use a motherboard with CAN on board (MKS Monster V1 and V2), and directly talk to the BTT EBB42 V1.2 over CAN, which also runs Marlin. So the MKS motherboards is kind of a master that sends some commands to the EBB42 to control fans/BLTouch/heaters and such. The EBB42 in return sends the hotend temp back (I use 4 times a second) and the IO status if anything changes. This works very well, but I cannot get the EBB42 extruder stepper to synchronize reliably. If I send a long command to the extruder stepper then I can see that they start at the same time, but the commands do not finish at the same time. For now I use an additional stepper cable next to the CAN bus cable to solve this. Still not bad in my view. |
But you can use an USB hub I guess...
SPI?
That seems right, I think a lower level control of the remote stepper is needed. |
The BTT EBB42 V1.2 runs at 64MHz, I'm not sure how this clock is generated, but what I can confirm is that there is a notable stepper clock difference (about 0.3% in my case). |
FYI there is an implementation here - https://github.com/markniu/PandaCAN/ - Personally ive kept away from any of the can implementations as none have brought in a clock sync. Its not a synchronous bus as many assume, and the output planning would need significant overhaul to execute blocks on a timing trigger. |
I'm aware of this project, I used it for reference and inspiration. You can avoid the synchronization issues by just using the extruder stepper driver on the motherboard. This requires an additional toolhead cable, but the cable is an easily available standard cable, so no big issue for now in my view. Other items work find like:
The onboard accelerometer ADXL345 needs some work, and there even is an SPI bus if you need one. |
Endstops / probe you will lose accuracy due to communication dwell vs interrupt driven local IO however this is within application requirements provided you lower homing speed to compensate. Heater output will absolutely need some heavy thought on local safety. We dont want to recreate the same issues klipper has where pin states are left stale and heater blocks melt when it disconnects just the wrong way / time. Regardless of design intent to limit motion on them... Ive seen people abuse toolboards for every axis on a machine... People find ways to do weird stuff lol |
My implementation is also interrupt driven, first on the toolhead, and also on the main motherboard that receives the CAN IO update. This results in a small but stable time delay of about 50uS (I run at 1M baud). As long as the delay is stable it doesn't impact accuracy. I keep the CAN bus idle as much as possible for this reason.
No worries on this topic, because the toolhead is running Marlin too, which has thermal protection enabled, and if you want you can enable HOTEND_IDLE_TIMEOUT and implement a heart beat signal (I didn't implement that yet).
Right, the toolboard is a tiny and powerful board that offers lots of possibilities |
Just wondering, how far you managed to progress on your implementation @rondlh? |
All tested and working well on the latest Marlin. |
Please post the Host and Head setup? What board you're using? |
What do you mean with "setup"? I'm using Marlin, not Klipper. Both boards are running the latest Marlin betas. The CAN bus needs some customizations of course, and additionally I have quite a number of customizations for ESP32 and BTT TFT integration (custom ExtUI). Perhaps I can filter out all non-essential changes. |
Thanks. |
There are hardware SPI modules to support CAN-FD on STM32F4 boards for RepRapFirmware (DFD to go into a stepstick driver slot, EFD to use the EXP expansion port), maybe those are worth looking at for enabling CAN on a wider range of boards. I believe @thinkyhead may have gotten one of these in the past. |
I like CAN very much, CAN is robust has many mechanisms build in for error checking, it is reasonably fast (depends on bitrate) It might be worth to think about device addressing and allocation, if everyone can set their own ID then it can become a mess real quickly. Having a good ID allocation will benefit making a robust bus and will contribute to making it easy to use maybe even plug and play, if devices are allocated an ID which also identifies the TYPE of device it would make filtering CAN packets super easy, and then a controller could send a discover command and figure out what devices are connected. after this a command protocol has to be build to communicate with the TYPE of device, to request the capabilities of the device and sending telemetry or other data (that is heat or speed or z-offset or anything else) Something to keep in mind: |
We're beginning to get some CAN bus features, so we can continue discussing specifics on those submissions as they arrive. Thanks for all your feedback on this most important feature! |
I have been toying with the idea for a few weeks now about unifying some of the communications with 3D printers. And thereby future proofing the 3D printer market.
One of these ideas, is looking at potential communication protocols/buses.
It came to conclusion that the use of a CAN bus could help streamline some of the control and sensing. Getting diagnostics, where available is also nice.
While things like the Trinamic 2130 can be interfaced to with a CAN to SPI bridge.
With CAN, external peripherals, like the common Remote Display (eg RepRapDiscount Full Graphic Display) could be easily extendable.
Though in the case of existing Remote Display's an interface controller would be needed, however, with bringing the code out of the main trunk, to enable Remote Displays to operate on a CAN, would alleviate the main processor of that extra processing overhead, and use those resources for printing, then just update the user as often as required.
The other thing too here is, what to do with the external SD card slots that are on these displays?
I have never been a fan of such long, and unshielded ribbon cables, which run via SPI on them. In future proofing, I would expect new Remote Displays to be engineered with USB (Type C connectors? Please?) thumb drive support, as these have shielding already, and are already designed for hot swap, whereas SD cards are not.
Question then is, would it be possible to have Marlin 2.x to incorporate CAN as a protocol/bus?
Disclaimer:
This is just a proposed idea.
I am not a coder at heart, and only do rudimentary dabbling from time to time.
The text was updated successfully, but these errors were encountered: