From f107cd307a6112224d93ad38e2d290549a60a8eb Mon Sep 17 00:00:00 2001 From: Bertho Stultiens Date: Thu, 30 Jul 2026 16:08:08 +0200 Subject: [PATCH] hal: Update next batch of components to getter/setter. --- src/hal/components/carousel.comp | 310 ++++++++-------- src/hal/components/corexy_by_hal.comp | 24 +- src/hal/components/differential.comp | 24 +- src/hal/components/gantry.comp | 42 +-- src/hal/components/histobins.comp | 119 +++--- src/hal/components/histobinstream.comp | 98 ++--- src/hal/components/homecomp.comp | 34 +- src/hal/components/laserpower.comp | 52 +-- src/hal/components/latencybins.comp | 65 ++-- src/hal/components/latencybinstream.comp | 72 ++-- src/hal/components/moveoff.comp | 164 ++++---- src/hal/components/sim_axis_hardware.comp | 434 +++++++++++----------- src/hal/components/sim_parport.comp | 268 ++++++------- 13 files changed, 854 insertions(+), 852 deletions(-) diff --git a/src/hal/components/carousel.comp b/src/hal/components/carousel.comp index 06de3ee31d4..354605f1d1f 100644 --- a/src/hal/components/carousel.comp +++ b/src/hal/components/carousel.comp @@ -101,52 +101,52 @@ at the completion of the tool search and at the same time the reverse duty/cycle velocity value will be sent to the motor-vel pin. """; -pin in signed pocket-number """The pocket to move to when the .enable pin goes high. If the value +pin in si32 pocket-number """The pocket to move to when the .enable pin goes high. If the value passed is higher than the number of pockets specified in the "pockets" modparam then modulo arithmetic is used. This is intended to allow the use of multiple tools in the same holder, as is sometimes useful with lathes."""; -pin in bit enable "Set this pin high to start movement. Setting it low will stop movement"; -pin out bit active "indicates that the component is active"; -pin out bit ready "This pin goes high when the carousel is in-position"; -pin in bit strobe = 1 """Use this pin to indicate that the position feedback is valid. Often +pin in bool enable "Set this pin high to start movement. Setting it low will stop movement"; +pin out bool active "indicates that the component is active"; +pin out bool ready "This pin goes high when the carousel is in-position"; +pin in bool strobe = 1 """Use this pin to indicate that the position feedback is valid. Often provided by binary encoders"""; -pin in bit parity_ """Some encoders supply a parity bit, if this is connected then the -parity-error output bit will indicate parity errors"""; -pin in bit sense-# [32:personality] """Carousel position feedback pins. In 'index' mode there +pin in bool parity_ """Some encoders supply a parity bit, if this is connected then the +parity-error output bool will indicate parity errors"""; +pin in bool sense-# [32:personality] """Carousel position feedback pins. In 'index' mode there will be only 2 pins. sense-0 is the index and sense-1 is the pocket sensor."""; -pin in float rev-pulse """The duration in seconds for which a ratchet changer (Boxford, Emco) +pin in real rev-pulse """The duration in seconds for which a ratchet changer (Boxford, Emco) should pulse the reverse pin to lock the holder"""; -pin in float fwd-dc "Velocity or duty cycle when forwards rotation is desired"; -pin in float rev-dc "Velocity or duty cycle when reverse rotation is desired"; -pin in float hold-dc "Duty cycle when carousel is in-position (to hold against stop)"; -pin in float align-dc """Use this pin to set the speed of a slower alignment move once the changer is in position. Such a system almost +pin in real fwd-dc "Velocity or duty cycle when forwards rotation is desired"; +pin in real rev-dc "Velocity or duty cycle when reverse rotation is desired"; +pin in real hold-dc "Duty cycle when carousel is in-position (to hold against stop)"; +pin in real align-dc """Use this pin to set the speed of a slower alignment move once the changer is in position. Such a system almost certainly needs decel-time setting too"""; -pin in float decel-time "Time to wait for carousel to stop before final alignment and position check"; -pin in signed counts "Connect to the rawcounts of an encoder or a stepgen in 'counts' mode"; -pin in signed scale = 100 "The number of stepgen or encoder counts between successive pockets"; -pin in signed width = 10 "How far each side of the exact scale to signal a new pocket"; -pin in signed home-offset = 0 "The offset (in counts) between the index and pocket 1"; -pin io bit index-enable "Used to home to an encoder index"; -pin in bit jog-fwd "Jog the carousel forwards one tool position"; -pin in bit jog-rev """Jog the carousel in reverse (only if dir = 2). +pin in real decel-time "Time to wait for carousel to stop before final alignment and position check"; +pin in si32 counts "Connect to the rawcounts of an encoder or a stepgen in 'counts' mode"; +pin in si32 scale = 100 "The number of stepgen or encoder counts between successive pockets"; +pin in si32 width = 10 "How far each side of the exact scale to signal a new pocket"; +pin in si32 home-offset = 0 "The offset (in counts) between the index and pocket 1"; +pin io bool index-enable "Used to home to an encoder index"; +pin in bool jog-fwd "Jog the carousel forwards one tool position"; +pin in bool jog-rev """Jog the carousel in reverse (only if dir = 2). It is very important that these pins should be debounced and should probably also be interlocked to only operate when the machine is idle."""; -pin out bit motor-fwd "Indicates the motor should run forwards (bigger numbers)"; -pin out bit motor-rev "Indicates the motor should run reverse."; -pin out bit parity-error "Indicates a parity error"; -pin out signed current-position "This pin indicates the current position feedback"; -pin out float motor-vel "The duty-cycle or velocity to drive a DC motor or stepgen"; -pin out bit homed = 0 "Shows that homing is complete. Only used in index and edge modes"; -pin in bit unhome = 0 "Should only really be necessary for testing"; -pin out float counts-target "Target position for a stepgen or external PID controller"; - -param r signed state = 0 "Current component state"; -param r bit homing = 0 "Shows that homing is in progress. Only used for index mode"; -param r float timer "Shows the value of the internal timer"; -param r signed motor-dir "Internal tag for search direction"; -param r signed counts-offset "Internal offset of index pin"; -param rw unsigned debounce "How many thread cycles to wait for the position to stabilise"; -param r signed target "Current target pocket, debug"; +pin out bool motor-fwd "Indicates the motor should run forwards (bigger numbers)"; +pin out bool motor-rev "Indicates the motor should run reverse."; +pin out bool parity-error "Indicates a parity error"; +pin out si32 current-position "This pin indicates the current position feedback"; +pin out real motor-vel "The duty-cycle or velocity to drive a DC motor or stepgen"; +pin out bool homed = 0 "Shows that homing is complete. Only used in index and edge modes"; +pin in bool unhome = 0 "Should only really be necessary for testing"; +pin out real counts-target "Target position for a stepgen or external PID controller"; + +param r si32 state = 0 "Current component state"; +param r bool homing = 0 "Shows that homing is in progress. Only used for index mode"; +param r real timer "Shows the value of the internal timer"; +param r si32 motor-dir "Internal tag for search direction"; +param r si32 counts-offset "Internal offset of index pin"; +param rw ui32 debounce "How many thread cycles to wait for the position to stabilise"; +param r si32 target "Current target pocket, debug"; option count_function; option extra_setup; @@ -160,7 +160,7 @@ variable int inst_pockets; variable int inst_code; variable int inst_parity; variable int old_index = 0; -param r signed base_counts = 0; +param r si32 base_counts = 0; variable int old_unhome = 0; function _ ; @@ -294,15 +294,15 @@ FUNCTION(_){ } if (strobe) { - current_position = new_pos; - parity_error = (pcalc != (inst_parity ^ parity_)); + current_position_set(new_pos); + parity_error_set(pcalc != (inst_parity ^ parity_)); } mod_pocket = ((pocket_number - 1) % inst_pockets) + 1; // mod is odd with negatives, so just in case if (mod_pocket < 1) mod_pocket = 1; if (mod_pocket > inst_pockets) mod_pocket = inst_pockets; - if (unhome && ! old_unhome) homed = 0; + if (unhome && ! old_unhome) homed_set(0); old_unhome = unhome; enum State { @@ -321,88 +321,88 @@ FUNCTION(_){ }; switch (state){ case WAITING: // waiting at start - motor_dir = 0; + motor_dir_set(0); if (jog_fwd || (jog_rev && inst_dir == 2)) { if ((inst_code == 'I' || inst_code == 'E' || inst_code == 'C') && ! homed){ - state = HOME_START; + state_set(HOME_START); break; } - target = current_position + jog_fwd - jog_rev; - counts_target += scale * (target - current_position); - if (target > inst_pockets ) target = 1; - if (target < 1) target = inst_pockets; + target_set(current_position + jog_fwd - jog_rev); + counts_target_set(counts_target + scale * (target - current_position)); + if (target > inst_pockets ) target_set(1); + if (target < 1) target_set(inst_pockets); if (jog_fwd){ - motor_fwd = 1; - motor_rev = 0; - motor_vel = fwd_dc; - motor_dir = 1; + motor_fwd_set(1); + motor_rev_set(0); + motor_vel_set(fwd_dc); + motor_dir_set(1); } if (jog_rev){ - motor_fwd = 0; - motor_rev = 1; - motor_vel = rev_dc; - motor_dir = -1; + motor_fwd_set(0); + motor_rev_set(1); + motor_vel_set(rev_dc); + motor_dir_set(-1); } - active = 1; - state = JOG; + active_set(1); + state_set(JOG); break; } - motor_vel = hold_dc; + motor_vel_set(hold_dc); if (! enable) return ; - active = 1; + active_set(1); if ((inst_code == 'I' || inst_code == 'E' || inst_code == 'C') && ! homed){ - state = HOME_START; + state_set(HOME_START); break; } - state = DIR_CHOOSE; - ready = 0; + state_set(DIR_CHOOSE); + ready_set(0); /* Fallthrough */ case DIR_CHOOSE: // choose direction if (mod_pocket < 1 || mod_pocket > inst_pockets) { - state = WAITING; + state_set(WAITING); return; } if (inst_dir == 2){ if (current_position < mod_pocket){ if (mod_pocket - current_position > (inst_pockets / 2)) { - motor_fwd = 0; - motor_rev = 1; - motor_vel = rev_dc; - motor_dir = -1; - counts_target += (mod_pocket - current_position - inst_pockets) * scale; + motor_fwd_set(0); + motor_rev_set(1); + motor_vel_set(rev_dc); + motor_dir_set(-1); + counts_target_set(counts_target + (mod_pocket - current_position - inst_pockets) * scale); } else { - motor_fwd = 1; - motor_rev = 0; - motor_vel = fwd_dc; - motor_dir = 1; - counts_target += (mod_pocket - current_position ) * scale; + motor_fwd_set(1); + motor_rev_set(0); + motor_vel_set(fwd_dc); + motor_dir_set(1); + counts_target_set(counts_target + (mod_pocket - current_position ) * scale); } } else { if (current_position - mod_pocket > (inst_pockets / 2)) { - motor_fwd = 1; - motor_rev = 0; - motor_vel = fwd_dc; - motor_dir = 1; - counts_target += (mod_pocket - current_position + inst_pockets) * scale; + motor_fwd_set(1); + motor_rev_set(0); + motor_vel_set(fwd_dc); + motor_dir_set(1); + counts_target_set(counts_target + (mod_pocket - current_position + inst_pockets) * scale); } else { - motor_fwd = 0; - motor_rev = 1; - motor_vel = rev_dc; - motor_dir = -1; - counts_target += (mod_pocket - current_position) * scale; + motor_fwd_set(0); + motor_rev_set(1); + motor_vel_set(rev_dc); + motor_dir_set(-1); + counts_target_set(counts_target + (mod_pocket - current_position) * scale); } } } else { - counts_target += (mod_pocket - current_position) * scale; + counts_target_set(counts_target + (mod_pocket - current_position) * scale); if (counts_target < counts ) { - counts_target += scale * inst_pockets; + counts_target_set(counts_target + scale * inst_pockets); } - motor_fwd = 1; - motor_rev = 0; - motor_vel = fwd_dc; - motor_dir = 1; + motor_fwd_set(1); + motor_rev_set(0); + motor_vel_set(fwd_dc); + motor_dir_set(1); } - state = MOVE; + state_set(MOVE); /* Fallthrough */ case MOVE: // moving if ((current_position != mod_pocket) && enable){ @@ -412,67 +412,67 @@ FUNCTION(_){ return; } if (rev_pulse > 0){ - motor_fwd = 0; - motor_rev = 1; - motor_vel = rev_dc; - timer = rev_pulse; - state = REV_TIME; + motor_fwd_set(0); + motor_rev_set(1); + motor_vel_set(rev_dc); + timer_set(rev_pulse); + state_set(REV_TIME); } else if (decel_time > 0) { // stop and prepare for alignment - motor_vel = 0; - timer = decel_time; - state = WAIT_STOP; + motor_vel_set(0); + timer_set(decel_time); + state_set(WAIT_STOP); } else { - motor_fwd = 0; - motor_rev = 0; - motor_vel = hold_dc; - active = 0; - if (enable && current_position == mod_pocket) ready = 1; - state = WAIT_ENABLE_FALSE; + motor_fwd_set(0); + motor_rev_set(0); + motor_vel_set(hold_dc); + active_set(0); + if (enable && current_position == mod_pocket) ready_set(1); + state_set(WAIT_ENABLE_FALSE); } break; case REV_TIME: // timed reverse pulse - timer -= fperiod; + timer_set(timer - fperiod); if (timer > 0) return; - state = WAIT_ENABLE_FALSE; - motor_fwd = 0; - motor_rev = 0; - motor_vel = hold_dc; - active = 0; - if (enable) ready = 1; + state_set(WAIT_ENABLE_FALSE); + motor_fwd_set(0); + motor_rev_set(0); + motor_vel_set(hold_dc); + active_set(0); + if (enable) ready_set(1); break; case WAIT_STOP: //Waiting for carousel to stop - timer -= fperiod; + timer_set(timer - fperiod); if (timer > 0) return; if (align_dc == 0){ - state = FINAL_MOVE_BACK; + state_set(FINAL_MOVE_BACK); break; } - motor_vel = -align_dc; + motor_vel_set(-align_dc); if (motor_dir == 1) { - state = BACK_UP_INDEX; + state_set(BACK_UP_INDEX); } else { - state = BACK_OFF_INDEX; + state_set(BACK_OFF_INDEX); } break; case BACK_UP_INDEX: //backing up to index if ( align_pin == 0 ) return; - state = BACK_OFF_INDEX; + state_set(BACK_OFF_INDEX); break; case BACK_OFF_INDEX: //backing back off of index if ( align_pin != 0 ) return; - motor_vel = align_dc; - state = FINAL_MOVE_BACK; + motor_vel_set(align_dc); + state_set(FINAL_MOVE_BACK); break; case FINAL_MOVE_BACK: // final move back to index if ( align_pin == 0 ) return; - motor_fwd = 0; - motor_rev = 0; - motor_vel = hold_dc; - active = 0; + motor_fwd_set(0); + motor_rev_set(0); + motor_vel_set(hold_dc); + active_set(0); // final safety check for in-position - if (enable && current_position == mod_pocket) ready = 1; - state = WAIT_ENABLE_FALSE; + if (enable && current_position == mod_pocket) ready_set(1); + state_set(WAIT_ENABLE_FALSE); break; case WAIT_ENABLE_FALSE: //waiting for enable to go false if (! ready && ! err_once){ @@ -481,19 +481,19 @@ FUNCTION(_){ } if (enable) return; err_once = 0; - state = WAITING; + state_set(WAITING); break; case HOME_START: // start of homing - homed = 0; - homing = 1; - motor_fwd = 1; - motor_rev = 0; - motor_vel = fwd_dc; - motor_dir = 1; - index_enable = 1; - counts_target += scale * inst_pockets; + homed_set(0); + homing_set(1); + motor_fwd_set(1); + motor_rev_set(0); + motor_vel_set(fwd_dc); + motor_dir_set(1); + index_enable_set(1); + counts_target_set(counts_target + scale * inst_pockets); old_index = 1; // ensure 0->1 cycle of home sensor - state = HOME_WAIT; + state_set(HOME_WAIT); /* Fallthrough */ case HOME_WAIT: ;// waiting for index & pulse int ind = 0; @@ -503,20 +503,20 @@ FUNCTION(_){ ind = (sense(0) && sense(1)); } if ( ! index_enable || ((! old_index) && ind)){ // index found - current_position = 1; - homed = 1; - homing = 0; - active = 0; - motor_fwd = 0; - motor_rev = 0; - motor_vel = 0; - base_counts = counts - home_offset; - counts_target = base_counts; + current_position_set(1); + homed_set(1); + homing_set(0); + active_set(0); + motor_fwd_set(0); + motor_rev_set(0); + motor_vel_set(0); + base_counts_set(counts - home_offset); + counts_target_set(base_counts); if ( align_dc == 0) { - state = WAITING; + state_set(WAITING); } else { - timer = decel_time; - state = WAIT_STOP; + timer_set(decel_time); + state_set(WAIT_STOP); } } old_index = ind; @@ -529,17 +529,17 @@ FUNCTION(_){ return; } if (align_dc != 0 && ! align_pin) return; - motor_fwd = 0; - motor_rev = 0; - motor_vel = hold_dc; - active = 0; + motor_fwd_set(0); + motor_rev_set(0); + motor_vel_set(hold_dc); + active_set(0); if (jog_fwd || jog_rev) return; // require button release to jog again if (align_dc != 0) { - motor_vel = -align_dc; - timer = decel_time; - state = WAIT_STOP; + motor_vel_set(-align_dc); + timer_set(decel_time); + state_set(WAIT_STOP); } else { - state = WAITING; + state_set(WAITING); } break; } diff --git a/src/hal/components/corexy_by_hal.comp b/src/hal/components/corexy_by_hal.comp index bde7d7b620d..50e8517c7b8 100644 --- a/src/hal/components/corexy_by_hal.comp +++ b/src/hal/components/corexy_by_hal.comp @@ -1,17 +1,17 @@ // Based on a forum posting by nbremond component corexy_by_hal "CoreXY kinematics"; -pin in float alpha_fb"typ: feedback from alpha motor controller"; -pin in float beta_fb "typ: feedback from beta motor controller"; +pin in real alpha_fb"typ: feedback from alpha motor controller"; +pin in real beta_fb "typ: feedback from beta motor controller"; -pin in float j0_motor_pos_cmd"typ: from joint.0.motor-pos-cmd"; -pin in float j1_motor_pos_cmd"typ: from joint.1.motor-pos-cmd"; +pin in real j0_motor_pos_cmd"typ: from joint.0.motor-pos-cmd"; +pin in real j1_motor_pos_cmd"typ: from joint.1.motor-pos-cmd"; -pin out float j0_motor_pos_fb"typ: to joint.0.motor-pos-fb"; -pin out float j1_motor_pos_fb"typ: to joint.1.motor-pos-fb"; +pin out real j0_motor_pos_fb"typ: to joint.0.motor-pos-fb"; +pin out real j1_motor_pos_fb"typ: to joint.1.motor-pos-fb"; -pin out float alpha_cmd"typ: command to alpha motor"; -pin out float beta_cmd "typ: command to beta ts motor"; +pin out real alpha_cmd"typ: command to alpha motor"; +pin out real beta_cmd "typ: command to beta ts motor"; function _; description """ @@ -57,10 +57,10 @@ author "Dewey Garrett based on forum post from nbremond"; FUNCTION(_) { // forward kinematics (j0==x,j1==y from motor positions): - j0_motor_pos_fb = alpha_fb + beta_fb; - j1_motor_pos_fb = alpha_fb - beta_fb; + j0_motor_pos_fb_set(alpha_fb + beta_fb); + j1_motor_pos_fb_set(alpha_fb - beta_fb); // inverse kinematics (motor positions from j0==x,j1==y): - alpha_cmd = 0.5*(j0_motor_pos_cmd + j1_motor_pos_cmd); - beta_cmd = 0.5*(j0_motor_pos_cmd - j1_motor_pos_cmd); + alpha_cmd_set(0.5*(j0_motor_pos_cmd + j1_motor_pos_cmd)); + beta_cmd_set(0.5*(j0_motor_pos_cmd - j1_motor_pos_cmd)); } diff --git a/src/hal/components/differential.comp b/src/hal/components/differential.comp index ec986495d02..c81f360a7ae 100644 --- a/src/hal/components/differential.comp +++ b/src/hal/components/differential.comp @@ -17,17 +17,17 @@ component differential "kinematics for a differential transmission"; -pin in float roll-cmd "position command for roll (in degrees)"; -pin in float pitch-cmd "position command for pitch (in degrees)"; +pin in real roll-cmd "position command for roll (in degrees)"; +pin in real pitch-cmd "position command for pitch (in degrees)"; -pin out float roll-fb "position feedback for roll (in degrees)"; -pin out float pitch-fb "position feedback for pitch (in degrees)"; +pin out real roll-fb "position feedback for roll (in degrees)"; +pin out real pitch-fb "position feedback for pitch (in degrees)"; -pin out float motor0-cmd "position command to motor0 (based on roll & pitch inputs)"; -pin out float motor1-cmd "position command to motor1 (based on roll & pitch inputs)"; +pin out real motor0-cmd "position command to motor0 (based on roll & pitch inputs)"; +pin out real motor1-cmd "position command to motor1 (based on roll & pitch inputs)"; -pin in float motor0-fb "position feedback from motor0"; -pin in float motor1-fb "position feedback from motor1"; +pin in real motor0-fb "position feedback from motor0"; +pin in real motor1-fb "position feedback from motor1"; option period no; function _; @@ -37,9 +37,9 @@ author "Sebastian Kuzminsky"; ;; FUNCTION(_) { - motor0_cmd = roll_cmd + pitch_cmd; - motor1_cmd = roll_cmd - pitch_cmd; + motor0_cmd_set(roll_cmd + pitch_cmd); + motor1_cmd_set(roll_cmd - pitch_cmd); - roll_fb = (motor0_fb + motor1_fb)/2; - pitch_fb = (motor0_fb - motor1_fb)/2; + roll_fb_set((motor0_fb + motor1_fb)/2); + pitch_fb_set((motor0_fb - motor1_fb)/2); } diff --git a/src/hal/components/gantry.comp b/src/hal/components/gantry.comp index cbb12bb4d02..9a53e4e8d2d 100644 --- a/src/hal/components/gantry.comp +++ b/src/hal/components/gantry.comp @@ -39,15 +39,15 @@ ******************************************************************************/ component gantry "LinuxCNC HAL component for driving multiple joints from a single axis."; -pin out float joint.##.pos-cmd [7 : personality] "Per-joint commanded position"; -pin in float joint.##.pos-fb [7 : personality] "Per-joint position feedback"; -pin in bit joint.##.home [7 : personality] "Per-joint home switch"; -pin out float joint.##.offset [7 : personality] "(debugging) Per-joint offset value, updated when homing."; -pin in float position-cmd "Commanded position from motion"; -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"; +pin out real joint.##.pos-cmd [7 : personality] "Per-joint commanded position"; +pin in real joint.##.pos-fb [7 : personality] "Per-joint position feedback"; +pin in bool joint.##.home [7 : personality] "Per-joint home switch"; +pin out real joint.##.offset [7 : personality] "(debugging) Per-joint offset value, updated when homing."; +pin in real position-cmd "Commanded position from motion"; +pin out real position-fb "Position feedback to motion"; +pin out bool home "Combined home signal, true if all joint home inputs are true."; +pin out bool limit "Combined limit signal, true if any joint home input is true."; +pin in real search-vel "HOME_SEARCH_VEL from INI file"; 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 """ @@ -81,8 +81,8 @@ When a joint home switch trips, the commanded velocity will drop immediately fro license "GPL"; author "Charles Steinkuehler"; option period no; -variable float offset[7] = 0.0; -variable float prev_cmd = 0.0; +variable rtapi_real offset[7] = 0.0; +variable rtapi_real prev_cmd = 0.0; variable int fb_joint = 0; variable int latching = 0; ;; @@ -90,8 +90,8 @@ FUNCTION(read) { int i=1; // First (or only) joint - home=joint_home(0); - limit=joint_home(0); + home_set(joint_home(0)); + limit_set(joint_home(0)); // All other joints, if configured while (i < personality) { @@ -99,20 +99,20 @@ FUNCTION(read) { if(latching==0) { // Don't assert home until all joints hit their home switches - home &= joint_home(i); + home_set(home && joint_home(i)); } else { // Don't release home until all joints have backed off their // home switches - home |= joint_home(i); + home_set(home || joint_home(i)); } // Remember the home state for next time latching=home; // Limit is always asserted if any home switch is asserted - limit |= joint_home(i); + limit_set(limit || joint_home(i)); i++; } @@ -123,19 +123,19 @@ FUNCTION(read) { if ((joint_home(fb_joint) == 1) && (home == 0)) { for (i=0; i < personality; i++) { if (joint_home(i) == 0) { - position_fb = joint_pos_fb(i) + offset[i]; + position_fb_set(joint_pos_fb(i) + offset[i]); fb_joint = i; break; } } } else { - position_fb = joint_pos_fb(fb_joint) + offset[fb_joint]; + position_fb_set(joint_pos_fb(fb_joint) + offset[fb_joint]); } } FUNCTION(write) { int i; - float delta; + rtapi_real delta; // Determine if we're moving in the same direction as home search @@ -164,8 +164,8 @@ FUNCTION(write) { // Update each joint's commanded position for (i=0; i < personality; i++) { - joint_pos_cmd(i) = position_cmd - offset[i]; - joint_offset(i) = offset[i]; + joint_pos_cmd_set(i, position_cmd - offset[i]); + joint_offset_set(i, offset[i]); } } diff --git a/src/hal/components/histobins.comp b/src/hal/components/histobins.comp index 2b708ec2bcb..2163467490b 100644 --- a/src/hal/components/histobins.comp +++ b/src/hal/components/histobins.comp @@ -42,36 +42,36 @@ Additional output statistics pins: The method input pin selects an alternate variance calculation. Maintainers note: hardcoded for MAXBINNUMBER==200 -"""; - -pin in u32 pintype; -pin in float input; -pin in s32 input_s32; -pin in u32 input_u32; -pin in bit input_bit; - -pin in u32 nbins = 20; // must be < MAXBINNUMBER -pin in float binsize = 1; -pin in float minvalue = 0; - -pin in s32 index; // use s32 to avoid 0x hex display in hal -pin out s32 check; // use s32 to avoid 0x hex display in hal -pin in bit reset; -pin in bit method; - -pin out bit input_error; -pin out float binvalue; -pin out float pextra; -pin out float nextra; -pin out float input_min; -pin out float input_max; - -pin out u32 nsamples; -pin out float variance; -pin out float mean; +"""; //" To make vim happy in syntax=c mode + +pin in ui32 pintype; +pin in real input; +pin in si32 input_s32; +pin in ui32 input_u32; +pin in bool input_bit; + +pin in ui32 nbins = 20; // must be < MAXBINNUMBER +pin in real binsize = 1; +pin in real minvalue = 0; + +pin in si32 index; // use s32 to avoid 0x hex display in hal +pin out si32 check; // use s32 to avoid 0x hex display in hal +pin in bool reset; +pin in bool method; + +pin out bool input_error; +pin out real binvalue; +pin out real pextra; +pin out real nextra; +pin out real input_min; +pin out real input_max; + +pin out ui32 nsamples; +pin out real variance; +pin out real mean; // user may interrogate availablebins to determine this compiled-in limit -pin out s32 availablebins = 200; //MAXBINNUMBER +pin out si32 availablebins = 200; //MAXBINNUMBER option period no; function _; @@ -80,31 +80,31 @@ variable int bin[200]; // MAXBINNUMBER variable int first = 1; variable unsigned last_nbins = 0; -variable hal_float_t maxvalue; +variable rtapi_real maxvalue; -variable hal_float_t last_binsize = 0; -variable hal_float_t last_minvalue = 0; +variable rtapi_real last_binsize = 0; +variable rtapi_real last_minvalue = 0; -variable hal_float_t sum; -variable hal_float_t sq_sum; -variable hal_float_t m2; +variable rtapi_real sum; +variable rtapi_real sq_sum; +variable rtapi_real m2; license "GPL"; author "Dewey Garrett"; ;; -hal_float_t invalue; +rtapi_real invalue; unsigned i; int idx; -check = index; +check_set(index); if ( (nbins > (unsigned)availablebins) || (nbins < 1) ) { - input_error = 1; - check = index; // allow continue with no updates + input_error_set(1); + check_set(index); // allow continue with no updates return; } -input_error = 0; +input_error_set(0); if (reset) {first = 1;} //pintype "0:float, 1:s32, 2:u32 3:bit"; @@ -123,56 +123,57 @@ if ( first ) { maxvalue = minvalue + nbins * binsize; first = 0; - pextra = 0; nextra = 0; + pextra_set(0); + nextra_set(0); for (i = 0; i < nbins; i++) { bin[i] = 0; } - nsamples = 0; - mean = 0; + nsamples_set(0); + mean_set(0); sum = 0; sq_sum = 0; - variance = 0; - input_min = 1e99; //dng - input_max = -1e99; //dng + variance_set(0); + input_min_set(1e99); //dng + input_max_set(-1e99); //dng m2 = 0; } else { if (invalue < minvalue) { - nextra++; + nextra_set(nextra + 1); } else if (invalue > maxvalue) { - pextra++; + pextra_set(pextra + 1); } else { idx = (invalue - minvalue)/binsize; bin[idx]++; } } -check = index; // user should verify check==index for reading values +check_set(index); // user should verify check==index for reading values // -1 value indicates illegal index if (index < 0) { - binvalue = -1; + binvalue_set(-1); } else if (index < (int)nbins) { - binvalue = bin[index]; + binvalue_set(bin[index]); } else { - binvalue = -1; + binvalue_set(-1); } -if (invalue < input_min) input_min = invalue; -if (invalue > input_max) input_max = invalue; +if (invalue < input_min) input_min_set(invalue); +if (invalue > input_max) input_max_set(invalue); -nsamples++; +nsamples_set(nsamples + 1); if (nsamples >= 2) { if (method == 0 ) { - hal_float_t delta; + rtapi_real delta; delta = invalue - mean; - mean = mean + delta / nsamples; + mean_set(mean + delta / nsamples); m2 = m2 + delta * (invalue - mean); - variance = m2/(nsamples - 1); + variance_set(m2/(nsamples - 1)); } else { sum += invalue; sq_sum += invalue * invalue; - variance = (sq_sum - (sum * sum)/nsamples)/(nsamples -1); - mean = sum/nsamples; + variance_set((sq_sum - (sum * sum)/nsamples)/(nsamples -1)); + mean_set(sum/nsamples); } } diff --git a/src/hal/components/histobinstream.comp b/src/hal/components/histobinstream.comp index b1deeaa40fe..d4d682aadb8 100644 --- a/src/hal/components/histobinstream.comp +++ b/src/hal/components/histobinstream.comp @@ -46,32 +46,32 @@ Maintainers note: hardcoded for MAXBINNUMBER==200 """; // "} make vim syntax highligting happy -pin in u32 pintype "Select the input pin (0:input 1:input-s32 2:input-u32 3:input-bit)."; -pin in float input "Floating point input value (pintype 0)."; -pin in s32 input_s32 "Signed input value (pintype 1)."; -pin in u32 input_u32 "Unsigned input value (pintype 2)."; -pin in bit input_bit "Bit input value (pintype 3)."; - -pin in u32 nbins = 20 "Number of active bins N (0 ... N-1)."; -pin in float binsize = 1 "Width of one bin in input units."; -pin in float minvalue = 0 "Lower edge of bin 0."; - -pin in bit reset = 1 "Reset state and bins."; -pin in bit stream = 0 "Set to high to stream all bins and tails on rising edge."; -pin in bit method = 0 "Variance method (0:Welford incremental, 1:sum of squares)."; - -pin out bit stream_error "Set if the data stream did not fit and was never sent."; -pin out bit input_error "Set when input rules are violated; updates are invalid until fixed and a reset."; - -pin out float input_min "Minimum input value seen (latched on stream rising edge)."; -pin out float input_max "Maximum input value seen (latched on stream rising edge)."; -pin out u32 nsamples "Number of samples accumulated (latched on stream rising edge)."; -pin out float variance "Variance of the input (latched on stream rising edge)."; -pin out float mean "Mean of the input (latched on stream rising edge)."; -pin out s64 stream_time "The time it took for the stream data to be pushed out in nanoseconds (ns)."; +pin in ui32 pintype "Select the input pin (0:input 1:input-s32 2:input-u32 3:input-bit)."; +pin in real input "Floating point input value (pintype 0)."; +pin in si32 input_s32 "Signed input value (pintype 1)."; +pin in ui32 input_u32 "Unsigned input value (pintype 2)."; +pin in bool input_bit "Bit input value (pintype 3)."; + +pin in ui32 nbins = 20 "Number of active bins N (0 ... N-1)."; +pin in real binsize = 1 "Width of one bin in input units."; +pin in real minvalue = 0 "Lower edge of bin 0."; + +pin in bool reset = 1 "Reset state and bins."; +pin in bool stream = 0 "Set to high to stream all bins and tails on rising edge."; +pin in bool method = 0 "Variance method (0:Welford incremental, 1:sum of squares)."; + +pin out bool stream_error "Set if the data stream did not fit and was never sent."; +pin out bool input_error "Set when input rules are violated; updates are invalid until fixed and a reset."; + +pin out real input_min "Minimum input value seen (latched on stream rising edge)."; +pin out real input_max "Maximum input value seen (latched on stream rising edge)."; +pin out ui32 nsamples "Number of samples accumulated (latched on stream rising edge)."; +pin out real variance "Variance of the input (latched on stream rising edge)."; +pin out real mean "Mean of the input (latched on stream rising edge)."; +pin out sint stream_time "The time it took for the stream data to be pushed out in nanoseconds (ns)."; // user may interrogate availablebins to determine this compiled-in limit -pin out s32 availablebins = 200; //MAXBINNUMBER +pin out si32 availablebins = 200; //MAXBINNUMBER option period no; function _; @@ -83,22 +83,22 @@ include ; variable int first = 1; variable unsigned last_nbins = 0; -variable real_t last_binsize = 0; -variable real_t last_minvalue = 0; -variable real_t maxvalue = 0; +variable rtapi_real last_binsize = 0; +variable rtapi_real last_minvalue = 0; +variable rtapi_real maxvalue = 0; variable hal_stream_data_u bins[200]; // MAXBINNUMBER variable hal_stream_data_u ptail; // count of inputs >= upper edge variable hal_stream_data_u ntail; // count of inputs < minvalue variable rtapi_u64 run_nsamples = 0; -variable real_t run_min = 1e99; -variable real_t run_max = -1e99; -variable real_t run_mean = 0; -variable real_t run_variance = 0; -variable real_t sum = 0; -variable real_t sq_sum = 0; -variable real_t m2 = 0; +variable rtapi_real run_min = 1e99; +variable rtapi_real run_max = -1e99; +variable rtapi_real run_mean = 0; +variable rtapi_real run_variance = 0; +variable rtapi_real sum = 0; +variable rtapi_real sq_sum = 0; +variable rtapi_real m2 = 0; variable bool last_stream = 0; variable hal_stream_t fifo; @@ -135,11 +135,11 @@ FUNCTION(_) { // Cache some pins rtapi_u32 c_nbins= nbins; - real_t c_binsize = binsize; - real_t c_minvalue = minvalue; + rtapi_real c_binsize = binsize; + rtapi_real c_minvalue = minvalue; // Select the input according to pintype. - real_t invalue; + rtapi_real invalue; switch (pintype) { case 0: invalue = input; break; case 1: invalue = input_s32; break; @@ -151,14 +151,14 @@ FUNCTION(_) { // Validate the requested bin geometry. binsize must be > 0 to avoid a // divide by zero and to keep the bin index monotonic. if (c_nbins < 1 || c_nbins > (unsigned)availablebins || c_binsize <= 0.0) { - input_error = 1; + input_error_set(1); last_stream = stream; // do not act on a stream edge while in error return; } if (reset) { first = 1; - input_error = 0; + input_error_set(0); } if ( first @@ -166,7 +166,7 @@ FUNCTION(_) { || c_binsize != last_binsize || c_minvalue != last_minvalue) { first = 0; - maxvalue = c_minvalue + (real_t)c_nbins * c_binsize; + maxvalue = c_minvalue + (rtapi_real)c_nbins * c_binsize; for (unsigned i = 0; i < c_nbins; i++) bins[i].u = 0; ptail.u = 0; @@ -201,7 +201,7 @@ FUNCTION(_) { ++run_nsamples; if (run_nsamples >= 2) { if (method == 0) { - real_t delta = invalue - run_mean; + rtapi_real delta = invalue - run_mean; run_mean += delta / run_nsamples; m2 += delta * (invalue - run_mean); run_variance = m2 / (run_nsamples - 1); @@ -227,11 +227,11 @@ FUNCTION(_) { bool b = stream; // On the low-to-high transition latch the statistics and push the bins. if (b && !last_stream) { - nsamples = (hal_u32_t)run_nsamples; - mean = run_mean; - variance = run_variance; - input_min = run_nsamples ? run_min : 0; - input_max = run_nsamples ? run_max : 0; + nsamples_set(run_nsamples); + mean_set(run_mean); + variance_set(run_variance); + input_min_set(run_nsamples ? run_min : 0); + input_max_set(run_nsamples ? run_max : 0); unsigned need = c_nbins + 2; int avail = hal_stream_maxdepth(&fifo) - hal_stream_depth(&fifo); @@ -243,12 +243,12 @@ FUNCTION(_) { hal_stream_write(&fifo, &bins[i]); // Positive overflow hal_stream_write(&fifo, &ptail); - stream_error = 0; - stream_time = rtapi_get_time() - now; + stream_error_set(0); + stream_time_set(rtapi_get_time() - now); } else { // Not enough room to stream an entire set; never stream an // incomplete data set. - stream_error = 1; + stream_error_set(1); } } last_stream = b; diff --git a/src/hal/components/homecomp.comp b/src/hal/components/homecomp.comp index 79c4691787f..f073114f0de 100644 --- a/src/hal/components/homecomp.comp +++ b/src/hal/components/homecomp.comp @@ -111,8 +111,8 @@ static custom_home_local_data customH[EMCMOT_MAX_JOINTS]; // data for per-joint custom-homing-specific hal pins: typedef struct { - hal_bit_t *request_custom_homing; // input requests custom homing - hal_bit_t *is_custom_homing; // output verifies custom homing + hal_bool_t request_custom_homing; // input requests custom homing + hal_bool_t is_custom_homing; // output verifies custom homing } custom_one_joint_home_data_t; typedef struct { @@ -126,7 +126,7 @@ static int custom_makepins(int id,int njoints) int jno,retval; custom_one_joint_home_data_t *addr; - custom_joint_home_data = hal_malloc(sizeof(custom_all_joints_home_data_t)); + custom_joint_home_data = hal_malloc(sizeof(*custom_joint_home_data)); if (custom_joint_home_data == 0) { rtapi_print_msg(RTAPI_MSG_ERR, "HOMING: custom_all_joints_home_data_t malloc failed\n"); return -1; @@ -136,9 +136,9 @@ static int custom_makepins(int id,int njoints) for (jno = 0; jno < njoints; jno++) { addr = &(custom_joint_home_data->custom_jhd[jno]); - retval += hal_pin_bit_newf(HAL_IN, &(addr->request_custom_homing), id, + retval += hal_pin_new_bool(id, HAL_IN, &(addr->request_custom_homing), 0, "joint.%d.request-custom-homing", jno); - retval += hal_pin_bit_newf(HAL_OUT, &(addr->is_custom_homing), id, + retval += hal_pin_new_bool(id, HAL_OUT, &(addr->is_custom_homing), 0, "joint.%d.is-custom-homing", jno); } return retval; @@ -150,7 +150,7 @@ static void custom_read_homing_in_pins(int njoints) custom_one_joint_home_data_t *addr; for (jno = 0; jno < njoints; jno++) { addr = &(custom_joint_home_data->custom_jhd[jno]); - customH[jno].request_custom_homing = *(addr->request_custom_homing); // IN + customH[jno].request_custom_homing = hal_get_bool(addr->request_custom_homing); // IN // echo for verification: customH[jno].is_custom_homing = customH[jno].request_custom_homing; @@ -163,7 +163,7 @@ static void custom_write_homing_out_pins(int njoints) custom_one_joint_home_data_t *addr; for (jno = 0; jno < njoints; jno++) { addr = &(custom_joint_home_data->custom_jhd[jno]); - *(addr->is_custom_homing) = customH[jno].is_custom_homing; // OUT + hal_set_bool(addr->is_custom_homing, customH[jno].is_custom_homing); // OUT } } @@ -344,12 +344,12 @@ static emcmot_joint_t *joints; // data for per-joint homing-specific hal pins: typedef struct { - hal_bit_t *home_sw; // home switch input - hal_bit_t *homing; // joint is homing - hal_bit_t *homed; // joint was homed - hal_bit_t *index_enable; // motmod sets: request reset on index + hal_bool_t home_sw; // home switch input + hal_bool_t homing; // joint is homing + hal_bool_t homed; // joint was homed + hal_bool_t index_enable; // motmod sets: request reset on index // encoder clears: index arrived - hal_s32_t *home_state; // homing state machine state + hal_sint_t home_state; // homing state machine state } one_joint_home_data_t; typedef struct { @@ -374,15 +374,15 @@ static int makepins(int id,int njoints) for (jno = 0; jno < njoints; jno++) { addr = &(joint_home_data->jhd[jno]); - retval += hal_pin_bit_newf(HAL_IN, &(addr->home_sw), id, + retval += hal_pin_new_bool(id, HAL_IN, &(addr->home_sw), 0, "joint.%d.home-sw-in", jno); - retval += hal_pin_bit_newf(HAL_OUT, &(addr->homing), id, + retval += hal_pin_new_bool(id, HAL_OUT, &(addr->homing), 0, "joint.%d.homing", jno); - retval += hal_pin_bit_newf(HAL_OUT, &(addr->homed), id, + retval += hal_pin_new_bool(id, HAL_OUT, &(addr->homed), 0, "joint.%d.homed", jno); - retval += hal_pin_s32_newf(HAL_OUT, &(addr->home_state), id, + retval += hal_pin_new_si32(id, HAL_OUT, &(addr->home_state), 0, "joint.%d.home-state", jno); - retval += hal_pin_bit_newf(HAL_IO, &(addr->index_enable), id, + retval += hal_pin_new_bool(id, HAL_IO, &(addr->index_enable), 0, "joint.%d.index-enable", jno); } return retval; diff --git a/src/hal/components/laserpower.comp b/src/hal/components/laserpower.comp index 8baf122041c..ee885d069ea 100644 --- a/src/hal/components/laserpower.comp +++ b/src/hal/components/laserpower.comp @@ -1,22 +1,22 @@ component laserpower "Scales laser power output based upon velocity input power and distance to go"; -pin in float min_power "Minimum allowed power level. "; -pin in float max_power "Maximum allowed power level"; -pin in float req_velocity "Requested motion velocity"; -pin in float cur_velocity "Current motion velocity"; -pin in bit enabled "True when laser output enabled"; +pin in real min_power "Minimum allowed power level. "; +pin in real max_power "Maximum allowed power level"; +pin in real req_velocity "Requested motion velocity"; +pin in real cur_velocity "Current motion velocity"; +pin in bool enabled "True when laser output enabled"; -pin in bit raster_mode "false for vector mode, true for raster mode"; -pin in float raster_power "Requested power level during raster operations"; +pin in bool raster_mode "false for vector mode, true for raster mode"; +pin in real raster_power "Requested power level during raster operations"; -pin in float vector_power "Requested power level during vector operations"; -pin in float distance_to_go "Distance to go of current move"; +pin in real vector_power "Requested power level during vector operations"; +pin in real distance_to_go "Distance to go of current move"; -pin out float power "Current power level command"; +pin out real power "Current power level command"; -pin out float command_power "Commanded power before normalization and velocity scaling"; -pin out float start_power "Power level when reqPower last changed"; -pin out float start_distance "Distance amount when reqPower last changed"; -pin out float vel_scale "Velocity related scaling component."; +pin out real command_power "Commanded power before normalization and velocity scaling"; +pin out real start_power "Power level when reqPower last changed"; +pin out real start_distance "Distance amount when reqPower last changed"; +pin out real vel_scale "Velocity related scaling component."; description """ During operation laserpower must be scaled proportionally to actual velocity vs @@ -40,49 +40,49 @@ include ; ;; -const hal_float_t zero = 0.00005; +const rtapi_real zero = 0.00005; -bool float_zero(hal_float_t a) { +bool float_zero(rtapi_real a) { return fabs(a) < zero; } FUNCTION(_) { - static float previous_vector_power = 0; - static float previous_distance_to_go = 0; + static rtapi_real previous_vector_power = 0; + static rtapi_real previous_distance_to_go = 0; //velocity gain is proportional to current velocity and requested velocity //if the machine slows down around a corner, we lower the laser power proportionally //if the machine is not moving, we want vel scale to be 0 if(float_zero(req_velocity) || float_zero(cur_velocity)) { - vel_scale = 0; + vel_scale_set(0); } else { - vel_scale = (fabs(cur_velocity) / fabs(req_velocity)); + vel_scale_set((fabs(cur_velocity) / fabs(req_velocity))); } if (raster_mode) { - command_power = raster_power; + command_power_set(raster_power); } else { if((previous_distance_to_go < distance_to_go) || !float_zero(vector_power - previous_vector_power)) { //if vector power changes during a move we begin scaling from the previously //commanded vector power to the new power during the move - start_power = previous_vector_power; - start_distance = distance_to_go; + start_power_set(previous_vector_power); + start_distance_set(distance_to_go); } previous_vector_power = vector_power; previous_distance_to_go = distance_to_go; - command_power = start_power + ((vector_power-start_power) * (1 - (distance_to_go / start_distance))); + command_power_set(start_power + ((vector_power-start_power) * (1 - (distance_to_go / start_distance)))); } if(!enabled || command_power < 0.0) { //if we aren't performing a feed move or // command power is less than 0 we don't output any power no matter what given min and max are - power = 0.0; + power_set(0.0); } else { - power = ((max_power-min_power) * vel_scale * (command_power / 100)) + min_power; + power_set(((max_power-min_power) * vel_scale * (command_power / 100)) + min_power); } } diff --git a/src/hal/components/latencybins.comp b/src/hal/components/latencybins.comp index 1304a854f33..78a75e104ee 100644 --- a/src/hal/components/latencybins.comp +++ b/src/hal/components/latencybins.comp @@ -34,23 +34,23 @@ The latency pin outputs the instantaneous latency. Maintainers note: hardcoded for MAXBINNUMBER==1000 """; -pin in s32 maxbinnumber = 1000; // MAXBINNUMBER -pin in s32 index; //use s32 to avoid 0x hex display in hal -pin in bit reset; -pin in s32 nsbinsize; - -pin out s32 check; -pin out s32 latency; -pin out s32 latency_max; -pin out s32 latency_min; -pin out s32 pbinvalue; -pin out s32 nbinvalue; -pin out s32 pextra; -pin out s32 nextra; -pin out s32 variance; +pin in si32 maxbinnumber = 1000; // MAXBINNUMBER +pin in si32 index; //use s32 to avoid 0x hex display in hal +pin in bool reset; +pin in si32 nsbinsize; + +pin out si32 check; +pin out si32 latency; +pin out si32 latency_max; +pin out si32 latency_min; +pin out si32 pbinvalue; +pin out si32 nbinvalue; +pin out si32 pextra; +pin out si32 nextra; +pin out si32 variance; // user may interrogate available bins to determine this compiled-in limit -pin out s32 availablebins = 1000; // MAXBINNUMBER +pin out si32 availablebins = 1000; // MAXBINNUMBER function _; variable rtapi_s64 last_timer = 0; @@ -87,10 +87,11 @@ if ( first || nsbinsize == 0 // important to avoid divide by zero ) { first = 0; - latency = 0; - latency_min = 0x7FFFFFFF; - latency_max = 0x80000000; - pextra = 0; nextra = 0; + latency_set(0); + latency_min_set(0x7FFFFFFF); + latency_max_set(0x80000000); + pextra_set(0); + nextra_set(0); for (i = 0; i <= binmax; i++) { pbins[i] = 0; nbins[i] = 0; } @@ -98,20 +99,20 @@ if ( first sum = 0; sq_sum = 0; } else { - latency = lat32; + latency_set(lat32); i = lat32/nsbinsize; - if (lat32 > latency_max) latency_max = lat32; - if (lat32 < latency_min) latency_min = lat32; + if (lat32 > latency_max) latency_max_set(lat32); + if (lat32 < latency_min) latency_min_set(lat32); if (i >= 0) { if (i > binmax) { - pextra++; + pextra_set(pextra + 1); } else { pbins[i]++; } } else { i = -i; if (i > binmax) { - nextra++; + nextra_set(nextra + 1); } else { nbins[i]++; } @@ -125,19 +126,19 @@ if ( first rtapi_u64 divisor; dividend = sq_sum - rtapi_div_u64(sum * sum,nsamples); divisor = nsamples -1; - variance = rtapi_div_u64(dividend,divisor); + variance_set(rtapi_div_u64(dividend,divisor)); } } -check = index; // user should verify check==index for reading values +check_set(index); // user should verify check==index for reading values // -1 value indicates illegal index if (index < 0) { - pbinvalue = -1; - nbinvalue = -1; + pbinvalue_set(-1); + nbinvalue_set(-1); } else if (index <=binmax) { - pbinvalue = pbins[index]; - nbinvalue = nbins[index]; + pbinvalue_set(pbins[index]); + nbinvalue_set(nbins[index]); } else { - pbinvalue = -1; - nbinvalue = -1; + pbinvalue_set(-1); + nbinvalue_set(-1); } diff --git a/src/hal/components/latencybinstream.comp b/src/hal/components/latencybinstream.comp index a496d81b292..1dbf725c565 100644 --- a/src/hal/components/latencybinstream.comp +++ b/src/hal/components/latencybinstream.comp @@ -41,22 +41,22 @@ of the *stream* pin. Maintainers note: hardcoded for MAXBINNUMBER==1000 """; -pin in s64 maxbinnumber = 1000 "Number of active bins N on each side (-N...0...N)."; // MAXBINNUMBER -pin in s64 nsbinsize "Time interval for one bin in nanoseconds (ns)."; -pin in bit reset = 1 "Reset state and bins."; -pin in bit stream = 0 "Set to high to stream all bins and tails on rising edge."; - -pin out bit stream_error "Set if the data stream did not fit and was never sent."; -pin out s64 latency "Last measured latency."; -pin out s64 latency_avg "Average latency (when stream pin is asserted)."; -pin out s64 latency_max "Maximum latency (when stream pin is asserted)."; -pin out s64 latency_min "Minimum latency (when stream pin is asserted)."; -pin out s64 variance "Variance of the latency (when stream pin is asserted)."; -pin out s64 stream_time "The time it took for the stream data to be pushed out in nanoseconds (ns)."; +pin in sint maxbinnumber = 1000 "Number of active bins N on each side (-N...0...N)."; // MAXBINNUMBER +pin in sint nsbinsize "Time interval for one bin in nanoseconds (ns)."; +pin in bool reset = 1 "Reset state and bins."; +pin in bool stream = 0 "Set to high to stream all bins and tails on rising edge."; + +pin out bool stream_error "Set if the data stream did not fit and was never sent."; +pin out sint latency "Last measured latency."; +pin out sint latency_avg "Average latency (when stream pin is asserted)."; +pin out sint latency_max "Maximum latency (when stream pin is asserted)."; +pin out sint latency_min "Minimum latency (when stream pin is asserted)."; +pin out sint variance "Variance of the latency (when stream pin is asserted)."; +pin out sint stream_time "The time it took for the stream data to be pushed out in nanoseconds (ns)."; // user may interrogate available bins to determine this compiled-in limit // MAXBINNUMBER -pin out s64 availablebins = 1000 """ +pin out sint availablebins = 1000 """ Hard-coded maximum number of bins. You need to change the source code if you need more bins. """; @@ -68,7 +68,7 @@ modparam dummy keys "Stream shmem unique key for each instance"; include ; include ; -variable rtapi_s64 last_time = 0; +variable rtapi_sint last_time = 0; variable int last_binmax = 0; variable int first = 1; variable hal_stream_data_u ptail; // Positive overflow count @@ -78,11 +78,11 @@ variable hal_stream_data_u nbins[1001]; // MAXBINNUMBER+1 variable bool last_stream = 0; variable hal_stream_t fifo; -variable rtapi_u64 nsamples; -variable rtapi_u64 sum; -variable rtapi_u64 sq_sum; -variable rtapi_s64 lat_min = RTAPI_INT64_MAX; -variable rtapi_s64 lat_max = RTAPI_INT64_MIN; +variable rtapi_uint nsamples; +variable rtapi_uint sum; +variable rtapi_uint sq_sum; +variable rtapi_sint lat_min = RTAPI_INT64_MAX; +variable rtapi_sint lat_max = RTAPI_INT64_MIN; license "GPL"; author "B.Stultiens"; @@ -110,11 +110,11 @@ EXTRA_SETUP() { } FUNCTION(_) { - rtapi_s64 now = rtapi_get_time(); - rtapi_s64 lat = now - last_time - period; + rtapi_sint now = rtapi_get_time(); + rtapi_sint lat = now - last_time - period; last_time = now; - rtapi_s64 binmax = maxbinnumber; + rtapi_sint binmax = maxbinnumber; if (binmax > MAXBINNUMBER) { binmax = MAXBINNUMBER; } @@ -124,7 +124,7 @@ FUNCTION(_) { first = 1; } - rtapi_s64 nsbs = nsbinsize; // May not be zero, important to avoid divide by zero + rtapi_sint nsbs = nsbinsize; // May not be zero, important to avoid divide by zero if (first || binmax != last_binmax || !nsbs) { first = 0; lat_min = RTAPI_INT64_MAX; @@ -135,13 +135,13 @@ FUNCTION(_) { nsamples = 0; sum = 0; sq_sum = 0; - latency = 0; - variance = 0; - latency_avg = 0; - latency_min = 0; - latency_max = 0; + latency_set(0); + variance_set(0); + latency_avg_set(0); + latency_min_set(0); + latency_max_set(0); } else { - latency = lat; + latency_set(lat); int i = lat/nsbs; if (lat > lat_max) lat_max = lat; if (lat < lat_min) lat_min = lat; @@ -170,10 +170,10 @@ FUNCTION(_) { // 1 ( sum^2 ) // s^2 = ----- * ( sq_sum - ----- ) // n - 1 ( n ) - variance = (sq_sum - (sum * sum / nsamples)) / (nsamples - 1); - latency_avg = sum / nsamples; - latency_min = lat_min; - latency_max = lat_max; + variance_set((sq_sum - (sum * sum / nsamples)) / (nsamples - 1)); + latency_avg_set(sum / nsamples); + latency_min_set(lat_min); + latency_max_set(lat_max); } int avail = hal_stream_maxdepth(&fifo) - hal_stream_depth(&fifo); if (avail >= 2 * binmax + 1 + 2) { @@ -187,12 +187,12 @@ FUNCTION(_) { hal_stream_write(&fifo, &pbins[i]); // Positive overflow hal_stream_write(&fifo, &ptail); - stream_error = 0; - stream_time = rtapi_get_time() - now; + stream_error_set(0); + stream_time_set(rtapi_get_time() - now); } else { // Else we have not enough room to stream an entire set and // will not stream incomplete data sets. - stream_error = 1; + stream_error_set(1); } } last_stream = b; diff --git a/src/hal/components/moveoff.comp b/src/hal/components/moveoff.comp index b67bace996a..3f6962d3a1f 100644 --- a/src/hal/components/moveoff.comp +++ b/src/hal/components/moveoff.comp @@ -93,39 +93,39 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -pin in bit power_on "Connect to motion.motion-enabled"; -pin in bit move_enable "Enable offsets (Enabling requires apply-offset TRUE also)"; -pin in bit apply_offsets "Enable offsets (Enabling requires move-enable TRUE also)"; -pin in bit backtrack-enable = 1 "Enable backtrack on auto-return"; - -pin in float epsilon=0.0005 "When enabling pins are deactivated, return to un-offsetted position within epsilon units. Warning: values that are too small in value may cause overshoot. A minimum value of 0.0001 is *silently enforced*."; -pin in float waypoint-threshold = 0.02 "Minimum distance (in a single axis) for a new waypoint"; -pin in float waypoint-sample-secs = 0.02 "Minimum sample interval (in seconds) for a new waypoint"; - -pin out bit warning "Set TRUE if apply-offsets is deasserted while offset-applied is TRUE."; -pin out bit offset_applied "TRUE if one or more offsets are applied."; -pin out bit waypoint-limit = 0 "Indicates waypoint limit reached (motion ceases), an enabling pin must be deasserted to initiate return to original position."; -pin out s32 waypoint-ct "Waypoint count (for debugging)"; -pin out s32 waypoint-percent-used "Percent of available waypoints used"; - -pin in float offset-in-#[9 : personality] "Joint offset input value"; -pin in float pos-#[9 : personality] "Joint position (typ: axis.0.motor-pos-cmd)"; -pin in float fb-#[9 : personality] "Joint feedback (typ from encoder and input to pid controller (pid.feedback))"; - -pin out float offset-current-#[9 : personality]"Joint offset current value"; -pin out float pos-plusoffset-#[9 : personality] "Computed joint position plus offset (typically connect to pid command input)"; -pin out float fb-minusoffset-#[9 : personality] "Computed Joint feedback minus offset (typically connected to axis.0.motor-pos-fb)"; - -pin in float offset-vel-#[9 : personality]=10 "Joint offset velocity limit"; -pin in float offset-accel-#[9 : personality]=100 "Joint offset acceleration limit"; -pin in float offset-min-#[9 : personality] = -1e20 "Minimum limit for applied joint offset (typ negative)"; -pin in float offset-max-#[9 : personality] = 1e20 "Maximum limit for applied offset (typ positive)"; +pin in bool power_on "Connect to motion.motion-enabled"; +pin in bool move_enable "Enable offsets (Enabling requires apply-offset TRUE also)"; +pin in bool apply_offsets "Enable offsets (Enabling requires move-enable TRUE also)"; +pin in bool backtrack-enable = 1 "Enable backtrack on auto-return"; + +pin in real epsilon=0.0005 "When enabling pins are deactivated, return to un-offsetted position within epsilon units. Warning: values that are too small in value may cause overshoot. A minimum value of 0.0001 is *silently enforced*."; +pin in real waypoint-threshold = 0.02 "Minimum distance (in a single axis) for a new waypoint"; +pin in real waypoint-sample-secs = 0.02 "Minimum sample interval (in seconds) for a new waypoint"; + +pin out bool warning "Set TRUE if apply-offsets is deasserted while offset-applied is TRUE."; +pin out bool offset_applied "TRUE if one or more offsets are applied."; +pin out bool waypoint-limit = 0 "Indicates waypoint limit reached (motion ceases), an enabling pin must be deasserted to initiate return to original position."; +pin out si32 waypoint-ct "Waypoint count (for debugging)"; +pin out si32 waypoint-percent-used "Percent of available waypoints used"; + +pin in real offset-in-#[9 : personality] "Joint offset input value"; +pin in real pos-#[9 : personality] "Joint position (typ: axis.0.motor-pos-cmd)"; +pin in real fb-#[9 : personality] "Joint feedback (typ from encoder and input to pid controller (pid.feedback))"; + +pin out real offset-current-#[9 : personality]"Joint offset current value"; +pin out real pos-plusoffset-#[9 : personality] "Computed joint position plus offset (typically connect to pid command input)"; +pin out real fb-minusoffset-#[9 : personality] "Computed Joint feedback minus offset (typically connected to axis.0.motor-pos-fb)"; + +pin in real offset-vel-#[9 : personality]=10 "Joint offset velocity limit"; +pin in real offset-accel-#[9 : personality]=100 "Joint offset acceleration limit"; +pin in real offset-min-#[9 : personality] = -1e20 "Minimum limit for applied joint offset (typ negative)"; +pin in real offset-max-#[9 : personality] = 1e20 "Maximum limit for applied offset (typ positive)"; // inputs for debugging: -pin in bit dbg_waypoint_limit_test "Debug input to test with limited number of waypoints"; +pin in bool dbg_waypoint_limit_test "Debug input to test with limited number of waypoints"; // outputs for debugging: -pin out s32 dbg_state "Debug output for current state of state machine"; +pin out si32 dbg_state "Debug output for current state of state machine"; option personality; option extra_setup; @@ -150,21 +150,21 @@ typedef enum { typedef struct { int state[NCHANNELS]; - hal_float_t old_in[NCHANNELS]; - hal_float_t old_out[NCHANNELS]; - hal_float_t old_v[NCHANNELS]; - hal_float_t old_limited_in[NCHANNELS]; + rtapi_real old_in[NCHANNELS]; + rtapi_real old_out[NCHANNELS]; + rtapi_real old_v[NCHANNELS]; + rtapi_real old_limited_in[NCHANNELS]; } old_values_t; struct lim3_input { - hal_float_t minlimit; - hal_float_t maxlimit; - hal_float_t maxvlimit; - hal_float_t maxalimit; - hal_float_t in; - hal_float_t old_in; - hal_float_t old_out; - hal_float_t old_v; + rtapi_real minlimit; + rtapi_real maxlimit; + rtapi_real maxvlimit; + rtapi_real maxalimit; + rtapi_real in; + rtapi_real old_in; + rtapi_real old_out; + rtapi_real old_v; }; static void reset_old(int nchan, old_values_t* d) { @@ -177,7 +177,7 @@ static void reset_old(int nchan, old_values_t* d) { } } -static int offset_removed(int nchan, old_values_t d, hal_float_t eps) { +static int offset_removed(int nchan, old_values_t d, rtapi_real eps) { int removed = 1; int i; for (i = 0 ; i < nchan ; i++) { @@ -190,8 +190,8 @@ static int offset_removed(int nchan, old_values_t d, hal_float_t eps) { } static int at_waypoint(int nchan, - hal_float_t g[], - hal_float_t p[],hal_float_t eps) { + rtapi_real g[], + rtapi_real p[], rtapi_real eps) { int within_eps = 1; int i; @@ -206,17 +206,17 @@ static int at_waypoint(int nchan, static long theperiod; static void lim3(struct lim3_input input, - hal_float_t* old_in, - hal_float_t* limited_out, - hal_float_t* old_v + rtapi_real* old_in, + rtapi_real* limited_out, + rtapi_real* old_v ) { /* following code is adapted from limit3.comp */ - hal_float_t dt = theperiod * 1e-9; - hal_float_t in_v, min_v, max_v, avg_v; - hal_float_t min_out,max_out; - hal_float_t ramp_a, match_time, est_in, est_out; - hal_float_t err, dv, dp; - hal_float_t limited_in; + rtapi_real dt = theperiod * 1e-9; + rtapi_real in_v, min_v, max_v, avg_v; + rtapi_real min_out,max_out; + rtapi_real ramp_a, match_time, est_in, est_out; + rtapi_real err, dv, dp; + rtapi_real limited_in; /* apply first order limit */ limited_in = input.in; @@ -289,18 +289,18 @@ static the_state state = IDLE; static int next_waypoint_index; static rtapi_s64 last_waypoint_time; static rtapi_s64 now; -static hal_float_t time_since_last_sample; -static hal_float_t move_threshold; -static hal_float_t min_sample_interval; +static rtapi_real time_since_last_sample; +static rtapi_real move_threshold; +static rtapi_real min_sample_interval; static bool backtrack; static bool gave_msg; static int max_waypoints = NWAYPOINTS; static struct lim3_input input; -static hal_float_t goal[NCHANNELS]; -static hal_float_t waypoints[NCHANNELS][NWAYPOINTS]; +static rtapi_real goal[NCHANNELS]; +static rtapi_real waypoints[NCHANNELS][NWAYPOINTS]; static old_values_t data; -static hal_float_t eps_in_use; +static rtapi_real eps_in_use; static bool move_in_progress = 0; static the_state next_state; @@ -313,7 +313,7 @@ static const bool allow_backtrack_enable_change = 1; // (e.g., unlimited no. of offset samples) FUNCTION(read_inputs) { - hal_float_t last,delta; + rtapi_real last,delta; int r; bool all_enables = power_on && move_enable && apply_offsets; @@ -344,7 +344,7 @@ FUNCTION(read_inputs) { int r; bool sufficient_movement_for_new_waypoint = 0; - time_since_last_sample = (hal_float_t)(now - last_waypoint_time)/1e9; + time_since_last_sample = (rtapi_real)(now - last_waypoint_time)/1e9; switch (state) { case IDLE: next_waypoint_index = 0; @@ -369,9 +369,9 @@ FUNCTION(read_inputs) { last_waypoint_time = now; next_waypoint_index++; if (next_waypoint_index > max_waypoints - 1) { - waypoint_limit = 1; + waypoint_limit_set(1); } else { - waypoint_limit = 0; + waypoint_limit_set(0); } break; case MOVE_BACK: break; @@ -404,7 +404,7 @@ FUNCTION(read_inputs) { if (!power_on) { reset_old(personality, &data); move_in_progress = 0; - offset_applied = 0; + offset_applied_set(0); next_state = IDLE; break; } @@ -416,7 +416,7 @@ FUNCTION(read_inputs) { for (r = 0; r < personality; r++) { goal[r] = waypoints[r][next_waypoint_index-1]; } - waypoint_limit = 0; + waypoint_limit_set(0); next_waypoint_index--; } } @@ -426,14 +426,14 @@ FUNCTION(read_inputs) { if (!power_on) { reset_old(personality, &data); move_in_progress = 0; - offset_applied = 0; + offset_applied_set(0); next_state = IDLE; break; } move_in_progress = 1; if (backtrack) { if ( next_waypoint_index > 0 ) { - hal_float_t pcur[NCHANNELS]; + rtapi_real pcur[NCHANNELS]; for (r=0; r < personality; r++) { pcur[r] = offset_current(r); } @@ -462,7 +462,7 @@ FUNCTION(read_inputs) { if ( !apply_offsets && offset_applied ) { - warning = 1; + warning_set(1); if (!gave_msg) { // apply_offsets deasserted while offset_applied // for example: @@ -482,7 +482,7 @@ FUNCTION(read_inputs) { } } else { gave_msg = 0; - warning = 0; + warning_set(0); } //}end state control } //read_inputs @@ -505,35 +505,35 @@ FUNCTION(write_outputs) { if ( waypoint_limit && (state == MOVE_AWAY) ) { // no movement in MOVE_AWAY (require: remove enable) } else { - hal_float_t last_old = data.old_out[r]; + rtapi_real last_old = data.old_out[r]; lim3(input, &data.old_in[r], &data.old_out[r], &data.old_v[r] ); - offset_current(r) = data.old_out[r]; - fb_minusoffset(r) = fb(r) - offset_current(r) - - (last_old - data.old_out[r]); - pos_plusoffset(r) = pos(r) + offset_current(r); + offset_current_set(r, data.old_out[r]); + fb_minusoffset_set(r, fb(r) - offset_current(r) + - (last_old - data.old_out[r])); + pos_plusoffset_set(r, pos(r) + offset_current(r)); } } else { - pos_plusoffset(r) = pos(r); - offset_current(r) = 0; - fb_minusoffset(r) = fb(r); + pos_plusoffset_set(r, pos(r)); + offset_current_set(r, 0); + fb_minusoffset_set(r, fb(r)); } } - offset_applied = ! offset_removed(personality, data, eps_in_use); + offset_applied_set(! offset_removed(personality, data, eps_in_use)); if ( !offset_applied ) { // reset backtrack next_waypoint_index = 0; - waypoint_limit = 0; + waypoint_limit_set(0); } - waypoint_ct = next_waypoint_index; - waypoint_percent_used = 100*next_waypoint_index/max_waypoints; + waypoint_ct_set(next_waypoint_index); + waypoint_percent_used_set(100*next_waypoint_index/max_waypoints); - dbg_state = state; + dbg_state_set(state); state = next_state; } //write_outputs diff --git a/src/hal/components/sim_axis_hardware.comp b/src/hal/components/sim_axis_hardware.comp index b89fdbc966d..8a77da95298 100644 --- a/src/hal/components/sim_axis_hardware.comp +++ b/src/hal/components/sim_axis_hardware.comp @@ -7,156 +7,156 @@ This component creates simulated home and limit switches based on the current po It currently can supply simulation for X, tandem X, Y, tandem Y, Z, U, V, and A axes. """; -pin in float Xcurrent_pos "The current position on the axis - eg connect to joint.0.motor-pos-fb"; -pin in float X2current_pos; -pin in float Ycurrent_pos; -pin in float Y2current_pos; -pin in float Zcurrent_pos; -pin in float Acurrent_pos; -pin in float Ucurrent_pos; -pin in float Vcurrent_pos; - -pin in float Xhomesw_pos =1 "The position of the home switch"; -pin in float X2homesw_pos =1; -pin in float Yhomesw_pos =1; -pin in float Y2homesw_pos =1; -pin in float Zhomesw_pos =1; -pin in float Ahomesw_pos =1; -pin in float Uhomesw_pos =1; -pin in float Vhomesw_pos =1; - -pin in float Xmaxsw_upper "The upper range of the maximum limit switch, above this is false."; -pin in float X2maxsw_upper; -pin in float Ymaxsw_upper; -pin in float Y2maxsw_upper; -pin in float Zmaxsw_upper; -pin in float Amaxsw_upper; -pin in float Umaxsw_upper; -pin in float Vmaxsw_upper; - -pin in float Xmaxsw_lower "The lower range of the maximum limit switch, below this is false."; -pin in float X2maxsw_lower; -pin in float Ymaxsw_lower; -pin in float Y2maxsw_lower; -pin in float Zmaxsw_lower; -pin in float Amaxsw_lower; -pin in float Umaxsw_lower; -pin in float Vmaxsw_lower; - -pin in float Xminsw_upper "The upper range of the minimum limit switch, above this is false."; -pin in float X2minsw_upper; -pin in float Yminsw_upper; -pin in float Y2minsw_upper; -pin in float Zminsw_upper; -pin in float Aminsw_upper; -pin in float Uminsw_upper; -pin in float Vminsw_upper; - -pin in float Xminsw_lower "The lower range of the minimum limit switch, below this is false."; -pin in float X2minsw_lower; -pin in float Yminsw_lower; -pin in float Y2minsw_lower; -pin in float Zminsw_lower; -pin in float Aminsw_lower; -pin in float Uminsw_lower; -pin in float Vminsw_lower; - -pin in float Xhomesw_hyst =.025 "range that home switch will be true +- half this to the home position"; -pin in float X2homesw_hyst =.025; -pin in float Yhomesw_hyst =.025; -pin in float Y2homesw_hyst =.025; -pin in float Zhomesw_hyst =.025; -pin in float Ahomesw_hyst =.025; -pin in float Uhomesw_hyst =.025; -pin in float Vhomesw_hyst =.025; - -pin in bit Xhoming "True is homing in progress"; -pin in bit X2homing; -pin in bit Yhoming; -pin in bit Y2homing; -pin in bit Zhoming; -pin in bit Ahoming; -pin in bit Uhoming; -pin in bit Vhoming; - -pin out bit Xhomesw_out "Home switch for the X axis"; -pin out bit X2homesw_out; -pin out bit Yhomesw_out; -pin out bit Y2homesw_out; -pin out bit Zhomesw_out; -pin out bit Ahomesw_out; -pin out bit Uhomesw_out; -pin out bit Vhomesw_out; -pin out bit homesw_all; - -pin out bit Xmaxsw_out "Max limit switch"; -pin out bit Xminsw_out "min limit switch"; -pin out bit Xbothsw_out "True for both max and min limit switch"; - -pin out bit X2maxsw_out; -pin out bit X2minsw_out; -pin out bit X2bothsw_out; - -pin out bit Ymaxsw_out; -pin out bit Yminsw_out; -pin out bit Ybothsw_out; - -pin out bit Y2maxsw_out; -pin out bit Y2minsw_out; -pin out bit Y2bothsw_out; - -pin out bit Zmaxsw_out; -pin out bit Zminsw_out; -pin out bit Zbothsw_out; - -pin out bit Amaxsw_out; -pin out bit Aminsw_out; -pin out bit Abothsw_out; - -pin out bit Umaxsw_out; -pin out bit Uminsw_out; -pin out bit Ubothsw_out; - -pin out bit Vmaxsw_out; -pin out bit Vminsw_out; -pin out bit Vbothsw_out; - -pin out bit limitsw_all; -pin out bit limitsw_homesw_all "True for all limits and all home."; - -pin out bit Xmaxsw_homesw_out; -pin out bit Xminsw_homesw_out; -pin out bit Xbothsw_homesw_out; - -pin out bit X2maxsw_homesw_out; -pin out bit X2minsw_homesw_out; -pin out bit X2bothsw_homesw_out; - -pin out bit Ymaxsw_homesw_out; -pin out bit Yminsw_homesw_out; -pin out bit Ybothsw_homesw_out; - -pin out bit Y2maxsw_homesw_out; -pin out bit Y2minsw_homesw_out; -pin out bit Y2bothsw_homesw_out; - -pin out bit Zmaxsw_homesw_out; -pin out bit Zminsw_homesw_out; -pin out bit Zbothsw_homesw_out; - -pin out bit Amaxsw_homesw_out; -pin out bit Aminsw_homesw_out; -pin out bit Abothsw_homesw_out; - -pin out bit Umaxsw_homesw_out; -pin out bit Uminsw_homesw_out; -pin out bit Ubothsw_homesw_out; - -pin out bit Vmaxsw_homesw_out; -pin out bit Vminsw_homesw_out; -pin out bit Vbothsw_homesw_out; - -pin in float limit_offset =.01 "how much the limit switches are offset from inputted position. added to max, subtracted from min"; +pin in real Xcurrent_pos "The current position on the axis - eg connect to joint.0.motor-pos-fb"; +pin in real X2current_pos; +pin in real Ycurrent_pos; +pin in real Y2current_pos; +pin in real Zcurrent_pos; +pin in real Acurrent_pos; +pin in real Ucurrent_pos; +pin in real Vcurrent_pos; + +pin in real Xhomesw_pos =1 "The position of the home switch"; +pin in real X2homesw_pos =1; +pin in real Yhomesw_pos =1; +pin in real Y2homesw_pos =1; +pin in real Zhomesw_pos =1; +pin in real Ahomesw_pos =1; +pin in real Uhomesw_pos =1; +pin in real Vhomesw_pos =1; + +pin in real Xmaxsw_upper "The upper range of the maximum limit switch, above this is false."; +pin in real X2maxsw_upper; +pin in real Ymaxsw_upper; +pin in real Y2maxsw_upper; +pin in real Zmaxsw_upper; +pin in real Amaxsw_upper; +pin in real Umaxsw_upper; +pin in real Vmaxsw_upper; + +pin in real Xmaxsw_lower "The lower range of the maximum limit switch, below this is false."; +pin in real X2maxsw_lower; +pin in real Ymaxsw_lower; +pin in real Y2maxsw_lower; +pin in real Zmaxsw_lower; +pin in real Amaxsw_lower; +pin in real Umaxsw_lower; +pin in real Vmaxsw_lower; + +pin in real Xminsw_upper "The upper range of the minimum limit switch, above this is false."; +pin in real X2minsw_upper; +pin in real Yminsw_upper; +pin in real Y2minsw_upper; +pin in real Zminsw_upper; +pin in real Aminsw_upper; +pin in real Uminsw_upper; +pin in real Vminsw_upper; + +pin in real Xminsw_lower "The lower range of the minimum limit switch, below this is false."; +pin in real X2minsw_lower; +pin in real Yminsw_lower; +pin in real Y2minsw_lower; +pin in real Zminsw_lower; +pin in real Aminsw_lower; +pin in real Uminsw_lower; +pin in real Vminsw_lower; + +pin in real Xhomesw_hyst =.025 "range that home switch will be true +- half this to the home position"; +pin in real X2homesw_hyst =.025; +pin in real Yhomesw_hyst =.025; +pin in real Y2homesw_hyst =.025; +pin in real Zhomesw_hyst =.025; +pin in real Ahomesw_hyst =.025; +pin in real Uhomesw_hyst =.025; +pin in real Vhomesw_hyst =.025; + +pin in bool Xhoming "True is homing in progress"; +pin in bool X2homing; +pin in bool Yhoming; +pin in bool Y2homing; +pin in bool Zhoming; +pin in bool Ahoming; +pin in bool Uhoming; +pin in bool Vhoming; + +pin out bool Xhomesw_out "Home switch for the X axis"; +pin out bool X2homesw_out; +pin out bool Yhomesw_out; +pin out bool Y2homesw_out; +pin out bool Zhomesw_out; +pin out bool Ahomesw_out; +pin out bool Uhomesw_out; +pin out bool Vhomesw_out; +pin out bool homesw_all; + +pin out bool Xmaxsw_out "Max limit switch"; +pin out bool Xminsw_out "min limit switch"; +pin out bool Xbothsw_out "True for both max and min limit switch"; + +pin out bool X2maxsw_out; +pin out bool X2minsw_out; +pin out bool X2bothsw_out; + +pin out bool Ymaxsw_out; +pin out bool Yminsw_out; +pin out bool Ybothsw_out; + +pin out bool Y2maxsw_out; +pin out bool Y2minsw_out; +pin out bool Y2bothsw_out; + +pin out bool Zmaxsw_out; +pin out bool Zminsw_out; +pin out bool Zbothsw_out; + +pin out bool Amaxsw_out; +pin out bool Aminsw_out; +pin out bool Abothsw_out; + +pin out bool Umaxsw_out; +pin out bool Uminsw_out; +pin out bool Ubothsw_out; + +pin out bool Vmaxsw_out; +pin out bool Vminsw_out; +pin out bool Vbothsw_out; + +pin out bool limitsw_all; +pin out bool limitsw_homesw_all "True for all limits and all home."; + +pin out bool Xmaxsw_homesw_out; +pin out bool Xminsw_homesw_out; +pin out bool Xbothsw_homesw_out; + +pin out bool X2maxsw_homesw_out; +pin out bool X2minsw_homesw_out; +pin out bool X2bothsw_homesw_out; + +pin out bool Ymaxsw_homesw_out; +pin out bool Yminsw_homesw_out; +pin out bool Ybothsw_homesw_out; + +pin out bool Y2maxsw_homesw_out; +pin out bool Y2minsw_homesw_out; +pin out bool Y2bothsw_homesw_out; + +pin out bool Zmaxsw_homesw_out; +pin out bool Zminsw_homesw_out; +pin out bool Zbothsw_homesw_out; + +pin out bool Amaxsw_homesw_out; +pin out bool Aminsw_homesw_out; +pin out bool Abothsw_homesw_out; + +pin out bool Umaxsw_homesw_out; +pin out bool Uminsw_homesw_out; +pin out bool Ubothsw_homesw_out; + +pin out bool Vmaxsw_homesw_out; +pin out bool Vminsw_homesw_out; +pin out bool Vbothsw_homesw_out; + +pin in real limit_offset =.01 "how much the limit switches are offset from inputted position. added to max, subtracted from min"; option period no; function update; @@ -165,9 +165,9 @@ author "Chris S Morley"; ;; /* private comparator function */ - int comp(double in0, double in1, double hyst) { - double tmp; - double halfhyst; + int comp(rtapi_real in0, rtapi_real in1, rtapi_real hyst) { + rtapi_real tmp; + rtapi_real halfhyst; tmp = in1 - in0; halfhyst = 0.5 * hyst; @@ -181,7 +181,7 @@ author "Chris S Morley"; } /* private window comparator function */ - int wcomp (double in, double max_, double min_){ + int wcomp (rtapi_real in, rtapi_real max_, rtapi_real min_){ return !((in >= max_)|| (in <= min_)); } @@ -189,82 +189,82 @@ author "Chris S Morley"; FUNCTION(update) { /*set home switches */ -Xhomesw_out = comp(Xhomesw_pos,Xcurrent_pos,Xhomesw_hyst); -X2homesw_out = comp(X2homesw_pos,X2current_pos,X2homesw_hyst); -Yhomesw_out = comp(Yhomesw_pos,Ycurrent_pos,Yhomesw_hyst); -Y2homesw_out = comp(Y2homesw_pos,Y2current_pos,Y2homesw_hyst); -Zhomesw_out = comp(Zhomesw_pos,Zcurrent_pos,Zhomesw_hyst); -Ahomesw_out = comp(Ahomesw_pos,Acurrent_pos,Ahomesw_hyst); -Uhomesw_out = comp(Uhomesw_pos,Ucurrent_pos,Uhomesw_hyst); -Vhomesw_out = comp(Vhomesw_pos,Vcurrent_pos,Vhomesw_hyst); +Xhomesw_out_set(comp(Xhomesw_pos,Xcurrent_pos,Xhomesw_hyst)); +X2homesw_out_set(comp(X2homesw_pos,X2current_pos,X2homesw_hyst)); +Yhomesw_out_set(comp(Yhomesw_pos,Ycurrent_pos,Yhomesw_hyst)); +Y2homesw_out_set(comp(Y2homesw_pos,Y2current_pos,Y2homesw_hyst)); +Zhomesw_out_set(comp(Zhomesw_pos,Zcurrent_pos,Zhomesw_hyst)); +Ahomesw_out_set(comp(Ahomesw_pos,Acurrent_pos,Ahomesw_hyst)); +Uhomesw_out_set(comp(Uhomesw_pos,Ucurrent_pos,Uhomesw_hyst)); +Vhomesw_out_set(comp(Vhomesw_pos,Vcurrent_pos,Vhomesw_hyst)); int homing = Xhoming || X2homing || Yhoming || Y2homing || Zhoming || Ahoming || Uhoming || Vhoming; -homesw_all = (Xhomesw_out || X2homesw_out || Yhomesw_out || Y2homesw_out || - Zhomesw_out || Ahomesw_out || Uhomesw_out || Vhomesw_out) && homing; +homesw_all_set((Xhomesw_out || X2homesw_out || Yhomesw_out || Y2homesw_out || + Zhomesw_out || Ahomesw_out || Uhomesw_out || Vhomesw_out) && homing); /* set limit switches */ -Xmaxsw_out = wcomp(Xcurrent_pos,Xmaxsw_upper,Xmaxsw_lower+limit_offset); -Xminsw_out = wcomp(Xcurrent_pos,Xminsw_upper-limit_offset,Xminsw_lower); -Xbothsw_out = (Xmaxsw_out || Xminsw_out) && !homing; +Xmaxsw_out_set(wcomp(Xcurrent_pos,Xmaxsw_upper,Xmaxsw_lower+limit_offset)); +Xminsw_out_set(wcomp(Xcurrent_pos,Xminsw_upper-limit_offset,Xminsw_lower)); +Xbothsw_out_set((Xmaxsw_out || Xminsw_out) && !homing); -X2maxsw_out = wcomp(X2current_pos,X2maxsw_upper,X2maxsw_lower+limit_offset); -X2minsw_out = wcomp(X2current_pos,X2minsw_upper-limit_offset,X2minsw_lower); -X2bothsw_out = (X2maxsw_out || X2minsw_out) && !homing; +X2maxsw_out_set(wcomp(X2current_pos,X2maxsw_upper,X2maxsw_lower+limit_offset)); +X2minsw_out_set(wcomp(X2current_pos,X2minsw_upper-limit_offset,X2minsw_lower)); +X2bothsw_out_set((X2maxsw_out || X2minsw_out) && !homing); -Ymaxsw_out = wcomp(Ycurrent_pos,Ymaxsw_upper,Ymaxsw_lower+limit_offset); -Yminsw_out = wcomp(Ycurrent_pos,Yminsw_upper-limit_offset,Yminsw_lower); -Ybothsw_out = (Ymaxsw_out || Yminsw_out) && !homing; +Ymaxsw_out_set(wcomp(Ycurrent_pos,Ymaxsw_upper,Ymaxsw_lower+limit_offset)); +Yminsw_out_set(wcomp(Ycurrent_pos,Yminsw_upper-limit_offset,Yminsw_lower)); +Ybothsw_out_set((Ymaxsw_out || Yminsw_out) && !homing); -Y2maxsw_out = wcomp(Y2current_pos,Y2maxsw_upper,Y2maxsw_lower+limit_offset); -Y2minsw_out = wcomp(Y2current_pos,Y2minsw_upper-limit_offset,Y2minsw_lower); -Y2bothsw_out = (Y2maxsw_out || Y2minsw_out) && !homing; +Y2maxsw_out_set(wcomp(Y2current_pos,Y2maxsw_upper,Y2maxsw_lower+limit_offset)); +Y2minsw_out_set(wcomp(Y2current_pos,Y2minsw_upper-limit_offset,Y2minsw_lower)); +Y2bothsw_out_set((Y2maxsw_out || Y2minsw_out) && !homing); -Zmaxsw_out = wcomp(Zcurrent_pos,Zmaxsw_upper,Zmaxsw_lower+limit_offset); -Zminsw_out = wcomp(Zcurrent_pos,Zminsw_upper-limit_offset,Zminsw_lower); -Zbothsw_out = (Zmaxsw_out || Zminsw_out) && !homing; +Zmaxsw_out_set(wcomp(Zcurrent_pos,Zmaxsw_upper,Zmaxsw_lower+limit_offset)); +Zminsw_out_set(wcomp(Zcurrent_pos,Zminsw_upper-limit_offset,Zminsw_lower)); +Zbothsw_out_set((Zmaxsw_out || Zminsw_out) && !homing); -Amaxsw_out = wcomp(Acurrent_pos,Amaxsw_upper,Amaxsw_lower+limit_offset); -Aminsw_out = wcomp(Acurrent_pos,Aminsw_upper-limit_offset,Aminsw_lower); -Abothsw_out = (Amaxsw_out || Aminsw_out) && !homing; +Amaxsw_out_set(wcomp(Acurrent_pos,Amaxsw_upper,Amaxsw_lower+limit_offset)); +Aminsw_out_set(wcomp(Acurrent_pos,Aminsw_upper-limit_offset,Aminsw_lower)); +Abothsw_out_set((Amaxsw_out || Aminsw_out) && !homing); -Umaxsw_out = wcomp(Ucurrent_pos,Umaxsw_upper,Umaxsw_lower+limit_offset); -Uminsw_out = wcomp(Ucurrent_pos,Uminsw_upper-limit_offset,Uminsw_lower); -Ubothsw_out = (Umaxsw_out || Uminsw_out) && !homing; +Umaxsw_out_set(wcomp(Ucurrent_pos,Umaxsw_upper,Umaxsw_lower+limit_offset)); +Uminsw_out_set(wcomp(Ucurrent_pos,Uminsw_upper-limit_offset,Uminsw_lower)); +Ubothsw_out_set((Umaxsw_out || Uminsw_out) && !homing); -Vmaxsw_out = wcomp(Vcurrent_pos,Vmaxsw_upper,Vmaxsw_lower+limit_offset); -Vminsw_out = wcomp(Vcurrent_pos,Vminsw_upper-limit_offset,Vminsw_lower); -Vbothsw_out = (Vmaxsw_out || Vminsw_out) && !homing; +Vmaxsw_out_set(wcomp(Vcurrent_pos,Vmaxsw_upper,Vmaxsw_lower+limit_offset)); +Vminsw_out_set(wcomp(Vcurrent_pos,Vminsw_upper-limit_offset,Vminsw_lower)); +Vbothsw_out_set((Vmaxsw_out || Vminsw_out) && !homing); -limitsw_all = (Xbothsw_out || X2bothsw_out || Ybothsw_out || Y2bothsw_out +limitsw_all_set(Xbothsw_out || X2bothsw_out || Ybothsw_out || Y2bothsw_out || Zbothsw_out || Abothsw_out || Ubothsw_out || Vbothsw_out); /* set limit and home switches */ -limitsw_homesw_all = (homesw_all || limitsw_all); -Xmaxsw_homesw_out = (Xmaxsw_out || Xhomesw_out); -Xminsw_homesw_out = (Xminsw_out || Xhomesw_out); -Xbothsw_homesw_out = (Xbothsw_out || Xhomesw_out); - -X2maxsw_homesw_out = (X2maxsw_out || X2homesw_out); -X2minsw_homesw_out = (X2minsw_out || X2homesw_out); -X2bothsw_homesw_out = (X2bothsw_out || X2homesw_out); - -Ymaxsw_homesw_out = (Ymaxsw_out || Yhomesw_out); -Yminsw_homesw_out = (Yminsw_out || Yhomesw_out); -Ybothsw_homesw_out = (Ybothsw_out || Yhomesw_out); - -Y2maxsw_homesw_out = (Y2maxsw_out || Y2homesw_out); -Y2minsw_homesw_out = (Y2minsw_out || Y2homesw_out); -Y2bothsw_homesw_out = (Y2bothsw_out || Y2homesw_out); - -Zmaxsw_homesw_out = (Zmaxsw_out || Zhomesw_out); -Zminsw_homesw_out = (Zminsw_out || Zhomesw_out); -Zbothsw_homesw_out = (Zbothsw_out || Zhomesw_out); - -Umaxsw_homesw_out = (Umaxsw_out || Uhomesw_out); -Uminsw_homesw_out = (Uminsw_out || Uhomesw_out); -Ubothsw_homesw_out = (Ubothsw_out || Uhomesw_out); - -Vmaxsw_homesw_out = (Vmaxsw_out || Vhomesw_out); -Vminsw_homesw_out = (Vminsw_out || Vhomesw_out); -Vbothsw_homesw_out = (Vbothsw_out || Vhomesw_out); +limitsw_homesw_all_set((homesw_all || limitsw_all)); +Xmaxsw_homesw_out_set((Xmaxsw_out || Xhomesw_out)); +Xminsw_homesw_out_set((Xminsw_out || Xhomesw_out)); +Xbothsw_homesw_out_set((Xbothsw_out || Xhomesw_out)); + +X2maxsw_homesw_out_set((X2maxsw_out || X2homesw_out)); +X2minsw_homesw_out_set((X2minsw_out || X2homesw_out)); +X2bothsw_homesw_out_set((X2bothsw_out || X2homesw_out)); + +Ymaxsw_homesw_out_set((Ymaxsw_out || Yhomesw_out)); +Yminsw_homesw_out_set((Yminsw_out || Yhomesw_out)); +Ybothsw_homesw_out_set((Ybothsw_out || Yhomesw_out)); + +Y2maxsw_homesw_out_set((Y2maxsw_out || Y2homesw_out)); +Y2minsw_homesw_out_set((Y2minsw_out || Y2homesw_out)); +Y2bothsw_homesw_out_set((Y2bothsw_out || Y2homesw_out)); + +Zmaxsw_homesw_out_set((Zmaxsw_out || Zhomesw_out)); +Zminsw_homesw_out_set((Zminsw_out || Zhomesw_out)); +Zbothsw_homesw_out_set((Zbothsw_out || Zhomesw_out)); + +Umaxsw_homesw_out_set((Umaxsw_out || Uhomesw_out)); +Uminsw_homesw_out_set((Uminsw_out || Uhomesw_out)); +Ubothsw_homesw_out_set((Ubothsw_out || Uhomesw_out)); + +Vmaxsw_homesw_out_set((Vmaxsw_out || Vhomesw_out)); +Vminsw_homesw_out_set((Vminsw_out || Vhomesw_out)); +Vbothsw_homesw_out_set((Vbothsw_out || Vhomesw_out)); } diff --git a/src/hal/components/sim_parport.comp b/src/hal/components/sim_parport.comp index 44e44486ffa..a8f6ea5a46d 100644 --- a/src/hal/components/sim_parport.comp +++ b/src/hal/components/sim_parport.comp @@ -28,101 +28,101 @@ The read and write functions pass the logic from pins to fake pins or vice vera The reset function is a no operation. """; -pin in bit pin_01_out; -pin in bit pin_02_out; -pin in bit pin_03_out; -pin in bit pin_04_out; -pin in bit pin_05_out; -pin in bit pin_06_out; -pin in bit pin_07_out; -pin in bit pin_08_out; -pin in bit pin_09_out; -pin in bit pin_14_out; -pin in bit pin_16_out; -pin in bit pin_17_out; - -pin out bit pin_01_out_fake; -pin out bit pin_02_out_fake; -pin out bit pin_03_out_fake; -pin out bit pin_04_out_fake; -pin out bit pin_05_out_fake; -pin out bit pin_06_out_fake; -pin out bit pin_07_out_fake; -pin out bit pin_08_out_fake; -pin out bit pin_09_out_fake; -pin out bit pin_14_out_fake; -pin out bit pin_16_out_fake; -pin out bit pin_17_out_fake; - -param rw bit pin_01_out_invert; -param rw bit pin_02_out_invert; -param rw bit pin_03_out_invert; -param rw bit pin_04_out_invert; -param rw bit pin_05_out_invert; -param rw bit pin_06_out_invert; -param rw bit pin_07_out_invert; -param rw bit pin_08_out_invert; -param rw bit pin_09_out_invert; -param rw bit pin_14_out_invert; -param rw bit pin_16_out_invert; -param rw bit pin_17_out_invert; - -param rw bit pin_01_out_reset; -param rw bit pin_02_out_reset; -param rw bit pin_03_out_reset; -param rw bit pin_04_out_reset; -param rw bit pin_05_out_reset; -param rw bit pin_06_out_reset; -param rw bit pin_07_out_reset; -param rw bit pin_08_out_reset; -param rw bit pin_09_out_reset; -param rw bit pin_14_out_reset; -param rw bit pin_16_out_reset; -param rw bit pin_17_out_reset; - -pin out bit pin_02_in; -pin out bit pin_03_in; -pin out bit pin_04_in; -pin out bit pin_05_in; -pin out bit pin_06_in; -pin out bit pin_07_in; -pin out bit pin_08_in; -pin out bit pin_09_in; -pin out bit pin_10_in; -pin out bit pin_11_in; -pin out bit pin_12_in; -pin out bit pin_13_in; -pin out bit pin_15_in; - -pin in bit pin_02_in_fake; -pin in bit pin_03_in_fake; -pin in bit pin_04_in_fake; -pin in bit pin_05_in_fake; -pin in bit pin_06_in_fake; -pin in bit pin_07_in_fake; -pin in bit pin_08_in_fake; -pin in bit pin_09_in_fake; -pin in bit pin_10_in_fake; -pin in bit pin_11_in_fake; -pin in bit pin_12_in_fake; -pin in bit pin_13_in_fake; -pin in bit pin_15_in_fake; - -pin out bit pin_02_in_not; -pin out bit pin_03_in_not; -pin out bit pin_04_in_not; -pin out bit pin_05_in_not; -pin out bit pin_06_in_not; -pin out bit pin_07_in_not; -pin out bit pin_08_in_not; -pin out bit pin_09_in_not; -pin out bit pin_10_in_not; -pin out bit pin_11_in_not; -pin out bit pin_12_in_not; -pin out bit pin_13_in_not; -pin out bit pin_15_in_not; - -pin in float reset_time; +pin in bool pin_01_out; +pin in bool pin_02_out; +pin in bool pin_03_out; +pin in bool pin_04_out; +pin in bool pin_05_out; +pin in bool pin_06_out; +pin in bool pin_07_out; +pin in bool pin_08_out; +pin in bool pin_09_out; +pin in bool pin_14_out; +pin in bool pin_16_out; +pin in bool pin_17_out; + +pin out bool pin_01_out_fake; +pin out bool pin_02_out_fake; +pin out bool pin_03_out_fake; +pin out bool pin_04_out_fake; +pin out bool pin_05_out_fake; +pin out bool pin_06_out_fake; +pin out bool pin_07_out_fake; +pin out bool pin_08_out_fake; +pin out bool pin_09_out_fake; +pin out bool pin_14_out_fake; +pin out bool pin_16_out_fake; +pin out bool pin_17_out_fake; + +param rw bool pin_01_out_invert; +param rw bool pin_02_out_invert; +param rw bool pin_03_out_invert; +param rw bool pin_04_out_invert; +param rw bool pin_05_out_invert; +param rw bool pin_06_out_invert; +param rw bool pin_07_out_invert; +param rw bool pin_08_out_invert; +param rw bool pin_09_out_invert; +param rw bool pin_14_out_invert; +param rw bool pin_16_out_invert; +param rw bool pin_17_out_invert; + +param rw bool pin_01_out_reset; +param rw bool pin_02_out_reset; +param rw bool pin_03_out_reset; +param rw bool pin_04_out_reset; +param rw bool pin_05_out_reset; +param rw bool pin_06_out_reset; +param rw bool pin_07_out_reset; +param rw bool pin_08_out_reset; +param rw bool pin_09_out_reset; +param rw bool pin_14_out_reset; +param rw bool pin_16_out_reset; +param rw bool pin_17_out_reset; + +pin out bool pin_02_in; +pin out bool pin_03_in; +pin out bool pin_04_in; +pin out bool pin_05_in; +pin out bool pin_06_in; +pin out bool pin_07_in; +pin out bool pin_08_in; +pin out bool pin_09_in; +pin out bool pin_10_in; +pin out bool pin_11_in; +pin out bool pin_12_in; +pin out bool pin_13_in; +pin out bool pin_15_in; + +pin in bool pin_02_in_fake; +pin in bool pin_03_in_fake; +pin in bool pin_04_in_fake; +pin in bool pin_05_in_fake; +pin in bool pin_06_in_fake; +pin in bool pin_07_in_fake; +pin in bool pin_08_in_fake; +pin in bool pin_09_in_fake; +pin in bool pin_10_in_fake; +pin in bool pin_11_in_fake; +pin in bool pin_12_in_fake; +pin in bool pin_13_in_fake; +pin in bool pin_15_in_fake; + +pin out bool pin_02_in_not; +pin out bool pin_03_in_not; +pin out bool pin_04_in_not; +pin out bool pin_05_in_not; +pin out bool pin_06_in_not; +pin out bool pin_07_in_not; +pin out bool pin_08_in_not; +pin out bool pin_09_in_not; +pin out bool pin_10_in_not; +pin out bool pin_11_in_not; +pin out bool pin_12_in_not; +pin out bool pin_13_in_not; +pin out bool pin_15_in_not; + +pin in real reset_time; option period no; function read; @@ -134,50 +134,50 @@ author "Chris S Morley"; FUNCTION(read) { -pin_02_in = pin_02_in_fake; -pin_03_in = pin_03_in_fake; -pin_04_in = pin_04_in_fake; -pin_05_in = pin_05_in_fake; -pin_06_in = pin_06_in_fake; -pin_07_in = pin_07_in_fake; -pin_08_in = pin_08_in_fake; -pin_09_in = pin_09_in_fake; -pin_10_in = pin_10_in_fake; -pin_11_in = pin_11_in_fake; -pin_12_in = pin_12_in_fake; -pin_13_in = pin_13_in_fake; -pin_15_in = pin_15_in_fake; - -pin_02_in_not = ! pin_02_in_fake; -pin_03_in_not = ! pin_03_in_fake; -pin_04_in_not = ! pin_04_in_fake; -pin_05_in_not = ! pin_05_in_fake; -pin_06_in_not = ! pin_06_in_fake; -pin_07_in_not = ! pin_07_in_fake; -pin_08_in_not = ! pin_08_in_fake; -pin_09_in_not = ! pin_09_in_fake; -pin_10_in_not = ! pin_10_in_fake; -pin_11_in_not = ! pin_11_in_fake; -pin_12_in_not = ! pin_12_in_fake; -pin_13_in_not = ! pin_13_in_fake; -pin_15_in_not = ! pin_15_in_fake; +pin_02_in_set(pin_02_in_fake); +pin_03_in_set(pin_03_in_fake); +pin_04_in_set(pin_04_in_fake); +pin_05_in_set(pin_05_in_fake); +pin_06_in_set(pin_06_in_fake); +pin_07_in_set(pin_07_in_fake); +pin_08_in_set(pin_08_in_fake); +pin_09_in_set(pin_09_in_fake); +pin_10_in_set(pin_10_in_fake); +pin_11_in_set(pin_11_in_fake); +pin_12_in_set(pin_12_in_fake); +pin_13_in_set(pin_13_in_fake); +pin_15_in_set(pin_15_in_fake); + +pin_02_in_not_set(! pin_02_in_fake); +pin_03_in_not_set(! pin_03_in_fake); +pin_04_in_not_set(! pin_04_in_fake); +pin_05_in_not_set(! pin_05_in_fake); +pin_06_in_not_set(! pin_06_in_fake); +pin_07_in_not_set(! pin_07_in_fake); +pin_08_in_not_set(! pin_08_in_fake); +pin_09_in_not_set(! pin_09_in_fake); +pin_10_in_not_set(! pin_10_in_fake); +pin_11_in_not_set(! pin_11_in_fake); +pin_12_in_not_set(! pin_12_in_fake); +pin_13_in_not_set(! pin_13_in_fake); +pin_15_in_not_set(! pin_15_in_fake); } FUNCTION(write) { - pin_01_out_fake = pin_01_out ^ pin_01_out_invert; - pin_02_out_fake = pin_02_out ^ pin_02_out_invert; - pin_03_out_fake = pin_03_out ^ pin_03_out_invert; - pin_04_out_fake = pin_04_out ^ pin_04_out_invert; - pin_05_out_fake = pin_05_out ^ pin_05_out_invert; - pin_06_out_fake = pin_06_out ^ pin_06_out_invert; - pin_07_out_fake = pin_07_out ^ pin_07_out_invert; - pin_08_out_fake = pin_08_out ^ pin_08_out_invert; - pin_09_out_fake = pin_09_out ^ pin_09_out_invert; - pin_14_out_fake = pin_14_out ^ pin_14_out_invert; - pin_16_out_fake = pin_16_out ^ pin_16_out_invert; - pin_17_out_fake = pin_17_out ^ pin_17_out_invert; + pin_01_out_fake_set(pin_01_out ^ pin_01_out_invert); + pin_02_out_fake_set(pin_02_out ^ pin_02_out_invert); + pin_03_out_fake_set(pin_03_out ^ pin_03_out_invert); + pin_04_out_fake_set(pin_04_out ^ pin_04_out_invert); + pin_05_out_fake_set(pin_05_out ^ pin_05_out_invert); + pin_06_out_fake_set(pin_06_out ^ pin_06_out_invert); + pin_07_out_fake_set(pin_07_out ^ pin_07_out_invert); + pin_08_out_fake_set(pin_08_out ^ pin_08_out_invert); + pin_09_out_fake_set(pin_09_out ^ pin_09_out_invert); + pin_14_out_fake_set(pin_14_out ^ pin_14_out_invert); + pin_16_out_fake_set(pin_16_out ^ pin_16_out_invert); + pin_17_out_fake_set(pin_17_out ^ pin_17_out_invert); } FUNCTION(reset) {