Multiple getvalue commands not processing

5 years 5 months ago #29530092 by stephen
I am developing in c++, but it seems the api is basically the same as the micro scripting.

I am connected to the motor controller over RS232. I have the motor controller hooked up to two motors. I also have two encoders hooked up.

I can do things like:

to run one motor for 5 seconds.

I can run one single getvalue command:
int rightEncoder;
getValue(_ABCNTR, 1, rightEncoder);
cout << "Right Encoder: " << rightEncoder << endl;

I cannot, however, run multiple getvalue commands:
int rightEncoder;
int leftEncoder;
getValue(_ABCNTR, 1, rightEncoder);
getValue(_ABCNTR, 2, leftEncoder);
cout << "Right Encoder: " << rightEncoder << endl;
cout << "Left Encoder: " << leftEncoder << endl;

The second getvalue command fails (does not return RQ_SUCCESS).

I can't replace the command with anything else either... (_VOLTS, etc.)

I can't send _GO commands after I getvalue either.

I'm guessing my getvalue command is blocking somehow. Is this the case?

Any help would be appreciated.

Please Log in or Create an account to join the conversation.

5 years 5 months ago #29530094 by TechSupport
Note* I'm not an experienced programmer by any means, nor do I have any experience or knowledge of C++ programming.

Have you tried adding in a delay after getting the values before using them? Have you tried reading back what those values in real time?

Regarding volts, the _Volts would be a query so it isn't a setcommand.

If I am understanding your code right, the C++ syntax for your getvalue works similar to the microbasic method (
rightEncoder = getvalue(_ABCNTR, 1) ) only it places the variable that is to be gathered at the end.

Please Log in or Create an account to join the conversation.

5 years 5 months ago #29530095 by stephen
I did try delays between attempting to read the values. I was worried there was a delay over the RS232 port. Any delay from 1 ms up to 5 seconds didn't make a difference.

The code I have above is the simplified version of what I am doing, but in essence, the functions GetValue and SetCommand return a status that I am checking. This status, when succeeding, is RQ_SUCCESS. Only the first GetValue function will return RQ_SUCCESS, the rest will falt.

I tried GetValue(_Volts,2) (not SetCommand), and it would only work if it was the first command.

Any other thoughts? I am worried this might be a hardware problem related to RS232?

Please Log in or Create an account to join the conversation.

5 years 5 months ago #29530096 by roboteq
Replied by roboteq on topic Multiple getvalue commands not processing
If you can read something, even just once, the RS232 port is working. If unsure, connect to your PC running Roborun, via a USB to serial adapter.

Not sure why the troubles but consider sniffing what actually goes on the RS232 lines. To do this, use a second PC running a terminal emulation program like ReatTerm or Hyperterm. To do this, use only the Rx pin of the spy PC and connect it in parallel either
with signal you want to observe. Leave the Tx pin unconnected.

Please Log in or Create an account to join the conversation.

Time to create page: 0.088 seconds