2 cognew instances with par
Im trying to modify the following object:
http://obex.parallax.com/objects/599/
It uses assembly code to essentially do PPM to drive an ESC connected to a brushless motor. The program is for one pin and i want to extend it for 2 pins i.e. running two motors.
I tried 2 approaches:
1) add parameters so i can do 2 cognew commands and start two instances of the assembly section but the trouble i have is how can i pass two parameters to cognew?
2) the dumber but simpler way to do it is to copy the same assembly code and give it a different name so i can have SingleServo1 and SingleServo2 but now when the code gets to the line
rdlong HighTime, par
i get the error "Error : Symbol already allocated here Loop"
i.e. i cant use par in two different data blocks containing assembly.
any suggestions?
http://obex.parallax.com/objects/599/
It uses assembly code to essentially do PPM to drive an ESC connected to a brushless motor. The program is for one pin and i want to extend it for 2 pins i.e. running two motors.
I tried 2 approaches:
1) add parameters so i can do 2 cognew commands and start two instances of the assembly section but the trouble i have is how can i pass two parameters to cognew?
2) the dumber but simpler way to do it is to copy the same assembly code and give it a different name so i can have SingleServo1 and SingleServo2 but now when the code gets to the line
rdlong HighTime, par
i get the error "Error : Symbol already allocated here Loop"
i.e. i cant use par in two different data blocks containing assembly.
any suggestions?
Comments
Now... I can't take credit for the features, I simply "liberated" them a very popular serial servo controller and implemented them -- pretty easily -- in the Propeller (again, thanks to its unique architecture). The attached demo uses my latest servo object to drive two channels and provides a nice menu that lets you bump either up or down, and shows you the current output for both.
[ Edit ] For the record, my servo driver creates pulses in the same manner as the assembly code you're using now. The difference is that it's not locked to a specific pin and can in fact work with up to eight outputs. Since the counter does the hard work of precise pulse generation, there is a lot time Spin to take care of loop overhead and making position/speed adjustments while the current channel pulse is active.