Looking over your code again, I realize that your current program is sufficient for calculating the integral. However, you are incorrectly using the integral.vi, which is why you are getting strange numbers out of it.
I have attached a vi I just wrote that performs the function you want to a generated ramp pattern. You can copy and paste and then integrate this code into your program.
Note that as this is a numerical integration scheme, the result is going to have some error.
Hope this helps.