ContributedHalFiles - rmu75/linuxcnc-wiki GitHub Wiki
This page is a place for users to contribute useful .hal files and hal file snippets. See also: ContributedComponents
Edit the .hal file to customize it for your environment and put it in the same directory as your .ini file. Then add a new HALFILE = line to the [HAL] section of the .ini file.
If your existing hal files and the new hal file both load the same component, then you will need to renumber the new hal file so that they can coexist. For instance, if file1.hal has these lines: loadrt and2 count=2 and refers to and.0 and and.1, and file2.hal has these lines: loadrt and2 count=1 and refers to and.0, you will have to change file1 to loadrt and2 count=3, and change references to and2.0 in file2.hal to and2.2 so that each hal file has its own and blocks to use. The loadrt and2 line in file2.hal is removed.
Edit the .hal file if necessary to customize it for your environment. Then run it with: halrun example.hal (to shut down hal when the .hal script finishes) or halrun -I example.hal (to show the halcmd prompt when the .hal script finishes). If the .hal file is not in the current directory, then use a path, such as: halrun -I /home/yourname/Desktop/example.hal
First, follow the BasicSteps so that you can edit the wiki. If your hal file is short, put it inside a <pre> block in this page. If it is long, use the "Upload" link to attach it to the wiki. Add any explanatory text that others may find useful.
This .hal file is useful for testing that communication with the pluto-p module works. Run it with halcmd -I. It
*Outputs a sine-wave function on the first PWM module, which also appears as a brightness ramp on the LED *sends a quadrature output with index pulse on dout.00, .01 and .02 which is externally looped to the QA1, QB1 and QZ1 inputs, so that the encoder.0 will repeatedly count up to 10160 and then reset because the index pulse is encountered.
Compatability: 2.3
loadrt pluto_servo test_encoder=1 loadrt threads name1=thread period1=200000 loadrt siggen loadrt sim_encoder loadrt tristate_bit setp sim-encoder.0.ppr 2540 setp pluto-servo.encoder.0.scale 10160 setp pluto-servo.pwm.0.enable 1 setp sim-encoder.0.speed 5 setp tristate-bit.0.in 1 addf tristate-bit.0 thread addf pluto-servo.read thread addf siggen.0.update thread addf sim-encoder.update-speed thread addf sim-encoder.make-pulses thread addf pluto-servo.write thread net sine siggen.0.sine => pluto-servo.pwm.0.value net index tristate-bit.0.out => pluto-servo.encoder.0.index-enable net phA sim-encoder.0.phase-A => pluto-servo.dout.00 net phB sim-encoder.0.phase-B => pluto-servo.dout.01 net phZ sim-encoder.0.phase-Z => pluto-servo.dout.02 start