- Posts: 13
- Thank you received: 0
encoder and hal. How to use them?
5 years 10 months ago #191510
by veroski
encoder and hal. How to use them? was created by veroski
hi everyone, I found an encoder that I would like to use to control a step motor, I would like to use it as a handweel. I read the documentation on the encoder component but didn't understand much about it. can you give me some advice? maybe with concrete examples it would be perfect.
i forgot, my encoder is incremental has a ttl output and has the following pins: VCC GND A B A- B-
regards
i forgot, my encoder is incremental has a ttl output and has the following pins: VCC GND A B A- B-
regards
Please Log in to join the conversation.
- tommylight
-
- Away
- Administrator
-
Less
More
- Posts: 22012
- Thank you received: 4
5 years 10 months ago #191512
by tommylight
Replied by tommylight on topic encoder and hal. How to use them?
That would be using it as an MPG, so a quick search for MPG shows:
www.google.com/search?source=hp&ei=dRfRX...OSB5QQ4dUDCAY&uact=5
www.google.com/search?source=hp&ei=dRfRX...OSB5QQ4dUDCAY&uact=5
Please Log in to join the conversation.
5 years 10 months ago #191543
by Benb
Replied by Benb on topic encoder and hal. How to use them?
You did not specify your interface card. Here are links that explain how to interface your MPG to the most popular cards in use with LCNC.
For connection to Mesa card cards
forum.linuxcnc.org/24-hal-components/38539-mpg-hal-question-s
For connection to parallel port:
linuxcnc.org/docs/2.5/html/examples/mpg.html
wiki.linuxcnc.org/cgi-bin/wiki.pl?Hooking_Up_A_MPG_Pendant
For connection to Mesa card cards
forum.linuxcnc.org/24-hal-components/38539-mpg-hal-question-s
For connection to parallel port:
linuxcnc.org/docs/2.5/html/examples/mpg.html
wiki.linuxcnc.org/cgi-bin/wiki.pl?Hooking_Up_A_MPG_Pendant
Please Log in to join the conversation.
5 years 10 months ago #191579
by veroski
Replied by veroski on topic encoder and hal. How to use them?
ok I took a quick look and edited my .hal file that I post below. sorry for the delay in replying and thanks for your hand
Attachment not found
Please Log in to join the conversation.
5 years 10 months ago #191580
by veroski
Replied by veroski on topic encoder and hal. How to use them?
I forgot to tell you that I have a Chinese BOB and I use a parallel port. so for now I will only command the x axis
Please Log in to join the conversation.
5 years 10 months ago #191583
by veroski
Replied by veroski on topic encoder and hal. How to use them?
I did a little experiment by putting a normally open button that simulates phase A of the encoder as input to pin 10 of the parallel port. Unfortunately, no changes are displayed in halmeter on the pin encoder.0.phase-A. So given the non-change I tried with ptest.hal if everything worked and it actually is.
loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadrt hal_parport cfg="0 out"
setp parport.0.reset-time 2500
loadrt stepgen step_type=0,0,0
loadrt pwmgen output_type=1
#encoder e mux4
loadrt encoder num_chan=1
loadrt mux4 count=1
addf parport.0.read base-thread
addf stepgen.make-pulses base-thread
addf pwmgen.make-pulses base-thread
addf parport.0.write base-thread
addf parport.0.reset base-thread
#encoder
addf encoder.update-counters base-thread
addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
addf pwmgen.update servo-thread
#encoder
addf encoder.capture-position servo-thread
net spindle-cmd-rpm => pwmgen.0.value
net spindle-on <= spindle.0.on => pwmgen.0.enable
net spindle-pwm <= pwmgen.0.pwm
setp pwmgen.0.pwm-freq 100.0
setp pwmgen.0.scale 1166.66666667
setp pwmgen.0.offset 0.114285714286
setp pwmgen.0.dither-pwm true
net spindle-cmd-rpm <= spindle.0.speed-out
net spindle-cmd-rpm-abs <= spindle.0.speed-out-abs
net spindle-cmd-rps <= spindle.0.speed-out-rps
net spindle-cmd-rps-abs <= spindle.0.speed-out-rps-abs
net spindle-at-speed => spindle.0.at-speed
net spindle-cw <= spindle.0.forward
net spindle-ccw <= spindle.0.reverse
net estop-out => parport.0.pin-01-out
net xdir => parport.0.pin-02-out
net xstep => parport.0.pin-03-out
setp parport.0.pin-03-out-reset 1
net ydir => parport.0.pin-04-out
net ystep => parport.0.pin-05-out
setp parport.0.pin-05-out-reset 1
net zdir => parport.0.pin-06-out
net zstep => parport.0.pin-07-out
setp parport.0.pin-07-out-reset 1
net adir => parport.0.pin-08-out
net astep => parport.0.pin-09-out
setp parport.0.pin-09-out-reset 1
net spindle-cw => parport.0.pin-14-out
#net spindle-ccw => parport.0.pin-14-out
net spindle-pwm => parport.0.pin-16-out
net xenable => parport.0.pin-17-out
net mpg-a encoder.0.phase-A <= parport.0.pin-10-in
net mpg-b encoder.0.phase-B <= parport.0.pin-11-in
those in bold are the only things I've added
loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadrt hal_parport cfg="0 out"
setp parport.0.reset-time 2500
loadrt stepgen step_type=0,0,0
loadrt pwmgen output_type=1
#encoder e mux4
loadrt encoder num_chan=1
loadrt mux4 count=1
addf parport.0.read base-thread
addf stepgen.make-pulses base-thread
addf pwmgen.make-pulses base-thread
addf parport.0.write base-thread
addf parport.0.reset base-thread
#encoder
addf encoder.update-counters base-thread
addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
addf pwmgen.update servo-thread
#encoder
addf encoder.capture-position servo-thread
net spindle-cmd-rpm => pwmgen.0.value
net spindle-on <= spindle.0.on => pwmgen.0.enable
net spindle-pwm <= pwmgen.0.pwm
setp pwmgen.0.pwm-freq 100.0
setp pwmgen.0.scale 1166.66666667
setp pwmgen.0.offset 0.114285714286
setp pwmgen.0.dither-pwm true
net spindle-cmd-rpm <= spindle.0.speed-out
net spindle-cmd-rpm-abs <= spindle.0.speed-out-abs
net spindle-cmd-rps <= spindle.0.speed-out-rps
net spindle-cmd-rps-abs <= spindle.0.speed-out-rps-abs
net spindle-at-speed => spindle.0.at-speed
net spindle-cw <= spindle.0.forward
net spindle-ccw <= spindle.0.reverse
net estop-out => parport.0.pin-01-out
net xdir => parport.0.pin-02-out
net xstep => parport.0.pin-03-out
setp parport.0.pin-03-out-reset 1
net ydir => parport.0.pin-04-out
net ystep => parport.0.pin-05-out
setp parport.0.pin-05-out-reset 1
net zdir => parport.0.pin-06-out
net zstep => parport.0.pin-07-out
setp parport.0.pin-07-out-reset 1
net adir => parport.0.pin-08-out
net astep => parport.0.pin-09-out
setp parport.0.pin-09-out-reset 1
net spindle-cw => parport.0.pin-14-out
#net spindle-ccw => parport.0.pin-14-out
net spindle-pwm => parport.0.pin-16-out
net xenable => parport.0.pin-17-out
net mpg-a encoder.0.phase-A <= parport.0.pin-10-in
net mpg-b encoder.0.phase-B <= parport.0.pin-11-in
those in bold are the only things I've added
Please Log in to join the conversation.
Time to create page: 0.079 seconds
