Pokeys_homecomp EncoderSearch / Encoder Arm Topic: Pos_Fb Following errors
- zarfld
- Offline
- Senior Member
-
- Posts: 40
- Thank you received: 14
axis are finally moving ...
there is both PositionMode and VelocityMode...
i can get pos-fb based on "CurrentPosition" (divided by [JOINT*] STEPSCALE)
DemandValues for both modes share the same variable "ReferencePositionSpeed"
so first i was using Position-Mode which worked quite well, but without of adjustement of velocity
then i also changed to velocity mode - where i first thought i would need additional encoders to provide velocityfeedback for each axis.
but havinf vel-cmd and pos-fb signals active this seems fine also - besides a small deviation in pos-fb<->pos-cmd in 4th decimal.
so in the end i tried to switch to position-mode for the last move to ensure that the pos-fb is exact to pos-fb. but then the move was not fluent anymore.
so i removed that. I think the PID that you mentioned would also need vel-fb from encoders, right?
i tried to ensure a constant loopfrequency by counting the number of loops done every second (using realtime-clock signals of pokeys), and based on that adjusting the duration used in usleep(sleepduration). i found that "Device load status" on pokeys device kept the lowest if we keep around 10Hz, and the maximum frequency which seemed somehow stable was around 40Hz.
->kbd48CNC observed some latency issues if it is connected using Pokeys57E and PoNet-extensionBoard. This does ius not observed if on Pokeys57CNC (and CAN-operation enabled)
Attachments:
Please Log in or Create an account to join the conversation.
- andypugh
-
- Away
- Moderator
-
- Posts: 23310
- Thank you received: 4938
No, I don’t think you need encoders. You can use steps-actually-made back from the hardware as feedback.
Please Log in or Create an account to join the conversation.
- MATZE-ATZE-SCH
- Offline
- Senior Member
-
- Posts: 51
- Thank you received: 6
I have now on the Pokeys 2 Potis for Spindel Override and Feed Override.
I want to change the potis to rotary encoders with push button,
to set the value to 100% with the push button.
Have tried to connect the rotary switch to the Pokeys, but the update rate with 15Hz seems to slow to correctly
use a rotary switch with 20 impuls/rev.
If I turn the switch slow, it works fine, but at faster speed it get stock.
Is there a solution for this, to increase the update rate at 4 IOs of the Pokeys?
Have tried with the Pokeys Software to set the Inputs to Encoders, under Windows it works, but Linux seems to Ignore all settings.
In the 5th post in this Topic, the user "fixer" wrote:
Maybe I just dont need to useyes, digital IO, HW encoder counters and analog inputs are supported in HAL component from first post. The board can also decode matrix keyboard and PWM outputs. It can also emulate USB HID keyboard and joystick buttons and pots.
"pokeys.0.in-XX" but another thing?
The Hardware I use is a 5i20, 7i37 and 7i33
Best regards
Marcel
Please Log in or Create an account to join the conversation.
- zarfld
- Offline
- Senior Member
-
- Posts: 40
- Thank you received: 14
you are right "pokeys.0.in-XX" will just provide a bit (true/false 0/1), for parametrized counters a different pin needs to be created which provides the counter-value already counted by pokeys. Otherwise you will be restricted to loopfrequency of your HAL-component.
in the component i have implemented it as shown below - but not tested yet (anyway MPG-CounterWheel and rotary encoders for axis are waiting for installation on my mill).
// pin name
pin out unsigned counter.#.value[55];
...
// read values
if (dev->info.iDigitalCounters > 0)
{
if (PK_DigitalCounterGet(dev) == PK_OK)
{
DigitalCounterGet = true;
loopPins = true;
}
}
// map values to pin
for(i=0;i<info_PinCount-1;i++)
{
...
if(dev->Pins[i].DigitalCounterAvailable)
{
counter_value(i) = dev->Pins[i].DigitalCounterValue;
//Pins_CounterOptions(i) = dev->Pins[i].CounterOptions;
}
...[/i][/i][/i]
[i][i][i]}
i would be glad if you could give it a try, as during vacation i have no acces to my mill to check it by myself.[/i][/i][/i]
Please Log in or Create an account to join the conversation.
- MATZE-ATZE-SCH
- Offline
- Senior Member
-
- Posts: 51
- Thank you received: 6
Okay, will give it a try.
What is The Pin Name?
Instead of „pokeys.0.in-XX“
„pokeys.0.Counter-XX“? So of i define in the pokeys Software pin 37 as A1 and pin 38 as B1,
I asume in linux i need to use „pokeys.0.Counter-01“?
Best regards
Marcel
Please Log in or Create an account to join the conversation.
- zarfld
- Offline
- Senior Member
-
- Posts: 40
- Thank you received: 14
but the issue is quite similar, besides the fact that on pins the inputs for Channel A&B are parametrized.
pokeys provide 25 nomal encoders + 3 FastEncoders. There is also one ultrafast-encoder (but i'm not sure if one of the normal encoder-channels get nominated as ultrafast, or if we can access this value on a seperate channel).
there is also a possibility to nominate one of these encoders as MPGJogEncoder in PulseEngine. Anyway i assume there will be some interferences between PulseEngineV2 and LinuxCnc, as i did not test it yet i cannot say if this can be used properly on a LinuxCnc-mill.
for normal encoders my implementations uses the following:
// pin names
pin out s32 encoder.#.count[29];
pin out float encoder.#.position[29];
pin out float encoder.#.velocity[29];
pin in bit encoder.#.reset[29];
pin in bit encoder.#.index-enable[29];
param rw float encoder.#.scale[29] "The scale factor used to convert counts to position units. It is in “counts per position unit”";
...
if (dev->info.iBasicEncoderCount)
{
// read encodervalues
if (PK_EncoderValuesGet(dev) == PK_OK)
{
EncoderValuesGet = true;
//map values to pins
for (i = 0; i < dev->info.iBasicEncoderCount; i++)
{
encoder_count(i)=dev->Encoders[i].encoderValue;
}
if (dev->info.iUltraFastEncoders)
{
for (i = dev->info.iBasicEncoderCount; i < (dev->info.iBasicEncoderCount + dev->info.iUltraFastEncoders); i++)
{
encoder_count(i) = dev->Encoders[i].encoderValue;
}
}
/*if (dev->info.iFastEncoders)
{
for (i = dev->info.iBasicEncoderCount+ dev->info.iUltraFastEncoders; i < (dev->info.iBasicEncoderCount + dev->info.iUltraFastEncoders + dev->info.iFastEncoders ); i++)
{
encoder_value(i) = dev->Encoders[i].encoderValue;
}
}*/
}
}
[/i][/i][/i]
Please Log in or Create an account to join the conversation.
- MATZE-ATZE-SCH
- Offline
- Senior Member
-
- Posts: 51
- Thank you received: 6
This code i paste in the Code from Andy in the first page, or?
Please Log in or Create an account to join the conversation.
- zarfld
- Offline
- Senior Member
-
- Posts: 40
- Thank you received: 14
in my case it compiles and seems running in my pokeys.comp you can fin it there:
github.com/zarfld/LinuxCnc_PokeysLibComp
the usage used here can also be found in the pokeys examples, just need to be translated to match HAL
in my comments above i just reduced to the parts relevant for Encoders seperated by "..."
Please Log in or Create an account to join the conversation.
- MATZE-ATZE-SCH
- Offline
- Senior Member
-
- Posts: 51
- Thank you received: 6
Just 4 hours at work, then i can try it out

Please Log in or Create an account to join the conversation.
- MATZE-ATZE-SCH
- Offline
- Senior Member
-
- Posts: 51
- Thank you received: 6
but when i start linuxcnc, i get some error:
Debug file information:
Note: Using POSIX realtime
HAL: ERROR: insufficient memory for parameter 'pokeys.0.adcin.0.offset'
rtapi_app: caught signal 11 - dumping core
./Ruhla.hal:297: waitpid failed /usr/bin/rtapi_app or2
./Ruhla.hal:297: /usr/bin/rtapi_app exited without becoming ready
./Ruhla.hal:297: insmod for or2 failed, returned -1
Any sugestions?
Please Log in or Create an account to join the conversation.