Welcome! Log In Create A New Profile

Advanced

Melzi motherboad - M42 Bed fan command hangs controller

Posted by cezar.suteu 
Melzi motherboad - M42 Bed fan command hangs controller
April 12, 2017 11:18PM
Dear all,

I have a Mendel 90 Dibond (2003 kit). The firmware I run is [github.com] .I am flashing the printer from a Raspberry PI v2 based on instructions found in [hydraraptor.blogspot.ro] . Lastly I use Octoprint for managing my printer.

I have tried to connect the bed fan for cooling by using the instructions provided in the Mendel90_Dibond.pdf (I used a IRLZ44N MOSFET for the Melzi spare IO).

My problem is that when I run either M42 P28 S255 or M42 P28 S0 (from Octoprint terminal) the communication hangs. The printer does no longer respond to any other message (like M105) until I disconnect and reconnect again (which seems to me like it's giving the whole Melzi board a reboot).

How can I address this issue?

Best Regards,
Cezar
Re: Melzi motherboad - M42 Bed fan command hangs controller
April 13, 2017 01:22AM
Try unplugging the MOSFET and see if it still hangs when you do M42. That will tell you if it is a hardware fault or a firmware bug.


[www.hydraraptor.blogspot.com]
Re: Melzi motherboad - M42 Bed fan command hangs controller
April 13, 2017 02:00AM
Hi, thanks for quick reply. I have unplugged the MOSFET from the Melzi header and the issue still persists after M42.
Re: Melzi motherboad - M42 Bed fan command hangs controller
April 13, 2017 04:20AM
I have done more tests (MOSFET is still removed) :

Sending M42 P28 does not hang the controller (it replies OK to the serial command).

In the Marlin code, the following lines exist:
    case 42: //M42 -Change pin status via gcode
      if (code_seen('S'))
      {
        int pin_status = code_value();
        if (code_seen('P') && pin_status >= 0 && pin_status <= 255)
        {
          int pin_number = code_value();
          for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++)
          {
            if (sensitive_pins == pin_number)
            {
              pin_number = -1;
              break;
            }
          }
          
          if (pin_number > -1)
          {              
            pinMode(pin_number, OUTPUT);
            digitalWrite(pin_number, pin_status);
            analogWrite(pin_number, pin_status);
          }
        }
      }
     break;

I suppose if there is no S it will just break so there is something in one of the following three lines:
pinMode(pin_number, OUTPUT);
digitalWrite(pin_number, pin_status);
analogWrite(pin_number, pin_status);

I have tried reflashing the firmware with each of the three instructions commented. I get the following results:

Commenting only digitalWrite : still hangs
Commenting only analogWrite : still hangs
Commenting all three (pinMode, digitalWrite, analogWrite) : doesn't hang anymore but the output is not set
Commenting pinMode AND digitalWrite : still hangs
Commenting pinMode AND analogWrite : still hangs
Commenting digitalWrite AND analogWrite : still hangs

It seems like any of these function calls causes the hang. First of all, which one of digitalWrite and analogWrite should be used? Second, how can I dig into this further?

Regards,
Cezar
Re: Melzi motherboad - M42 Bed fan command hangs controller
April 13, 2017 05:26AM
Good news:

I have tried to compile the firmware (exact same source code) on my laptop (Windows 10 PRO, arduino 1.0.1 with Melzi from [github.com] copied into the hardware folder) and it works. Both the commands to start and stop the bed fan go through. The fan also works (my MOSFET choice was good).

So it seems the ino compilation result on the Raspberry PI is not ok for some reason. All the other functions of the printer work just fine.

Any suggestion to make it work with ino? My scripts to compile and download are as follows:
ino build -m atmega1284
ino upload -p /dev/ttyUSB0 -m atmega1284

Regards,
Cezar
Re: Melzi motherboad - M42 Bed fan command hangs controller
April 13, 2017 06:04AM
Update: I tried to use the arduino IDE over SSH with x forwarding to compile the firmware and download it (same result).

The version is 1.0.5 from the debian apt-get repositories.

(Linux octopi 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linux)
deb [mirrordirector.raspbian.org] jessie main contrib non-free rpi

I suspect the arduino 1.0.5 produces a compiled firmware that doesn't respond well to the M42 commands (it hangs). Unfortunately on the arduino website with old releases there is are no binaries for the platform arm (only windows and linux). So for now I am stuck with flashing the firmware with my laptop.

If someone can guide me into getting some arduino 1.0.1 binaries for the raspberry PI I would like to give it a try. It is very nice to have the possibility of flashing the firmware from the same machine that runs the printer.

Best Regards,
Cezar
Re: Melzi motherboad - M42 Bed fan command hangs controller
April 14, 2017 06:17AM
I use Arduino 1.0.5 and ino with the same command line on Raspberry PIs and M42 works fine. Perhaps your Melzi board support package has got corrupted. I can't think what else would make M42 hang. The I/O library calls must be used in other places, not just M42.


[www.hydraraptor.blogspot.com]
Sorry, only registered users may post in this forum.

Click here to login