File: test.hal

package info (click to toggle)
linuxcnc 1%3A2.9.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 285,604 kB
  • sloc: python: 202,568; ansic: 109,036; cpp: 99,239; tcl: 16,054; xml: 10,631; sh: 10,303; makefile: 1,255; javascript: 138; sql: 72; asm: 15
file content (127 lines) | stat: -rw-r--r-- 2,967 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
setexact_for_test_suite_only


#
# This siggen produces test patterns for limit3 to try to follow.
#

loadrt siggen
setp siggen.0.frequency 2
setp siggen.0.amplitude 100
setp siggen.0.offset 0

net sine <= siggen.0.sine
net cosine <= siggen.0.cosine
net square <= siggen.0.square
net sawtooth <= siggen.0.sawtooth
net triangle <= siggen.0.triangle


#
# This mux selects one of the available input patterns.  Later in this
# file, after loading the limit3 component, we'll add the output of
# limit3 as another option in this mux.
#

loadrt mux_generic config=ff8

net sine => mux-gen.00.in-float-00
net cosine => mux-gen.00.in-float-01
net square => mux-gen.00.in-float-02
net sawtooth => mux-gen.00.in-float-03
net triangle => mux-gen.00.in-float-04

net input <= mux-gen.00.out-float


#
# Here's the limit3, the component under test.
#
# These pos/vel/accel limits are just a hair above the limits of the
# input sine wave.
#

loadrt limit3
setp limit3.0.min -101
setp limit3.0.max 101
setp limit3.0.maxv 1500
setp limit3.0.maxa 15800

net input => limit3.0.in
net output <= limit3.0.out
net output => mux-gen.00.in-float-05


#
# Compute the velocity and acceleration of the limit3 output.
#

loadrt ddt names=ddt.out-accel,ddt.out-vel

net output => ddt.out-vel.in

net out-vel <= ddt.out-vel.out
net out-vel => ddt.out-accel.in

net out-accel <= ddt.out-accel.out


#
# This part cycles through the muxed signals.  It uses a charge pump to
# generate a high-frequency square wave, and an encoder in counter-mode,
# with a large scale, to produce a slowly growing number (the encoder
# position).  The encoder position is converted from a float to a u32,
# and fed to the mux select pin.
#

loadrt charge_pump

# The heartbeat toggles every other time the thread runs (so at 500 Hz).
net heartbeat <= charge-pump.out

# The scale of the encoder makes the .position output move forward by
# about 1.0 per second.
loadrt encoder num_chan=1
encoder.0.counter-mode = 1
encoder.0.position-scale = 500

net heartbeat => encoder.0.phase-A
net encoder-position <= encoder.0.position

loadrt conv_float_u32
net encoder-position => conv-float-u32.0.in

net mux-select <= conv-float-u32.0.out
net mux-select => mux-gen.00.sel-int


#
# This sampler reports everything we care about out to disk, so we can
# validate it after the realtime part of the test completes.
#

loadrt sampler depth=1500 cfg=ffffu
net input => sampler.0.pin.0
net output => sampler.0.pin.1
net out-vel => sampler.0.pin.2
net out-accel => sampler.0.pin.3
net mux-select => sampler.0.pin.4


loadrt threads name1=t period1=1000000 fp1=1

addf charge-pump              t
addf encoder.update-counters  t
addf encoder.capture-position t
addf conv-float-u32.0         t

addf siggen.0.update          t
addf mux-gen.00               t
addf limit3.0                 t
addf ddt.out-vel              t
addf ddt.out-accel            t
addf sampler.0                t

start

loadusr -w halsampler -t -n 5100