How to fill pwmgen.0.offset with value of mux2.0.out ?

More
20 Nov 2021 15:58 #227095 by dgdodo
To all,

Already 1 week of adjusting / testing / learning, and have default X - Y movement of direct stepper motors active.
Had to write my own .hal and .ini files as very few still use direct stepper on a raspberry Pi.
Using the PREEMPT version on the raspberry.

I have a servo which lowers a Pen to write, and I can do a setp command on HAL-Config and it works.
'setp pwmgen.0.offset 0.17' for PenUp and 'setp pwmgen.0.offset 0.21' for PenDown

But had to search days to find a way to change these float values (pwmgen.0.offset) on a bit value (stepgen.2.dir)
Now I found mux2, which should do that, but I can not get the 'mus2.0.out' into 'pwmgen.2.offset'.

I always get one of the following errors:

If I do in hal: net PenMove mux2.0.out => pwmgen.0.offset
--
Signal 'PenMove' can not add I/O pin 'pwmgen.0.offset', it already has OUT pin 'mux2.0.out'
--

If I do in hal: net mux2.0.out => pwmgen.0.offset
--
Signal name 'mux2.0.out' must not be the same as a pin. Did you omit the signal name?
--
And for both messages I do not understand what or why they are given.
Can somebody help me out here?

Found out that I CAN fill the pwmgen.0.value, but that does not change the servo!
Value and offset are both float (offset even in- and output), but offset can not be set within hal, from mux2.0.out ??

Regards, DG.
(I though I get wiser when I get older, it looks it is the other way around.)
 

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

More
20 Nov 2021 18:41 #227112 by dgdodo
And I found the answer myself.
Need to read better: www.linuxcnc.org/docs/2.4/html/man/man9/pwmgen.9.html

The formula is stated there: Duty Cylce = ( Value / Scale ) + offset
Earlier my value was always 0, so the offset did set the servo.
But it SHOULD be the value, that CAN be set with:
net PenValue mux2.0.out => pwmgen.0.value

It works now!

Regards, DG.
The following user(s) said Thank You: tommylight

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

More
20 Nov 2021 21:45 #227125 by tommylight
Thank you for reporting back.
The following user(s) said Thank You: dgdodo

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

Time to create page: 0.055 seconds
Powered by Kunena Forum