Using ?AI command
- marcusbarnet
- Topic Author
- Offline
Less
More
- Posts: 69
- Thank you received: 0
10 years 9 months ago #29527197
by marcusbarnet
Using ?AI command was created by marcusbarnet
In Roborun utility, I\'m able to send the \"?AI n\" command to check the analog input 1 status and it works very well.
If I try to use the same command in my C application, it does not work and always return a 0 value even if the analog input has a different value.
I use the SetCommand(_AI, 1, report) instruction, it gives me no error but always returns 0 and not the correct input value.
Do I have to use a different instruction in my C program?
I have to say that I\'m able to successfully use all the other commands in my C program to control the acceleration and the motor direction without problems.
The only thing that does not work is the SetCommand(_AI, 1, report).
May be it is not correct?
If I try to use the same command in my C application, it does not work and always return a 0 value even if the analog input has a different value.
I use the SetCommand(_AI, 1, report) instruction, it gives me no error but always returns 0 and not the correct input value.
Do I have to use a different instruction in my C program?
I have to say that I\'m able to successfully use all the other commands in my C program to control the acceleration and the motor direction without problems.
The only thing that does not work is the SetCommand(_AI, 1, report).
May be it is not correct?
Please Log in or Create an account to join the conversation.
- roboteq
10 years 9 months ago #29527199
by roboteq
Replied by roboteq on topic Re:Using ?AI command
you need to use getvalue(_AI ...)
getvalue is for reading parameters as you would with ? via terminal
setcommand is for sending commands as you would with !
getconfig is for reading configurations as with ~
setconfig is for writing configuration as with ^
getvalue is for reading parameters as you would with ? via terminal
setcommand is for sending commands as you would with !
getconfig is for reading configurations as with ~
setconfig is for writing configuration as with ^
Please Log in or Create an account to join the conversation.
- marcusbarnet
- Topic Author
- Offline
Less
More
- Posts: 69
- Thank you received: 0
10 years 9 months ago #29527203
by marcusbarnet
Replied by marcusbarnet on topic Re:Using ?AI command
I did a mistake, in my previous post.
I\'m using GetValue(_AI, 1, report) and not SetCommand(..) but it always returns me a 0 value.
I\'m using GetValue(_AI, 1, report) and not SetCommand(..) but it always returns me a 0 value.
Please Log in or Create an account to join the conversation.
- roboteq
10 years 9 months ago #29527205
by roboteq
Replied by roboteq on topic Re:Using ?AI command
The syntax is
int GetValue(int operatingItem, int index, int &result)
you must pass the address of the result variable.
If this is what you are doing, then check with other queries, like _V volts for example to verify the the problem is unique to _AI
int GetValue(int operatingItem, int index, int &result)
you must pass the address of the result variable.
If this is what you are doing, then check with other queries, like _V volts for example to verify the the problem is unique to _AI
Please Log in or Create an account to join the conversation.
- marcusbarnet
- Topic Author
- Offline
Less
More
- Posts: 69
- Thank you received: 0
10 years 9 months ago #29527209
by marcusbarnet
Replied by marcusbarnet on topic Re:Using ?AI command
I tried with device.GetConfig(_V, result) but I always get 0 value.
To read analog values, I use this very simple code:
If I send the same command in Roborun utility it works fine.
Moreover, the other commands like device.SetCommand(_MG, 1, 1) work very well so I do not know why the _AI and _V commands don\'t work.
Can you help me with this, please?
I have to order three additional SDC2150 since I have to control additional motors but I need to be able to read analog and digital inputs, too.
To read analog values, I use this very simple code:
while(1){
int result;
cout<<\"- GetConfig(_AI, 1)...\";
if((status = device.GetConfig(_AI,1, result)) != RQ_SUCCESS)
cout<<\"failed --> \"<<status<<endl;
else
cout<<\"returned --> \"<<result<<endl;
//Wait 10 ms before sending another command to device
sleepms(10);
}
If I send the same command in Roborun utility it works fine.
Moreover, the other commands like device.SetCommand(_MG, 1, 1) work very well so I do not know why the _AI and _V commands don\'t work.
Can you help me with this, please?
I have to order three additional SDC2150 since I have to control additional motors but I need to be able to read analog and digital inputs, too.
Please Log in or Create an account to join the conversation.
- roboteq
10 years 9 months ago #29527211
by roboteq
Replied by roboteq on topic Re:Using ?AI command
you use GetConfig
you must use GetValue
you must use GetValue
Please Log in or Create an account to join the conversation.
- marcusbarnet
- Topic Author
- Offline
Less
More
- Posts: 69
- Thank you received: 0
10 years 9 months ago #29527213
by marcusbarnet
Replied by marcusbarnet on topic Re:Using ?AI command
Thanks a lot!
Please Log in or Create an account to join the conversation.
Moderators: tonysantoni
Time to create page: 0.076 seconds