Menu

Topic-icon How to access the data of MGS1600GY with Visual Studio 2015?

More
3 months 1 week ago #29533481 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:

#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.

Attachments:

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

More
3 months 1 week ago #29533483 by Gabriel_Isko

Would you mind logging the output of your program to a file?

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

More
3 months 1 week ago #29533485 by Muchammad Sobrun Ibnu Atf

I want to access data from MGS1600GY without MagSensor Control Utility

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

More
3 months 1 week ago #29533492 by blake

Please find attached an update f for the VS2015 API. We've adjusted the sample to periodically reads MagSensor detect (MGD).
You

File Attachment:

File Name: WindowsVS20151.zip
File Size:1,211 KB
needs to change the com port in sample.cpp line 15 to reflect the correct port.
int status = device.Connect("\\\\.\\com4");

Attachments:

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

More
3 months 4 days ago #29533497 by Muchammad Sobrun Ibnu Atf

Thank you Blake, i will try :)

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

Moderators: tonysantoni
Time to create page: 0.213 seconds
Go to top