On My Claw, I don’t see any marking that shows if it is a 10 or 25, but I will guess a 10…
I don’t have much time right now, but did a little hacking to see how the new version is working. It appears to behave much better now!
Still just playing, but for example if I run the following code:
; L1 button, try driving both motors for a certain distance.
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 = 20000 ; It appeared like maybe 4700+ was max so lets try this.
; cmd 43 Speed1, Distance 1, speed2, Distance 2, Clearbuf
CRC = (RCLAW_ADDRESS + 43 + RencoderSpeed.Byte3 + RencoderSpeed.Byte2 + RencoderSpeed.Byte1 + RencoderSpeed.Byte0 + |
REncoderCnt.Byte3 + REncoderCnt.Byte2 + REncoderCnt.Byte1 + REncoderCnt.Byte0 + |
RencoderSpeed.Byte3 + RencoderSpeed.Byte2 + RencoderSpeed.Byte1 + RencoderSpeed.Byte0 + |
REncoderCnt.Byte3 + REncoderCnt.Byte2 + REncoderCnt.Byte1 + REncoderCnt.Byte0 + |
0) & 0x7f
serout RCLAWSeroutPin, RCLAW_BAUD, [RCLAW_ADDRESS, 43, |
RencoderSpeed.Byte3, RencoderSpeed.Byte2, RencoderSpeed.Byte1, RencoderSpeed.Byte0, |
REncoderCnt.Byte3, REncoderCnt.Byte2, REncoderCnt.Byte1, REncoderCnt.Byte0, |
RencoderSpeed.Byte3, RencoderSpeed.Byte2, RencoderSpeed.Byte1, RencoderSpeed.Byte0, |
REncoderCnt.Byte3, REncoderCnt.Byte2, REncoderCnt.Byte1, REncoderCnt.Byte0, |
0, CRC];
sound p9, [50\4000]
pause (REncoderCnt/REncoderSpeed)*1000 + 500 ; pause until we think the command should be done.
sound p9, [50\5000]
ENDIF
The Tri-track now runs in pretty much a straight line which is much better than before!. Still trying to figure out how to do distances. The Distance I asked for was: 1900*12 or 22800.
After the rover stopped, I hit another butotn on the PS2 that printed asked the claw for the encoder counts and speeds and printed them out. After this run I had the results:
Left Encoder: 34973 80 Speed: 528 0 Right Encoder: 34964 82 Speed: 478 1
I also modified my other attempt, to simply start the tracks running and when it got to a certain distance stop: The code looks like:
[code] IF (DualShock(2).bit0 = 0) and LastButton(1).bit0 THEN ;L2 Button test
; lets try starting both motors foreward and then go into a query loop and try to read in the encoders and see if we can stop automatically
; after maybe two feet…
; Reset the encoder counts
serout RCLAWSeroutPin, RCLAW_BAUD, [RCLAW_ADDRESS, 20, (RCLAW_ADDRESS + 20) & 0x7f] ;Reset both encoders
; Start both wheels going foreword...
RencoderSpeed = 25000 ; It appeared like maybe 37000 was max so lets try this.
; cmd 37 Speed1, speed2,
CRC = (RCLAW_ADDRESS + 37 + RencoderSpeed.Byte3 + RencoderSpeed.Byte2 + RencoderSpeed.Byte1 + RencoderSpeed.Byte0 + |
RencoderSpeed.Byte3 + RencoderSpeed.Byte2 + RencoderSpeed.Byte1 + RencoderSpeed.Byte0) & 0x7f
serout RCLAWSeroutPin, RCLAW_BAUD, [RCLAW_ADDRESS, 37, |
RencoderSpeed.Byte3, RencoderSpeed.Byte2, RencoderSpeed.Byte1, RencoderSpeed.Byte0, |
RencoderSpeed.Byte3, RencoderSpeed.Byte2, RencoderSpeed.Byte1, RencoderSpeed.Byte0, |
CRC];
; now lets loop reading in the current distance and stop when we think we are there.
do
serout RCLAWSeroutPin, RCLAW_BAUD, [RCLAW_ADDRESS, 16] ;read command for M1 encoder
serin RCLAWSerinPin, RCLAW_BAUD, [REncoderCnt.Byte3, REncoderCnt.Byte2, REncoderCnt.Byte1, REncoderCnt.Byte0, REncoderStat, CRC]
while (RencoderCnt < 34000) ; roughly 24 inches ???
; and then stop...
serout RCLAWSeroutPin, RCLAW_BAUD, [RCLAW_ADDRESS, 0, 0, ((0 + RCLAW_ADDRESS) & 0x7f)] ; Stop
serout RCLAWSeroutPin, RCLAW_BAUD, [RCLAW_ADDRESS, 4, 0, ((4 + RCLAW_ADDRESS) & 0x7f)] ; Stop
sound p9, [50\5000]
ENDIF[/code]
Again it appeared to run much smoother and it stopped in a reasonable time, When I printed out the distances like the first test I saw:
Left Encoder: 35223 80 Speed: 0 0 Right Encoder: 35126 82 Speed: 0 1
I won’t have much time to do anything with this for several days, so I uploaded the code so you could play with it if you want!
Kurt