Hi there,
I need to know how exactly the commands like Forwards , SetMotors work. i.e in the Matlab script of these functions there are statements of fwrite which i see are calling again to some another macro listed by numbers like 2,3,4,5etc. in the script.
If it is possible could you please upload the macros details.
I require to modify and know how exactly things are so that i can utilize the maximum out of it.
Thanks!!!
Matlab Function codes of the macros called in scripts
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Matlab Function codes of the macros called in scripts
Hello,
The Formula AllCode works in binary mode and string mode. The Matlab scripts are accessing the binary mode to help speed up communications.
This document contains the overview of the binary and string modes and should help you to get the right command numbers.
Commands are always sent in the following format: Component ID, Function Index, Parameters, Returns
The Formula AllCode works in binary mode and string mode. The Matlab scripts are accessing the binary mode to help speed up communications.
This document contains the overview of the binary and string modes and should help you to get the right command numbers.
Commands are always sent in the following format: Component ID, Function Index, Parameters, Returns
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Matlab Function codes of the macros called in scripts
Hello,
I'm currently working for some projects with students but with Python. Inspired by the Matlab's API, I suggest you to add this two python's API function in FA.py based on "binary mode" :
def EncoderReset(self):
"""Resets the motor encoder counters
"""
self.__ser.write(bytearray([0, 14]))
return;
def EncoderRead(self, index):
"""Reads one of the motor encoder counters
Approx 0.328296mm of travel per encoder unit.
Args:
index: value of encoder (0=Left, 1=Right)
Returns:
int: Value of the encoder counter
"""
self._flush()
self.__ser.write(bytearray([0, 15, index]))
ret = self.__ser.read(2)
r = ret[1]<<8 | ret[0]
return(r);
Maybe some other Python's API function should be rewritten/added with the binary mode if that could improve speed up communication.
Regards,
Alan
I'm currently working for some projects with students but with Python. Inspired by the Matlab's API, I suggest you to add this two python's API function in FA.py based on "binary mode" :
def EncoderReset(self):
"""Resets the motor encoder counters
"""
self.__ser.write(bytearray([0, 14]))
return;
def EncoderRead(self, index):
"""Reads one of the motor encoder counters
Approx 0.328296mm of travel per encoder unit.
Args:
index: value of encoder (0=Left, 1=Right)
Returns:
int: Value of the encoder counter
"""
self._flush()
self.__ser.write(bytearray([0, 15, index]))
ret = self.__ser.read(2)
r = ret[1]<<8 | ret[0]
return(r);
Maybe some other Python's API function should be rewritten/added with the binary mode if that could improve speed up communication.
Regards,
Alan
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Matlab Function codes of the macros called in scripts
Hi Alan,
Thanks for that I wasn't aware the API for Python wasn't already using the binary mode. It certainly will run faster than the string mode as it can jump directly to the correct command rather then having to parse through the string and do string comparisons.
I'll investigate this when I get some time thanks.
Thanks for that I wasn't aware the API for Python wasn't already using the binary mode. It certainly will run faster than the string mode as it can jump directly to the correct command rather then having to parse through the string and do string comparisons.
I'll investigate this when I get some time thanks.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel