ArduinoIMU output to VisualExpress C++

Hey everyone, I’m new to the forum… Hopefully there is someone here that knows more than i do about this issue I’m having.

The basics of what I’m trying to do is read the data from an ArduinoIMU V2 flat and output via the serial to a cmd window. The C++ program was an open source program I found that just needed to tweak a little. My C++ is a bit rusty and I don’t doubt that there is something easy that I am overlooking. The program i have compiles, opens the cmd window, but does not read the data. I have gotten the program to work in an EXTREMELY simple way, so i know it can connect/transmit data, but when i tried to expand the capability- something went terribly wrong. If someone has some insight into how i can solve this it would be a huge help!

This is a few lines of the output from the IMU via the serial monitor:

<RLL:-45.73 PCH:-16.89 YAW:28.12>

<RLL:-45.73 PCH:-16.90 YAW:27.91>

<RLL:-45.73 PCH:-16.91 YAW:27.72>

<RLL:-45.72 PCH:-16.91 YAW:27.53>

Where RLL is the roll, PCH is the pitch, and YAW is well…yaw.

This is the main func i have written in C++ Visual Express that should read the data :

int main(const int &)
{
	//Serial *ard = new Serial("COM4");
	Serial ard("COM5");
	int count = 0;
	while(ard.IsConnected())
	{
		char holder[100];	// set character string 'holder' to 
		strset(holder,NULL);
		char buffer[25];
		strset(buffer,NULL);
		char roll[10] ;
		signed int rolldata = 0;
		char pitch[10] ;
		signed int pitchdata = 0;
		char yaw[10] ;
		signed int yawdata = 0;
//		char imu_h;
//		int imu_hdata;

		ard.ReadData(buffer,25);
		strcat(holder,buffer);
		for(int i = 0; i<100; i++)
		{
			if(holder[i] == '<' && i+9 < 100)
			{
				if(i+9 < 100 && holder[i+9] == '>')
				{
					sscanf(holder+i,"<%s%d %s%d %s%d>",&roll, &rolldata, &pitch, &pitchdata, &yaw, &yawdata); //extract packet
					memset(holder+i,NULL,10);//set found packet to NULL
					cout<<roll<<" "<<rolldata<<" "<<pitch<<" "<<pitchdata<<" "<<yaw<<" "<<yawdata<<" "<<endl;
				}
			}
			else if(holder[i] == '<') //if < found near end
			{
				memcpy(holder,holder+i,strlen(holder+i));
			}
		}
		sprintf_s(buffer,"");
	}
	return 0;
}

the link for the serial communication and header file is here. The main function above is one I have written: http://www.arduino.cc/playground/Interfacing/CPPWindows

thanks,

Wes

Hello Wes,

I also wanted to visualize accelerometer data and found that there was no easy way. So ended up writing a simple tool that plots accelerometer data. I have written general version of this tool and it is available for download here

http://www.negtronics.com/simplot

If you want code to modify it for your use, let me know I will open source it. So far no one as has asked for it and I have not yet taken the trouble to setup a independent project and open source it. The tool is written in Visual Basic using Visual Studio 2010 Express.

Comments and suggestions for new features are always welcome.

Cheers