DIY enclosure controller - prototype on Arduino

I don’t have the original enclosure for the Snapmaker 2.0 so I decided to make my own Andurino based device to control my DIY enclosure.
Source code for Arduino was developed based on the original open source provided on Github by Snapmaker.
Well, honestly it was not easy to understand the open source code for the controller and Snapmaker modules - I spent many hours analyzing the details of the specifications CAN bus communication between the controller and the modules. I think I finally understood what this communication should look like. I quickly made a prototype for Andurino Nano - the tests were successful - module it is fully compatible and correctly detected when the machine is started.

I don’t have the original 4-wire cable (not available in the snapmaker store) so for the communication test I used cables dedicated to prototype boards. I only used 2 wires dedicated to the CAN bus and a separate power supply.
Now it’s time to design a more professional PCB.
So to be continued …

→ See how it works ←

10 Likes

Great stuff!

Any chance you could share your code please?

Wow - great job!
It looks like it really works and is controllable from the touch screen and Luban. Cool.

Some guys from this forum also doing something similar but more like “reverse engineering”. You should make a team together!
I’ve looked a few times inside this source codes on Github, but for me it’s a terrible abstraction.
So respect.
I am very curious about the final version.

1 Like

Thanks . I’m doing this for fun - not for profit, so I think I’ll share it - why not.
But first I have to finish it and clean up my code because it’s a terrible mess - now I’m a little ashamed of how it looks inside :disappointed:
I think I will create some tutorial or documentation to make it more useful and understandable for everyone.

Thanks.
I would like to make some additional modification / improvement: In the original enclosure you can control the Led lighting and fan speed with the M-code M1010 :

M1010 Sx Px
* S0: disable door event
* S1: enable door event
* S3: set light power, P 0-100%, eg.M1010 S3 P100 -> light 100%
* S4: set fan power, P 0-100%, eg.M1010 S4 P100  -> fan 100%

Parameter P is linear and means power in percent:

  • P0 - 0% of power - means OFF
  • P50 - 50% power
  • P100 - 100% power - means ON

But de facto it can take the values 0-255 (that’s one byte). So the values 101-255 are unused and treated always as 100%.

:thinking: I would like to add an additional RGB LED strip to my DIY enclosure, connect to this controller and then use the values from P101 … to P255 to switch different colors in this additional lighting - for example P101 - green, P102 blue … etc etc. also many RGB color mixes.
Then such a color change command, e.g. M1010 S3 P150, can be inserted into a Gcode executed by the printer and various interesting effects of color lighting can be generated automatically.
I think it would be cool and effective e.g. for recording a timelapse movie, etc.

5 Likes

Hi.
I am curious if there is any progress with this project? Did you implement what you planned?

Hi
Sorry for the late reply - I don’t have enough time lately. I think I have too much passion, hobbies, interesting things to do. Besides, work, family, and it’s winter and I like skiing …

Regarding the DIY module - well, I made a dedicated PCB, assembled it, well … it works,
looks like this:

I added an emergency button function in the software. I am currently testing a DS18B20 digital temperature sensor with 1-wire interface, LCD display, small buzzer, etc. I have some ideas for their functionality but it’s just more fun than any real need.

A soon I’ll prepare a short movie where you can see the details better and I will share
all necessary files to make such device.

By the way, I was a bit surprised because I ordered a 4 pin cable from Snapmaker. I cut it in half to connect it to my module. But I saw that this is probably somehow different (maybe new) version.

The longest pin is GND and it is connected to the black wire. It makes sense, of course.
:thinking: But it is the opposite of the cable cut by other users from this forum (e.g. Streupfeffer.)

P.S.
By the way, I am preparing a description /guide on CAN communication in Snapmaker 2.0, which includes examples, message identifiers, my program code fragments, etc.
It is 80% ready - I want to supplement it with examples and log files from CAN Bus Sniffer
to make everything better understandable. In a few days it will be ready.

7 Likes

Hi @ronin, thanks for the very awesome work! have you had time to finish up that guide on the can communication?

Hi Ronin,

This is some great work! Will you be sharing the Arduino code even if not finished?
I would love to tweek my SM2.0 and this would be an excellent starting point.

Hi @Ronin ,

Did you ggot around this module for snapmaker? I’m really interested in tweek m SM2.0 .

Thank ou for your awesome job

@Ronin thanks for great work on the DIY enclosure controls.
Anyway you could share with the world anything? I’m building my own enclosure and controlling lights/air assist/ nevermore filtration in manual is going to be “not optimal” :slight_smile:

@Ronin it’s quite impressive what you achieved on re-engineering the CAN communication and to turn it into an extension!
The code on the Nano: is this a fork of what Snapmaker published as module source code on GitHub (written for a different mcu) or built more less from scratch based on Arduino CAN examples for 328 mcu and your analysis of the Snapmaker CAN communication ?

Would be great if you could share your code - even with little or no documentation.
I assume I’m not the only one longing for it and we are heading Christmas… :wink:

Hello to all here,
I’m just building up the eletronics of the DIY enclosure controller.
The board works, but I can not switch the “LED-output” for the enclosure-lightning.
I have programmed the Arduino with the hex-file, provided by the YOUTUBE video.
Has anyone the same problem or a solution?

@Ronin Thank you for your work, if you could share the code, maybe it will help me.
I will also build up your “Rotary-Module”. Thank you also for this work.

Hi,
I suppose, @Ronin doesn’t visit this forum very often :frowning:

Back to this DIY controller - I also assembled it - it works quite well. However, after updating some firmware version in the Snapmaker controller it is no longer possible to control RGB LEDs - but I don’t need it.

Regarding to your problem - first check if you have the appropriate signal on Arduino pin D3 - responsible for turning on the lighting.

If you use a 24 V DC LED strip and want to power it from the Snapmaker controller, remember to make a jumper marked as ISO on the PCB and set the J1 jumper to 24 V. Make sure you use the appropriate transistors - I didn’t use Darlingtons at the beginning and it didn’t work at all. After replacing it with exactly the same one as in the project - everything works.

Hi Tomi,
thank you for your hints, I’m familar with electronics and all this was checked by me before I wrote here in the forum.
The D3 Port always stays at 0V!
The fan works and if I press the emergency stop, the RGB-red flashes.

Hi @dolle
maybe you have an older version of the HEX file?
If you connect your computer to Snapmaker with a USB cable and enter M1010 S3 P50 in the LUBAN console window, does the lighting work?

you are right, Ronin answered me, that he had put an actual HEX file for download in the Youtube description.
With this HEX file the light switches on and off!

1 Like