how to change motor spin directions?

More
23 Mar 2016 04:03 #72056 by famus
Hi, Can anyone teach me how to change the motor turning direction?

I am using halrun to execute a .hal file. I am able to turn the motor at the default positive direction. I tried to set the pin "stepgen.0.dir" to 1 but it is a pin and not writable. Thank you for your help!

-famus

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

More
23 Mar 2016 12:43 - 23 Mar 2016 12:45 #72059 by Todd Zuercher
There are lots of ways to do this. For an axis joint, you can change the sign of the scale, or (on step/dir setups) you can invert the output pin on your direction signal (for a parallel port example if the dir output of the step gen you want to reverse is on pin 2, add the line "setp parport.0.pin-02-out-invert true" to your hal file). There are a few more ways in the software. Another way is to swap around a couple of wires between the motor and drive to revers its direction there.
Last edit: 23 Mar 2016 12:45 by Todd Zuercher.
The following user(s) said Thank You: famus, dmcmd

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

More
23 Mar 2016 21:38 #72071 by famus
Thank you, Todd!

How would you do it software-wise? Besides inverting parport pin-02?

I am interested in changing the stepgen.0.dir via a command or checkbox. I tried this:

net xdir => parport.0.pin-07-out
net xdir <= stepgen.0.dir
net stepgen.0.dir <= GUI.checkbox_ReverseDir

where GUI.checkbox_ReverseDir is a variable of a GUI checkbox.

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

More
24 Mar 2016 05:42 #72083 by famus
Todd, I tried "setp parport.0.pin-02-out-invert true" and it worked fine to reverse the direction. Thank you!

What I'd like to do is to have a button or checkbox in GUI (gladeVCP) to get the .hal file to reverse direction. I tried this but didn't work:

setp parport.0.pin-07-out-invert GUI.checkbox_ReverseDir

It complained that GUI.checkbox_ReverseDir "invalid for bit". But the parameter is a Boolean bit. Puzzled!

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

More
24 Mar 2016 13:15 #72088 by Todd Zuercher
The line should be:
net (your signal name) <= (output pin name) => (input pin name)
The signal name is an arbitrary name you create for this signal. So for your purpose the line should be something like this.
net reverse <= GUI.checkbox_ReverseDir => parport.0.pin-07-out-invert

However this might not work as parport.0.pin-07-out-invert is a parameter rather than an ordinary input pin. What exactly are you trying to accomplish? Maybe there is a better way we could suggest if we knew what you are doing?
The following user(s) said Thank You: famus

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

More
24 Mar 2016 16:19 #72100 by famus
Thank you for replying, Todd!

I am trying to have an external input to my setup of three stepper motors to turn the motors. I'd like to have speed and direction control. So far, I am trying a simple GladeVCP GUI to have button to control speed and direction to learn about LinuxCNC HAL.

I first tried manipulating "stepgen.0.dir". Shouldn't it be a pin to control directions? It's a bit and low is positive, high is negative direction.

I will try what you suggested tonight.

Thank you!

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

More
24 Mar 2016 16:45 - 24 Mar 2016 16:46 #72103 by Todd Zuercher
The "stepgen.0.dir" pin is an output from the step generator that it uses to change the motors direction. If you are wanting to change the direction of movement it would be better to change the input to the step generator to make it move the motor in the direction you want. What you are trying to do will cause the stepgen to loose track of it's position.
Last edit: 24 Mar 2016 16:46 by Todd Zuercher.

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

More
24 Mar 2016 18:23 #72106 by famus
Ok. Then I should not directly manipulate "stepgen.0.dir".

I have a signal called "xdir" that's connected to "stepgen.0.dir" pin. I should be able to change "xdir".

I'll keep trying tonight.

Thank you!

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

More
25 Mar 2016 06:07 - 25 Mar 2016 06:08 #72127 by famus
Tried:

net reverse <= GUI.checkbox_ReverseDir => parport.0.pin-07-out-invert

couldn't work because "GUI.checkbox_ReverseDir" is not a pin. How can I change signal "xdir" via a GUI variable? I guess I have to read more.

Thank you for the suggestion!
Last edit: 25 Mar 2016 06:08 by famus.

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

More
25 Mar 2016 21:06 #72157 by Todd Zuercher

Thank you for replying, Todd!

I am trying to have an external input to my setup of three stepper motors to turn the motors. I'd like to have speed and direction control. So far, I am trying a simple GladeVCP GUI to have button to control speed and direction to learn about LinuxCNC HAL.

I first tried manipulating "stepgen.0.dir". Shouldn't it be a pin to control directions? It's a bit and low is positive, high is negative direction.

I will try what you suggested tonight.

Thank you!


The stepgen component can accept a velocity command (as opposed to the ordinary position command) via the pin stepgen.0.velocity-cmd. This input pin is a float, that you could connect an output float to directly from your ui. As to how to create a hal pin from your ui, that depends on what sort of ui you are trying to use.

A good place to start researching how to do this is here.
linuxcnc.org/docs/html/
Specifically the sections "User Interface Programming" and "HAL (Hardware Abstraction Layer)"

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

Time to create page: 0.174 seconds
Powered by Kunena Forum