Urgent help required with EMC please

More
16 Aug 2016 00:27 #78816 by sxyuklad
Thanks Todd, I will try what you suggested.

Thank you so much for coming in here cncbasher. I was so much awaiting for either arceye or you to come and help me out.

OK, I have already written my M6 macro in vb script for mach which has been running perfect. Now, I do not know what language hal files use and if I know that language. In Mach3 as you maybe familiar, when you send M6T202 code, it calls for a macro file and runs whatever is in there. First of all, I need to know which part of which file is run when you issue an M6 command and which variable or DRO or whatever will have old tool number and the requested new tool number.

I am attaching my Mach3 macro here, so if you know writing codes, which obviously you are expert of, you will quite easily understand it. And basically, if you can convert this mach3 macro to linuxcnc macro or whatever which will execute the same way when M6 command is given, that will be wonderful.

Since I have written my macro in vb scripting, I know how it works. I will explain. It is very close to the one you already wrote but you used stepper, I have a dc motor, even simpler to turn on a relay for forward and turn off for reverse. But obviously I do not know how to set parallel port pin high to turn on the relay and then turn it off. On the other hand, I also need to scan two inputs from two optical sensors. One is for tool # 1 and the other for a mark on each tool so I also need to run a counter which basically increments with input going high or low and when the requested tool number matches, that is the completion of the process. I hope you got my whole point. It is very simple. Well, much simpler than a stepper setup because I will not need any pwm generation. Simple turn outpin high, relay tuns on, motor moves forward, when tool number matches, turn output pin low and relay turns off hence locking the turret against ratchet/pawl.

OK, now I will explain how it works or at least how I got it working with Mach3 so you can alter your already made comp to suit mine.

There are 6 positions on the turret (Max tools)
There are two optical sensors which are connected to my two parallel port input pins (11 and 12). Number 11 pin is INPUT1 and is for Index / Tool 1 position at starting. Number 12 pin is INPUT2 and is for a mark on each tool and on this basis, I need to count.
There are two outputs connected to my parallel port pin 8 and 16. Pin 16 is OUTPUT1 and is basically the power on relay for the dc motor. Well, I chaged the way it used to work. I used to turn it off at the end of too change complete but I have realised this is not good as removing power from the motor makes turret unlock and vibrate. So now I just keep it active at the start of Mach3 or linuxcnc in this case. Pin 8 is OUTPU2 and this is relay when it turn on, motor moves forward and when off motor reverse to lock when the requested tool has reached. So it is pretty simple ATC but as I said I do not know the coding language so I tried to alter your comp but there is so much stuff that I just cannot understand like timer delays and progress level and stuff.

If you can convert my vb macro to equivalent linuxcnc macro that will be so wonderful but even if you cannot, I mean you maybe too busy then just guide me a little to covert me the following vb coding lines into linuxcnc equivalent please and I think I will manage to alter and then if I get an error I can always come and ask you.

So in Mach3 if I want to wait for a parallel port pin to go high and then move forward the code is pretty simple, I am sure it is very close to this in linuxcnc language too. For example from my ATC, pin 11 of my parallel port is INPUT1. So if I want to check and stop there I will say (without quotes):

"While IsActive(INPUT1)

So this line means stop here and wait until INPUT1 goes active (depending you have active low or high). So as soon as INPUT1 which is parallel port 11 goes active, it moves forward from this line otherwise it will stay here. So as soon as input goes active that means I have reached my tool 1 / index. So please convert this line for me in linuxcnc language.

Secondly, How can I declare a variable? I mean I need a few variables to store current tool number and new tool number and maximum tool number and some variables for making a counter. And what holds these tool numbers in linuxcnc? Like if I want to grab old tool number and new tool number to two variables, how the lines will look like?

Thirdly, how can I change the state of a parallel port pin. Like in Mach3 (VB), when I want to drive the motor forward I would say:

ActivateSignal(OUTPUT6)

This activate OUTPUT6 which is connected to my parallel port pin 8 and thus motor starts rotation forward and when I have found my new tool, I say:

DeActivateSignal(OUTPUT6)

This turns off OUTPUT6 which is again parallel port pin 8 and the relay turns off, motor reverses and hence turret locks in position against ratchet/pawl.

Number four, I need to know how to take a pause let us say for 5 seconds. In Mach3, I say

Sleep(5000)

This means code will stay here for 5000 milliseconds or 5 seconds in other words and then will go to next line.

Seriously, if you can help me with these lines, I think I can convert my macro to linuxcnc compatible.

Or as I said I am attaching my code here, just go through it and convert it for me line by line and the rest I will understand by myself. That will be so kind of you.

So you have seen my ATC is very close to the comps already written, in fact it is more simpler. There you have stepper I have dc motor, you check 4 inputs for truth table to know position, I have only one sensor for that and a simple counter need to do the job.

Will be keeping my eyes opened and really looking forward to hearing from you.

And I am really surprised to see how well linuxcnc works. I somehow managed to get G76 working. Checked standard format for linuxcnc online, quickly written a thread code and I am surprised with the quality of threads it has produced man. Wow. My RPM are not stable even then it made perfect threads. How possible? But can you also throw some light why my RPM display which is added via stepconf is not stable. I check encoder signals with Halscope, the waves are pretty clean. And plus threads verify that there is no hardware problem. It is some code I am missing or something. How can I add debounce setting for my enoder pins? Spindle Index is parallel port pin 10 and phase A is parallel port pin 13. Can you please explain how can I add debounce setting to reject any noise if there is any to stabilize my rpm readout. Phase A has 100 ppr, Disc type. Or something else you suggest to stabilize reading in linuxcnc or even at the hardware part?

If you need images of my tool changer, I will gladly take that and share them here so if anything is unclear to you still.

here is my VB script ATC code which works perfect in Mach3, basically need exactty same equivalent for linuxcnc.

OldTool = GetCurrentTool()
tool = GetSelectedTool()
NewTool = tool
MaxToolNum = 6
CurrPos = OldTool
Steps = 0
i = 0

While (NewTool > MaxToolNum)
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend

If (NewTool = OldTool) And (NewTool > 0) Then
Exit Sub
End If

If (OldTool = 0) Then
ActivateSignal(OUTPUT5)
ActivateSignal(OUTPUT6)
While Not IsActive(INPUT2)
Wend
CurrPos = 1
SetCurrentTool(CurrPos)
If (CurrPos = NewTool) Then
DeActivateSignal(OUTPUT6)
Sleep(2000)
SetCurrentTool(NewTool)
Exit Sub
End If
End If

If NewTool > CurrPos Then
Steps = NewTool - CurrPos
Else
Steps = MaxToolNum - CurrPos + NewTool
End If
Steps = Steps + 1
ActivateSignal(OUTPUT5)
ActivateSignal(OUTPUT6)
CountPulses:
While Not IsActive(INPUT1)
Wend
i = i + 1
While IsActive(INPUT1)
Wend
If (i = Steps) Then
DeActivateSignal(OUTPUT6)
Sleep(5000)
SetCurrentTool(NewTool)
End
End If
GoTo CountPulses

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

More
16 Aug 2016 00:51 #78817 by sxyuklad
Oh an one more question: Todd or cncbasher, if any of you can answer.

Can I also connect a PLC with linux to get more inputs and outputs rather than adding parallel ports. Because I can get Mitsubishi or panasonic PLC very cheap here. It is almost the same as buying a parallel port card or two. Like in 20 to 30 USD I can get a very good PLC here. Is it possible to connect it via ethernet or RS232 to RS485 stuff or linuxcnc support both TCP/IP and RS485?

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

More
16 Aug 2016 01:01 #78818 by sxyuklad
And one more question. How can I ask a question while tool changing process from the user. For example, the max tool number on my ATC is 6. So if user enters M6T7, that is an error and in that case I do not want to stop the g code and process from the beginning, I want to stop there and ask the user a question to put in the valid tool number and hence the gcode moves forward from there even though the tool number 7 remains the same in the gcode. In mach3 I do it like this again using While loop. While loop because it keeps asking again and again till user enters a valid number. In MAch3

While (NewTool > MaxToolNum)
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend

This check is made at the top of the macro. If there is invalid number (more than 6 in my case), machine is already in pause mode because of tool changing process, but it will give a dialogue to use asking this question "Enter new tool number upto 6 (maxtool)" and till use puts a valid number it is will keep asking again and again and when enter valid number, it takes that number and stores it as New tool number rather than what was actually requested in gcode. So I want this same line equivalent in linuxcnc so if the tool requested number is invalid it can ask for a new tool number and keep asking of course is simple I can do with While loop as I did with Mach3.

Thank you.

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

More
16 Aug 2016 01:50 #78819 by sxyuklad
Okay, I have just finished converting my VB script macro to linuxcnc compatible by altering arceye written and tested by you comp. I am attching both here, the original by you and arceye and separate file which I altered.

Can you please go through both of these and let me know if it will work what I am trying to do here and if any errors you see, please point them out to me. My VB Mach 3 macro attaching again, so just compare my altered one with VB one to see if it will work the way Mach3 one works for me. I have basically tried to convert it line by line. But I sure there will be errors as I have said I have zero knowledge of how to write for linuxcnc and how linuxcnc works.

I am just attaching them as text files so easy to open them for you.

Thanking you.
Attachments:

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

More
16 Aug 2016 02:35 #78820 by Todd Zuercher

Oh an one more question: Todd or cncbasher, if any of you can answer.

Can I also connect a PLC with linux to get more inputs and outputs rather than adding parallel ports. Because I can get Mitsubishi or panasonic PLC very cheap here. It is almost the same as buying a parallel port card or two. Like in 20 to 30 USD I can get a very good PLC here. Is it possible to connect it via ethernet or RS232 to RS485 stuff or linuxcnc support both TCP/IP and RS485?


The answer is a little complicated. You can but the connection likely will not be real time (at least with RS232 or RS485). For Some things that may or may not be hugely critical. It just depends how it is being used. I do not know if anyone has made any real time ethernet connections work with a PLC and Linuxcnc. I could see it being theoretically possible, but I don't think I could set it up.
A parallel port can be had for $6-$12, but if you add the cost of a breakout board

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

More
16 Aug 2016 10:54 #78825 by cncbasher
the orac toolchanger code works with dc motor

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

More
16 Aug 2016 11:20 #78826 by sxyuklad
Hi cncbasher

I was expoecting a little more detailed reply from you. Can you please have a look at the code that I altered and advise me if that will work or just simply convert the lines I need which I posted in my previous post and once I know what are the equivalent lines I will be able to write them. As far as I know Orac uses a stepper motor too. Can you share the link which works with dc motor?

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

More
16 Aug 2016 11:22 #78827 by sxyuklad
Hi Todd

I always thought RS485 was faster than the parallel connection, am I wrong? And what about Ethernet speed?

Because I always thought and have read parallel ports are not suitable for speeds and all that stuff you know.

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

More
16 Aug 2016 11:24 #78828 by sxyuklad
And Todd

Can you please look at all three files that I shared and go through them if you can let me know the code I altered from another ATC program will work with my setup or maybe you are able to point out any mistake in there or something.

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

More
16 Aug 2016 11:32 #78829 by sxyuklad
One more thing if anyone can throw some light on this.

Let us say I want to install a comp for my ATC. For example Orac one. How do I go about it? Can I simply put in the code required into my hal file and just make a comp file with text editor and put the comp file in my config directory. Is that it or there are some terminal run commands involved and simple copying paste will not work???

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

Time to create page: 0.244 seconds
Powered by Kunena Forum