Remap Pin D9 to Pin 44 for Laser PWM

New Home Forum Mostly Printed CNC – MPCNC Troubleshooting – MPCNC Remap Pin D9 to Pin 44 for Laser PWM

Tagged: , , , ,

This topic contains 41 replies, has 9 voices, and was last updated by  Dan Garrison 9 months ago.

Viewing 30 posts - 1 through 30 (of 42 total)
  • Author
    Posts
  • #50698

    BrianP
    Participant

    I am adding a laser to my MPCNC with Arduino Mega 2560 with Ramps 1.4. To do this I am attempting to remap D9 fan to pin 44 (pin 7 of Aux2) for PWM control of the laser. I was running Marlin 1.0.1 and read that this had bugs in it. I have since updated to Marlin 1.1.8 which is supposed to be the latest and greatest. It is compiling and loading OK but my D9 is still active and pin 44 seems to be sitting around 2 VDC all the time regardless of what I have the fan set to.

    Any tips on how to fix this? Is there a better pin for me to map to?

    #50701

    Jeffeb3
    Participant

    How are you remapping it? Are you sure you’ve changed the right place?

    #50703

    BrianP
    Participant

    Thanks for the reply. I am remapping in the pins_Ramps.h

    //

    // Heaters / Fans

    //

    #ifndef MOSFET_D_PIN

    #define MOSFET_D_PIN -1

    #endif

    #ifndef RAMPS_D8_PIN

    #define RAMPS_D8_PIN 8

    #endif

    #ifndef RAMPS_D9_PIN

    #define RAMPS_D9_PIN 44 //remapped 9 to 44

    #endif

    #ifndef RAMPS_D10_PIN

    #define RAMPS_D10_PIN 10

    #endif

     

    #50709

    Mike
    Participant

    That sounds right. Some Old Guy Coding walked through it in this video:

    https://www.youtube.com/watch?v=LEjgp77TIy4&t=625s

    I don’t think he changed anything other than the one line “#define RAMPS_D9_PIN” Not sure exactly which version of Marlin he was working in, but it worked for me in the suggested version in the software download section here and on the new dual endstop version. Are you using the download from this site? Made other changes to the code? Maybe re-download Marlin and start fresh?

    #50712

    Vincent Pollaro
    Participant

    All I recall changing in the pins_Ramps.h was the following:

    #if MB(RAMPS_13_EFF) || ENABLED(IS_RAMPS_EFB)
    #define FAN_PIN 9 // (Sprinter config)

    to

    #if MB(RAMPS_13_EFF) || ENABLED(IS_RAMPS_EFB)
    #define FAN_PIN 44 // (Sprinter config)

     

    #50713

    BrianP
    Participant

    Mike I have used both the download version from this site and tried the latest Marlin had to offer.

    #50715

    Mike
    Participant

    Grasping at straws, but my setup uses the full graphic controller and I had to install the library for it, but I doubt that would have anything to do with this.

    #50716

    BrianP
    Participant

    Perhaps I need to manipulate this?

    #define SOFT_PWM_SCALE 0

    Setting to 1 will double the frequency

    #50717

    Jeffeb3
    Participant
    #ifndef RAMPS_D9_PIN
    
    #define RAMPS_D9_PIN 44 //remapped 9 to 44
    
    #endif

    That might not be active, if someone has set RAMPS_D9_PIN somewhere else. You can put in a message, to see if it’s being compiled:

    #ifndef RAMPS_D9_PIN
    
    #define RAMPS_D9_PIN 44 //remapped 9 to 44
    
    #error Good news everyone the code is reaching this location
    
    #endif

    If you don’t see that error message when compiling, then it’s being set somewhere else. It doesn’t have to be that exact sentence, but it does have to be a futurama reference. 🙂

    #50718

    Jeffeb3
    Participant

    I’m looking closer at this fan code, and I’m not sure I like it at all. I think there might be a bug in it (said every software engineer about every piece of code, ever).

    What about just setting the laser with M42?

    M42 P44 S255
    M42 P44 S0

    You should be able to put that in your CAM software or gcode tools to control the laser instead, right? Is there something I don’t understand about the magic of the fan pin?

    #50719

    Jeffeb3
    Participant

    This just seems broken to me: (from Conditionals_post.h) #define HAS_FAN0 (PIN_EXISTS(FAN)). Seems like it should be dependent on FAN_PIN, not FAN.

    That code looks really old, so I must be crazy.

    #50720

    Ryan
    Keymaster

    Verify with this firmware, this is proven good. You could have a bad ramps board…

     

    https://www.v1engineering.com/wp-content/uploads/2017/07/MPCNC511_GLCD_T8_laser.zip

    2 users thanked author for this post.
    #50727

    Mike
    Participant

    What about just setting the laser with M42? M42 P44 S255 M42 P44 S0 You should be able to put that in your CAM software or gcode tools to control the laser instead, right? Is there something I don’t understand about the magic of the fan pin?

    Some Old Guy Coding did that, but per his re-wiring video, M42 is an immediate command and would turn on the laser before it reached its intended start point, M106 and M107 are buffered so the on/off can happen in its intended locations.

    #50743

    BrianP
    Participant

    Thanks everybody. I tried everybody’s suggestions to no avail. I went ahead and ordered a new ramps board and will try again when I get it. I can only assume at this point that that part of my board is bad.

    #51586

    BrianP
    Participant

    Grettings, I have purchased 2 new Arduino/Ramps board combos since my last post, one had a defective Arduino and the other setups smoked when I applied power so they were non starters.

    I brought home and O-Scope from work and found that on my original setup there is no PWM on either the D9 Pin or the remapped pin 44 which explains whey I can’t drive the laser. Its still possible that something is wrong with the Ramps board.

    Question: Is there any other setups that I should worry about to enable PWM?

    Question: Is there another hardware combo other than the Arduino/Ramps that I could use to drive the MPCNC with a laser?

    #51591

    Ryan
    Keymaster

    All boards. I had to switch to the Ultimachine line of boards, I have not looked back since. The import ramps have just been compromised too far.

    1 user thanked author for this post.
    #51593

    BrianP
    Participant

    Are you saying I should consider the Ultimachine manufactured Ramps board?

    #51595

    Ryan
    Keymaster
    #51597

    BrianP
    Participant

    Thanks Ryan. Pleas excuse my questioning, I have been messing with for a month and am fairly frustrated. With the mini Rambo 1.3, what LCD’s does it support? Can I still use the same LCD I used on my Ramps wish SD support?

    Do you have a version of firmware already setup for  Laser TTL PWM? Instructions for wiring?

    #51598

    Ryan
    Keymaster

    Thanks Ryan. Pleas excuse my questioning, I have been messing with for a month and am fairly frustrated. With the mini Rambo 1.3, what LCD’s does it support? Can I still use the same LCD I used on my Ramps wish SD support?

    Understandable, Imagine that times a few hundred boards / customers. Yes all the same LCD’s.

    Do you have a version of firmware already setup for Laser TTL PWM? Instructions for wiring?

    I don’t have a laser firmware for any board. The instructions should link to the mini-rambo edits. If they are not on linked on the laser page let me know and I can find them after shipping this evening.

    #51826

    BrianP
    Participant

    I received my mini Rambo last night. Thanks for getting this to me so quickly! Nice board.

    I flashed the code with the following modifications:

    #define Z_MIN_PIN   23 //10

    #define Z_MAX_PIN -1 //23

    #define FAN_PIN  10 //8

    Question: when I measure the voltages at both +/- for z min and z max I am seeing +5VDC. Should I see the +5VDC go away on the Z Max due to the -1 pin assignment? Also I am still not getting any control over the laser with varying the fan parameters. Is there a parameter I need to adjust that I have missed?

    #51827

    Ryan
    Keymaster

    The + pin is 5V and does not change. The pin should be referring to referring to the Signal pin.

     

    #51828

    Ryan
    Keymaster

    You test from signal to negative, If you touch that + pin there is a 99% chance of destroying your board. Use the utmost care.

    #51832

    BrianP
    Participant

    Thanks for all your help. the signal was the secret sauce to get it to work. I dug out my O-Scope and sure enough I had PWM. The next trick was to wire the laser properly.  There were no instructions with it, only pictures. Grrr.

    So when the pins are remapped for the PWM, do I use straight up M106/M107 for fan on and of or the M108 or M113 for the extruder fan?

     

    #51839

    BrianP
    Participant

    Well… I got it to the point where I can control the laser via the display-> fan1 setting. this is a fantastic start

    But… I can not control it with software. 3dpBurner, 3dpBurner Sender and repetier host are all a fail. I have even tried running GCode directly from the SD card. Nothing. I can only assume that I am using the wrong GCode for the mapping.

    Any ideas anybody? I am using the Mini Rambo with my PWM on the z_MIN

     

    #51840

    Ryan
    Keymaster

    Does my focusing test script work?

    #51842

    BrianP
    Participant

    I don’t know what that is

     

    #51843

    Ryan
    Keymaster

    Link to the code in the description, from the info, how-to page, https://www.youtube.com/watch?v=yUk8ttJmpz4

    1 user thanked author for this post.
    #51851

    BrianP
    Participant

    Thanks Ryan! Your Script worked really well. I manipulated the power intensities and was able to get really good results. At this point I can run gcode from the SD card and control the laser. Now I just need to figure out why I can’t control the laser from a computer and software.

     

    #51852

    Jeffeb3
    Participant

    The laser script uses M106 S255 to turn the laser to full power. Then M107 to turn it off. Can you send these commands via the console in repetier?

    Also, Ryan’s script adjusts speeds, but sets the laser to full power (255). You will still need to verify that you can adjust the power with different values M106 S200, for example.

Viewing 30 posts - 1 through 30 (of 42 total)

You must be logged in to reply to this topic.