Understanding hardware stepgens
- btvpimill
- Offline
- Elite Member
- Posts: 229
- Thank you received: 3
Still stuck with how to generate what is being sent to the hardware stepgen, and how to generate that in HAL.
And thanks Peter. Maybe I need a simple config to look at to find the answers I seek, does anyone have a suggestion for what one I should look at?
Please Log in or Create an account to join the conversation.
- btvpimill
- Offline
- Elite Member
- Posts: 229
- Thank you received: 3
axis.N.motor-pos-cmd is what I "send" to my hardware?
If so, then my hardware needs to calculate the difference between it and where it is now to decide how fast/far it needs to move before the next thread read? This seems not right to me, maybe it is starting to dawn on me now. If I use axis.N.joint-vel-cmd instead of position, would this be what I have referred to as the "adder" a few posts ago? That seems easier if I am correct.
then
axis.N.motor-pos-fb is where my accumulator value is "sent" back to? or would I want to use axis.N.joint-pos-fb?
As always, thank you all for your help in trying to get this newbee on track.
Please Log in or Create an account to join the conversation.
- jmelson
- Offline
- Moderator
- Posts: 817
- Thank you received: 151
My boards all use the parallel port to communicate with. Using the EPP mode,Thanks Jon, that is pretty cool! Unfortunetly I am not adding encoders. Care to help me out with exactly what is going on between HAL and your hardware? Do I have the concept correct? In my case I will be reporting the acc value for the position I assume.
you can send an 8-bit address to the target device(s) and then transfer data.
So, what I have is an address counter in the board, which increments in
sync with the transfers. So, you set the address once and can then read
or write a string of consecutive registers. Our Universal Stepper Controller
has 24-bit position counts, and 24-bit step rate counters. it does not use
the direct digital synthesis scheme, but just a counter that counts up to
a limit, issues a step and then starts back at zero. This was simpler in the
early days of FPGAs. The count limit is computed as :
(FPGA clock)/(rate in steps/second)
So, the servo cycle is like this:
1. read all position counters, compute velocity, etc. in PPMC driver
2. perform trajectory interpolation, PID, etc.
3. output new velocity in PPMC driver
Still stuck with how to generate what is being sent to the hardware stepgen, and how to generate that in HAL.
That would be the value written to ppmc.xx.stepgen.yy.velocity
where xx is the parallel port number (usually zero) and yy is
the step generator number. Normally, it is a value sent directly
from the PID component to the step generator.
The HAL parameter ppmc.xx.stepgen.yy.scale
scales this velocity from user units/second to the necessary
step pulses/second.
You can browse the source code here :
<git.linuxcnc.org/gitweb?p=linuxcnc.git;a...b2e76ad09867;hb=HEAD>
sorry for the hideously long link.
You can read the univstep sample configs file set in any LinuxCNC
distro to see how it is all connected up.
Jon
Please Log in or Create an account to join the conversation.
- btvpimill
- Offline
- Elite Member
- Posts: 229
- Thank you received: 3
Quite intresting stuff this is
Please Log in or Create an account to join the conversation.
- jmelson
- Offline
- Moderator
- Posts: 817
- Thank you received: 151
Well, my USC doesn't use an accumulator, it uses a counter and aJon, Thank you for this great explanation!! So I suppose if I send the axis.N.vel to my hardware, that will be what gets added to the accumulator until the next vel comes in.
Quite intresting stuff this is
limit comparator. When the count exceeds the limit, it resets the
counter to zero and issues a step. The driver does all the calibration
to figure out what value to send to the hardware. Then, it just keeps
on doing the same until the next value comes in.
Jon
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
- Posts: 23559
- Thank you received: 4858
Using the velocity pin probably won't work without feedback. Rounding errors and jitter will conspire to not give you exactly the right number of steps every time.Thank you for this great explanation!! So I suppose if I send the axis.N.vel to my hardware, that will be what gets added to the accumulator until the next vel comes in
If you consider the way that the software stepgen works, a new target position is sent every servo period, and the base-thread component attempts to produce that number of steps before the next update comes in 1mS later.
I think that any spare steps (or left-over steps) are compensated for on the next servo cycle. It is not uncommon for there to be much fewer than one step per servo cycle, after all.
I have never used a PPMC system, but with the Mesa system the stepgen driver has a "scale" parameter and receives position commands. Internally the position commmands are converted to a number of steps required.
It is worth noting that the number of steps required is much more often zero than many.
Please Log in or Create an account to join the conversation.
- btvpimill
- Offline
- Elite Member
- Posts: 229
- Thank you received: 3
Thank you Andy, This may also help me get going in some(hopefully correct) direction. Of course there will be feedback, but I am guessing not the kind you are talking about.
In an effort to wrap my brain around this better - here is what I think happens:
first current position is read from hardware - This is either the current value of counter/accumulator or encoder feedback value
however the position is determined in hardware, this number is given to axis.N.fb pin. lets call this 9.997
LinuxCNC (lcnc) has on pin axis.N.cmd a value of say 10.000
current position is 9.997
in PPMC, the driver determines .003" needs to move over the next mS, so some number corrasponding to generating the steps needed is sent to hardware
in MESA, the hardware figures out that .003" needs to happen over the next mS and generates the needed steps to make that happen.
Both of course need a scale number to know how many steps it takes to get .003" of travel, so counters/accumulators/whatever are running to make those steps.
I am assuming here that axis.N.cmd is an absolute position and not an incremental one. I guess maybe that is my last bit of confusion for now. Of course if it is incremental thigs get easier, then axis.N.cmd would equal .003 instead of 10.000
Please Log in or Create an account to join the conversation.
- jmelson
- Offline
- Moderator
- Posts: 817
- Thank you received: 151
No, this is NOT in the PPMC driver, it is in the PID component. PID compares theThanks Jon, I am trying to let your driver sink into my brain.
Thank you Andy, This may also help me get going in some(hopefully correct) direction. Of course there will be feedback, but I am guessing not the kind you are talking about.
In an effort to wrap my brain around this better - here is what I think happens:
first current position is read from hardware - This is either the current value of counter/accumulator or encoder feedback value
however the position is determined in hardware, this number is given to axis.N.fb pin. lets call this 9.997
LinuxCNC (lcnc) has on pin axis.N.cmd a value of say 10.000
current position is 9.997
in PPMC, the driver determines .003" needs to move over the next mS, so some number corrasponding to generating the steps needed is sent to hardware
commanded vs. actual position (instantaneous following error), the current commanded velocity, the
change in following error since last sample, etc. and computes a new velocity to send to
any of the devices (stepper, PWM servo, analog servo).
Yes, the position command is in absolute machine coordinates, in user units (typicallyin MESA, the hardware figures out that .003" needs to happen over the next mS and generates the needed steps to make that happen.
Both of course need a scale number to know how many steps it takes to get .003" of travel, so counters/accumulators/whatever are running to make those steps.
I am assuming here that axis.N.cmd is an absolute position and not an incremental one. I guess maybe that is my last bit of confusion for now. Of course if it is incremental thigs get easier, then axis.N.cmd would equal .003 instead of 10.000
either inch or mm).
Jon
Please Log in or Create an account to join the conversation.
- btvpimill
- Offline
- Elite Member
- Posts: 229
- Thank you received: 3
Anyway, thank you all fr the help given thus far, I will be back to this in a few weeks or so.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
- Posts: 23559
- Thank you received: 4858
I will leave it at this until I have a machine up again and can actually look at these signals as they are generated. Well maybe I can, I am sure they are hard to watch
linuxcnc.org/docs/html/hal/tutorial.html..._tutorial_halscope_a
One of the truly great parts of LinuxCNC
Please Log in or Create an account to join the conversation.