PKUMakers

 找回密码
 立即注册加入
搜索
查看: 19681|回复: 0

【3D打印】xyzprinter Da Vinci 1.0打印机刷材料盒线材长度复位程序

[复制链接]

25

主题

34

帖子

194

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
194
发表于 2017-10-9 20:05:12 | 显示全部楼层 |阅读模式

XYZPrinting达芬奇是一个非常有趣的打印机。它提供了一个只有300g材料盒,打完就要换原厂的材料盒(有一个芯片保存了材料盒中材料的存量)。

这篇教程教怎么在使用外部材料的情况下刷新原厂的芯片中的材料存量。


  背景知识


打开墨盒后,可以在其底部找到一个小PCB。它有三个连接器用于与打印机本身进行通信。仔细检查该微小PCB显示了Microchip 11LC010 1K EEPROM的核心。该EEPROM具有128字节的存储容量,其存储关于长丝盒的信息。

SCIO引脚运行UNI / O协议,芯片通过8位指令寄存器进行控制。


  步骤


0. 将打印机的墨盒拿出来,找到底部的芯片

1. 创建一个的Arduino程序(程序已经写好见附件),程序可以写入EEPROM的内容,把计数器重置为999m剩余可用材料。

这里是EEPROM的内容。

您可以在字节偏移53处看到一个小字节格式的4字节长HEX值,这反映了传送给打印机的剩余长丝长度。这不是一个字面值,而是以某种方式“被破坏”。但是,将此值设置为0x3f420f00将灯丝计数器恢复为剩余999m。(想要复写计数器就保持默认)


00:5A41570000343141C0D40100C0D40100 ZAW..41A ...... ..
10:D2005A00544847423031313500000000 ..Z.THGB0115 ...。
20:000000003400000001010101AA55AA55 ... .4 ...... ..UU
30:883355AA 3F420f00 D04407202FAE0A00 .3U ...... D。/ ...
40:5A41570000343141C0D40100C0D40100 ZAW..41A ...... ..
50:D2005A00544847423031313500000000 ..Z.THGB0115 ...。
60:000000003400000001010101AA55AA55 ... .4 ...... ..UU
70:883355AAC0D40100AA55AA5507830A00 .3U ...... UU ...。


2. 写入Arduino该程序
写入没有开始时,Arduino上的LED会闪烁。
3. 以一下方式分别连接Arduino上的引脚和材料盒子上的触点

三个连接器如下(从上图的左到右):

  1. 线材盒接头=Arduino接头
复制代码

4. 按照上述方法进行上述连接后,LED将保持点亮约2秒,然后闪烁一下,表示EEPROM已成功写入。5. 实际测试是否可以打印,如果显示Unidentified Cartridge的错误,重新从0步骤开始刷芯片

参考https://www.voltivo.com/da-vinci ... t-using-an-arduino/

程序:

  1. #ifndef _NANODEUNIO_LIB_H
  2. #define _NANODEUNIO_LIB_H

  3. #if ARDUINO >= 100
  4.   #include <Arduino.h> // Arduino 1.0
  5. #else
  6.   #include <WProgram.h> // Arduino 0022
  7. #endif

  8. #define NANODE_MAC_DEVICE 0xa0
  9. #define NANODE_MAC_ADDRESS 0xfa

  10. #define CODE 0x00 //1 Byte
  11. #define MATERIAL 0x01 //1 Byte
  12. #define COLOR 0x02  //2 Bytes
  13. #define DATE 0x05        //4 Bytes
  14. #define TOTALLEN 0x08 //4 Bytes
  15. #define NEWLEN 0x0C //4 Bytes
  16. #define HEADTEMP 0x10        //2 Bytes
  17. #define BEDTEMP 0x12        //2Bytes
  18. #define MLOC 0x14        //2 Bytes
  19. #define DLOC 0x16        //2 Bytes
  20. #define SN 0x18                //12 Bytes
  21. #define CRC 0x24        //2 Bytes
  22. #define LEN2 0x34        //4 Bytes
  23. #define EOFM 0x38        //4 Bytes
  24. #define SCODE 0x3c        //4 Bytes

  25. void IncrementSerial(unsigned char * cArray, long lAddress, long lSize)
  26. {
  27.         unsigned char szTempBuffer[20] = {0};
  28.         memcpy(szTempBuffer,&cArray[lAddress],lSize);
  29.         long lSerial = atol((char *)szTempBuffer);
  30.         lSerial++;
  31.         sprintf((char *)szTempBuffer,"%04d",lSerial);
  32.         memcpy(&cArray[lAddress],szTempBuffer,lSize);
  33. }

  34. class NanodeUNIO {
  35. private:
  36.   byte addr;
  37. public:
  38.   NanodeUNIO(byte address);

  39.   boolean read(byte *buffer,word address,word length);
  40.   boolean start_write(const byte *buffer,word address,word length);
  41.   boolean enable_write(void);
  42.   boolean disable_write(void);
  43.   boolean read_status(byte *status);
  44.   boolean write_status(byte status);
  45.   boolean await_write_complete(void);
  46.   boolean simple_write(const byte *buffer,word address,word length);
  47. };

  48. #endif /* _NANODEUNIO_LIB_H */

  49. #define UNIO_STARTHEADER 0x55
  50. #define UNIO_READ        0x03
  51. #define UNIO_CRRD        0x06
  52. #define UNIO_WRITE       0x6c
  53. #define UNIO_WREN        0x96
  54. #define UNIO_WRDI        0x91
  55. #define UNIO_RDSR        0x05
  56. #define UNIO_WRSR        0x6e
  57. #define UNIO_ERAL        0x6d
  58. #define UNIO_SETAL       0x67

  59. #define UNIO_TSTBY 600
  60. #define UNIO_TSS    10
  61. #define UNIO_THDR    5
  62. #define UNIO_QUARTER_BIT 10
  63. #define UNIO_FUDGE_FACTOR 5
  64. #define UNIO_OUTPUT() do { DDRD |= 0x80; } while (0)
  65. #define UNIO_INPUT() do { DDRD &= 0x7f; } while (0)

  66. static void set_bus(boolean state) {
  67.   PORTD=(PORTD&0x7f)|(!!state)<<7;
  68. }

  69. static boolean read_bus(void) {
  70.   return !!(PIND&0x80);
  71. }
  72. static void unio_inter_command_gap(void) {
  73.   set_bus(1);
  74.   delayMicroseconds(UNIO_TSS+UNIO_FUDGE_FACTOR);
  75. }

  76. static void unio_standby_pulse(void) {
  77.   set_bus(0);
  78.   UNIO_OUTPUT();
  79.   delayMicroseconds(UNIO_TSS+UNIO_FUDGE_FACTOR);
  80.   set_bus(1);
  81.   delayMicroseconds(UNIO_TSTBY+UNIO_FUDGE_FACTOR);
  82. }

  83. static volatile boolean rwbit(boolean w) {
  84.   boolean a,b;
  85.   set_bus(!w);
  86.   delayMicroseconds(UNIO_QUARTER_BIT);
  87.   a=read_bus();
  88.   delayMicroseconds(UNIO_QUARTER_BIT);
  89.   set_bus(w);
  90.   delayMicroseconds(UNIO_QUARTER_BIT);
  91.   b=read_bus();
  92.   delayMicroseconds(UNIO_QUARTER_BIT);
  93.   return b&&!a;
  94. }

  95. static boolean read_bit(void) {
  96.   boolean b;
  97.   UNIO_INPUT();
  98.   b=rwbit(1);
  99.   UNIO_OUTPUT();
  100.   return b;
  101. }

  102. static boolean send_byte(byte b, boolean mak) {
  103.   for (int i=0; i<8; i++) {
  104.     rwbit(b&0x80);
  105.     b<<=1;
  106.   }
  107.   rwbit(mak);
  108.   return read_bit();
  109. }

  110. static boolean read_byte(byte *b, boolean mak) {
  111.   byte data=0;
  112.   UNIO_INPUT();
  113.   for (int i=0; i<8; i++) {
  114.     data = (data << 1) | rwbit(1);
  115.   }
  116.   UNIO_OUTPUT();
  117.   *b=data;
  118.   rwbit(mak);
  119.   return read_bit();
  120. }

  121. static boolean unio_send(const byte *data,word length,boolean end) {
  122.   for (word i=0; i<length; i++) {
  123.     if (!send_byte(data[i],!(((i+1)==length) && end))) return false;
  124.   }
  125.   return true;
  126. }

  127. static boolean unio_read(byte *data,word length)  {
  128.   for (word i=0; i<length; i++) {
  129.     if (!read_byte(data+i,!((i+1)==length))) return false;
  130.   }
  131.   return true;
  132. }

  133. static void unio_start_header(void) {
  134.   set_bus(0);
  135.   delayMicroseconds(UNIO_THDR+UNIO_FUDGE_FACTOR);
  136.   send_byte(UNIO_STARTHEADER,true);
  137. }

  138. NanodeUNIO::NanodeUNIO(byte address) {
  139.   addr=address;
  140. }

  141. #define fail() do { sei(); return false; } while (0)

  142. boolean NanodeUNIO::read(byte *buffer,word address,word length) {
  143.   byte cmd[4];
  144.   cmd[0]=addr;
  145.   cmd[1]=UNIO_READ;
  146.   cmd[2]=(byte)(address>>8);
  147.   cmd[3]=(byte)(address&0xff);
  148.   unio_standby_pulse();
  149.   cli();
  150.   unio_start_header();
  151.   if (!unio_send(cmd,4,false)) fail();
  152.   if (!unio_read(buffer,length)) fail();
  153.   sei();
  154.   return true;
  155. }

  156. boolean NanodeUNIO::start_write(const byte *buffer,word address,word length) {
  157.   byte cmd[4];
  158.   if (((address&0x0f)+length)>16) return false; // would cross page boundary
  159.   cmd[0]=addr;
  160.   cmd[1]=UNIO_WRITE;
  161.   cmd[2]=(byte)(address>>8);
  162.   cmd[3]=(byte)(address&0xff);
  163.   unio_standby_pulse();
  164.   cli();
  165.   unio_start_header();
  166.   if (!unio_send(cmd,4,false)) fail();
  167.   if (!unio_send(buffer,length,true)) fail();
  168.   sei();
  169.   return true;
  170. }

  171. boolean NanodeUNIO::enable_write(void) {
  172.   byte cmd[2];
  173.   cmd[0]=addr;
  174.   cmd[1]=UNIO_WREN;
  175.   unio_standby_pulse();
  176.   cli();
  177.   unio_start_header();
  178.   if (!unio_send(cmd,2,true)) fail();
  179.   sei();
  180.   return true;
  181. }

  182. boolean NanodeUNIO::disable_write(void) {
  183.   byte cmd[2];
  184.   cmd[0]=addr;
  185.   cmd[1]=UNIO_WRDI;
  186.   unio_standby_pulse();
  187.   cli();
  188.   unio_start_header();
  189.   if (!unio_send(cmd,2,true)) fail();
  190.   sei();
  191.   return true;
  192. }

  193. boolean NanodeUNIO::read_status(byte *status) {
  194.   byte cmd[2];
  195.   cmd[0]=addr;
  196.   cmd[1]=UNIO_RDSR;
  197.   unio_standby_pulse();
  198.   cli();
  199.   unio_start_header();
  200.   if (!unio_send(cmd,2,false)) fail();
  201.   if (!unio_read(status,1)) fail();
  202.   sei();
  203.   return true;
  204. }

  205. boolean NanodeUNIO::write_status(byte status) {
  206.   byte cmd[3];
  207.   cmd[0]=addr;
  208.   cmd[1]=UNIO_WRSR;
  209.   cmd[2]=status;
  210.   unio_standby_pulse();
  211.   cli();
  212.   unio_start_header();
  213.   if (!unio_send(cmd,3,true)) fail();
  214.   sei();
  215.   return true;
  216. }

  217. boolean NanodeUNIO::await_write_complete(void) {
  218.   byte cmd[2];
  219.   byte status;
  220.   cmd[0]=addr;
  221.   cmd[1]=UNIO_RDSR;
  222.   unio_standby_pulse();
  223.   do {
  224.     unio_inter_command_gap();
  225.     cli();
  226.     unio_start_header();
  227.     if (!unio_send(cmd,2,false)) fail();
  228.     if (!unio_read(&status,1)) fail();
  229.     sei();
  230.   } while (status&0x01);
  231.   return true;
  232. }

  233. boolean NanodeUNIO::simple_write(const byte *buffer,word address,word length) {
  234.   word wlen;
  235.   while (length>0) {
  236.     wlen=length;
  237.     if (((address&0x0f)+wlen)>16) {
  238.       wlen=16-(address&0x0f);
  239.     }
  240.     if (!enable_write()) return false;
  241.     if (!start_write(buffer,address,wlen)) return false;
  242.     if (!await_write_complete()) return false;
  243.     buffer+=wlen;
  244.     address+=wlen;
  245.     length-=wlen;
  246.   }
  247.   return true;
  248. }

  249. static void status(boolean r)
  250. {
  251.   if (r) Serial.println("(success)");
  252.   else Serial.println("(failure)");
  253. }

  254. static void dump_eeprom(word address,word length)
  255. {
  256.   byte buf[128];
  257.   char lbuf[80];
  258.   char *x;
  259.   int i,j;

  260.   NanodeUNIO unio(NANODE_MAC_DEVICE);
  261.   
  262.   memset(buf,0,128);
  263.   status(unio.read(buf,address,length));
  264.   
  265.   for (i=0; i<128; i+=16) {
  266.     x=lbuf;
  267.     sprintf(x,"%02X: ",i);
  268.     x+=4;
  269.     for (j=0; j<16; j++) {
  270.       if (!(j & 0x03)) {
  271.         sprintf(x, " ");
  272.         x+=1;
  273.       }
  274.       sprintf(x,"%02X",buf[i+j]);
  275.       x+=2;
  276.     }
  277.     *x=32;
  278.     x+=1;
  279.     for (j=0; j<16; j++) {
  280.       if (buf[i+j]>=32 && buf[i+j]<127) *x=buf[i+j];
  281.       else *x=46;
  282.       x++;
  283.     }
  284.     *x=0;
  285.     Serial.println(lbuf);
  286.   }
  287. }

  288. int led = 13;

  289. /*
  290. These are the values to be written to the EEPROM
  291. Make sure only one is uncommented.
  292. By default its set for the starter ABS cartdridge with 120m of filament

  293. Verified with firmware 1.1.I
  294. */

  295. // Value to write to the EEPROM for remaining filament lenght
  296. // Default Starter Cartdridge is 120m

  297. //char x[] = {0xc0,0xd4,0x01,0x00}; //120m
  298. char x[] = {0x80,0xa9,0x03,0x00}; //240m
  299. //char x[] = {0x80,0x1a,0x06,0x00}; //400m

  300. // extruder temp, default is 210 C for ABS
  301. // 180 C for PLA
  302. //char et[] = {0xb4,0x00}; // 180 C
  303. //char et[] = {0xb9,0x00}; // 185 C
  304. //char et[] = {0xbe,0x00}; // 190 C
  305. //char et[] = {0xc8,0x00}; // 200 C
  306. //char et[] = {0xd2,0x00}; // 210 C
  307. char et[] = {0xe6,0x00}; // 230 C
  308. //char et[] = {0xf5,0x00}; // 245 C
  309. //char et[] = {0xfa,0x00}; // 250 C

  310. // bed temp 90 degrees, default ABS
  311. // 30 degrees foe PLA
  312. char bt[] = {0x5a,0x00}; // 90 C
  313. //char bt[] = {0x1e,0x00}; // 30 C

  314. char cc[] = {0xa7,0x06,0x0b,0x00}; //seems to be relavent to the first 5 characters of Serial number. In this case RF10X
  315. //char cc[] = {0x07,0x83,0x0a,0x00}; // for serial number beginning with 3DP01

  316. char ef[] = {0xaa,0x55,0xaa,0x55};

  317. char mt[] = {0x41}; // Material - "A" for ABS
  318. //char mt[] = {0x50}; // Material - "P" for PLA

  319. char cr[] = {0x5a,0x00}; // COLOUR - Default-0x5a,0x00  [White-0x57,0x00 Blue-0x42,0x00 Green-0x47,0x00 Black-0x4B,0x00 Red-0x52,0x00 Yellow-0x59,0x00 VirginViolet-0x43,0x00]

  320. byte sr;
  321. NanodeUNIO unio(NANODE_MAC_DEVICE);
  322.   
  323. void setup() {
  324.   pinMode(13, OUTPUT);
  325.   Serial.begin(115200);
  326. }

  327. void loop() {
  328.   
  329.   do {
  330.     digitalWrite(led, LOW);
  331.     Serial.println("Testing connection to Da Vinci EEPROM CHIP\n");   
  332.     delay(100);
  333.     digitalWrite(led, HIGH);
  334.   } while(!unio.read_status(&sr));
  335.   
  336.   Serial.println("Da Vinci EEPROM found...");
  337.   Serial.println("Reading the Davinci EEPROM Contents...");
  338.   dump_eeprom(0,128);
  339.   //dump_eeprom(116,4);

  340.   //*
  341.   //Read the serial number - added by Matt
  342.   byte buf[20];
  343.   memset(buf,0,20);
  344.   status(unio.read(buf,SN,12));
  345.   //Increment the serial number
  346.   IncrementSerial(&buf[0], 0, 12);       

  347.   Serial.println("Updating EEPROM...");
  348.   status(unio.simple_write((const byte *)mt,MATERIAL,1));
  349.   status(unio.simple_write((const byte *)cr,COLOR,2));
  350.   status(unio.simple_write((const byte *)x,TOTALLEN,4));
  351.   status(unio.simple_write((const byte *)x,NEWLEN,4));
  352.   status(unio.simple_write((const byte *)et,HEADTEMP,2)); // extruder temp
  353.   status(unio.simple_write((const byte *)bt,BEDTEMP,2)); // bed temp
  354.   //Write the serial number
  355.   status(unio.simple_write((const byte *)buf,SN,12)); //Serial Number
  356.   status(unio.simple_write((const byte *)x,LEN2,4));
  357.   status(unio.simple_write((const byte *)ef,EOFM,4));
  358.   status(unio.simple_write((const byte *)cc,SCODE,4));
  359.   // same block from offset 0 is offset 64 bytes
  360.   status(unio.simple_write((const byte *)mt,64 + MATERIAL,1));
  361.   status(unio.simple_write((const byte *)cr,64 + COLOR,2));
  362.   status(unio.simple_write((const byte *)x,64 + TOTALLEN,4));
  363.   status(unio.simple_write((const byte *)x,64 + NEWLEN,4));
  364.   status(unio.simple_write((const byte *)et,64 + HEADTEMP,2)); // extruder temp
  365.   status(unio.simple_write((const byte *)bt,64 + BEDTEMP,2)); // bed temp
  366.    //Write the serial number
  367.   status(unio.simple_write((const byte *)buf,64 + SN,12)); //Serial Number
  368.   status(unio.simple_write((const byte *)x,64 + LEN2,4));
  369.   status(unio.simple_write((const byte *)ef,64 + EOFM,4));
  370.   status(unio.simple_write((const byte *)cc,64 + SCODE,4));

  371.   Serial.println("Dumping Content after modification...");
  372.   dump_eeprom(0,128);
  373.   // */
  374.   
  375.   digitalWrite(led, HIGH);   // turn the LED on
  376.   delay(10000);               // wait for two seconds
  377. }
复制代码






davinci_filament_reset.ino

11.62 KB, 下载次数: 3

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册加入

本版积分规则

Archiver|手机版|小黑屋|北京大学创客空间

GMT+8, 2021-4-15 01:06 , Processed in 0.035004 second(s), 21 queries .

快速回复 返回顶部 返回列表