Re: Linear acceleration ramp

I don't know if it will execute quickly enough but you could use a lookup table in a for next loop where the counter VAR is the lookup VAR.
example:
for i = 0 to 10
lookup i,[10,25,50, . . . . ] pulsevar
next i

If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets..

What would be ideal is set up a timer and add a value so that it overflows after "Incr_Time_ms". You can then use interrupts, or just poll the flag bit. increment your "Current_Val", clear the flag bit, and then add the value to set up the overflow after "Incr_Time_ms". Wash-Rinse-Repeat until "Current_Val = End_Val"

What would be ideal is set up a timer and add a value so that it overflows after "Incr_Time_ms". You can then use interrupts, or just poll the flag bit. increment your "Current_Val", clear the flag bit, and then add the value to set up the overflow after "Incr_Time_ms". Wash-Rinse-Repeat until "Current_Val = End_Val"

Hi Steve,

I've used what you said, and I've also included a deceleration ramp:
(sorry for renaming the values, it's for a easier integration in my main program).

It works quite good, but I cannot exeed 65 seconds (because 66*1000=66000, 16-bit integer is overflowed).
But, more importantly, I want to integrate the loop in a low priority DT interrupt. I really don't understand how you're using flags, etc. (I'm a beginner lol).

Re: Linear acceleration ramp

Here is a start (not tested!). But it should get you going in the right direction. I only included the acceleration stuff to keep the logic simpler.
You will need the include files (Get Darrel's from http://darreltaylor.com/DT_INTS-18/downloads.html), and make sure the file names match.

Re: Linear acceleration ramp

Originally Posted by pxidr84

Hi Steve,

It works quite good, but I cannot exeed 65 seconds (because 66*1000=66000, 16-bit integer is overflowed).
But, more importantly, I want to integrate the loop in a low priority DT interrupt. I really don't understand how you're using flags, etc. (I'm a beginner lol).

Thanks

Use a long for your variable - you'll have to work hard to overflow 32 bits.

Re: Linear acceleration ramp

Thanks for mentioning that Charlie! (I forgot too)

It would certainly simplify the code. I went with the non-LONG method in the case that Pxidr84 might not have PBP3, and so no LONG variables. But yes, I would definitely use them if available. Either way, hopefully the methodology of the example is instructive in learning to scale integers to fit into the given variable space.

Also, there is a correction I need to make to the code. I forgot an ENDIF:

Re: Linear acceleration ramp

Originally Posted by SteveB

Thanks for mentioning that Charlie! (I forgot too)

It would certainly simplify the code. I went with the non-LONG method in the case that Pxidr84 might not have PBP3, and so no LONG variables. But yes, I would definitely use them if available. Either way, hopefully the methodology of the example is instructive in learning to scale integers to fit into the given variable space.

Also, there is a correction I need to make to the code. I forgot an ENDIF: