LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help to find a function to upsample a dataset based on timestamp of other dataset

Solved!
Go to solution

Hi,

 

I have servo actuator PWM signals and motor PWM signals each generated on different timestamp (microseconds). Now, I need to upsample the servo PWM signals to match the timestamp of motor PWM signals.

 

servo_sample = 1985 rows x 2 columns (1st column-timestamp of servo in microseconds, 2 nd column-servo PWM values)

 

Motor_sample = 9192 rows x 1 column (timestamp of motors in microseconds )

I have attached the sample file for reference.

 

Kindly to Note: Upsampled servo PWM array (9192 rows x 2 columns (1st column - timestamp of motors, 2nd column- upsampled servo pwm values) must contain previous/nearest values (strictly no interpolations) by comparing the timestamp of motor and servo.

 

Thank you.

Download All
0 Kudos
Message 1 of 6
(1,078 Views)
Solution
Accepted by topic author Muralishan

I assume you also have motor PWM values somewhere but chose not to include them in the attached spreadsheet?

 

And further assuming both measurements are using the *same* microsecond timer and that time will only increase (no rollover back to 0), this one's pretty easy.

 

Kevin_Price_0-1618946275692.png

 

Code is attached and input arrays are populated with the data you provided.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 6
(1,055 Views)

It worked. Great Help. Thank You, Kelvin. 

0 Kudos
Message 3 of 6
(1,010 Views)

Just a small additional tip:

 

That simple code was fine for your particular dataset because *all* the motor microsec timestamps were *interior* to the range represented by the set of servo microsec.

 

In a more general case, you'd need to add some checks and corrections for such situations.

 

I also notice that I accidentally labeled the output as "servo pwm" instead of "motor pwm".  Oops, but you probably caught and fixed that already.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 6
(995 Views)

Oops, just reread what I wrote.   Checks and corrections are needed for the more general case where some of the motor microsec timestamps may fall OUTSIDE the range in the set of servo microsec.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 5 of 6
(960 Views)

Hi Kelvin,

 

Your suggestions are noted. I appreciate your continuous update on this.

 

Actually your vi helped me to upsample the current servo pwm values (logged at time interval of approx 80 millisec) to  the motor timestamp (logged at approx.20 millisec) with only 1% error. To  cross check, I manually chose the timestamp which is almost same in both motor and servo, then at this timestamp, I checked the output of servo pWM from your vi and log file. there is difference of about 1%. This is because of less similar values of motor and servo time stamp. To correct this 1 % error, I converted the time stamp from microsec to secs from 0 to 205 and used your vi. This helped me to remove even this 1% error.

 

Thank you for your help.

0 Kudos
Message 6 of 6
(923 Views)