The countor of turned detailed

More
13 Jul 2011 09:58 #11492 by aike
Hi!
I need to make detail counter. How to create u32 pin I know, but what to oass the value to hal pin?
Can I wait for the START button or I need to watch M30 or M1** command?
How is it released in other programs?

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

More
13 Jul 2011 10:05 #11493 by andypugh
Sorry, but I don't understand your question.

Are you trying to create a counter for total parts manufactured?

You could do that with a HAL function that looks at the transition from run to stop, which would work for any G-code without modification, but will count aborted parts too.
You could use an M1nn command at the end of the program to only count completed parts, but that requires modifying every part program.

Which works better for you?

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

More
13 Jul 2011 13:40 #11495 by aike
andypugh wrote:

Sorry, but I don't understand your question.

Are you trying to create a counter for total parts manufactured?

You could do that with a HAL function that looks at the transition from run to stop, which would work for any G-code without modification, but will count aborted parts too.
You could use an M1nn command at the end of the program to only count completed parts, but that requires modifying every part program.

Which works better for you?

Yes, manufactured parts. To avoid broken parts better to use M1** comand befor the M30.

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

More
13 Jul 2011 13:57 #11497 by BigJohnT

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

More
14 Jul 2011 00:13 #11508 by andypugh
OK, here is a very simple way to do it.

You need a pyvcp panel. ( www.linuxcnc.org/docview/html/hal_pyvcp.html ) Just create a file with a .xml extension containing this
<s32>
        <halpin>count<.halpin>
</s32>

And set that as your pyvcp panel in the INI file.

Then create a file called M123 (capital M, no file extension) and put the following in it.
#!/bin/bash
COUNT=$(halcmd getp pyvcp.count)
let "COUNT += 1"
halcmd setp pyvcp.count $COUNT
exit 0
Save that file in your emc2/nc_files directory then make it executable (right-click, properties, permissions, execute, or use chmod if you prefer)

Then, any time you call M123 in your G-code the number will increase by one.

it would be easy to make it count down, and not difficult to make it count down from the value in another pyvcp number box

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

More
14 Jul 2011 10:18 - 14 Jul 2011 12:55 #11518 by piasdom
is this for emc2.5 and on? or 2.4 can use this ?
i get can't find module 'time' .

sorry i read your other link John.
will be waiting for 2.5


andy, how to reset your counter to zero?
Last edit: 14 Jul 2011 12:55 by piasdom.

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

More
14 Jul 2011 14:08 - 14 Jul 2011 14:10 #11520 by piasdom
well, i made another file to reset it. it works,
but will it cause trouble somewhere else later ?
and don't understand how it knows to reset the COUNT
without any connection to M123. not any i see.


M124
#!/bin/bash
RESET=$(halcmd getp pyvcp.reset)
let "RESET = 0"
halcmd setp pyvcp.count $RESET
exit 0
Last edit: 14 Jul 2011 14:10 by piasdom.

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

More
14 Jul 2011 14:31 #11521 by piasdom
i see the connection :) pyvcp.reset and pyvcp.count
Cool


#!/bin/bash
RESET=$(halcmd getp pyvcp.reset)
let "RESET = 0"
halcmd setp pyvcp.count $RESET
exit 0

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

More
14 Jul 2011 14:45 - 14 Jul 2011 14:50 #11522 by piasdom
i'm trying to learn this for future reference. :)
is this possible without rebuilding the world ?
to msg the total of m123


g17 g20 g40 g49 g54 g80 g90 g94

m123 (start counter)
run program .....
each depth m123

(msg, total of m123 = ??)
m124 (reset counter)

m2

if nothing else i can reset at start of file i guess :)
Last edit: 14 Jul 2011 14:50 by piasdom.

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

More
14 Jul 2011 15:49 #11525 by andypugh
piasdom wrote:

well, i made another file to reset it. it works,
...
M124
#!/bin/bash
RESET=$(halcmd getp pyvcp.reset)
let "RESET = 0"
halcmd setp pyvcp.count $RESET
exit 0


That doesn't make any sense at all....

First you read a value from a (probably non-existent) pin called pyvp.reset. and store it in RESET
Then you throw away that value and set RESET to 0
Then you set the counter to the value of RESET.

Much simple would be:
M124
#!/bin/bash
halcmd setp pyvcp.count 0
exit 0

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

Time to create page: 0.136 seconds
Powered by Kunena Forum