Marlin icon indicating copy to clipboard operation
Marlin copied to clipboard

[FR] XYZPrinting Da Vinci 1.0

Open kubark42 opened this issue 4 years ago • 27 comments

Description

A number of people have an XYZPrinting Da Vinci printer, and while it has a Repetier fork bouncing around, it's quite old now and the Marlin firmware would be a very nice upgrade.

The Da Vinci is a nicely build enclosed printer which uses a 32-bit Atmel ATSAM3X8E microcontroller and A4988ET stepper motor drivers.

Configuration Details

  • Manufacturer: XYZPrinting
  • Model: Da Vinci 1.0
  • Motherboard: 1.0
  • Repetier fork: https://github.com/luc-github/Repetier-Firmware-4-Davinci

Additional Information

  • Pinout: https://github.com/luc-github/Repetier-Firmware-4-Davinci/blob/master/pinout.xlsx
  • WINSTAR 16x4 documentation: https://github.com/luc-github/Repetier-Firmware-4-Davinci/blob/master/lcd-4x16-bn.pdf
  • Extruder and bed temperature vs ADC reading: https://github.com/luc-github/Repetier-Firmware-4-Davinci/blob/master/bed-extruder-tables.xlsx

kubark42 avatar Sep 01 '21 13:09 kubark42

I'd be very happy to take point on this if someone can walk me through the process of bringing up a new board. I did this a lot at Tau Labs, so am familiar with what it takes in general. I lack the specifics of how to do this with Marlin.

kubark42 avatar Sep 01 '21 13:09 kubark42

Its not just a board... The LCD is also non standard. a WINSTAR 16x4 char display. and 5 buttons, but how is it all connected? 24pin ribbon cable...

ellensp avatar Sep 01 '21 13:09 ellensp

I feel like the LCD is a nice-to-have, but certainly not a requirement. If there's already support in Marlin for this style of driver and it's only the pins which change, then cool. Otherwise, arguably it's not worth adding code bloat for a non-standard screen. The real payoff for the firmware upgrade is all the cool Marlin features.

Great question about how it's all connected. I did some digging in the Repetier fork and found several interesting documents. I linked them to my top post. It has uC pinouts, LCD documentation, etc...

The LCD is connected with a thin ribbon cable, as show in the pic below:

Screen Shot 2021-09-01 at 10 01 25

kubark42 avatar Sep 01 '21 14:09 kubark42

Well the first thing in my view is to examine the script apply_patches.py, work out what it does

It updates .platformio/packages/framework-arduino-sam with specifics for this board,

It replaces .platformio/packages/framework-arduino-sam/cores/arduino/USB/USBCore.cpp with the file Repetier-Firmware-4-Davinci/PIOPatches/USBCore.cpp and .platformio/packages/framework-arduino-sam/variants/arduino_due_x/variant.cpp with the file Repetier-Firmware-4-Davinci/PIOPatches/variant.cpp

diff Repetier-Firmware-4-Davinci/PIOPatches/USBCore.cpp .platformio/packages/framework-arduino-sam/cores/arduino/USB/USBCore.cpp
202,208c202
< //USB PATCH to avoid dead loop
< 		int count=0;
<     while( UOTGHS_DEVEPTISR_TXINI != (UOTGHS->UOTGHS_DEVEPTISR[ep & 0xF] & UOTGHS_DEVEPTISR_TXINI ))
<         {
<             count++;
<             if (count>10000) return len;
<         }
---
>
diff Repetier-Firmware-4-Davinci/PIOPatches/variant.cpp .platformio/packages/framework-arduino-sam/variants/arduino_due_x/variant.cpp
20c20
< //For Davinci Printer
---
> 
271,273c271,273
<     // 85 - USB
<   //{ PIOB, PIO_PB11A_UOTGID|PIO_PB10A_UOTGVBOF, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // ID - VBOF
<   { PIOB, PIO_PB11A_UOTGID, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // ID - VBOF
---
>   // 85 - USB
>   { PIOB, PIO_PB11A_UOTGID|PIO_PB10A_UOTGVBOF, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // ID - VBOF
> 
290,334c290
<   // 92 .. 99 placeholders, future-proofing.
<  // { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
<  // { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
<   { PIOB, PIO_PB22,          ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // PIN 92 - PB22 E1 Enabled
<   { PIOB, PIO_PB10, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL,NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // ID  9
<   { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
<   { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
<   { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
<   { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
<   { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
<   { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
<   // 100 - 108 extra SAM3X8E pins, not wired on Due
<   { PIOA, PIO_PA5, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 100
<   { PIOC, PIO_PC27, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 101
<   { PIOA, PIO_PA0, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 102
<   { PIOA, PIO_PA1, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 103
<   { PIOC, PIO_PC11, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 104
<   { PIOC, PIO_PC8B_PWML3, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH3, NOT_ON_TIMER }, // PWM 105
<   { PIOC, PIO_PC2B_PWML0, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH0, NOT_ON_TIMER }, // PWM 106
<   { PIOC, PIO_PC6B_PWML2, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH2, NOT_ON_TIMER }, //PWM 107
<   { PIOC, PIO_PC20, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, //PWM 108
<   // 109 .. 114
<   { PIOA, PIO_PA20A_MCCDA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN_HSMCI_MCCDA_GPIO 109
<   { PIOA, PIO_PA19A_MCCK, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN_HSMCI_MCCK_GPIO 110
<   { PIOA, PIO_PA21A_MCDA0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN_HSMCI_MCDA0_GPIO 111
<   { PIOA, PIO_PA22A_MCDA1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN_HSMCI_MCDA1_GPIO 112
<   { PIOA, PIO_PA23A_MCDA2, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN_HSMCI_MCDA2_GPIO 113
<   { PIOA, PIO_PA24A_MCDA3, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN_HSMCI_MCDA3_GPIO 114
<   // 115 .. 124 - ETHERNET MAC
<   { PIOB, PIO_PB0A_ETXCK, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // ETXCK 115
<   { PIOB, PIO_PB1A_ETXEN, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // ETXEN 116
<   { PIOB, PIO_PB2A_ETX0, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // ETX0 117
<   { PIOB, PIO_PB3A_ETX1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // ETX1 118
<   { PIOB, PIO_PB4A_ECRSDV, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // ECRSDV 119
<   { PIOB, PIO_PB5A_ERX0, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // ERX0 120
<   { PIOB, PIO_PB6A_ERX1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // ERX1 121
<   { PIOB, PIO_PB7A_ERXER, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // ERXER 122
<   { PIOB, PIO_PB8A_EMDC, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // EMDC 123
<   { PIOB, PIO_PB9A_EMDIO, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // EMDIO 124
<   // 125
<   { PIOB, PIO_PB24, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 125
<   { PIOB, PIO_PB21X1_AD14,   ID_PIOB, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC0,  ADC14,  NOT_ON_PWM,  NOT_ON_TIMER },  // PIN 126 - PB21 with enabled ADC
<   { PIOB, PIO_PB13X1_AD9,   ID_PIOB, PIO_INPUT,    PIO_DEFAULT, PIN_ATTR_ANALOG,                   ADC0,  ADC9,  NOT_ON_PWM,  NOT_ON_TIMER },  // PIN 127 - PB13 with enabled ACD AD9
< 
<  // END
---
>   // END

Mostly this is adding pins 92-99,109 -114 and 115 .. 125

which leaves the change to this line, what does it do? Do we need to create a variant, or can it be done some other way.

Modofied < { PIOB, PIO_PB11A_UOTGID, <- this one is changed ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM,
NOT_ON_TIMER }, // ID - VBOF

Original.

{ PIOB, PIO_PB11A_UOTGID|PIO_PB10A_UOTGVBOF, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM,
NOT_ON_TIMER }, // ID - VBOF

And then there is the "USB PATCH to avoid dead loop" to consider.

I suspect will need to create our own marlin board variant to support this board.

ellensp avatar Sep 04 '21 10:09 ellensp

So would it be fair to say this is not as straightforward as appropriately configuring Configuration.h and Configuration_adv.h?

If so, that's disappointing, and arguably not worthwhile until there's a larger pool of people who'd benefit.

kubark42 avatar Sep 05 '21 10:09 kubark42

Needs a board variant created, need a new board pins.h file added, needs a new type of LCD added. Then you can add a Configuration.h and Configuration_adv.h that uses these features

ellensp avatar Sep 05 '21 10:09 ellensp

Needs a board variant created, need a new board pins.h file added, needs a new type of LCD added. Then you can add a Configuration.h and Configuration_adv.h that uses these features

So, here's my understanding:

  • New variant
    • Where are the variants kept? I have perused https://github.com/MarlinFirmware/Marlin/tree/2.0.x/Marlin/src and nothing jumps out at me.
  • New pins.h
    • This seems easy and straightforward: Clone a ATSAM3X8E board, e.g. https://github.com/MarlinFirmware/Marlin/blob/2.0.x/Marlin/src/pins/sam/pins_ARCHIM1.h, and point toward the Da Vinci board pins.
  • LCD
    • Ignore LCD for the time being, as it's not a priority and is not required
  • Add Configuration.h and Configuration_adv.h.
    • This seems like it requires some amount of specialized familiarity. If I get things as far as this, is it easy to find someone to guide me at that point?

kubark42 avatar Sep 06 '21 23:09 kubark42

I have created a Marlin that complies for this board. It creates the Variant It has a boards pins.h file LCD is not supported at all It has a rudimentary Configuration files

I have no way to test any of this.

Test each function with extreme caution!

It may not boot, it may set all heaters to max and try and burn you, all the axes are probably backward. Pins could be all wrong. Assume nothing!

You probably should not do this is you cannot restore the machine to its current state.

NB the thermistor type are wrong... at default of 1.

Its a start https://github.com/ellensp/Marlin/tree/Da_Vinci_1.0

ellensp avatar Sep 08 '21 10:09 ellensp

You can see whats been changed in https://github.com/ellensp/Marlin/commit/9b5c44aa68427ea807c8cd57774dfbf8a3883942

ellensp avatar Sep 08 '21 10:09 ellensp

Thanks! I'm sincerely appreciative of this, I hadn't at all expected such an awesome boost this early in the project.

I've got the board pulled out of the machine and sitting on my desk, so it should be easy to test.

So that I know how to start massaging these values myself, how did you determine what changes to make? I notice that some tweaks, such as https://github.com/ellensp/Marlin/commit/9b5c44aa68427ea807c8cd57774dfbf8a3883942#diff-bb298d18dac4268225a7a53a5ad24844472530bdc63f6a98a2ba8d8158b75080R1375, seem very precise.

kubark42 avatar Sep 08 '21 11:09 kubark42

Information was extracted from https://github.com/luc-github/Repetier-Firmware-4-Davinci/blob/master/src/ArduinoDUE/Repetier/Configuration.h where possible

ellensp avatar Sep 08 '21 11:09 ellensp

Ahhhh, makes sense. I'm guessing you've done this before so you knew how to translate from Repetier settings to Marlin. 😄

Okay, gonna get right on this today and see how far I can get. Hopefully because there's already Repetier on it I can easily use the bootloader to switch to Marlin.

kubark42 avatar Sep 08 '21 11:09 kubark42

Its sort of readable, but no I've have very little to do with Repetier. I just read through it, picking out what I could see translated easily to marlin

ellensp avatar Sep 08 '21 11:09 ellensp

Gotcha.

BTW, hats off to whoever created Auto Build Marlin. I just discovered it and it was everything I could have wanted. The only, admittedly very minor, challenge was realizing that I needed to check-out the Da_Vinci_1.0 branch in order to have ABM see the correct build files. Once on the correct branch, ABM downloaded all the correct reqs and built everything flawlessly. Now on to the next step!

kubark42 avatar Sep 08 '21 12:09 kubark42

GRUMBLE, GRUMBLE, first hiccup is that the board won't power on with a pure USB connection. The upshot is that I have to bring it back to my lab, where the rest of the printer is, before I can power it on and test any further.

kubark42 avatar Sep 08 '21 12:09 kubark42

On the plus side, it flashed okay.

On the negative side, well, it didn't exactly brick the board since the bootloader still works, but once past the bootloader stage the USB port disappears. I haven't started to look into it yet, but I suspect that Marlin firmware uses a set of alternative serial port pins from the ones used on the board.

kubark42 avatar Sep 11 '21 12:09 kubark42

@ellensp, do you think the serial port issue could be because https://github.com/ellensp/Marlin/commit/9b5c44aa68427ea807c8cd57774dfbf8a3883942#diff-bb298d18dac4268225a7a53a5ad24844472530bdc63f6a98a2ba8d8158b75080R105 sets the SERIAL_PORT to -1?

kubark42 avatar Sep 11 '21 12:09 kubark42

when the usb port is directly connected to the Controller cpu, SERIAL_PORT should be -1 If its using a uart with a usb to serial chip, then its ports 0-3, but I don't see any usb-serial chips on your board...not on the picture above.

Trace the D-,D+ pins from usb port, where do they go?

On the due its these pins D- pin 38 DHSDM D+ pin 37 DHSDP

ellensp avatar Sep 11 '21 12:09 ellensp

https://github.com/ellensp/Marlin/commit/9b5c44aa68427ea807c8cd57774dfbf8a3883942#diff-1cc05ed1b31b129e4b57e0d9f1da1ad3bf9aa261f05c5f09c84f1b4473ffdd8dR124 shows that the serial port is configured as PA8/PA9, which is the same as in the pinout.xls file.

I'll trace the pins and report back to be sure.

kubark42 avatar Sep 11 '21 13:09 kubark42

Scoped out and confirmed that D- goes to 38 and D+ to pin 37.

Could this be a crystal configuration issue? The Davinci board uses a 12.000H40 crystal, which is the same 12MHz xtal as on the Archim I have here.

https://github.com/ellensp/Marlin/blob/9b5c44aa68427ea807c8cd57774dfbf8a3883942/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.h shows 12MHz, but I can't find the equivalent for this board setting.

kubark42 avatar Sep 11 '21 14:09 kubark42

Due also has 12mhz crystal on xin,xout

ellensp avatar Sep 12 '21 00:09 ellensp

Hmmm..., I am too unfamiliar with the ATSAM to have many other ideas why the chip might have crashed or the serial port might be misconfigured.

I'm thinking it might make sense to shotgun this with the variants of DUE boards and see if anything boots up properly. With a bit of luck, it would give us a known good scaffold upon which to progress.

Thoughts?

kubark42 avatar Sep 12 '21 14:09 kubark42

Complete Noob here - But I am following this thread anxiously...This would be such a great mod for this printer. I have the AiO version though, with the scanner built in. Could anyone help me backup the firmware that is on the MCU in case i brick mine. Before i try any mods

TokoloshiMedicine avatar Mar 29 '22 06:03 TokoloshiMedicine

I'm in the midst of trying to get Marlin working on the Duet 2 Maestro with the ARMv4 ATSAM4S8C. My brain is falling out.

thinkyhead avatar Apr 21 '22 12:04 thinkyhead

Haha I hear you, well good luck with that,keep up the great work

On Thu, 21 Apr 2022, 14:37 Scott Lahteine, @.***> wrote:

I'm in the midst of trying to get Marlin working on the Duet 2 Maestro with the ARMv4 ATSAM4S8C. My brain is falling out.

— Reply to this email directly, view it on GitHub https://github.com/MarlinFirmware/Marlin/issues/23628#issuecomment-1105156812, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYOS47JITAUSCN3JVHFK2JLVGFDYPANCNFSM5M36BUDA . You are receiving this because you commented.Message ID: @.***>

TokoloshiMedicine avatar Apr 21 '22 12:04 TokoloshiMedicine

could v1.1 source for a Crazy3DPrint CZ-300 help .. it also have an SAM4S mcu.. (ATSAM4S8C) same as due maestro but A5984 steppers.. CZ-300.zip

DragonSlayerSE avatar Aug 16 '23 13:08 DragonSlayerSE

HI guys, just to ask if the marlin for the davinci was created, thanks.

yoroboticscolombia avatar Feb 02 '24 22:02 yoroboticscolombia

Hi everyone, what about creating a draft PR gathering all the work?, I think we are missing just a few things

chepo92 avatar Sep 25 '25 15:09 chepo92

I have faith in the community to figure it out!

thinkyhead avatar Oct 02 '25 06:10 thinkyhead

Hey @thinkyhead, you mentioned you have some work done for the duet 2, do you have that in a public repo?

chepo92 avatar Oct 02 '25 11:10 chepo92