Hi- I am fairly new to Arduino. I am making a tensile tester where I am using a nema17 stepper motor, a controller, a rotary encoder and a load cell (Hx711 amplifier). I have assembled a makerbeam structure whereby the stepper mounted to a rotary screw moves a gantry up and down. The encoder reads a precise travel and the load cell reads how much resistance a clamped sample material stretches (until breaking) between the gantry and the load cell. I intend to take both continuous data streams and graph it.
The mechanics of this project work great so far. I have put together a bunch of code from examples I gather up and can now control the stepper speed and number of rotations via the serial monitor. The rotary encoder reports back its data. When I put that code together to do multiple tasks within the same look I noticed that the baud rate effects the speed of the stepper. It pauses between each step to read the encoder data and println to serial.
This pause is not the end of the world, but I would prefer a smooth motion. The complexity came when I added the load cell with the amplifier to the analog pins and read that within the same loop. Now the delay between each step is very long. It does report back to the serial monitor the wt in g as well as the encoder movement, but the pause between each stepper step is nearly 1 sec.
If I could get all moving smoothly it would be great.
Attached is my code so far. Please help. I have spent hours on this problem, read books and blogs. I know the issue is the loop. I know I could cheat by controlling the stepper with one Uno board and the others with another...but I would be much cooler the have one board do everything.
Thank you in advance - I promise to give back to the forum where I can.
Stepper_Encoder_Load_ver_106.ino (1.45 KB)