[solved]Unable to WRITE float pin OUT
X100 Y[40 + #<_hal[mycomp.yo]>] Z800 .... in my gcode I use already #<_hal[mycomp.value] pin with success.
in my comp have this:
pin in float my = 0 "some description";
...
...
pin out float yo = 0 "some description";
void usermainloop(void)
{
while(true)
{
FOR_ALL_INSTS()
yo = my;
......
In my hal file:
net encoder2 encoder.2.position => mycomp.my
In hal configuration I can see change both the value but the GCODE don't work properly ......
WHY??? where is My Mystake .... some ideas?
I CHANGE THE TITLE BECAUSE BETTER DESCRIBE MY REAL PROBLEM
Please Log in or Create an account to join the conversation.
I can't load pin in float on user_mainloop in this way: myPinOutFloat = myPinInFloat.... I understand that is not possible this way too:
void myfunction (float var)
{
......
}
void usermainloop(void)
{
while(true)
{
FOR_ALL_INSTS()
myFloatGlobalVariable = myPinInFloat;
myfunction(myFloatGlobalVariable);
........
......
there is some way to do this ??????
THE PROBLEM RESULT: I READ THE PIN VALUE BUT NOT SPREADS ALONG THE CODE .
I TRY TO MAKE AN OTHER COMPONENT NOT USER.
Please Log in or Create an account to join the conversation.
I try to make a component non user ... similar to this:
component tcomp "";
pin in float value "";
pin out float vx1 "";
pin out float vy1 "";
pin out float vx2 "" ;
pin out float vy2 "" ;
function _ ;
;;
FUNCTION(_){
float cx = 0;
cx = value;
vx1 = 40.0;
vy1 = value - 40.0;
vx2 = -200.0;
vy2 = value - 300.0;
}
than I install it with sudo --install tcomp.comp, and put it in myhal.hal file in this way:
loadrt mycustomkinematics
loadusr -W myfirstcomp
loadrt tcomp
.....
....
at start of myhal file obtai this error:
tcomp.value pin do not exist 4232 ??????????
Please Log in or Create an account to join the conversation.
than I install it with sudo --install tcomp.comp, and put it in myhal.hal file in this way:
loadrt mycustomkinematics
loadusr -W myfirstcomp
loadrt tcomp
.....
at start of myhal file obtai this error:
tcomp.value pin do not exist 4232 ??????????
I thought that perhaps 'value' was a protected name, but it is not
I built your code (had to add license "LGPL" before it would build but thats it) and ran halrun
msgd:0 stopped
rtapi:0 stopped
halcmd: loadrt test
halcmd: show pin
Component Pins:
Owner Type Dir Value NameEpsilonFlags
32770 float IN 0 test.0.value0.0000100
32770 float OUT 0 test.0.vx10.0000100
32770 float OUT 0 test.0.vx20.0000100
32770 float OUT 0 test.0.vy10.0000100
32770 float OUT 0 test.0.vy20.0000100
Normally this error occurs because the pin is referenced before it is created and properly initialised
That is why userspace modules are normally started with loaduser -W to force a wait until ready before continuing.
Alternately it could be you forgot to add it to a thread ( or you added it to a non fp thread?)
regards
Please Log in or Create an account to join the conversation.
I have load my compom in this way ... is wrong? (yess .... i not correctly addf tcomp .... tanks ... now work but not solve my problem)
loart kins
loadusr -W myusrcomp
loadrt tcomp
loadrt thread name=myth period2=1100000 fp2=1
.....
addf tcomp.0 myth
PROBLEM:
My intention is to grab encoder position (value .... or some other name ex: valy) and put out a float value for Gcode. Es:
component tcomp "";
pin in float value "";
pin out float vx1 "";
pin out float vy1 "";
pin out float vx2 "" ;
pin out float vy2 "" ;
function _ ;
license "LGPL";
;;
FUNCTION(_){
float cx = 0;
cx = value;
vx1 = 40.0; <----real x value
vy1 = value - 40.0; <----real y value
vx2 = -200.0; <----real x value
vy2 = value - 300.0; <----real y value
}
and in gcode
X#<_hal[tcomp.vx1]> Y#<_hal[tcomp.vy1]> Z100
.....
.....
X#<_hal[tcomp.vx2]> Y#<_hal[tcomp.vy2]> Z100
......
.....
problem2: tcomp.vx1/2 is OK AND WORK PERFECT
tcomp.vy2/1 never updated ... why??????
The second idea is to use sampler and take the data from the FIFO . I already have a component that works and that reads from an ethernet port .
But utilize the fifo it seems ridiculous to do this simple thing.
Why the encoder pin in in tcomp seems not to be used ?
Please Log in or Create an account to join the conversation.
NOTE: the encoder value change always .... my operation in real world (from a request to an other) is every 0.7 sec.
basically I have a delta pik & place . Every 0.7-0.9 sec try to remove an offset on a Cartesian axis .
Please Log in or Create an account to join the conversation.
problem2: tcomp.vx1/2 is OK AND WORK PERFECT
tcomp.vy2/1 never updated ... why??????
The obvious difference is that the x values are set and always the same, so they will work.
You transfer the value to cx but never use it?
I would be debugging by printing out the contents of 'value' and cx, even though it will soon fill the terminal, just to see what is happening and if there is some way of printing the encoder output to compare do that too.
regards
Please Log in or Create an account to join the conversation.
The obvious difference is that the x values are set and always the same, so they will work.
ok ... I had it figured out I also .... but I not undesrtand why .... how cat printf to terminal the result?? I use rtapi_print ... but how terminal call??
Please Log in or Create an account to join the conversation.
........
........
Sratting Linuxcnc ....
ERROR: channel 0 realtime part is not loaded
no other .... but in my tcomp I have already insert
rtapi_print("cx, %3.2f", cx);
I don't know the origin of this error.....
OK OK my mystache .... i have not cancel loadrt halsampler that not use yet.
But not print value in my terminal ....
Please Log in or Create an account to join the conversation.
Ok the terminal fills up early ... but if I see all EMC_TRAJ_LINEAR_MOVE .... i see only GCode coordinate or coordinates that originate from the numbers and not by the variablexample:
FUNCTION(_){
float cx = 0;
cx = valy;
vx1 = 40.0; <----real x value
vy1 = cx - 40.0; <----real y value
vx2 = -200.0; <----real x value
vy2 = cx - 300.0; <----real y value CX value seems to be always 0
}
Please Log in or Create an account to join the conversation.