Poking around in CAN Bus

Ive posted about a couple findings already. (Please publish some technical drawings) @Atom Suggested to make a new Thread to keep the Technicaldrawing Threat cleaner.
So i’ve opened up the Controller today and had a look at its two boards.
There is a total of 2 CAN transceivers. Each is singleend terminating the CAN Lines. The Modules so far didnt have a Termination Resistor. Simple reason: All the Connectors do share the same Bus. Which is pushing the standart a bit (from what ive read so far) but as long as it works, who cares eh?
I was mostly prepared to start soldering a DB9 COnnector to multible pads as i expected each connector having its own transceiver and the MCU relaying the important Data over to the Toolhead plug (which i had open yesterday). As all of them are in Parallel, and the Pins are 2.54mm apart, two Pinheaders ive had laying around, some Wire, Shrinkwrap and a Female DB9 Connector made a “Perfect” Adapter to get it into the CAN analyser im using.


With now a none intrusive way, ive hooked up the 3DPrinthead and had a look.
There is an ID “Pinged” frequently but it has no data send along. My guess, request to report something. Another ID is usually showing the Nozzletemp. If the Nozzletemp is set, its replaying the Current temp in Data 0-2 and Data 3 is the target point. Like the 190/220 readout. it needs 3 Bytes as Byte 0 and 1 are used and 2 acts as a 0x00 buffer. The reading is 10x higher to also have one digit after the decimal point.
The Filament runout sensor is also on CAN as well as the Surface Probe.
I didnt check the Fans fully but there were two commands sent when i changed the Nozzle Temp. The Feeding stepper is controlled over the Step, DIR lines in the Plug as well (Im guessing, as the Linear modules work the same way and i didnt see a rpm setting or simmilar. Would also make sense for the extrusion as you dont need a continous movement you can start and then “walk away” from. like the CNC module has).
The laser module Test fell through, sort off, as the lasermodule wanted to be calibrated first and i had the Module sittign soemwhere save but not fully coverd. The Blue light is quite nice looking at my Room ceiling, still emergance turned off the PSU :smiley:. should have worn the Savety goggels :sunglasses:. To the Huge codedump Franky provieded, i tried to send some commands with data, nobody answerd. and from my tests so far, when homing most values on “Set_Something” are getting 0x00ed and then not touched again. As all the IDs activly used sofar have been from 21 and up.
At start up, a couple Extended Frames make it onto the CAN aswell, dont know if thats activly used or if thats a spurr of data at init of the MCU.
Thanks for the read, have a good day.
Depending on what is suggested ill have another look onto stuff.

5 Likes

To recap what ive posted in the Other Thread.
Ive Taken the Splitter apart with Top and Bottom Pictures, its a streight through PCB, no Resitors (CAN wise), some small SMD componets (i guess resistors for the Step,Dir and Enable lines) and two Caps for Power smoothing.

The Lasermdule has gotten a basic look at, didnt take it to a PCB Lever Bits yet. It has the main controller PCB for Laserdiode and Fan and a ESP32-S Board for the Camera and its white LED. The black sticker on the Top of the Lasermodule is a Antenna which is connected to the ESP32 board via UFL connector.

The CNC Module again relativly simple in construction. The top of the PCB has all the components on it. The motor inside is a Spinpowertech.com one (which is a quite empty webpage, no infos on their products btw).
My guess, the reason why this motor is on the CAN and not on the “normal Motorcontrolle”, its not a Stepper so a Dir,Step, Enable signal isnt needed, give it Power, PWM, direction and your set.

2 Likes

Just had a second look at the 3D Printmodule itself.
The Filamentdrive has its own Driver (between the Cap and the 4Pin connector on the right) on the controller PCB and is controlled via the Steppermotor Lines by the Maincontroller. To keep the driver “cool” a thermalpad connects it to the Module Housing. All sensors and fans are, as in the other modules, done by Connectors. so if you fry a Board and you can rule out you killed the other components, you could ask Support for a Board instead of the full module (not sure if they will ship that though). If you are confident you can replace it yourself that is.

2 Likes

@Franky, on your dive through the Source code, have you seen a G/M command or a CAN ID which can be talked to get data from one to the other?
Like Ping a specific (hardcoded) ID with a specified (hardcoded) set of data options (1 or 0) or even a freely modifyable “GXXX YYID Data0 … Data7” ?
Not sure how a CAN Command would handle it as the G/M commands can get a bit long depending on what your trying to do.

1 Like

@Streupfeffer, sorry for the late delay, I’ve been extremely busy. Regarding your request, not seen anything similar yet. It’s really not an easy code to look for and now my machine is dismanteled as I’m conditioning a new space for it. The easiest way should be to look at the logs when starting the machine as it seems to have a lot but I have not yet get there.

I’ll keep you posted when I do :slight_smile:

1 Like

Hello, I wanted to pick your brains on something.

I’m brainstorming a project here (External Z Probe Sensor) where the CNC module (and maybe the 3DP head too) can use an external contact for Z probing.

Have you come across anything in the firmware or CAN poking around that would lend itself to any of the following approaches:

  • Modifying the firmware and building a CAN connected microprocessor that will allow the firmware to use an external contact
    • Have you ever come across the particular cable connector SM uses? Would be awesome if it was on Digikey or something.
  • Rather than modifying the firmware, would it be better to try and directly drive the motors from something plugged into the CAN bus?

Just saw your Post.

  1. I can get you the IDs which report when the Homing Endstops are hit (not usefull as the Printer is not behavign as i expected, maybe sourcecode digging will show why)
  2. Each linear module is controlled with a “EN,DIR,STEP” signal which is coming in via the cable. There is a Levelshifter for each Connector with 8 Pins.
    As priviously mentioned, there are two VP230 CAN transceivers on the Mainboard one is for all Extensions (i think) and one is for something else, maybe a PSU bus?
    Maybe if you Send on the 3D Printerhead Probe ID somethgni will happen?
    Im going to order a couple CAN enabled Boards for another Project, i do have a ESP32 laying around with a Transceiver. Sofar just using the Microchip CAN analyser was enough as i was mainly listening and manually triggering Send msgs.

I see the CanModule.cpp code seems to poll limits with FUNC_REPORT_LIMIT on line 339? If that’s relevant at all, I don’t have a debugger hooked up at the moment.

Thanks for the tips, I’ll keep poking along and let you know if I find anything useful as well.

Btw, if you have a pair of 2.54mm pins laying around, the Smaller Datapins are spaced perfectly for them to be stuffed in. Just be Carefull not to break anything :smiley:
Check the first Post in this thread, you see the “cable” there which i am using.

I do have a bunch of those laying around…Hmm, great tip. I also have male crimp JST pins, maybe I just make a ribbon cable with small pins that stick in the end.
image

Just did a Boot to 3D Calibration CAN sniff. https://pastebin.com/p0Pka2gz all the Data is in Hex

IDs 0-20 are Marlin specific and only set to 0 at Homing start.
0x16 looks like a Info request or a Heartbeat as its regular 500ms intervalls
0x615 Probe 3D module
0x616 is the Filament sensor (which is currently 0x01 as it has Filament loaded)
0x617 Target Nozzletemp (Bytes 0,1 report current x10, 2 is a spacer and 3 is the target Temp)
0x60D is Limitswitch Z axis
0x600 is Limitswitch X Axis
0x605 is Limitswitch Y Axis
Im not sure which limitswitch counts for the Dual Modules, i guess first reported?

2 Likes

Hi there,

I’ve been able to get the logs when starting up and get the reported IDs vs Functions for the 3 toolheads. Here you have what the FW says ( I’ve added the comment function myself :wink: ):

3DPRINT Module

Basic MacID:25863 FuncID:8 // FUNC_SET_FAN
Basic MacID:25863 FuncID:9 // FUNC_SET_FAN2
Basic MacID:25863 FuncID:6 // FUNC_REPORT_TEMPEARTURE
Basic MacID:25863 FuncID:7 // FUNC_SET_TEMPEARTURE
Basic MacID:25863 FuncID:1 // FUNC_REPORT_PROBE
Basic MacID:25863 FuncID:10 // FUNC_SET_PID
Basic MacID:25863 FuncID:2 // FUNC_REPORT_CUT
Basic MacID:25863 FuncID:16 // FUNC_REPORT_TEMP_PID
MsgID:20-FuncID:8 // FUNC_SET_FAN
MsgID:21-FuncID:1 // FUNC_REPORT_PROBE
MsgID:22-FuncID:2 // FUNC_REPORT_CUT
MsgID:23-FuncID:6 // FUNC_REPORT_TEMPEARTURE
MsgID:24-FuncID:9 // FUNC_SET_FAN2
MsgID:25-FuncID:10 // FUNC_SET_PID
MsgID:26-FuncID:7 // FUNC_SET_TEMPEARTURE
MsgID:27-FuncID:16 // FUNC_REPORT_TEMP_PID
Configuring Module, MAC ID: 0x00006507
Executer Count: 1
Basic ID: 0x00006507

Laser Module

Basic MacID:2120553 FuncID:8 // FUNC_SET_FAN
Basic MacID:2120553 FuncID:11 // FUNC_SET_CAMERA_POWER
Basic MacID:2120553 FuncID:12 // FUNC_SET_LASER_FOCUS
Basic MacID:2120553 FuncID:13 // FUNC_REPORT_LASER_FOCUS
MsgID:20-FuncID:8 // FUNC_SET_FAN
MsgID:21-FuncID:11 // FUNC_SET_CAMERA_POWER
MsgID:22-FuncID:13 // FUNC_SET_LASER_FOCUS
MsgID:23-FuncID:12 // FUNC_REPORT_LASER_FOCUS
Configuring Module, MAC ID: 0x00205B69
Executer Count: 1
Basic ID: 0x00205B69

CNC Module

Basic MacID:1073413 FuncID:5 // FUNC_REPORT_MOTOR_SPEED
Basic MacID:1073413 FuncID:4 // FUNC_SET_MOTOR_SPEED
MsgID:20-FuncID:5 // FUNC_REPORT_MOTOR_SPEED
MsgID:21-FuncID:4 // FUNC_SET_MOTOR_SPEED
Configuring Module, MAC ID: 0x00106105
Executer Count: 1
Basic ID: 0x00106105

Hope that helps to facilitate the understanding of the Snapmaker CAN Bus.

2 Likes

I’ll just tag on the corresponding code from the firmware to that. Helps parse the module ID from the MACID, if nothing else. I’m excited for the Snapmaker Air Conditioner…

// FuncID defines
typedef enum {
  FUNC_REPORT_LIMIT          ,  // 0
  FUNC_REPORT_PROBE          ,  // 1
  FUNC_REPORT_CUT            ,  // 2
  FUNC_SET_STEP_CTRL         ,  // 3
  FUNC_SET_MOTOR_SPEED       ,  // 4
  FUNC_REPORT_MOTOR_SPEED    ,  // 5
  FUNC_REPORT_TEMPEARTURE    ,  // 6
  FUNC_SET_TEMPEARTURE       ,  // 7
  FUNC_SET_FAN               ,  // 8
  FUNC_SET_FAN2              ,  // 9
  FUNC_SET_PID               ,  // 10
  FUNC_SET_CAMERA_POWER      ,  // 11
  FUNC_SET_LASER_FOCUS       ,  // 12
  FUNC_REPORT_LASER_FOCUS    ,  // 13
  FUNC_SET_LIGHT_COLOR       ,  // 14
  FUNC_REPORT_ENCLOSURE      ,  // 15
  FUNC_REPORT_TEMP_PID       ,  // 16
  FUNC_PROOFREAD_KNIFE       ,  // 17
  FUNC_SET_ENCLOSURE_LIGHT   ,  // 18
  FUNC_SET_FAN_MODULE        ,  // 19
}FUNC_ID_E;

#define MODULE_MASK_BITS  0x1ff00000
#define MODULE_EXECUTER_PRINT   0
#define MODULE_EXECUTER_CNC     1
#define MODULE_EXECUTER_LASER   2
#define MODULE_LINEAR           3
#define MODULE_LIGHT            4
#define MODULE_ENCLOSER         5
#define MODULE_ROTATE           6
#define MODULE_AIRCONDITIONER   7

//Can prepare
enum
{
  CMD_M_CONFIG = 0,
  CMD_S_CONFIG_REACK,
  CMD_M_REQUEST_FUNCID,
  CMD_S_REPORT_FUNCID,
  CMD_M_CONFIG_FUNCID,
  CMD_S_CONFIG_FUNCID_REACK,
  CMD_M_UPDATE_REQUEST, //6
  CMD_S_UPDATE_REQUEST_REACK,
  CMD_M_UPDATE_PACKDATA,
  CMD_S_UPDATE_PACK_REQUEST,
  CMD_M_UPDATE_END,
  CMD_M_VERSIONS_REQUEST,
  CMD_S_VERSIONS_REACK,
  CMD_M_SET_RANDOM,  // 设置随机数
  CMD_S_SET_RANDOM_REACK,
  CMD_M_SET_LINEAR_LEN,  // 设置模组长度
  CMD_S_SET_LINEAR_LEN_REACK,
  CMD_M_SET_LINEAR_LEAD,  // 设置导程
  CMD_S_SET_LINEAR_LEAD_REACK,
  CMD_M_SET_LINEAR_LIMIT,  // 设置限位开关位置
  CMD_S_SET_LINEAR_LIMIT_REACK,
  CMD_M_UPDATE_STATUS_REQUEST,
  CMD_S_UPDATE_STATUS_REACK,
  CMD_M_UPDATE_START,
};

2 Likes

Using @Franky’s help, I thought I would throw my complete startup dump on here, so we can compare the different in MACID and functions, etc. This is with the 3DP tool.

start
echo:PowerUp
Marlin SM2-3.2.2
 echo:Compiled: Aug 31 2020

echo: Last Updated: 2020-8-22 | Author: Snapmaker Team
echo:Compiled: Aug 31 2020
echo: Free Memory: 32735  PlannerBufferBytes: 1728
echo:V66 stored settings retrieved (1003 bytes; crc 37685)
echo:  G21 ; (mm)

echo:Filament settings: Disabled
echo:  M200 D1.75
echo:  M200 D0
echo:Steps per unit:
echo: M92 X400.00 Y400.00 Z400.00 E242.27
echo:Maximum feedrates (units/s):
echo:  M203 X150.00 Y150.00 Z30.00 E25.00
echo:Maximum Acceleration (units/s2):
echo:  M201 X5000.00 Y5000.00 Z100.00 E10000.00
echo:Acceleration (units/s2): P<print_accel> R<retract_accel> T<travel_accel>
echo:  M204 P750.00 R1000.00 T1000.00
echo:Advanced: B<min_segment_time_us> S<min_feedrate> T<min_travel_feedrate> J<junc_dev>
echo:  M205 B20000.00 S0.00 T0.00 J0.02
echo:Home offset:
echo:  M206 X-19.00 Y-10.00 Z0.00
echo:Auto Bed Leveling:
echo:  M420 S0 Z0.00
echo:  G29 W I0 J0 Z6.04875
echo:  G29 W I1 J0 Z6.23250
echo:  G29 W I2 J0 Z6.36875
echo:  G29 W I3 J0 Z6.51500
echo:  G29 W I4 J0 Z6.68625
echo:  G29 W I0 J1 Z6.25125
echo:  G29 W I1 J1 Z6.49625
echo:  G29 W I2 J1 Z6.63125
echo:  G29 W I3 J1 Z6.76250
echo:  G29 W I4 J1 Z6.84625
echo:  G29 W I0 J2 Z6.40375
echo:  G29 W I1 J2 Z6.58375
echo:  G29 W I2 J2 Z6.67500
echo:  G29 W I3 J2 Z6.84875
echo:  G29 W I4 J2 Z6.90875
echo:  G29 W I0 J3 Z6.46000
echo:  G29 W I1 J3 Z6.60625
echo:  G29 W I2 J3 Z6.73500
echo:  G29 W I3 J3 Z6.83250
echo:  G29 W I4 J3 Z6.87125
echo:  G29 W I0 J4 Z6.50750
echo:  G29 W I1 J4 Z6.53750
echo:  G29 W I2 J4 Z6.67500
echo:  G29 W I3 J4 Z6.69875
echo:  G29 W I4 J4 Z6.81750
echo:PID settings:
echo:  M301 P13.00 I0.10 D17.00
echo:Z-Probe Offset (mm):
echo:  M851 Z1.00
echo:Linear Advance:
echo:  M900 K0.07
echo:Filament load/unload lengths:
echo:  M603 L0.00 U60.00
success to create marlin task!
success to create HMI task!
success to create heartbeat task!
Screen Plugged!
Module enum
LEN:356
LEN:356
LEN:356
LEN:356
LEN:356
Length:356 Axis:1
Length:356 Axis:2
Length:356 Axis:1
Length:356 Axis:0
Length:356 Axis:2
Machine Size:
   X:0.00 - 345.00
   Y:0.00 - 357.00
   Z:0.00 - 334.00
Directions:
   X:1 Y:0 Z:0 E:0
Home Directions:
   X:-1 Y:1 Z:1
Home offset:
   X:-19.00 Y:-10.00 Z:0.00
MacIC:3652871 FuncID:0
MacIC:3653951 FuncID:0
MacIC:3653989 FuncID:0
MacIC:3654173 FuncID:0
MacIC:3654263 FuncID:0
Bind LinearModule
Linear Module:3652871 MsgID:5
Linear Module:3653951 MsgID:6
Linear Module:3653989 MsgID:12
Linear Module:3654173 MsgID:0
Linear Module:3654263 MsgID:13
Basic MacID:29125 FuncID:8
Basic MacID:29125 FuncID:9
Basic MacID:29125 FuncID:6
Basic MacID:29125 FuncID:7
Basic MacID:29125 FuncID:1
Basic MacID:29125 FuncID:10
Basic MacID:29125 FuncID:2
Basic MacID:29125 FuncID:16
Extend MacID:5266975 FuncID:15
Extend MacID:5266975 FuncID:18
Extend MacID:5266975 FuncID:19
MsgID:20-FuncID:8
MsgID:21-FuncID:1
MsgID:22-FuncID:2
MsgID:23-FuncID:6
MsgID:24-FuncID:9
MsgID:25-FuncID:10
MsgID:26-FuncID:7
MsgID:27-FuncID:16
Configuring Module, MAC ID: 0x000071C5
MsgID:28-FuncID:15
MsgID:29-FuncID:18
MsgID:30-FuncID:19
Configuring Module, MAC ID: 0x00505E1F
Executer Count: 1
Basic ID: 0x0037BD07
Basic ID: 0x0037C13F
Basic ID: 0x000071C5
Basic ID: 0x0037C165
Basic ID: 0x0037C21D
Basic ID: 0x0037C277
Extend ID: 0x00505E1F
grid manual
X:23 - 68
Y:18 - 76
PL: first free block index: 0
PL: first non-free block index: 0
PL: data has been masked
PL: next write index: 1
PL: Unavailable data!
3DPRINT Module
Chamber is connected
Finish init

Its been quite a while.
After getting shown how to unlock the Controller and add custom Firmware driectly without going throught Luban as a Upload preperation, i managed to add my custom M-Command which is able so send out CAN messages (just standart frames for now). Having the SN side “working” i needed something for it to controlle.
a ESP32 board and a couple Adressable LEDs later, i can send Data form my analyser to the ESPboard.
Next will be to get the SN2 to controlle them.

Pictures:
Canbus seen in ESPboard on the left, Data that has been sent from the Analyser on the right
ID for filtering, Data0 = LED, Data1= Red, Data2 = Green, Data3 = Blue, Data4 = Brightness
Brightness is changed on all LEDs when changed.

How its looking on the LEDs

4 Likes

Awesome work! Following this post to learn more. Going to tear down the SM2 laser module soon.

is anyone still messing around with this? I’m pretty interested in putting a better laser on my SM2. I’ve actually been looking at the Duet3 tool boards since they support CAN-BUS, I honestly haven’t done near the work y’all have but it would be awesome to work these in. If not I’ve also thought about working on changing out the controller for a Duet3 and then being able to use the tool boards. Unfortunately, I’m going to be gone on a long work trip and won’t be around my SM for a few months. But you guys have my juices flowing. For instance, I would like to put the endurance laser 8.5 watt. I think, the SM should of at least came with a 5 watt, but if I can get the 8.5 working that would be awesome. Keep up the good work!

You have to follow the thread here, if you want :wink:

So you know the SM does not communicate with the laser over CAN. All it does for the laser over CAN is set the fan speed and get the wireless info for the camera.

So if you wanted to, and can figure out witch wire was enable and witch was the pwm for laser power. All you should have to do is comondere those two wires (and the power if you wanted the new laser to be powered by the SM) and wire them to your new laser driver.

1 Like

The laser is directly controlled by the controller to have command over it. Canbus could fail to tell teh laser to turn off incase of a unforseen event, the controller will more likely be able to turn the laser off in that event. A meassuer im fully understanding and supporting. IF i would do a external laser controller module, There would be more safety features then just the Heartbeat of the controller. Like, hard wierd Emergency Stops, who wont let the laser be turned on if the circuit is broken, The coming Emergencystop would also be part of that, not sure if i would just rely on the Door contacts (which would be a requirement to have an encosure).
Also, how secure is your external driver, how are you getting the beam up to the Module spot, what about focusing the laser.