Yep, needless to say that won’t be a problem, my 12v 1600mah battery won’t make it that far
Back to experimenting: I borrowed the LCD display that I had on the rover toput on the tri-track so I can display things like encoder counts…
So I thought I would try some of the use encoder to set speed and distance (commands 40-47). So I have tried a couple of variations, but the current code tries command 44, which says drive move motors forward. It currently looks like:
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
IF (DualShock(2).bit0 = 0) and LastButton(1).bit0 THEN ;L2 Button test
ENDIF
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:
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