Welcome! Log In Create A New Profile

Advanced

help me plz adding fiber sensor

Posted by ddi423 
help me plz adding fiber sensor
October 13, 2019 01:29PM
Sorry i'm not good at English.
i want to adding fiber sensor in my 3d printer.
sensor spec : NPN fiber sensor , 3 line : V+, GND , S

i can't make custom g-code, because it's too hard.
I tried several times but it didn't work as I wanted.
i tried making custom g-code.

void FIBER_SENSOR(millis_t time){
int FIBER_HOLD = 0;
int FIBER_BEEP = 5;
int FIBER_INPUT_PIN = 4;
pinMode(FIBER_INPUT_PIN, INPUT_PULLUP);
pinMode(FIBER_BEEP, OUTPUT);
time += millis();
while (PENDING(millis(), time))
{
if (digitalRead(FIBER_INPUT_PIN) == LOW)
{
if (FIBER_HOLD != 2) {
FIBER_HOLD = 2;
if (FIBER_HOLD == 2) {
digitalWrite(FIBER_BEEP, HIGH);

lcd_setstatus("Click to Continue");
idle();
}
}
}
else{
FIBER_HOLD = 0;
digitalWrite(FIBER_BEEP, LOW);
}
}
}
// i put this code in 'main.cpp ' above 'void dwell() ' function.
and change M911 case statement.
-> case 911 : FIBER_SENSOR(8800);

8800 ms means time to move; (0,0) to G1 Y220 F3000 to G1 Y0 F3000 (my bed Ymax is 220mm)
uploaded firmware but this code dosen't work..
sensor output voltage 5.2V when do sensing.
but The if statement inside the while statement does not work.

i want this action.
1.start

2.nozzle is in (0,0)

3.sensor on

4.Read input pin (= D4 this is servo pin )

5.while moving heatbed Y0 to Y220 to Y0

6. if sensor output exist, i want M1 gcode and lcd masage "Click to continue."

7. else (sensor output) no exist, going on print or sensor off.

8.end.
Please help.. i want to make action function..

using cura 3.6
arduino mega 2560 + ramps 1.4
hardware : way of mendel , prusa (rectang-)
bed : 220×220×250
Re: help me plz adding fiber sensor
October 19, 2019 04:15PM
Hi DDI,

Check this link

[marlinfw.org]

[marlinfw.org]

Make sure you have the right conditions enabled

No programming required!
Its all there

Best,

C

Edited 1 time(s). Last edit at 10/19/2019 04:46PM by Coolerooney.
Sorry, only registered users may post in this forum.

Click here to login