I have a thread about this up on the Lynxmotion site:
http://www.lynxmotion.net/viewtopic.php ... 607#p62607 This thread also has an attachment of the current sources.
However I thought I would also mention it here. Currently experimenting with the Roboclaw on my Tri-track and am trying to drive the motors using the encoder commands to drive both motors forward by some speed and for some distance. I may be doing something wrong but I am not currently getting the results I expect.
The code when I press the L1 button looks like:
Code:
IF (DualShock(2).bit2 = 0) and LastButton(1).bit2 THEN ;L1 Button test
; lets try to go forward about a feet, under the control of the encoder.
REncoderCnt = 1900 * 12 ; lets see how close this is
RencoderSpeed = 2500 ; It appeared like maybe 4700+ was max so lets try this.
CRC = (RCLAW_ADDRESS + 44 + 255 + REncoderCnt.Byte3 + REncoderCnt.Byte2 + REncoderCnt.Byte1 + REncoderCnt.Byte0 + |
REncoderSpeed.Byte3 + REncoderSpeed.Byte2 + REncoderSpeed.Byte1 + REncoderSpeed.Byte0 + |
255 + 1) & 0x7f
; motor 1
serout RCLAWSeroutPin, RCLAW_BAUD, [RCLAW_ADDRESS, 44, 255, |
REncoderSpeed.Byte3, REncoderSpeed.Byte2, REncoderSpeed.Byte1, REncoderSpeed.Byte0, |
REncoderCnt.Byte3, REncoderCnt.Byte2, REncoderCnt.Byte1, REncoderCnt.Byte0, |
255, 1, CRC] ; go forward the specified distance at the specified speed and stop when we get there.
; can I query to find out this is done?
#if 0 ;// try mixed mode above
; motor 2
CRC = (RCLAW_ADDRESS + 42 + 255 + REncoderCnt.Byte3 + REncoderCnt.Byte2 + REncoderCnt.Byte1 + REncoderCnt.Byte0 + |
REncoderSpeed.Byte3 + REncoderSpeed.Byte2 + REncoderSpeed.Byte1 + REncoderSpeed.Byte0 + |
255 + 1) & 0x7f
serout RCLAWSeroutPin, RCLAW_BAUD, [RCLAW_ADDRESS, 42, 255, |
REncoderSpeed.Byte3, REncoderSpeed.Byte2, REncoderSpeed.Byte1, REncoderSpeed.Byte0, |
REncoderCnt.Byte3, REncoderCnt.Byte2, REncoderCnt.Byte1, REncoderCnt.Byte0, |
255, 1, CRC] ; go forward the specified distance at the specified speed and stop when we get there.
#endif
sound p9, [50\4000]
pause (REncoderCnt/REncoderSpeed)*1000 + 500 ; pause until we think the command should be done.
sound p9, [50\5000]
ENDIF
Note about code above: Have also tried using seperate commands for both motors (40 and 42)
My thought from earlier displays of encoder outputs that this should move the tritrack forward about a foot. But so far I have found that not to be the case. Each attempt appears to do differently. So I tried running this with the tri-track off of the ground so little friction. I then setup the debug cable, used my R1 button to clear out the encoders, the pressed R2 to display the counters, hit L1 to run the above code, and then hit R2 again to see the counters after it completed. The results were:
Code:
Left Encoder: 1 80 Speed: 0 0 Right Encoder: 0 80 Speed: 0 0
Left Encoder: 257214 80 Speed: 0 0 Right Encoder: 225744 82 Speed: 0 1
I was expecting counts of about 22800 and they appear to be off by a lot and the two motor values differed by a considerable amount. Not sure what to do here.
I am also wondering if instead of pausing, if instead I could do a query to find out maybe the current speed or count to decide that this previous command was completed. Will play more later.
The other side effect of the pause of several seconds is the PS2 dropped out of analog mode and things stopped working. Changed the code to now check the mode and reinit the ps2 if wrong...
Kurt