concurrent motor control
kutalinelucas
Posts: 80
Hey guys...after a long break away from everything I'm trying to get one of my spin programs to work, and was wondering if somebody could give me a little advice.
I have an object named 'motors1&2' which recieves two variables; one identifying which motor to manipulate and the other the amount/direction of rotation.
The first time the object is called, two new cogs are started, each controlling one motor and is passed the amount of rotation.
Then, depending on which motor is to be actuated, the method is called:
All I'm looking to do is at this point, pass the 'reconstructed_data' variable to the motorone method, which should hopefully be run in a seperate cog, and return to the previous object.
The amount of rotation executed within the motorone method is defined by pausing the program for a determined amount of time, but the problem is that through this approach all other aspects of the program are also halted,
So I was wondering if somebody could help me out with this and any suggestions would be greatly appriciated.
Cheers
Lucas. (Archived project->) 4motorscntrl.zip
I have an object named 'motors1&2' which recieves two variables; one identifying which motor to manipulate and the other the amount/direction of rotation.
The first time the object is called, two new cogs are started, each controlling one motor and is passed the amount of rotation.
if(motor_setup == 0) 'this statement only triggers the first instance this method is called motors12.start(M1_PWM, M1_DIR, M2_PWM, M2_DIR, 2_500) 'sends motor variables to motor control object cognew(motorone(reconstructed_data), @Stack1) 'starts new cogs to control both motors one and two cognew(motortwo(reconstructed_data), @Stack2) motor_setup := 1
Then, depending on which motor is to be actuated, the method is called:
if(Motor_Ident == 1) ' motorone(reconstructed_data) return
All I'm looking to do is at this point, pass the 'reconstructed_data' variable to the motorone method, which should hopefully be run in a seperate cog, and return to the previous object.
The amount of rotation executed within the motorone method is defined by pausing the program for a determined amount of time, but the problem is that through this approach all other aspects of the program are also halted,
So I was wondering if somebody could help me out with this and any suggestions would be greatly appriciated.
Cheers
Lucas. (Archived project->) 4motorscntrl.zip
Comments