Hello Guest it is March 28, 2024, 03:23:21 PM

Author Topic: Mach3 and a tube bender  (Read 48980 times)

0 Members and 1 Guest are viewing this topic.

Mach3 and a tube bender
« on: February 08, 2009, 05:02:48 PM »
Hey yall!  I am currently in the process of using Mach3 to control a tube bender I made last year.  Details of my build can be found here:

http://cnczone.com/forums/showthread.php?t=68163

I am using a 360 PPR rotary encoder to track die position.  I am aware that Mach3 isn't well equipped to interface encoders.  My bender never moves past 100 degrees and takes 15+ seconds to go from 0 to 100 degrees. 

I finally have my rotary encoder hooked up to a breakout board from CNC4PC.  I have configured the pins in Mach3.  How can I display readings from the encoder?  I have hooked up the encoder, but I don't know how to verify if it is working through Mach. 

I am using a Vickers valve to extend or retract a hydraulic cylinder.   Mach3 will energize and de-energize pins 2 or 3.  Pins 2 and 3 then go to a relay board from CNC4PC.  These relays energize either coil A or B on the valve.  I have assigned spindle CW and CCW to control the relay board. 

My ultimate goal is to enter a value between 1 and 100 degrees.  I would like Mach to energize Pin 2, compare the user input value with the rotary encoder reading, the de-energize Pin 2 when the user input value and the rotary value are equal.

The first step is to interface the encoder with Mach3.  Can I set up a DRO to read degrees from a rotary encoder?

More info about my rotary encoder can be found on page 8 of my thread at cnczone.com

http://cnczone.com/forums/showthread.php?t=68163&page=8

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Mach3 and a tube bender
« Reply #1 on: February 08, 2009, 06:30:35 PM »
Absolutly you can!!!

here is a few steps:

Under Config>ports and Pins click the tab for Encoder/mpgs
pick encoder1 and enable it, set the input pins you going to use
for the A and B channel of the encoder.

you can use the CW and CCW comands if you want or directly on/off
the output your choice, for now we will do it with your set up.

Once you get your encoder hooked up, goto the settings page,
and look at the DRO value for Encoder1(X axis). Turn your die
a specific number of degrees... say 10 or 90 or something you
can easily measure. and look at the encoder display.
if the two dont match, figure the difference, then go back
to ports and pins, encoders and set the steps per detent to
what you think it should be, you may have to play with it.

Now, Put something like this in the macro pump.

also put a user DRO for the angle entry on your screen, call it UserDRO2000.

Note for the macropump I am going to say that when you say CW (0-100) OUTPUT2 goes
high, and CCW (100-0) output3 goes high.

I am going to assume that CW is going from 0 towards 100
and CCW is moving back towards 0.

Now what happens here is you can set your CW or CCW for direction,
the code "Activates".

'Goto angle
'Macropump.m1s

DesiredAnglePos = GetUserDRO(2000) 'angle entry dro on your screen
CurrentAngPos= GetOEMDRO(29) 'encoder1 DRO from your die

if GetOEMLED(164) or GetOEMLED(165) then 'if the CW or CCW led is on

   if GetOEMLED(164) then 'if the spindle CW led is on.
      if CurrentAngPos <= DesiredAnglePos then
      ActivateSignal(OUTPUT2) 'coil A cw
      else
      DeActivateSignal(OUTPUT2)
      end if   
   end if

   if GetOEMLED(165) then 'if the spindle CCW led is on.
      if CurrentAngPos >= DesiredAnglePos then
      ActivateSignal(OUTPUT3) 'coil B ccw
      else
      DeActivateSignal(OUTPUT3)
      end if   
   end if
   
end if

'scott



'Note: you could also do this with Buttons or by calling custom macros from you G code.........
'the maximum resolution of this will be at the speed of the macro pump which is 1/10 th or a little over of a second.
'so you may have some error depending on how far your encouder moves evey 1/10th of a second.
fun times
Re: Mach3 and a tube bender
« Reply #2 on: February 08, 2009, 09:29:58 PM »
Wow Scott, thank you so much!  I wasn't expecting someone to reply that fast and with that much information!  My first problem is that the DRO on the settings page doesn't change.  I am positive I have the A+ and B+ outputs of the encoder hooked up to pins 12 and 13 on the BOB.  If I put a multimeter up to either A+ or B+ I get a change in voltage as I rotate the encoder.  I have verified the encoder is working.  Here is a pic of my pin and port config:



Here is a pic of my Settings page:



Any ideas?

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Mach3 and a tube bender
« Reply #3 on: February 08, 2009, 11:11:13 PM »
in your screen shot, your "Encoder1" is NOT enabled!!! there is a Red X next to it, you have to click on it and make it be a green Check.

scott
fun times
Re: Mach3 and a tube bender
« Reply #4 on: February 08, 2009, 11:31:24 PM »
Sorry, that screen shot is older.  The check box is indeed checked.  I have updated the first screen shot above.  What is the function of the "To DRO" and "Load DRO" buttons?

Any more ideas?  I see a voltage fluctuation when I put the red lead to either the A+ or B+.  I see absolutely nothing from the settings screen.  Should I see anything on the Diagnostics screen?  Must I have some sort of X Axis stepper configuration enable to "activate" the encoder reading?


Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Mach3 and a tube bender
« Reply #5 on: February 09, 2009, 08:23:31 AM »
Ok, try this, if your sure your encoder is reading, then drop these two DROs on your screen set some where, and see if either of them will show a value when you turn your Encoder.

Put a DRO 170 (Encoder 1 position in units DRO)
Put a DRO 205 (Endocer 1 DRO external)

put those two above, and if you want copy over your DRO 29, then turn the encoder, if none of these are moving, then the problem is in the way your hooking up your encoder.

I dont have an encoder to test with here, BUT, I think Hood was using one recently, for a simular Encoder test, ask him if the above fails to bear fruit.
I mostly bring in MPGs and they are just a different type encoder. Principle should be the same.

Also: This is a GREAT site, with ALOT of great people with all kinds of different backgrounds and experiences.........  I may be totally "Shot in the Head", on your encoder problem, so perhaps someone who has done encoder unputs recently can take it from here.


I honestly dont know why your not reading it, if the encoder is working, and you have it electrically hooked up right to the inputs on your board, then it should be reading.......

scott
fun times
Re: Mach3 and a tube bender
« Reply #6 on: February 09, 2009, 04:12:32 PM »
Scott,

When you say "Put a DRO 170", do you mean create a screen with a DRO, and assign it an OEM value of 170?  I apologize, I am new to Mach3 as of yesterday afternoon.  I am still learning.  I still have A LOT to learn judging by the main screen of Mach3.  

I created 3 DROs, assigned them OEM values of 170, 205 and 29.  I turned the encoder and neither worked.

On the settings tab, I can click the "Set steps per unit".  It asks me how far I would like to move the X-Axis.  I type in 360.  They only way to get anything to display on the settings tab is to rotate the encoder, then click the "Load DRO" button.  A new value updates.  Mach3 then prompts me with "How far did the x-axis move?".  It then tells me it has set X number of steps/unit.  I can now get something to show up on the screen, but I still have to hit "Load DRO", and the displayed value is highly inaccurate.  Isn't the DRO supposed to display in real time?    
Re: Mach3 and a tube bender
« Reply #7 on: February 11, 2009, 05:37:37 PM »
How can I make Mach3 send a 5V signal to an OUTPUT pin?  I need to verify Mach3 is interfacing with my BOB.  The more I troubleshoot my setup, the more I believe Mach isn't communicating with my board.

I have little Omron photosensor switches.  They have a lens which sends 5V when its field of view has been broken.  With the 5V and 0V connected, I have verified 5V comes out of the output wire.  I connected the third wire to pin 10.  If I go to "Automated Setup of Inputs", Mach can't find the signal.  I put my multimeter up to the post where the output wire is connected, and I get a true 5V.  If I look at the diagnostics page, nothing lights up for pin 10. 

I wrote a program in VB a while back with three buttons: Extend, Retract and Pause.  My program works just fine, therefore I know my BOB is working correctly.

I would like to test to see if I can get the BOB to send 5V to pins 2 and 3 to active my relay board.  If I assign pins 2 and 3 to output 2 and 3, what value do I assign the two buttons in ScreenDesigner?

Thanks,
Brenton
« Last Edit: February 11, 2009, 07:51:37 PM by supahonkey »
Re: Mach3 and a tube bender
« Reply #8 on: February 12, 2009, 10:51:48 PM »
I got Mach to read my rotary encoder and limit switch.  I installed XP on another drive and installed Mach.  I simply configured the pins and every thing is working just fine.  I believe I know why it was giving me so much trouble.  I used a file called inpout32.dll to interface the VB program I made to the parallel port.  Apparently this was somehow over riding the parallel port driver, or simply just the commands send to the parallel port. 

My encoder is 360 PPR.  I typed in 360 in units/rev in the pins config.  Unfortunately, it doesn't read accurately under the settings screen.  I am going slow.  Any idea whats going on here?
Re: Mach3 and a tube bender
« Reply #9 on: February 13, 2009, 12:50:15 AM »
Good to hear you got it working,

As I stated over at cnczone, have you tried on putting 1440 in the units per rev?

Best regards
Fernando