Using beep with LinuxCNC M code

More
03 Oct 2012 09:01 #24901 by Rick G
Beep is a neat little program that allows you to create a beep or a series of beeps on the PC speaker. You can control the frequency, number and length of these beeps.

Some computers that are used only for running LinuxCNC are stripped down with no speakers or sound cards, but they may have a PC speaker.

If you use a joypad, a pendant or some other input device for setting up new work you may not be looking at the screen when you hit a button. For example a button to switch from continuous to incremental jog, a button to switch from manual to MDI mode and "touch off" buttons. It is helpful to have some audible feedback to confirm what is happening.

You can access these beeps with M codes.

To install beep from the terminal.

sudo apt-get install beep

Information on beep can be found on the terminal by typing.

man beep

You may find that the PC speaker is blacklisted and could not be accessed so blacklist.conf may need to edited.

From the terminal.

sudo gedit

In gedit navigate to /etc/modprobe.d/blacklist.conf

Comment out the line

blacklist pcspkr

Save the file and reboot.

Beep will hopefully work now, to test from a terminal just type.

beep

You should hear a single beep on the PC speaker

If all is well you can now use M codes to create a beep, a series of beeps or even a song, for example pick an unused user definable M code in this case M105 and save it in the proper directory for your computer.

#M105
#beep charge
#! /bin/sh
beep -f 261.6 -l 300 -n -f 329.6 -l 275 -n -f 392.0 -l 250 -n -f 392.0 -l 250 -n -f 1 -l 300 -n -f 329.6 -l 300 -n -f 392.0 -l 350 -n -f 1 -l 400
exit 0

Then to hear it in LinuxCNC from the MDI window enter

M105

To hook this up to a button. In this example push the right stick down on a joypad for the first MDI command in the ini file. Substitute the correct M code, MDI command number and button for your set up.

In the [HALUI] section of your ini file add

MDI_COMMAND = M105

In the custom_postgui.hal add

net right_stick_down halui.mdi-command-00 <= input.0.btn-base6

Putting it all together...

Change your MDI command to do something useful such as.

MDI_COMMAND = G10 L20 P1 X-.125 M105

For G10 I use a single beep for X (beep -f 261.6 -l 300) , a double beep for Y, etc.

Use a button or combination of buttons on a joypad to call the sub called "home" for this I use M105.

o<home> sub
M105
(debug, CAUTION HIT RESUME TO RAPID MACHINE Z THEN X AND Y TO G53 0 POSITIONS)
M0 (pause)
M110
;raise z first then go home
G53 g0 z0
G53 g0 x0y0

o<home> endsub
M2

That should do it.

Rick G
The following user(s) said Thank You: emcPT, johns00056, KGHN

Please Log in or Create an account to join the conversation.

More
03 Oct 2012 11:10 #24903 by BigJohnT
That's pretty cool Rick.

John

Please Log in or Create an account to join the conversation.

More
11 Aug 2014 01:50 #49667 by johns00056
Thanks Rick, your instructions worked great.

I got my probe to beep when it makes contact. It is really cool now!


net renishaw hm2_5i25.0.7i84.0.1.input-06-not => motion.probe-input
net renishaw => halui.mdi-command-00 ## to make probe beep on contact ### see M198 , user defined m code ##


[HALUI]
# M198 probe beep on contact #
MDI_COMMAND = M198


M198 file
#!/bin/bash
# file to beep when probe touches -l= length -f= pitch frequency (not a halcmd)
beep -l 125 -f 400
exit 0

Please Log in or Create an account to join the conversation.

More
11 Aug 2014 02:12 #49668 by emcPT
My machines are too loud for this, but very helpful information for a next project.
Thanks

Please Log in or Create an account to join the conversation.

More
11 Aug 2014 02:43 #49669 by Zahnrad Kopf
That is a VERY handy, worthwhile, and appreciated effort. Thanks. I will most certainly be looking to use this in the near future.

Please Log in or Create an account to join the conversation.

More
12 Aug 2014 14:57 #49741 by Rick G
Glad to hear it is of some interest.

Rick G

Please Log in or Create an account to join the conversation.

Time to create page: 0.581 seconds
Powered by Kunena Forum