Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Calculation of Angular Position from Angular Velocity

  1. Nov 17, 2011 #1
    Dear All,

    After long time, I have to start working again on basic physics for my application in one of our automotive project.
    Anyway, my problem is, I receive the angular velocity of wheel from external source like (say CAN bus) for every 10ms, now, I need to calculate the Angular position of the wheel using this angular velocity.
    Ofcourse, I need to do it in C-language. I'm completely out of any idea now :(.

    Can some one please help me by giving any idea or sample code ?

    Thanks
    Kasu
     
  2. jcsd
  3. Nov 17, 2011 #2
    FYI, the units for angular velocity that I receive is "deg/sec".
     
  4. Nov 19, 2011 #3
    If the angular velocity remains relatively constant just add measured velocity to a running tally of the position, if you need more precision try adding the average of the newly read velocity with the previous one. How accurate do you need to be?
     
  5. Nov 21, 2011 #4
    Hi JHamm

    Thanks a lot for your reply.
    My angular speed input looks like something as shown in the attached figure, it is not constant.
    Right now, I'm thinking to do below steps to calculate the angular position

    Angular Position = (Current Speed Sample - Previous Speed Sample)*(Time difference between current & previous sample)

    As I said, I receive the speed sample for every 10ms.

    1. So, first I calculate the angular position sample from angular speed sample
    2. Then, I accumulate (add the angular position sample) the angular position sample to calculate the current position of the angle..

    Do you think, it makes sense ?
     

    Attached Files:

  6. Nov 21, 2011 #5
    To find the incremental change in angular position you may use
    [tex]\Delta \theta= \frac{\omega_{current}+\omega_{previous}}{2} \Delta t[/tex]
    Then you add this to the previous angular position, as you mentioned already.
    "Omega" is the angular speed and Delta t is the time increment.
     
  7. Nov 21, 2011 #6

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    If you want to know the position after a long time, this could be difficult. The total angle moved would be the integral of the velocity over this time and a lot of error can creep in as time progresses.
    It's easy for uniform speed or even uniform acceleration (steady increase in speed) but your recorded graph would make things a lot more complicated and prone to error. Do you really want to calculate the final angle after all the speed variations on that graph?
     
  8. Nov 21, 2011 #7
    Hi Nasu and Sophiecentaur

    Thank you for your inputs.

    @Nasu,
    I calculated the angular position using your inputs and simulated the graphs.
    Please check it in the attachment.

    @Sophiecentaur
    I think, I understand your point. The angular speed that I recorded is during random case. Means, I recorded the data when the car was going at random speeds. But, in my real application, I believe I will activate this "angular position" calculated function only at certain speeds.

    By checking the attached graphs, do you think I'm going in right path?
     

    Attached Files:

  9. Nov 22, 2011 #8

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    I can't see what you have done here. You just need to integrate (sum) all the angular speeds (degrees per second), starting from a given time and that will give you the total angle after t seconds (Modify that for whatever your time increment happens to be). That second graph is very puzzling. Why did you do that?

    I should think that the answer would be totally unreliable -if you wanted to know the final angle Modulo 360, particularly. But even to find the total angle, the error could be poor. What is the cause of those short 'dips' on the first graph?
     
  10. Nov 22, 2011 #9
    Hi, sophiecentaur

    I just did the integration of Angular speed only...
    As I said earlier, I receive the angular speed for every 10ms.
    So, after every 10ms, I need to find the current angular position of the wheel.
    Lets consider the below example with four samples of received wheel Speed.


    Speed(deg/sec) Time Angular Position (degree)
    ------ ----- ------------------------
    200 10ms 2.0 deg
    220 10ms 2.1 deg --> { (200+220)/2 *10ms }
    220 10ms 2.2 + 2.1 = 4.3 deg --> { (220+220)/2 *10ms + 2.1 }
    222 10ms 2.21 + 2.2 + 2.1 = 6.51 deg --> { (222+220)/2 *10ms + 4.3 }

    So, the final angular position of the wheel after the 4 samples will be 6.51 deg.
    The 2nd graph in the attachment is the plot of angular position at each sample.

    Is there any problem in the above process, kindly let me know please.

    Also, the short 'dips' in the input wheel speed is noise from the wheel speed sensor itself. I think I may have to use some kind of software filter function to avoid these dips.

    For easy analysis, I am attaching the graph here calculated with few samples.


    Thank You
     

    Attached Files:

  11. Nov 22, 2011 #10

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    The total angle is increasing in a nice convincing manner - which has got to be good!

    I still don't see why it is a two-step process, though. I would have expected the values on the middle graph to correspond numerically to the first graph(like in your short numerical example). The values do not follow the top graph at all. Why? They seem to produce a more or less constant value- which would clearly give you that nice triangular (integral) plot in the bottom graph.

    Why do you just not add all of the speed values together and the result will be what you want - with suitable scaling to take into account the 10ms samples: i.e. divide the sum by 100?
    You seem to be working out the distance increment for each interval and then accumulating these values rather than just adding the instantaneous values and accumulating them. I can't see that you accomplish anything by taking the mean of two successive sample values and adding these means together - arithmetically is will be the same as just adding them all up (you are effectively adding half of each value twice).
    Working out the probable total error would be difficult without, perhaps, analysing the variation of your original speed samples and their absolute accuracy. Any constant error in speed will just mount up as the time increases. This is the problem with any dead reckoning system.

    I may have got this totally wrong but it seems glaringly obvious to me(?)
     
  12. Nov 22, 2011 #11
    There is something funny with your plots. What is the second graph? Maybe the increments of the position at each step?
    And what are the units on the axes, anyway?
     
  13. Nov 29, 2011 #12
    Sorry about late reply (Due to Thanks Giving Holidays)

    And thank you for your suggestions.

    @sophiecentaur
    Yes, I reduced the two step process for calculating the angular position to 1 step as you suggested.

    And infact, the low dips in the input Wheel speed signal was due to my fault. There was small bug in my filter coding. And here I attached my final graphs here. But, if you see the graph of wheel speed signal graph, there are some samples which goes to zero un-intentionally. It is ok, i confirmed it, its due to some other hardware problem. We have to find some other way to avoid this problem.

    I once again thank you for your help.
     

    Attached Files:

  14. Nov 30, 2011 #13

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    The graph you have obtained of total angle looks more convincing now; it has an uneven gradient in accord with the bumpiness of the input data. Getting rid of those dips was good!

    Did you consider putting some false data in (linear acceleration or constant speed) to check that you get the correct answers out?

    I'm not clear what you actually want out of the exercise. If you want an estimate of total distance traveled then errors would be reasonable but, if you want to estimate the final position of rotation of the wheel (angle modulo 360) then this method - and in fact any method of integrating velocity - could be extremely error-prone.

    Good luck with taking it further.
     
  15. Nov 30, 2011 #14
    After every 10ms, I need to estimate the current wheel position and then calculate the Sine, Cosine values for this angle. For example...

    - At first, I calculate the angular position (say for very 1st sample) and then calculate Sine,Cosine values for that angle.
    - And now, calculate the next angular position (2nd sample after 10ms) by integrating with the previous angular position sample and then calculate Sine,Cosine values for the current angular position...

    Basically, by integrating the angular velocity, I need to calculate the Angular position and finally generate Sine, Cosine waves. Please check the attached graphs, it has the output sine,cosine waves. One graph shows the real wheel speed input and the 2nd graph shows the data with constant input wheel speed (I change the input wheel speed deliberately to a constant value to check the output sine,cos waves).

    And as you said, I understand, by integrating any calculations like this (angular velocity, angular position) can cause a serious error prone, .. :(... Is there any better way to do ? Any suggestions please ?

    Thank You
     

    Attached Files:

  16. Nov 30, 2011 #15

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    I would have suggested synthesising a sine wave with a frequency based on the reciprocal of an averaged value of the angular velocity. A frequency locked loop (as opposed to a phase locked loop).
     
  17. Nov 30, 2011 #16
    Can you explain what is going on physically or is this just a graph exercise??
     
  18. Dec 1, 2011 #17
    @netgypsy

    I logged the data through CAN message from the real Car to get the Wheel Speed data.
    So, when I logged the data from the Car, I got around 10,000 samples of Wheel Speed Signal.
    And I import these values to excel sheet and at first trying to calculate Wheel position.

    And after the excel sheet simulation, I want to implement the same logic in the C language.
    I still have to test in the real function in my project and the hardware. That is the next step.
     
  19. Dec 1, 2011 #18

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    But you didn't answer the question. Does this have a practical application or is it 'just' an exercise?
     
  20. Dec 1, 2011 #19
    @sophiecentaur

    Yes, it does have practical application. The sine, cos values (calculated using angular position) will be used by "function" to control the current input to the Motor in the EPS (Electronic Power Steering) ECU. As of now, I'm not quite sure what that "function" about.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Calculation of Angular Position from Angular Velocity
  1. Angular velocity (Replies: 2)

Loading...