MPG Handwheel - how to use encoder?
- frogandspanner
- Offline
- Senior Member
Less
More
- Posts: 65
- Thank you received: 2
02 Dec 2022 18:58 - 05 Dec 2022 00:13 #258345
by frogandspanner
MPG Handwheel - how to use encoder? was created by frogandspanner
I bought one of the MPG handwheels (rather like the ISM8060 at www.machinetoolproducts.com/content/Yumo...s%20Spec%20Sheet.jpg)
I have connected this to a parallel port, (A, B and gnd) and power it from a bench supply at 5V.
Then:Using halmeter I can see that encoder.0.phase-A and encoder.0.phase-B are being detected.
From reading various examples I assumed that encoder.0.counts would change as I operated the wheel, but it doesn't - and no other encoder pin does. I then
setp encoder.0.counter-mode TRUE
and still get no changes on any pins.
As the inputs change and are detected (at least at the hal pin level), and I get no output even in counter-mode, I assume I am doing something wrong.
I have connected this to a parallel port, (A, B and gnd) and power it from a bench supply at 5V.
Then:
$ halrunloadrt hal_parport cfg="0x3030 out"
loadrt encoder num_chan=1
net mpg-a encoder.0.phase-A <= parport.0.pin-10-in
net mpg-b encoder.0.phase-B <= parport.0.pin-11-in
loadusr halmeter
From reading various examples I assumed that encoder.0.counts would change as I operated the wheel, but it doesn't - and no other encoder pin does. I then
setp encoder.0.counter-mode TRUE
and still get no changes on any pins.
As the inputs change and are detected (at least at the hal pin level), and I get no output even in counter-mode, I assume I am doing something wrong.
Last edit: 05 Dec 2022 00:13 by andypugh.
Please Log in or Create an account to join the conversation.
- PCW
- Away
- Moderator
Less
More
- Posts: 17948
- Thank you received: 4816
02 Dec 2022 21:10 #258367
by PCW
Replied by PCW on topic MPG Handwheel - how to use encoder?
There are two encoder functions that must be added for the
encoder to operate:
addf encoder.capture-position servo-thread
addf encoder.update-counters base-thread
encoder to operate:
addf encoder.capture-position servo-thread
addf encoder.update-counters base-thread
Please Log in or Create an account to join the conversation.
- frogandspanner
- Offline
- Senior Member
Less
More
- Posts: 65
- Thank you received: 2
02 Dec 2022 22:05 #258375
by frogandspanner
Replied by frogandspanner on topic MPG Handwheel - how to use encoder?
No joy:
halcmd: addf encoder.capture-position servo-thread
HAL: ERROR: thread 'servo-thread' not found
<stdin>:5: addf failed
halcmd: addf encoder.update-counters base-thread
HAL: ERROR: thread 'base-thread' not found
<stdin>:6: addf failed
halcmd: addf encoder.capture-position servo-thread
HAL: ERROR: thread 'servo-thread' not found
<stdin>:5: addf failed
halcmd: addf encoder.update-counters base-thread
HAL: ERROR: thread 'base-thread' not found
<stdin>:6: addf failed
Please Log in or Create an account to join the conversation.
- PCW
- Away
- Moderator
Less
More
- Posts: 17948
- Thank you received: 4816
02 Dec 2022 22:16 #258377
by PCW
Replied by PCW on topic MPG Handwheel - how to use encoder?
If you have other names for your fast (base) and slow (servo)
threads, you must use those
threads, you must use those
Please Log in or Create an account to join the conversation.
- frogandspanner
- Offline
- Senior Member
Less
More
- Posts: 65
- Thank you received: 2
02 Dec 2022 22:24 #258378
by frogandspanner
Replied by frogandspanner on topic MPG Handwheel - how to use encoder?
Do threads exist by defaul,t or must they be created? If the latter how is that done?
Please Log in or Create an account to join the conversation.
- PCW
- Away
- Moderator
Less
More
- Posts: 17948
- Thank you received: 4816
02 Dec 2022 22:39 #258379
by PCW
Replied by PCW on topic MPG Handwheel - how to use encoder?
They need to be created, If you have a parallel port step/dir hardware,
you should use stepconf to create a hal/ini configuration file set
that takes care of these details
you should use stepconf to create a hal/ini configuration file set
that takes care of these details
Please Log in or Create an account to join the conversation.
- frogandspanner
- Offline
- Senior Member
Less
More
- Posts: 65
- Thank you received: 2
02 Dec 2022 22:48 #258382
by frogandspanner
Replied by frogandspanner on topic MPG Handwheel - how to use encoder?
I was hoping to shortcut that process and just use halrun. I managed to (I think) work out some things:
loadrt hal_parport cfg="0x3030 out"
loadrt encoder num_chan=1
net mpg-a encoder.0.phase-A <= parport.0.pin-10-in
net mpg-b encoder.0.phase-B <= parport.0.pin-11-in
loadrt threads name1=base-thread period1=50000 name2=servo-thread period2=1000000
addf encoder.update-counters base-thread
addf encoder.capture-position servo-thread
loadusr halmeter
But encoder.0.counts refuses to budge when I rotate the wheel.
loadrt hal_parport cfg="0x3030 out"
loadrt encoder num_chan=1
net mpg-a encoder.0.phase-A <= parport.0.pin-10-in
net mpg-b encoder.0.phase-B <= parport.0.pin-11-in
loadrt threads name1=base-thread period1=50000 name2=servo-thread period2=1000000
addf encoder.update-counters base-thread
addf encoder.capture-position servo-thread
loadusr halmeter
But encoder.0.counts refuses to budge when I rotate the wheel.
Please Log in or Create an account to join the conversation.
- PCW
- Away
- Moderator
Less
More
- Posts: 17948
- Thank you received: 4816
02 Dec 2022 22:58 #258384
by PCW
Replied by PCW on topic MPG Handwheel - how to use encoder?
I think you need to start the threads
(I don't recall exactly how, it may be as simple as typing "start")
(I don't recall exactly how, it may be as simple as typing "start")
Please Log in or Create an account to join the conversation.
- frogandspanner
- Offline
- Senior Member
Less
More
- Posts: 65
- Thank you received: 2
03 Dec 2022 16:44 #258438
by frogandspanner
Replied by frogandspanner on topic MPG Handwheel - how to use encoder?
I got it working with this:
$ halrun -I -f ptest.hal
loadrt encoder num_chan=1
net pin10 encoder.0.phase-A
net pin11 encoder.0.phase-B
loadusr halmeter
# Add encoder routines to the porttest thread from ptest.hal
addf encoder.update-counters porttest
addf encoder.capture-position porttest
$ halrun -I -f ptest.hal
loadrt encoder num_chan=1
net pin10 encoder.0.phase-A
net pin11 encoder.0.phase-B
loadusr halmeter
# Add encoder routines to the porttest thread from ptest.hal
addf encoder.update-counters porttest
addf encoder.capture-position porttest
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23170
- Thank you received: 4860
05 Dec 2022 00:16 #258541
by andypugh
Replied by andypugh on topic MPG Handwheel - how to use encoder?
I tend to just "loadrt threads" which gives you one thread (called "thread1") but all that was missing from your code above was "start" to start the threads.
loadrt hal_parport cfg="0x3030 out"
loadrt encoder num_chan=1
net mpg-a encoder.0.phase-A <= parport.0.pin-10-in
net mpg-b encoder.0.phase-B <= parport.0.pin-11-in
loadrt threads name1=base-thread period1=50000 name2=servo-thread period2=1000000
addf encoder.update-counters base-thread
addf encoder.capture-position servo-thread
loadusr halmeter
start
Please Log in or Create an account to join the conversation.
Time to create page: 0.132 seconds