@@ -36,28 +36,28 @@ pin is current-scale-out as it depends on the iscale-factor setting.
3636Simulation Config: `configs/sim/axis/anglejog/anglejog.in`
3737""";
3838
39- pin in bit enable_in "enables motion (disables alteration of angle and scale)";
40- pin in s32 counts_in "MPG (wheel) counts";
41- pin in float angle_degrees_in "vector angle";
42- pin in s32 iscale_factor = 10000 "integer scaling factor (>1)";
43- pin in float scale_in "magnitude units/count (mag = counts * scale)";
44- pin in float max_vel "vector max velocity magnitude";
45- pin in float max_accel "vector max acceleration magnitude";
46- pin in float accel_fraction_in = 1 "acceleration fraction input";
39+ pin in bool enable_in "enables motion (disables alteration of angle and scale)";
40+ pin in si32 counts_in "MPG (wheel) counts";
41+ pin in real angle_degrees_in "vector angle";
42+ pin in si32 iscale_factor = 10000 "integer scaling factor (>1)";
43+ pin in real scale_in "magnitude units/count (mag = counts * scale)";
44+ pin in real max_vel "vector max velocity magnitude";
45+ pin in real max_accel "vector max acceleration magnitude";
46+ pin in real accel_fraction_in = 1 "acceleration fraction input";
4747
48- pin out bit enable_out "to: axis.M.jog-enable AND axis.N.jog-enable";
49- pin out float current_scale "effective scale (informational)";
50- pin out float current_scale_out "to: axis.M.jog-scale AND axis.N.jog-scale";
51- pin out s32 coscounts "to: axis.M.jog-counts (cosine counts)";
52- pin out s32 sincounts "to: axis.N.jog-counts (sine counts)";
53- pin out float cos_accel_fraction "to: axis.M.jog-accel-fraction";
54- pin out float sin_accel_fraction "to: axis.N.jog-accel-fraction";
48+ pin out bool enable_out "to: axis.M.jog-enable AND axis.N.jog-enable";
49+ pin out real current_scale "effective scale (informational)";
50+ pin out real current_scale_out "to: axis.M.jog-scale AND axis.N.jog-scale";
51+ pin out si32 coscounts "to: axis.M.jog-counts (cosine counts)";
52+ pin out si32 sincounts "to: axis.N.jog-counts (sine counts)";
53+ pin out real cos_accel_fraction "to: axis.M.jog-accel-fraction";
54+ pin out real sin_accel_fraction "to: axis.N.jog-accel-fraction";
5555
5656// output monitor pins:
57- pin out bit active "angle jog move in progress";
58- pin out float current_angle_degrees "current angle";
59- pin out float current_mag "current vector magnitude";
60- pin out float current_vel "current vector speed";
57+ pin out bool active "angle jog move in progress";
58+ pin out real current_angle_degrees "current angle";
59+ pin out real current_mag "current vector magnitude";
60+ pin out real current_vel "current vector speed";
6161
6262function _;
6363license "GPL";
@@ -66,7 +66,7 @@ author "Dewey Garrett";
6666#include <rtapi_math.h>
6767#define TO_RAD M_PI/180
6868// replicate simple_tp.h define for tiny magnitude delta:
69- #define TINY_DP(max_accel,period ) (max_accel*period*period *0.001)
69+ #define TINY_DP(_max_accel,_period ) ((_max_accel)*(_period)*(_period) *0.001)
7070#define MIN_ISCALE_FACTOR 10
7171#define MAX_ISCALE_FACTOR 100000
7272
@@ -83,9 +83,9 @@ static int ifactor = 0;
8383 int newcounts;
8484
8585 if (once) {
86- current_angle_degrees = angle_degrees_in;
87- current_scale = scale_in;
88- current_scale_out = scale_in/iscale_factor;
86+ current_angle_degrees_set( angle_degrees_in) ;
87+ current_scale_set( scale_in) ;
88+ current_scale_out_set( scale_in/iscale_factor) ;
8989 ifactor = iscale_factor;
9090 once = 0;
9191 }
@@ -100,13 +100,13 @@ static int ifactor = 0;
100100 delta_counts = newcounts - old_counts_in;
101101 old_enable_in = enable_in;
102102 old_counts_in = newcounts;
103- enable_out = enable_in;
103+ enable_out_set( enable_in) ;
104104
105105 if (delta_counts!=0) {wait_for_count_change = 0;}
106106 if (enable_in) { tot_counts = tot_counts + delta_counts;}
107107 mag_cmd = tot_counts * current_scale_out;
108108
109- active = 0 ;
109+ active_set(0) ;
110110 /* compute max change in velocity per servo period */
111111 max_dv = max_accel * fperiod;
112112 /* compute a tiny magnitude range, to be treated as zero */
@@ -123,12 +123,12 @@ static int ifactor = 0;
123123 vel_req = -max_dv +
124124 sqrt(2.0 * max_accel * mag_err + max_dv * max_dv);
125125 /* mark planner as active */
126- active = 1 ;
126+ active_set(1) ;
127127 } else if (mag_err < -tiny_dp) {
128128 vel_req = max_dv -
129129 sqrt(-2.0 * max_accel * mag_err + max_dv * max_dv);
130130 /* mark planner as active */
131- active = 1 ;
131+ active_set(1) ;
132132 } else {
133133 /* within 'tiny_dp' of desired mag, no need to move */
134134 vel_req = 0.0;
@@ -158,11 +158,11 @@ static int ifactor = 0;
158158 }
159159 }
160160 }
161- current_angle_degrees = angle_degrees_in;
161+ current_angle_degrees_set( angle_degrees_in) ;
162162 if ( current_scale_out != scale_in
163163 || new_ifactor) {
164- current_scale = scale_in;
165- current_scale_out = scale_in/ifactor;
164+ current_scale_set( scale_in) ;
165+ current_scale_out_set( scale_in/ifactor) ;
166166 tot_counts = current_mag/current_scale_out;
167167 }
168168 }
@@ -176,24 +176,24 @@ static int ifactor = 0;
176176 }
177177 /* ramp velocity toward request at accel limit */
178178 if (vel_req > current_vel + max_dv) {
179- current_vel += max_dv;
179+ current_vel_set( current_vel + max_dv) ;
180180 } else if (vel_req < current_vel - max_dv) {
181- current_vel -= max_dv;
181+ current_vel_set( current_vel - max_dv) ;
182182 } else {
183- current_vel = vel_req;
183+ current_vel_set( vel_req) ;
184184 }
185185 /* check for still moving */
186186 if (current_vel != 0.0) {
187187 /* yes, mark planner active */
188- active = 1 ;
188+ active_set(1) ;
189189 }
190190 /* integrate velocity to get new magnitude */
191- current_mag += current_vel * fperiod;
191+ current_mag_set( current_mag + current_vel * fperiod) ;
192192 double cos_angle,sin_angle;
193193 cos_angle = cos(current_angle_degrees * TO_RAD);
194194 sin_angle = sin(current_angle_degrees * TO_RAD);
195- coscounts = current_mag * cos_angle/current_scale_out;
196- sincounts = current_mag * sin_angle/current_scale_out;
197- cos_accel_fraction = accel_fraction_in * cos_angle;
198- sin_accel_fraction = accel_fraction_in * sin_angle;
195+ coscounts_set( current_mag * cos_angle/current_scale_out) ;
196+ sincounts_set( current_mag * sin_angle/current_scale_out) ;
197+ cos_accel_fraction_set( accel_fraction_in * cos_angle) ;
198+ sin_accel_fraction_set( accel_fraction_in * sin_angle) ;
199199}
0 commit comments