Heater Extruder 0 D10 used for a magnet: how to reduce power after 1s?

I am using ramps1.4 as a controller for a plotter.
for Pen up/down I use the Extruder 0 output for a cylindrical magnet.

The magnet can be overpowered for a shorttime to increase force, when moving back the stroke into the magnet.
When the stroke is inside, then the magnet works better and the power for the magnet can be reduced (otherwise the magne becomes too hot).

So I would like to work  with 100% on the output (in my case extruder 0=D10) and after 1s reduce it to 50%.
What is the best way to achieve that? and where do I have to change the code?

According the scemata I can also start with 24V (for 12V magnet) and switch back to 6V=25% when the stroke is inside the magnet.
There is 5A and 11A input - do both have the same currency? or are they different?

Thanks for advice!


  • 11A input is assigned to Heatbed only , 5A input is for Motors Extruders and the Arduino Mega.

    working on 24V needs modification on Ramps, otherwise you´ll fry your arduinos voltage regulator.

    also depending on manufacturer of Ramps supply of 24V at 11A input might get critical as the Polyfuse

    can handle max16V.

    so as you have 12V magnet supply on 12V ( keep as it is)

    in Firmware assign Extruder 0  pin to a pin not used , so you get D10 out of the sensitive Pin List.

    Power control should be possible by M42 command then.

  • Thanks for input, I will stay with 12V.
    I use the lasermode - there is a function that could controll intensity:
    void LaserDriver::changeIntensity(uint8_t newIntensity)
    (there is a comment in drivers.h - which I did not 100% understand - to recode this function to really use 0-255 intensity)

    M42 changes the output: I have the relation to the time: the fist second is 100% afterwards 50%.
    would you recommend "Custom_100MS()" to check if the pin is on - for example if it is 10xtimes in row on then change intensity with LaserDriver::changeIntensity(125)?

  • Default driver will always set 100%. So the 100ms timer trick might be a solution if analog values work without breaking firmware (depends on required timer interrupt). You will miss on/off periosd if they are fast (dotted line). A better way is to use the event system to implement a correct set intensity function. Then you could use a timer that you set to current time when enabling and in 100ms you reduce if time on > 900ms.
  • Thanks and you are right: the 100ms does not work!

    How to change the intensity:
    in drivers.h is a comment:
    With laser support you can exchange a extruder by a laser. A laser gets controlled by a digital pin.
    By default all intensities > 200 are always on, and lower values are always off. You can overwrite
    this with a programmed event EVENT_SET_LASER(intensity) that return false to signal the default
    implementation that it has set it's value already.
    EVENT_INITALIZE_LASER should return false to prevent default initialization.
    so I changed in events.h:
    #define EVENT_INITALIZE_LASER true
    #define EVENT_INITALIZE_LASER false

    I did not understand the EVENT_INITALIZE_LASER comment:
    // Set laser to intensity level 0 = off, 255 = full. Return false if you have overridden the setting routine.
    // with true the default solution will set it as digital value.
    #define EVENT_SET_LASER(intensity) true
    should I just change it to:??
    #define EVENT_SET_LASER(intensity) false
    but the function is nowhere defined?
    Should I make a new function?

  • I sitched now from Laser to CNC - because the G28 was easy to solve ...
    but now how can I use M3 Sxxx under CNC-control?
  • No, speed control is also only prepared for driver specific override but default only is on/off like for lasers.

    Events are quite simple if you look where they get used. Often it is inside a if condition, so return value determines if the if condition should get executed or not. If you have own initializer you replace
    #define EVENT_INITALIZE_LASER true
    #define EVENT_INITALIZE_LASER initMyLaser()

    and initMyLaser returns false after doing its work since it did now initalize the pins.

    Handling the set intensity is similar - either your function does it pr old default or both.
  • Thanks for tips ..
    I  find a WRITE function like:
    but this is a digital command.
    As far as I understood I have to replace that by a analog function.
    like  WRITE(CNC_ENABLE_PIN,125);
    but this obviously wrong.
    I do not find a analogWrite...
    What is the corresponding function in repetier?

  • Makes that sense?
    (In theory CNC_ENABLE_PIN could be down in between but that is not very likely)

    void Custom_500MS()
     //reduce power after max 3x500ms
      if (analogRead(CNC_ENABLE_PIN)>180){penup=penup+1;}
      else {penup=0;}
      if (penup>3){analogWrite(CNC_ENABLE_PIN,150);}

  • NEVER use analogRead - We use ADC interrupt for reading analog values internally while arduino does not disabling interrupt or at least disturbing the read procedure. You have to use a variable instead that gets set. My advice is to use the current time in milliseconds.

    analogWrite is what you need to set power as long as it uses a free interrrupt (3,4 or 5 should be fine also sounds may use 3 I think with M300).
Sign In or Register to comment.