- Posts: 13
- Thank you received: 0
how to change motor spin directions?
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 to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
- Posts: 4739
- Thank you received: 2
Please Log in to join the conversation.
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 to join the conversation.
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 to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
- Posts: 4739
- Thank you received: 2
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?
Please Log in to join the conversation.
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 to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
- Posts: 4739
- Thank you received: 2
Please Log in to join the conversation.
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 to join the conversation.
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!
Please Log in to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
- Posts: 4739
- Thank you received: 2
famus wrote: 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 to join the conversation.
