by LROBBINS » 07 Sep 2012, 23:08
Burgerman,
Try running it in simulation without the Roboteq controller connected. If it doesn't work then, there's something wrong with your copy of the script - try a mbs renamed version of the zip. If it does work without the controller, then my code is AFU with respect to your configuration. For example, do you have analog sources connected to analog inputs 3 and 4 (the one the code is using to read amps), and have you configured them to scale -1000 to 1000?
I have no idea why it would be hopping from one input mode to another. Or maybe I do. You have your PC connected to the Roboteq and I bet you didn't click "mute" before running the script. That's going to send lots of serial stuff to and from the PC that could be causing a conflict. or just fooling the Roboteq into thinking that it has a serial input device connected. Search for "mute" in the Roboteq manual to see what I'm talking about.
I think a better way to remove the mode checking, and forcing the use of Pulse for troubleshooting would be to comment out the line:
GoSub FindMode
in MainLoop: and add a line right below there that says
vMode = 1
If it now works, the problem is in the FindMode subroutine (or just because you didn't mute the PC serial connection). If it still doesn't work, the problem is in how vMode is being used in the ScaleSpeed subroutine. Making this kind of troubleshooting easier is a good reason for doing modular, structured programming.
Hmm - thinking about that organization now, the first bit of ScaleSpeed should be in a separate subroutine, say named SetModeSpecificCIx. MainLoop would then call GoSub SetModeSpecificCIx before calling ScaleSpeed. Then, if we later decided we wanted to do just ScaleTurn and not ScaleSpeed (now that speed scaling can be set with the configuration GUI), we'd still be reading the correct mode. If I did this, both scaling routines would still work properly even if the order of the ScaleSpeed and ScaleTurn calls in the script got reversed. Tomorrow I'll make this little change and upload a fresh copy.
I'm working on figuring out the three Roboteq mixing modes. I have figured out how to mimic MixingMode 1 and MixingMode 2, but haven't yet figured out how they get MixingMode 3. Once I have that figured out, I'll do some more code writing so that the calculations can be done with Throttle and Turn input data for whichever mixing mode one selects. I didn't see any command for finding out what MixingMode has been set in the configuration, so it will be important to either always specify the same mixing mode in both the script and configuration, or have the script override the configuration setting. It should be easy to automate that as there is a command for setting mixing mode from a script. This may take some time!
Ciao,
Lenny