Thanks for your help!
As spending some time with machinekit I am getting more comfortable, begin 
to understand the whole concept of the hal-structure and start to really 
like that concept.
It all makes sense now.


@ TJoseph Powderly: Thanks for your explanation, this also makes sense. But 
for now I will be alright having two people drive the car.


I created a .comp-File for the RCServo and edited the .ini- and .hal-File. 
Everything works fine, or at least it seems so to me ;)
Could you guys please check if I could improve any of the code? 

I designed the RCServo.comp file the way that it can be used with any 
RCServo. The timing parameters are set in the .ini-File and therefore can 
easily be changed.


Question: Should i set the functions of the RCServo as servo-threads or 
base-threads?









































































































*.INI-File:[AXIS_3]################################################################################
 
A-Axis 
(RC-Servo)###############################################################################TYPE
 
=                  ANGULARMAX_VELOCITY =          50MAX_ACCELERATION =     
 100MIN_LIMIT =             -90MAX_LIMIT =             90# Is this relevant 
for the Servo or only used by stepgen?BACKLASH =              0.000FERROR = 
               1.0MIN_FERROR =            0.25# RC-Servo timing 
parametersSERVO_CYCLETIME =       20000SERVO_TIME_MIN =       
 900SERVO_TIME_MAX =        2100        .HAL-File:# 
#################################### Core EMC/HAL Loads# 
###################################loadrt RCServo# 
################################################# THREADS# 
################################################# Servo- or 
Base-Threads?addf RCServo.0.period             servo-threadaddf 
RCServo.0.convert            servo-thread# ################# A [3] Axis# 
################# get Command from motion controller and send it to 
RCServonet rcservo.pos-cmd <= axis.3.motor-pos-cmdnet rcservo.pos-cmd => 
RCServo.0.axis-pos-cmd# Putting the Command of the motion controller 
directly as the # Feedback, to avoid errors net rcservo.pos-cmd => 
axis.3.motor-pos-fb# Get pwm Command from RCServo and send it to pwmgennet 
emcmot.03.pos-cmd <= RCServo.0.motor-pos-cmdnet emcmot.03.pos-cmd => 
hpg.pwmgen.00.out.00.value### timing parameters #### This specifies the PWM 
period, in nS. # For the RC-Servo: 20000000 ns = 0.02 s = 50 Hznet 
motor.03.pwm-period <= RCServo.0.pwm-periodnet motor.03.pwm-period => 
hpg.pwmgen.00.pwm_period setp RCServo.0.pwm-cycletime       
 [AXIS_3]SERVO_CYCLETIMEsetp RCServo.0.pwm-min             
 [AXIS_3]SERVO_TIME_MINsetp RCServo.0.pwm-max             
 [AXIS_3]SERVO_TIME_MAX# If true, the pwmgen will output pulses. # If 
'enable' is false, pwmgen will not output any signals.setp 
hpg.pwmgen.00.out.00.enable        1# 20000ms cycleTimesetp 
hpg.pwmgen.00.out.00.scale     [AXIS_3]SERVO_CYCLETIME# P8.13 PWM.out1setp 
hpg.pwmgen.00.out.00.pin       813RCServo.compcomponent RCServo "Machinekit 
HAL component for driving a RCServo";pin in float axis-pos-cmd "Commanded 
position from motion";pin out float motor-pos-cmd "Commanded position for 
Servo";pin out u32 pwm-period "Set Period for pwmgen";pin in u32 
pwm-cycletime "RCServo Cycletime in ms";pin in u32 pwm-min "-90 degrees in 
ms";pin in u32 pwm-max "+90 degrees in ms";variable float 
pwm_middle;function period fp "Calculate the pwmgen Period";function 
convert fp "Convert degrees into pwm-signal";license 
"GPL";;;FUNCTION(period) {    pwm_period = pwm_cycletime * 
1000;}FUNCTION(convert) {    pwm_middle = pwm_min + (pwm_max - pwm_min) / 
2;    motor_pos_cmd = (pwm_max - pwm_middle) / 90 * axis_pos_cmd + 
pwm_middle;}*

-- 
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 machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to