encoder and hal. How to use them?

More
09 Dec 2020 18:11 #191510 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

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

More
09 Dec 2020 18:29 #191512 by tommylight
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
The following user(s) said Thank You: veroski

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

More
10 Dec 2020 01:15 #191543 by Benb
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
The following user(s) said Thank You: veroski

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

More
10 Dec 2020 13:10 #191579 by veroski
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

File Attachment:

File Name: drill.hal
File Size:4 KB
Attachments:

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

More
10 Dec 2020 13:12 #191580 by veroski
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 or Create an account to join the conversation.

More
10 Dec 2020 15:44 - 10 Dec 2020 15:46 #191583 by veroski
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
Last edit: 10 Dec 2020 15:46 by veroski.

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

Time to create page: 0.077 seconds
Powered by Kunena Forum