Dear community,
since i am new to the community (and arduino alltogether) id like to take a short moment to say hi and introduce myself. I am a 38 year old flight instructor from switzerland, and as a hobby fly radio controlled model jets. Technology is moving along, and me as an old "analog geek" am more and more confronted with digital solutions. A new project is now forcing me towards new technologies, so im taking this as chance to find my way into arduino programming.
Now to my problem (I have tried search function with little to no luck): I want to replicate a motion sensed by a 9 axis IMU (Have a GY9250 and BNO055 on the way to me). The motions that are placed upon the sensor need to be relayed via A4988 stepper controllers to stepper motors. To achieve higher top speeds i want to ramp the motors.
For this i have started using a sourcecode from iforce2d's youtube channel. I have adapted it to my arduino nano and have been able to get my motors running correctly on them.
There are 2 versions of the code online, one using interrupts, the other conventional, and i am not sure which one better suits my needs.
Here to my main questions and problems:
The code is designed to power a cnc unit, which is fed with fixed coordinates that are sequenced one behind the other. I do not need this, i need it to constantly update the target position.
As you can see in the code, at the end there are numerous orders to move the motors. They always ramp up the motor (constantly checking if the halfway point is reached), then move at full speed towards a rampdown point (total steps required minus rampup steps taken), and then stop at the desired at time of start before starting the next motion.
Problem: The motion would ramp up and down at each sensor readind, never ever reaching full speed.
What i want to do is the following:
1.) Instead of a fixed target value, use a constantly updated target value. (Goal: no ramping up and down but creating a smooth motion )
2.) Change the motion adressing from "steps to be taken" towards an absolute adressing system (e.g. heading value, correlating to an absolute step position North = 0, East =200 steps ....much like a cnc coordinate).
My first mayor problem: do i better use the interrupt code, or the "normal" code? I have not quite understood the use of interrupts, but i do understand it frees processing capacity (for example to read new sensor data meanwhile).
Id very much appreciate any hints, helps or program lines to get the project rolling at a bit faster pace than i can work out with google and youtube.
Best regards and many thanks in advance
Stepper4_linearSpeedInterrupt.ino (2.54 KB)