Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions docs/src/hal/basic-hal.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ Owner CodeAddr Arg FP Users Name

You have to add a function from a HAL real time component to a thread to get the function to update at the rate of the thread.
Usually there are two threads as shown in this example.
Some components use floating point math and must be added to a thread that supports floating point math.
The `FP` indicates if floating point math is supported in that thread.

[NOTE]
====
The `FP` column and the `uses_fp` parameter are deprecated.
All threads now unconditionally save and restore floating point state.
The `fp`/`nofp` distinction will be removed in a future version.
====

----
$ halrun
Expand All @@ -78,14 +83,13 @@ halcmd: show thread
Realtime Threads:
Period FP Name ( Time, Max-Time )
995976 YES servo-thread ( 0, 0 )
55332 NO base-thread ( 0, 0 )
55332 YES base-thread ( 0, 0 )
----

- base-thread (the high-speed thread):
This thread handles items that need a fast response, like making step pulses, and reading and writing the parallel port.
Does not support floating point math.
- servo-thread (the slow-speed thread):
This thread handles items that can tolerate a slower response, like the motion controller, ClassicLadder, and the motion command handler and supports floating point math.
This thread handles items that can tolerate a slower response, like the motion controller, ClassicLadder, and the motion command handler.

.addf Syntax and Example
[source,{hal}]
Expand All @@ -94,9 +98,6 @@ addf <function> <thread>
addf mux4.0 servo-thread
----

[NOTE]
If the component requires a floating point thread that is usually the slower servo-thread.

[[sub:hal-loadusr]]
=== loadusr

Expand Down
10 changes: 5 additions & 5 deletions docs/src/hal/rtcomps.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ image::images/stepgen-type11-14.png["Step Types: Five-Phase",align="center"]
The component exports three functions.
Each function acts on all of the step pulse generators - running different generators in different threads is not supported.

* (funct) `stepgen.make-pulses` - High speed function to generate and count pulses (no floating point).
* (funct) `stepgen.make-pulses` - High speed function to generate and count pulses.
* (funct) `stepgen.update-freq` - Low speed function does position to velocity conversion, scaling and limiting.
* (funct) `stepgen.capture-position` - Low speed function for feedback, updates latches and scales position.

Expand Down Expand Up @@ -258,7 +258,7 @@ Each PWM generator will also have some of these pins, depending on the output ty

The component exports two functions. Each function acts on all of the PWM generators - running different generators in different threads is not supported.

* (funct) `pwmgen.make-pulses` - High speed function to generate PWM waveforms (no floating point).
* (funct) `pwmgen.make-pulses` - High speed function to generate PWM waveforms.
The high speed function `pwmgen.make-pulses` should be run in the base (fastest) thread, from 10 to 50&#8239;µs depending on the capabilities of the computer.
That thread's period determines the maximum PWM carrier frequency, as well as the resolution of the PWM or PDM signals.
If the base thread is 50,000&#8239;ns then every 50&#8239;µs the module decides if it is time to change the state of the output.
Expand Down Expand Up @@ -361,7 +361,7 @@ halcmd: unloadrt encoder
The component exports two functions.
Each function acts on all of the encoder counters - running different counters in different threads is not supported.

* (funct) `encoder.update-counters` - High speed function to count pulses (no floating point).
* (funct) `encoder.update-counters` - High speed function to count pulses.
* (funct) `encoder.capture-position` - Low speed function to update latches and scale position.

[[sec:pid]]
Expand Down Expand Up @@ -515,7 +515,7 @@ Most encoder counters will count four times during one complete cycle.

The component exports two functions. Each function affects all simulated encoders.

* (funct) `sim-encoder.make-pulses` - High speed function to generate quadrature pulses (no floating point).
* (funct) `sim-encoder.make-pulses` - High speed function to generate quadrature pulses.
* (funct) `sim-encoder.update-speed` - Low speed function to read `.speed`, do scaling, and set up `.make-pulses`.

[[sec:debounce]]
Expand Down Expand Up @@ -638,7 +638,7 @@ They were changed to pins to allow control by other components.]
(((lut5)))
The `lut5` component is a 5 input logic component based on a look up table.

* `lut5` does not require a floating point thread.
* `lut5` does not use floating point math.

.Loading `lut5`
----
Expand Down
3 changes: 1 addition & 2 deletions docs/src/hal/tools.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ or
2. If no pinname is specified, default is: `motion-command-handler.time`.
3. This app may be opened for 5 pins.
4. Pintypes float, s32, u32, bit are supported.
5. The pin must be associated with a thread supporting floating point.
For a base thread, this may require using `loadrt motmod ... base_thread_fp=1` .
5. The pin must be associated with a realtime thread.

.hal-histogram Window
image::images/hal-histogram.png["hal-histogram Window"]
Expand Down
16 changes: 8 additions & 8 deletions docs/src/hal/tutorial.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ Owner CodeAddr Arg FP Users Name
----

The siggen component exported a single function.
It requires floating point.
It is not currently linked to any threads, so 'users' is
zero footnote:[CodeAddr and Arg fields were used during development and
should probably disappear.].
Expand Down Expand Up @@ -241,7 +240,7 @@ Realtime Threads:

It did. The period is not exactly 1,000,000 ns because of hardware
limitations, but we have a thread that runs at approximately the
correct rate, and which can handle floating point functions.
correct rate.
The next step is to connect the function to the thread:

.Add Function
Expand Down Expand Up @@ -557,13 +556,15 @@ component.
halrun
halcmd: loadrt stepgen step_type=0,0 ctrl_type=v,v
halcmd: loadrt siggen
halcmd: loadrt threads name1=fast fp1=0 period1=50000 name2=slow period2=1000000
halcmd: loadrt threads name1=fast period1=50000 name2=slow period2=1000000
----

The first command loads two step generators, both configured to generate stepping type 0.
The second command loads our old friend siggen, and the third one creates two threads,
a fast one with a period of 50 microseconds (µs) and a slow one with a period of 1 millisecond (ms).
The fast thread doesn't support floating point functions.

NOTE: The `fp1=` parameter is deprecated and ignored.
All threads now unconditionally support floating point.

As before, we can use `halcmd show` to take a look at the HAL.
This time we have a lot more pins and parameters than before:
Expand Down Expand Up @@ -731,7 +732,6 @@ is time to take a step, and if so sets the outputs accordingly.
For smooth step pulses, it should run as frequently as possible.
Because it needs to run so fast, 'make_pulses'
is highly optimized and performs only a few calculations.
Unlike the others, it does not need floating point math.

The last function, `stepgen.update-freq`, is responsible for doing
scaling and some other calculations that need to be performed
Expand All @@ -754,13 +754,13 @@ halcmd: show thread
Realtime Threads:
Period FP Name ( Time, Max-Time )
996980 YES slow ( 0, 0 )
49849 NO fast ( 0, 0 )
49849 YES fast ( 0, 0 )
----

The two threads were created when we loaded `threads`.
The first one, 'slow', runs every millisecond, and is capable of running floating point functions.
The first one, 'slow', runs every millisecond.
We will use it for `siggen.0.update` and `stepgen.update_freq`.
The second thread is 'fast', which runs every 50 microseconds (µs), and does not support floating point.
The second thread is 'fast', which runs every 50 microseconds (µs).
We will use it for `stepgen.make_pulses`.
To connect the functions to the proper thread, we use the `addf` command.
We specify the function first, followed by the thread.
Expand Down
3 changes: 2 additions & 1 deletion docs/src/man/man3/hal_create_thread.3.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ name::
period::
The interval, in nanoseconds, between iterations of the thread.
uses_fp::
Must be nonzero if a function which uses floating-point will be attached to this thread.
Deprecated and ignored. All threads now unconditionally save and restore
floating point state. This parameter will be removed in a future version.

== DESCRIPTION

Expand Down
4 changes: 2 additions & 2 deletions docs/src/man/man3/hal_export_funct.3.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ funct::
arg::
The argument to be passed as the first parameter of _funct_.
uses_fp::
Nonzero if the function uses floating-point operations, including
assignment of floating point values with "=".
Deprecated and ignored. All threads now unconditionally save and restore
floating point state. This parameter will be removed in a future version.
reentrant::
If reentrant is non-zero, the function may be preempted and called again before the first call completes.
Otherwise, it may only be added to one thread.
Expand Down
3 changes: 2 additions & 1 deletion docs/src/man/man3/rtapi_task_new.3.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ arg::
prio::
A task priority value returned by *rtapi_prio_xxxx*
uses_fp::
A flag that tells the OS whether the task uses floating point or not.
Deprecated and ignored. All tasks now unconditionally save and restore
floating point state. This parameter will be removed in a future version.
task_id::
A task ID returned by a previous call to *rtapi_task_new*

Expand Down
7 changes: 3 additions & 4 deletions docs/src/man/man9/motion.9.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ the motion-controller function.

== DESCRIPTION

By default, the base thread does not support floating point. Software
stepping, software encoder counting, and software pwm do not use floating point.
*base_thread_fp* can be used to enable floating point in
the base thread (for example for brushless DC motor control).
NOTE: The *base_thread_fp* parameter is deprecated and ignored.
All threads now unconditionally save and restore floating point state.
This parameter will be removed in a future version.

These pins and parameters are created by the realtime *motmod* module.
This module provides a HAL interface for LinuxCNC's motion planner.
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/abs_s32.comp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pin out bit is_positive "TRUE if input is positive, FALSE if input is 0 or negat
pin out bit is_negative "TRUE if input is negative, FALSE if input is 0 or positive";

option period no;
function _ nofp;
function _;
license "GPL";
author "Sebastian Kuzminsky";
;;
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/abs_s64.comp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pin out bit is_positive "true if input is positive, false if input is 0 or negat
pin out bit is_negative "true if input is negative, false if input is 0 or positive";

option period no;
function _ nofp;
function _;
license "GPL";
author "ArcEye based on code from Sebastian Kuzminsky";
;;
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/and2.comp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ to the following truth table:
"""
;
option period no;
function _ nofp;
function _;
see_also """
*logic*(9),
*lut5*(9),
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/bin2gray.comp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ pin out unsigned out "gray code out";
license "GPL";
author "Andy Pugh";
option period no;
function _ nofp;
function _;
;;
out = (in >> 1) ^ in;
2 changes: 1 addition & 1 deletion src/hal/components/bitmerge.comp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pin out u32 out "The output value";
pin in bit in-##[32:personality];
author "Andy Pugh";
license "GPL2+";
function _ nofp;
function _;
option personality yes;
option period no;
;;
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/bitslice.comp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pin in u32 in "The input value";
pin out bit out-##[32:personality];
author "Andy Pugh";
license "GPL2+";
function _ nofp;
function _;
option personality yes;
option period no;
;;
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/bitwise.comp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pin out u32 out-xnor "The inverse of the bitwise XOR";

author "Andy Pugh";
license "GPL 2+";
function _ nofp;
function _;
option period no;
;;

Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/charge_pump.comp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pin out bit out "Square wave if 'enable' is TRUE or unconnected, low if 'enable'
pin out bit out-2 "Square wave at half the frequency of 'out'";
pin out bit out-4 "Square wave at a quarter of the frequency of 'out'";
pin in bit enable = TRUE "If FALSE, forces all 'out' pins to be low";
function _ nofp "Toggle the output bit (if enabled)";
function _ "Toggle the output bit (if enabled)";
description """
The 'Charge Pump' should be added to the base thread function.
When enabled the output is on for one period and off for one period. To calculate the
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/comp.comp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Keep in mind that floating point calculations are never absolute
and it is wise to always set *hyst* if you intend to use equal """;

option period no;
function _ fp "Update the comparator";
function _ "Update the comparator";
license "GPL";
author "Jeff Epler";
;;
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/conv.comp.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pin out @OUT@ out;
@CC@pin out bit out_of_range "TRUE when 'in' is not in the range of @OUT@";
@CC@param rw bit clamp """If TRUE, then clamp to the range of @OUT@. If FALSE, then allow the value to "wrap around".""";
option period no;
function _ @FP@ "Update 'out' based on 'in'";
function _ "Update 'out' based on 'in'";
license "GPL";
author "Jeff Epler";

Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/dbounce.comp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pin in u32 delay = 5;

variable unsigned state;
option period no;
function _ nofp;
function _;
license "GPL";
author "Dewey Garrett";
;;
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/edge.comp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ param r signed time_left_ns "Time left in this output pulse";
param r bit last_in "Previous input value";
variable int first = 1;

function _ nofp "Produce output pulses from input edges";
function _ "Produce output pulses from input edges";
license "GPL";
author "Jeff Epler";
;;
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/estop_latch.comp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pin out bit ok_out = false;
pin out bit fault_out = true;
pin out bit watchdog;
option period no;
function _ nofp;
function _;
option data estop_data;
license "GPL";
author "John Kasunich";
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/flipflop.comp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pin io bit out-not "inverted output";
option data flipflop_data;

option period no;
function _ nofp;
function _;
license "GPL";
author "John Kasunich";
;;
Expand Down
4 changes: 2 additions & 2 deletions src/hal/components/gantry.comp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ pin out float position-fb "Position feedback to motion";
pin out bit home "Combined home signal, true if all joint home inputs are true.";
pin out bit limit "Combined limit signal, true if any joint home input is true.";
pin in float search-vel "HOME_SEARCH_VEL from INI file";
function read fp "Update position-fb and home/limit outputs based on joint values.";
function write fp "Update joint pos-cmd outputs based on position-cmd in.";
function read "Update position-fb and home/limit outputs based on joint values.";
function write "Update joint pos-cmd outputs based on position-cmd in.";
description """
--- Deprecation Notice

Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/gray2bin.comp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pin in unsigned in "gray code in";
pin out unsigned out "binary code out";
license "GPL";
author "Andy Pugh";
function _ nofp;
function _;
option period no;
;;
unsigned int mask;
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/histobins.comp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pin out float mean;
pin out s32 availablebins = 200; //MAXBINNUMBER

option period no;
function _ fp;
function _;

variable int bin[200]; // MAXBINNUMBER
variable int first = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/latencybins.comp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pin out s32 variance;
// user may interrogate available bins to determine this compiled-in limit
pin out s32 availablebins = 1000; // MAXBINNUMBER

function _ nofp;
function _;
variable rtapi_s64 last_timer = 0;
variable int last_binmax = 0;
variable int first = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/led_dim.comp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
component led_dim "HAL component for dimming LEDs";
pin in float in "Brightness input value -> 0 to 1";
pin out float out "Luminance output value -> 0 to 1";
function _ fp "Update the output value";
function _ "Update the output value";
description """
Component for LED dimming according to human perception of brightness of light.
.LP
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/logic.comp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pin out bit or if personality & 0x200;
pin out bit xor if personality & 0x400;
pin out bit nand if personality & 0x800;
pin out bit nor if personality & 0x1000;
function _ nofp "Read the inputs and toggle the output bit.";
function _ "Read the inputs and toggle the output bit.";
description """
General `logic function' component. Can perform `and', `or',
`nand', `nor' and `xor' of up to 16 inputs.
Expand Down
2 changes: 1 addition & 1 deletion src/hal/components/lut5.comp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pin in bit in_3;
pin in bit in_4;
pin out bit out;
param rw u32 function;
function _ nofp;
function _;
description """
*lut5*
constructs a logic function with up to 5 inputs using a **l**ook-**u**p **t**able.
Expand Down
Loading
Loading