[Home]SampleParport

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

This page describes adding a stepper powered rotary axis to the three axis stepper setup in HAL. You already know that it is possible to run up to six axes. You may also know that one of the first steps to adding an axis is to expand the INI file by copying an axis definition and changing a few values.

The first thing you want to do is copy several files so that you preserve the originals. This will help if you need to back up because a change killed something. For this configuration page let's assume that you are in the emc2 directory, regardless of where that is on your computer. On mine that is here.

 rayh@ray64:~/emcdevelop/testing/emc2$

You will often see this because it is the command prompt in my bash terminal. Most of the way through this page I'll shorten it so just look for the emc2$. (add from here)


Now I've written the first take of a small script to use to show myself around the HAL. This is available from http://www.linuxcnc.org/dropbox/hal_show.tcl

Below is the conversation that is the basis for this page. This has been recently edited to be human-readable and might not be 100% correct in syntax etc. If the information does not work for you, click "View other Revisions" to see the original conversation.


chinamill:

   [I got the XYZ axes of the mill and EMC working, but I want to add a fourth axis.]
   [I'm a completely new to HAL and not sure how to do this.]

rayh:

   No problem. I was the same a few weeks ago.

chinamill:

   Where do I create the signal for the new axis? 
   Or, where can I read how the signals for the XYZ axes? are stored?

rayh:

   May I send you a short Tcl/Tk? script? [See the link above for the script]
   Put it into the emc2 directory. Start EMC2.
   It just shows hal pins and things.
   Once EMC2 is running, start another terminal in the EMC2 directory and enter the command "./hal_show.tcl"

chinamill:

   Now its setup... The EMC2 window next by the new window.
   I can see HAL settings...

rayh:

   Let's copy some of the files in the "emc/config" directory and edit the copied files.

chinamill:

   :) Good idea!

rayh:

   What would you like to call your setup?
   Perhaps we could use "4axis" and as the basis for file names

chinamill:

   good

rayh:

   Copy "configs/emc.ini" to "configs/4axis.ini"

[rayh looks at a few other files]

chinamill:

   I made a backup of the "config" directory, so I think I will just edit the original "emc.ini"
   Is that okay?

rayh:

   Okay.  That will work.
   I'll do the same here for this test.
   In emc.ini change these lines.
      "AXES = 3"    to    "AXES =  4"
      "COORDINATES = X Y Z"    to    "COORDINATES = X Y Z A"
      "HOME = 0 0 0 0"

chinamill:

   I tried this already (except adding the last zero in "HOME").

rayh:

   Select all of one axis definition and copy it to just after the last axis.
   ["AXIS_2" selected and copied in this instance]
   Edit "[AXIS_2]" to "[AXIS_3]"

chinamill:

   "ANGUALAR"?

rayh:

   Yes, if you wish to use degrees. [Rotating axis as opposed to linear.]
   But use "ANGULAR"

chinamill:

   units 1.0

rayh:

   I say "YES" to the ignore limits.
   I'd cut the value for input scale way back, try 60.
   This will allow 1 arc-second movements and still allow you to get the speed of the axis up later.

chinamill:

   Done.

rayh:

   Okay, now we move to the "core_stepper.hal" file.
   Start EMC2 using "scripts/emc.run"
   Open a second terminal in EMC2 and enter "./hal_show.tcl"
   I must rename that file!

chinamill:

   On this one [terminal?] I have no realtime kernel.

rayh:

   Right.
   Did "servo_tune" start up okay?

chinamill:

    yep..
    I can browse

rayh:

   Good. Press the "show all" button.
   This is everything that HAL knows.

chinamill:

   Okay.
   [There's a lot!]

rayh:

   Yes there is, but it's not so bad to learn if we look at a little at a time.
   So let's do that by using the other "show" buttons.
   Start with "pins"
   You will see right off that there are 8 axes available.
   We won't have trouble with adding a fourth.

chinamill:

   Okay...
   Is the signal there already?

rayh:

   Right below the "show" buttons on "servo_tune" there is an entry widget.
   The motion module that makes the axis pins has those available, yes?

chinamill:

   Yes.

rayh:

   Click in that entry and type "axis.0"
   Then press the "show pins" again.
   These are the motion pins for axis.0

chinamill:

   [A lot of "FALSE" is displayed!]

rayh:

   Look at the first line: "02    bit   -W     FALSE      axis.0.amp-enable-out ==> Xen"
   See the "==> Xen"?
   That tells us that the pin "axis.0.amp-enable-out" is connected to a signal named "Xen"
   Place just "X" in that search entry and press "show signals"
   This shows all of the signals used for the X axis.  Look for the "Xen"

chinamill:

   Looks beautiful.

rayh:

   Now you can see that the signal "Xen" is connected to "==> stepgen.0.enable"

chinamill:

   Yes. The bit is set FALSE though...

rayh:

   Yes. If you brought the machine out of EStop and searched again it would show true.

chinamill:

   Ah ha...
   I guess we need a "Aen"?

rayh:

   You are getting it.
   Now if you search for "stepgen.0" using "show pins" you will see all of the connections to the step generator.
   You will need to add all of these connections within the *.hal files for the A axis.
   It looks like a lot when viewed this way, but taken one at a time it is not so bad.

chinamill:

   I tried this, bit in the wrong way I guess.

rayh:

   The smallest mistake on any of the xxx.hal files will cause a failure.
   The reason for the failure is not always clear from the error message.

chinamill:

   I think its good with abstraction... only need a little guidens... [We should try to update the wiki.]

rayh:

   The developers are working on this problem.
   You bet.  A wiki page for this was just created. [Ta-dah!]

   We need to do a few more things so that we enable the extra axes in "stepgen" so that we have pins to connect to.
   Open "core_stepper.hal"
   The 4th line contains "loadrt stepgen step_type=0,0,0"
   Add a ",0"
   Now we are getting into new stuff for me as well.
   Save the file and restart EMC2.
   Search for "stepgen" again using the "show pins" button.
   You should see a set of pins for "stepgen.3"

chinamill:

   Yep.
   Axis 4!

rayh:

   That's it.
   [rayh does a bit of testing]

chinamill:

   "newsig Apos-cmd float ad" to "core_stepper.hal"?
   "linksp Apos-cmd <= axis.3.motor-pos-cmd"
   "linksp Apos-cmd => stepgen.3.position-cmd"

rayh:

   In each section you can simply copy what is there for the other axes as we have added the extra axis to the INI file.
   "setp stepgen.3.position-scale [AXIS_3]INPUT_SCALE" will bring those values into HAL from that section of the INI.
   And last you should edit "standard_pinout.hal" and place the signals from "Astep" and "Adir" on parport pins.
   If you match EMC2 those would be 09-out and 08-out.

chinamill:

   Okay... and pin 9 is not used for something else? Such as spindle something?

rayh:

   We can look at that using the "servo_tune" script.
   Search for "parport" using "show pins"
   Yes it does so you will want to remove that line or use another out for the A axis.
   IMO, I'd use 8 and 9 for A and move spindle on.

chinamill:

   How would I move the spindle on?

rayh:

   Simply change "linksp spindle_on parport.0.pin-09-out" to something like "linksp spindle_on parport.0.pin-01-out"

chinamill:

   I'll test...

rayh:

   If you have no typos it should start.
   I have never been successful on the first try, so I will be very angry if you are.

[Darn, chinamill was successful]


LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited July 7, 2009 1:45 am by UniquelyCommon (diff)
Search:
Published under a Creative Commons License