- Forum
- Roboteq Motor Controllers
- Troubleshooting
- How to access the data of MGS1600GY with Visual Studio 2015?
How to access the data of MGS1600GY with Visual Studio 2015?
- Muchammad Sobrun Ibnu Atf
- Topic Author
- Offline
Less
More
- Posts: 3
- Thank you received: 0
5 years 3 months ago #29533481
by Muchammad Sobrun Ibnu Atf
How to access the data of MGS1600GY with Visual Studio 2015? was created by Muchammad Sobrun Ibnu Atf
Hello, I am really new here.
I'm using an MGS1600GY to detect the magnetic line. in my plan, I want to interfacing with BLDC Driver Motor. first, I want to access the data of MGS1600GY by Visual Studio 2015. but I have a problem when I am running the code from an example.
Code from this example
I have seen:
Opening port: '\\.\com23'. . . succeeded.
Initializing port. . . . . . done.
Detecting device version. . .
(after this step then suddenly close)
code:
I have set and changing the configuration command following MGS1600GY datasheet, but the result is the same.
can somebody help me what I do wrong? Thank you for your attention.
I'm using an MGS1600GY to detect the magnetic line. in my plan, I want to interfacing with BLDC Driver Motor. first, I want to access the data of MGS1600GY by Visual Studio 2015. but I have a problem when I am running the code from an example.
Code from this example
I have seen:
Opening port: '\\.\com23'. . . succeeded.
Initializing port. . . . . . done.
Detecting device version. . .
(after this step then suddenly close)
code:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include "RoboteqDevice.h"
#include "ErrorCodes.h"
#include "Constants.h"
using namespace std;
int main(int argc, char *argv[])
{
string response = "";
//Create an instance of RoboteqDevice.
RoboteqDevice device;
//Connect to the device, for windows use "\\\\.\\com1" for com1.
int status = device.Connect("/dev/ttyS0");
//Check to see if the connection succeeded.
if(status != RQ_SUCCESS)
{
cout<<"Error connecting to device: "<<status<<"."<<endl;
return 1;
}
cout<<"- SetConfig(_DINA, 1, 1)...";
if((status = device.SetConfig(_DINA, 1, 1)) != RQ_SUCCESS)
cout<<"failed --> "<<status<<endl;
else
cout<<"succeeded."<<endl;
//Wait 10 ms before sending another command to device
sleepms(10);
int result;
cout<<"- GetConfig(_DINA, 1)...";
if((status = device.GetConfig(_DINA, 1, result)) != RQ_SUCCESS)
cout<<"failed --> "<<status<<endl;
else
cout<<"returned --> "<<result<<endl;
//Wait 10 ms before sending another command to device
sleepms(10);
Copyright © Roboteq Inc. 2017. All Rights Reserved. 4
cout<<"- GetValue(_ANAIN, 1)...";
if((status = device.GetValue(_ANAIN, 1, result)) != RQ_SUCCESS)
cout<<"failed --> "<<status<<endl;
else
cout<<"returned --> "<<result<<endl;
//Wait 10 ms before sending another command to device
sleepms(10);
cout<<"- SetCommand(_GO, 1, 1)...";
if((status = device.SetCommand(_GO, 1, 1)) != RQ_SUCCESS)
cout<<"failed --> "<<status<<endl;
else
cout<<"succeeded."<<endl;
device.Disconnect();
return 0;
}
I have set and changing the configuration command following MGS1600GY datasheet, but the result is the same.
can somebody help me what I do wrong? Thank you for your attention.
Please Log in or Create an account to join the conversation.
- Gabriel_Isko
5 years 3 months ago #29533483
by Gabriel_Isko
Replied by Gabriel_Isko on topic How to access the data of MGS1600GY with Visual Studio 2015?
Would you mind logging the output of your program to a file?
Please Log in or Create an account to join the conversation.
- Muchammad Sobrun Ibnu Atf
- Topic Author
- Offline
Less
More
- Posts: 3
- Thank you received: 0
5 years 3 months ago #29533485
by Muchammad Sobrun Ibnu Atf
Replied by Muchammad Sobrun Ibnu Atf on topic How to access the data of MGS1600GY with Visual Studio 2015?
I want to access data from MGS1600GY without MagSensor Control Utility
Please Log in or Create an account to join the conversation.
5 years 2 months ago #29533492
by blake
Replied by blake on topic How to access the data of MGS1600GY with Visual Studio 2015?
Please find attached an update f for the VS2015 API. We've adjusted the sample to periodically reads MagSensor detect (MGD).
You needs to change the com port in sample.cpp line 15 to reflect the correct port.
int status = device.Connect("\\\\.\\com4");
You needs to change the com port in sample.cpp line 15 to reflect the correct port.
int status = device.Connect("\\\\.\\com4");
Please Log in or Create an account to join the conversation.
- Muchammad Sobrun Ibnu Atf
- Topic Author
- Offline
Less
More
- Posts: 3
- Thank you received: 0
5 years 2 months ago #29533497
by Muchammad Sobrun Ibnu Atf
Replied by Muchammad Sobrun Ibnu Atf on topic How to access the data of MGS1600GY with Visual Studio 2015?
Thank you Blake, i will try :)
Please Log in or Create an account to join the conversation.
Moderators: tonysantoni
- Forum
- Roboteq Motor Controllers
- Troubleshooting
- How to access the data of MGS1600GY with Visual Studio 2015?
Time to create page: 0.073 seconds