Shop OBEX P1 Docs P2 Docs Learn Events
concurrent motor control — Parallax Forums

concurrent motor control

kutalinelucaskutalinelucas Posts: 80
edited 2011-12-13 08:24 in Propeller 1
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.
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

  • kutalinelucaskutalinelucas Posts: 80
    edited 2011-12-13 08:24
    can see where I'm going wrong, I'm trying to call a method when really I should be declaring a global variable in this object, modifiying it and running an infinate loop within the subsequent cogs to check if any rotation info has been recieved in the initial cog. Will get on it and see where i end up
Sign In or Register to comment.