Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6187093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:00:05+00:00 2026-05-24T02:00:05+00:00

I’m attempting to code an application that reads in the values from an IMU.

  • 0

I’m attempting to code an application that reads in the values from an IMU. I’m trying to get the different values of the attitude (i.e. direction) of the IMU for 1 second when using the getAtr_Click method. However, while this is calling the Get_Attitude function, it only changes the textbox values once on my form. How do I make it change each time? (I want to see 10 different values flash by on the textbox).

Here’s my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Timers;
using VectorNav.Devices;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
    public static Vn100 vn100 = new Vn100("COM5", 9600);
    // New Vn100 on COM5

    private void Get_Attitude()
        //gets the current yaw, pitch, roll in degrees, and displays
    {
        var attitude = vn100.CurrentAttitude;
        yaw.Text = Convert.ToString(attitude.Ypr.YawInDegs);
        pitch.Text = Convert.ToString(attitude.Ypr.PitchInDegs);
        roll.Text = Convert.ToString(attitude.Ypr.RollInDegs);
    }
    public Form1()
        //connect to the Vn100, set its output to YPR, output at 10Hz
    {
        InitializeComponent();
        vn100.Connect();
        vn100.SetAsyncDataOutputType(Vn100.AsyncOutputType.Ypr, true);
        vn100.SetAsyncDataOutputFreq(10, true);
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        Get_Attitude();
    }

    private void tare_Click(object sender, EventArgs e)
    {
        vn100.Tare(true);
        vn100.Tare(true); //for some reason it doesn't display the correct Attitude     values w/out a double Tare
        Get_Attitude();
    }

    private void getAtr_Click(object sender, EventArgs e)
    {
        for (int i = 1; i <= 10; i++)
        {
            while (vn100.CurrentAttitude == null)
                Thread.Sleep(10);
            Get_Attitude();
        }
    }

    protected override void OnFormClosing(FormClosingEventArgs e)
        //disconnect from the Vn100 when the box is closed
    {
        vn100.Disconnect();
        base.OnFormClosing(e);
    }

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:00:05+00:00Added an answer on May 24, 2026 at 2:00 am

    Do you want to see 10 (possibly) different values displayed in your textboxes during 1s, at an interval of 10ms, once you call getAttr_Click()?

    If yes, then that would be the way to do it:

    private void getAtr_Click(object sender, EventArgs e)
    {
        for (int i = 1; i <= 10; i++)
        {
            while (vn100.CurrentAttitude == null)
                Thread.Sleep(10);
            Get_Attitude();
    
            Thread.Sleep(10);
        }
    }
    

    In your version, the thread that called the getAttr_Click() method just checks vn100.CurrentAttutude at 10ms intervals. Once that has a non-null value, I suspect it remains non-null, meaning your while() loop will be skipped in every for() iteration so Get_Attitude() will be called 10 times in a row (probably) so fast that you only get to see the last values on the screen.

    Thing is, this will keep your UI unresponsive each 10ms during the click, so you might consider calling this getAtr_Click() asynchronously or other trivial solution.

    EDIT: Actually, it would help knowing the behaviour of the vn100 component. In the case it is unpredictable, the only thing you can be sure of is displaying 10 different values at no less than 10ms distance in time, regardless if you do everything on the UI thread or on a different thread. It is all related to that vn100.CurrentAttitude behaviour…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.