Welcome to Our Community

Some features disabled for guests. Register Today.

Setting up proximity sensors

Discussion in 'CNC Mills/Routers' started by Louw Lourens, Jun 17, 2024.

  1. Louw Lourens

    Builder

    Joined:
    Jun 17, 2024
    Messages:
    1
    Likes Received:
    0
    Good morning all

    I am busy building a CNC router machine. I am at the point now where I am installing the proximity sensors (NPN type). I am a newbie in the CNC world so excuse me if I ask simple questions.

    I use CNCJS and have enabled hard limits through $21=1. After I activated it I got the following message:

    CNCjs 1.10.2 [Grbl]
    Connected to COM4 with a baud rate of 115200
    Grbl 1.1f ['$' for help]
    client> $$
    $0=10 (Step pulse time, microseconds)
    $1=25 (Step idle delay, milliseconds)
    $2=0 (Step pulse invert, mask)
    $3=0 (Step direction invert, mask)
    $4=0 (Invert step enable pin, boolean)
    $5=0 (Invert limit pins, boolean)
    $6=0 (Invert probe pin, boolean)
    $10=1 (Status report options, mask)
    $11=0.010 (Junction deviation, millimeters)
    $12=0.002 (Arc tolerance, millimeters)
    $13=0 (Report in inches, boolean)
    $20=0 (Soft limits enable, boolean)
    $21=0 (Hard limits enable, boolean)
    $22=0 (Homing cycle enable, boolean)
    $23=0 (Homing direction invert, mask)
    $24=25.000 (Homing locate feed rate, mm/min)
    $25=500.000 (Homing search seek rate, mm/min)
    $26=250 (Homing switch debounce delay, milliseconds)
    $27=1.000 (Homing switch pull-off distance, millimeters)
    $30=1000 (Maximum spindle speed, RPM)
    $31=0 (Minimum spindle speed, RPM)
    $32=0 (Laser-mode enable, boolean)
    $100=500.000 (X-axis travel resolution, step/mm)
    $101=500.000 (Y-axis travel resolution, step/mm)
    $102=500.000 (Z-axis travel resolution, step/mm)
    $110=500.000 (X-axis maximum rate, mm/min)
    $111=500.000 (Y-axis maximum rate, mm/min)
    $112=500.000 (Z-axis maximum rate, mm/min)
    $120=10.000 (X-axis acceleration, mm/sec^2)
    $121=10.000 (Y-axis acceleration, mm/sec^2)
    $122=10.000 (Z-axis acceleration, mm/sec^2)
    $130=200.000 (X-axis maximum travel, millimeters)
    $131=200.000 (Y-axis maximum travel, millimeters)
    $132=200.000 (Z-axis maximum travel, millimeters)
    ok
    feeder> G91
    feeder> G0 X5
    ok
    feeder> G90
    ok
    ok
    feeder> G91
    ok
    feeder> G0 X-30
    feeder> G90
    ok
    ok
    feeder> G91
    feeder> G0 X30
    ok
    feeder> G90
    ok
    ok
    > $21=1
    ok
    ALARM:1 (Hard limit)
    [MSG:Reset to continue]
    client>
    Grbl 1.1f ['$' for help]
    [MSG:���'|'$X' to unlock]
    client> $X
    [MSG:���������������������'|'$X' to unlock]
    ok
    ALARM:1 (Hard limit)
    [MSG:Reset to continue]
    client> $X
    client>
    Grbl 1.1f ['$' for help]
    [MSG:���'|'$X' to unlock]
    client> $X
    [MSG:���������������������'|'$X' to unlock]
    ok
    ALARM:1 (Hard limit)
    [MSG:Reset to continue]
    >
    From here nothing I do seems to work. So I disabled my Arduino Uno R3 board and disable the Hard Limits again. After that CNCjs work again and can I do test runs.

    Is there anything else that I must do?
     
  2. Misterg

    Misterg Veteran
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 27, 2022
    Messages:
    340
    Likes Received:
    264
    You may need to set $5 depending on whether the switches are NO or NC.

    FWIW, I would enable homing and soft limits and leave hard limits alone.
     
  3. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
    Good day
    I am also leaning towards soft limits and homing. How do I set these up in UGS?
     
  4. Misterg

    Misterg Veteran
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 27, 2022
    Messages:
    340
    Likes Received:
    264
    I don’t think you need to do anything to UGS, you just need to set up your grbl controller.

    Homing:
    Set up the Homing Cycle

    Set your machine travel in $130…132 and enable soft limits in $20
    Grbl v1.1 Configuration
     
    Alex Chambers likes this.
  5. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
    Thanks for the info.
    I do however see that you need limit switches to do your homing, which bring me back to my original challenge.
     
  6. Misterg

    Misterg Veteran
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 27, 2022
    Messages:
    340
    Likes Received:
    264
    The link I posted above to setting up the homing cycle walks you through setting up the limit switches too.

    Are your sensors NO or NC?

    Use the troubleshooting tab on Control to verify that the limit switches are operating correctly before enabling homing.
     
  7. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
    The proximity sensors I currently have is No.
     
  8. Giarc

    Giarc OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Jan 24, 2015
    Messages:
    2,992
    Likes Received:
    1,670
    What kind of sensor? If inductive, is it PNP or NPN?

    If you are having issues, microswitches are easy, cheap, and accurate.
     
  9. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,701
    Likes Received:
    4,249
    Especially Xtension Limit Switch Kit (and little known fact, more repeatable than inductives - they drift quite a bit depending on the flux of the magnetic field as well as temperature)
     
  10. Misterg

    Misterg Veteran
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 27, 2022
    Messages:
    340
    Likes Received:
    264
    Already stated NPN
     
  11. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
    I do have some micro switches somewhere. I will try them and see if it solve my problem.
     
  12. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
    Just a status update.

    I have connected a micro switch to the x axis. Cncjs showed the same message as described in my original post. I do not know what to do next. I need to home my machine and I do need some limits.

    O yes and the power to the control box is earthed.
     
  13. Alex Chambers

    Alex Chambers Master
    Moderator Builder

    Joined:
    Nov 1, 2018
    Messages:
    2,760
    Likes Received:
    1,352
    Are your microswitches normally closed? Your original post suggests that you had a permanent "triggered" signal from your sensor. Try changing $5 to 1.

    Alex.
     
  14. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
    Hi Alex.
    I connected the switches as normally open as the proximity sensors were that. I will try $5 =1 and will get back to you.
     
  15. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,701
    Likes Received:
    4,249
    Arduino, with NO switches = $5=0

    Sure you wired correct pins (Using a CNC shield? Cheap Chinise Chinese knockoff clone with the Z switch on the wrong pin? Or proper Protoneer original. Or followed Grbl Wiki and wired correctly directly to Arduino?)

    Use CONTROL instead of CNCJS see which switch is triggered - probably just one not all

    OpenBuilds Software: OpenBuilds CONTROL and OpenBuilds CAM - FREE software to run your CNC, Laser, Plasma or Pen Plotter > Troubleshooting tab

    Or, ran the 6-30v Inductives (typical) powered off PSU, and burned out the limits inputs (max 5V)
     
  16. Alex Chambers

    Alex Chambers Master
    Moderator Builder

    Joined:
    Nov 1, 2018
    Messages:
    2,760
    Likes Received:
    1,352
    Sorry, should have put "if so" in that last sentence - see Setting up proximity sensors

    Alex.
     
  17. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
    Hi Peter
    You gave me a mouth full to think about. What I can tel you is that my uno r3 is original. I believe that I wired it correctly.
    There is something that do bother me and that is how can a micro switch and a proximity sensor give me the same error/alarm if they operate in totally different ways.
     
  18. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,701
    Likes Received:
    4,249
    Post pics of wiring if you need us to review
     
  19. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
    Which wiring? The control box with the drivers and control board?
     
  20. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,701
    Likes Received:
    4,249
    The limits you were having trouble with. Inductives needs voltage divider or reverse diode, limit switches can be wired wrong too. Also so we can check you have the right pins Connecting Grbl etc
     
  21. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
    Ok so I got the micro switches to work. I still have no joy with the proximity sensors.
     
  22. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
    Hi Guys. I want to use my proximity sensors and have read that I will need to use 10Kohm pull up resistors. Where do I install them?
     
  23. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,701
    Likes Received:
    4,249
    On a Blackbox : plug and play
    On a Arduino. No pull ups. But you need to run NPN type, on 6-30v. Then to prevent damaging the arduino, level shift the signal. Not as easy it looks. To install an inferior sensor (terrible repeatability). Their only advantage is waterproofness. Not worth it
     
  24. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
    Thanks for the reply Peter. I bought the NPN sensors to do my limits but it seems now that I must accept that I am not going to use them and write it of as school fee's.
     
    #24 LouwL, Jun 25, 2024
    Last edited: Jun 25, 2024
  25. Misterg

    Misterg Veteran
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 27, 2022
    Messages:
    340
    Likes Received:
    264
    Do you have a link to the ones you bought?
     
  26. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
  27. Misterg

    Misterg Veteran
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 27, 2022
    Messages:
    340
    Likes Received:
    264
    Hmm. I was wondering if I could find out what type of output circuit they had, but there isn't sufficient information. ('Open Collector' NPN outputs can be connected straight to an Arduino, but I can't tell if these are Open Collector or not, so wouldn't like to risk it.)
     
  28. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
    I tried connecting them directly. When I enable $21 after connecting them that is when the alarm message appears.
     
  29. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    14,701
    Likes Received:
    4,249
    Without wiring pics we can't confirm. But keep in mind they need at least 6v (so run them off PSU) - BUT BUT BUT some of them do float at supply voltage (PSU voltage into 5V GPIO = dead arduino) thus usually circuitry in between (optocoupler, reverse biased diode, voltage divider etc)
    If you powered them off 5V they won't be "on" thus always locked off
     
  30. LouwL

    LouwL New
    Builder

    Joined:
    Jan 28, 2020
    Messages:
    23
    Likes Received:
    0
    I did an of machine test. I connected the blue wire to ground and the brown to positive on my 24v power supply. I connected the black wire to pin 9 on the Arduino board. Nothing weird about that. It is just as soon as the limits are enabled nothing happens, so something needs to added or remove to make it work. The other strange bit for me is that I was under the impression that the led on an NPN sensor will be off and only comes on when an obstacle is sensed. All my the led's on the connected sensors were on without any obstacles present and goes of when an obstacle is sensed.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice