As I mentioned the Open Propeller Project #8 thread
, I'm now keeping code I intend to share with the world in my GitHub repository
I am now longer maintaining two different versions of this code. I previously had a two motor/encoder version and a four motor/encoder version. Now the single version will work with any number of motors and encoders from one to possibly nine.
To tell the object how many motors/encoders you wish to use set the value of "TOTAL_ENCODERS" appropriately. The "TOTAL_ENCODERS" constant is presently located on line # 113 of the file "QuadratureMotors".
TOTAL_ENCODERS = 2
The object presently only works with quadrature encoders. I'm planning on making a modified version for use with single channel encoders.
Warning! The direction the encoders advance is opposite the earlier versions of this code used. I changed the lines:
update if_z mov encoderChange, one ' decrement value
decvalue if_nz mov encoderChange, negOne ' increment
update if_z mov encoderChange, negOne ' decrement value
decvalue if_nz mov encoderChange, one ' increment
I see I forgot to change the name "decvalue" to a more appropriate "incValue". I'll probably make the change the next commit.
If any of you want the encoder values to increment the same direction as the earlier code, you can change the lines above back to the original version.
I added a "ReverseMotor" method to allow one to swap the direction pins without needing to change the physical connections. If HB-25 or other motor controllers using servo pulses are used, the "ReverseMotor" will still have the effect of reversing the motor direction.
I haven't tested the code with all configurations of h-bridge wiring. I also haven't tested many of the methods lately. Please let me know if any of you find any problems.
The code attached to this post is buggy. I don't recommend using it. Use the code from GitHub.