I’m a novice learning on the fly and I’ve been reading as much as my brain can absorb but I’m completely flummoxed. I’m trying to control a conveyor’s position by moving a pulley, based on and average value from an analog sensor. My first headache involved “negative” values of an unknown origin that were mucking up my control comparisons but I reluctantly used absolute values and some floats to get rid of that. My control values are nice and stable now but I cant get the conditional outputs for the stepper motor to work. It always executes the “else if” part of the logic, regardless of the relationship between the process value and the set-point, so the motor only goes one direction. I’m probably doing something remedially stupid but I can’t find it. I’ve attached the code. Admittedly, I’m a little lazy with annotations but it should be pretty straightforward. I’d appreciate any guidance that I can get but please try to contain the impulses to heap abuse: I’m already feeling plenty stupid.
conveyor.txt (2.44 KB)