Hello Jeff,
I have tried to add the PID loop to my setup. I copied the code from the 
Xylotek HAL and Config file. But for some reason when I feed the PID loop 
output into the velocity command, the motors don't move at all. When i feed 
the PID output into the position command the machine starts moving but 
completly uncontrolable. 

This is part my current HAL file

*# ################*
*# X [0] Axis ( Back LMS )*
*# ################*

*# axis enable chain*
*newsig emcmot.00.enable bit*
*sets emcmot.00.enable FALSE*

*net emcmot.00.enable <= axis.0.amp-enable-out*
*net emcmot.00.enable => hpg.stepgen.00.enable pid.0.enable*

*# position command and feedback*
*net emcmot.00.pos-cmd <= axis.0.motor-pos-cmd*
*net emcmot.00.pos-cmd => pid.0.command*
*net emcmot.00.vel-cmd <= axis.0.joint-vel-cmd*
*net emcmot.00.vel-cmd => pid.0.command-deriv*

*net motor.00.pos-fb <= hpg.stepgen.00.position-fb*
*net motor.00.pos-fb => axis.0.motor-pos-fb pid.0.feedback *
*net motor.00.command <= pid.0.output *
*net motor.00.command => hpg.stepgen.00.velocity-cmd ddt.0.in*
*#net emcmot.00.pos-cmd => hpg.stepgen.00.position-cmd ddt.0.in*

*setp pid.0.error-previous-target true*
*setp pid.0.maxerror .001*

*# timing parameters*
*setp hpg.stepgen.00.dirsetup        [AXIS_0]DIRSETUP*
*setp hpg.stepgen.00.dirhold         [AXIS_0]DIRHOLD*

*setp hpg.stepgen.00.steplen         [AXIS_0]STEPLEN*
*setp hpg.stepgen.00.stepspace       [AXIS_0]STEPSPACE*

*setp hpg.stepgen.00.position-scale  [AXIS_0]SCALE*

*setp hpg.stepgen.00.maxvel          [AXIS_0]STEPGEN_MAX_VEL*
*setp hpg.stepgen.00.maxaccel        [AXIS_0]STEPGEN_MAX_ACC*

*# P8.9 X_Step*
*setp hpg.stepgen.00.steppin         0x65*
*# P8.10 X_Dir*
*setp hpg.stepgen.00.dirpin          0x64*

*# PID settings to prevent PRU pin hunting*
*setp pid.0.Pgain [AXIS_0]P*
*setp pid.0.Igain [AXIS_0]I*
*setp pid.0.Dgain [AXIS_0]D*
*setp pid.0.bias [AXIS_0]BIAS*
*setp pid.0.FF0 [AXIS_0]FF0*
*setp pid.0.FF1 [AXIS_0]FF1*
*setp pid.0.FF2 [AXIS_0]FF2*
*setp pid.0.deadband [AXIS_0]DEADBAND*
*setp pid.0.maxoutput [AXIS_0]MAX_OUTPUT*

*# set the signals for the velocity and acceleration*
*net Xvel ddt.0.out => ddt.1.in *
*net Xacc <= ddt.1.out*

*# The home switch for the back LMS is connected to the X_MAX pin*
*net home-x bb_gpio.p8.in-08 => axis.0.home-sw-in*

And in the INI file this is the part that sets the PID parameters

*# PID tuning params to prevent PRU hunting*
*DEADBAND   = 0*
*P          = 50*
*I          = 0*
*D          = 0*
*FF0        = 0*
*FF1        = 1*
*FF2        = 0*
*BIAS       = 0*
*MAX_OUTPUT = 0*

These have been copied directly from GitHub.

Does anybody see what is wrong here?

With regards,
Michel


Op woensdag 10 mei 2017 18:08:39 UTC+2 schreef Jeff Pollard:
>
>
> Hi,
>
>   A PID loop has been added to the Xylotex HAL file in the 
> ARM/BeagleBone/Xylotex configs section.
>   Take a look there for a way to set up the axes with a PID loop that gets 
> rid of the hunting problem.
>
> Jeff
>
>
> On Wednesday, May 10, 2017 at 7:15:44 AM UTC-7, Alexander Rössler wrote:
>>
>> This phenomena is known as PRU pin hunting and a result of the internal 
>> PRU stepper feedback loop being too "tight" (so the DIR pin toggles all 
>> the time). You can fix it by adding a PID loop before the stepper and 
>> adding a minimum threshold. Just search for PRU pin hunting in the 
>> mailing list. 
>>
>> Another solution would be to adapt the PRU HAL driver code. However, the 
>> PID loop has the additional advantage that it smoothes out RT jitter. 
>>
>> The solution is also present in the Machinekit fdm Python libraries: 
>>
>> https://github.com/machinekit/machinekit/blob/master/lib/python/fdm/config/base.py#L61-L75
>>  
>>
>> [email protected] writes: 
>>
>> > Hello Nick, 
>> > If i am correct this is some form of "hunting" mode which is being done 
>> by 
>> > the feedback loop in the PRU. I have seen the same behavior on our 
>> > machines, but I have no clue what this actually does internally in 
>> > machinekit. 
>> > 
>> > Op woensdag 10 mei 2017 11:14:45 UTC+2 schreef Nick Collier: 
>> >> 
>> >> I am running Machinekit on a BBB. 
>> >> 
>> >> When tasting the physical step and direction output pins with an 
>> >> oscilloscope, I noticed that there are various rectangle/pulse type 
>> waves 
>> >> on the direction pins when the respective axis are not moving. Is this 
>> >> normal? 
>> >> 
>> >> As soon I make the axis move, the direction pin goes to either high or 
>> low 
>> >> depending on the direction. 
>> >> 
>> >> When the axis are moving, everything looks fine. But I would expect no 
>> >> signal when there is no movement. The step outputs produce no signal 
>> when 
>> >> there is no movement, so I guess the signal from the direction outputs 
>> are 
>> >> not going to do any harm. 
>> >> 
>> >> 
>>
>>
>> -- 
>> Alexander 
>>
>

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to