how to change motor spin directions?

More
10 years 7 months ago - 10 years 7 months ago #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: 10 years 7 months ago by Todd Zuercher.

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

More
10 years 7 months ago #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
10 years 7 months ago - 10 years 7 months ago #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: 10 years 7 months ago by famus.

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

More
10 years 7 months ago #72157 by Todd Zuercher

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 or Create an account to join the conversation.

More
10 years 7 months ago - 10 years 7 months ago #72170 by famus
Yes, thank you! I had that working by:

net p-scale stepgen.0.velocity-cmd <= GUI.hal_spinbutton1-f

However, I could not input a negative number to reverse velocity direction.

I fixed the previous problem of "GUI.checkbox_ReverseDir" is not a pin, I changed the checkbox to a HAL_toggle button and that was a pin. But still can't change as "parport.0.pin-07-out-invert" is not a pin but a parameter as you said earlier.

Still trying ...
Last edit: 10 years 7 months ago by famus.

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

More
10 years 7 months ago #72187 by Todd Zuercher
I would think the most elegant solution would be to figure out why you can't get a negative number and fix that
.
But you could create a series of hal commands that could convert your number you are sending to a negative number. This seems like a rather tortured hack but,here goes. Connect your float (absolut velocity) value to a mult2, (other mult2 input would be -1), then connect your original float value to one float input of a mux2, and the other float input of the mux2 to the product of the sum2. Then the input bit of the mux2 you would use to change your direction.

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

Time to create page: 0.063 seconds
Powered by Kunena Forum