Hey guys I got this program running. i am taking the trend at RampTimer.acc, it is a ramp, but a saw tooth not triangle. is there anyway to modidy this into an actual triangle? Can I take the second rung and invert it to make the ramp down?
Edit:I think I am creating the trend with the wrong tag?
To answer your first question: yes.
If you look carefully at the piece of code you found, and read the comments, you will see that it is designed to ramp either direction, based on the limit checking in rungs 2 and 3.
You are on the right track with your second question, thinking of inverting the 2nd rung (rung 1). But you don't need another rung, and you don't need to modify it, just modify the information you are feeding into it.
What is the relationship of Begin_Point to End_Point if ramping up? End point is higher, no? So how should that relationship change, if you want to ramp down?
Now, how do you know that it is time to change your ramp direction? What is your trigger? Remember, Troy's code was not designed to fulfill your lab requirements. It was simply intended as a ramp generator. It certainly has the capability of generating a triangle pulse, but you have to help it along.
I'll give you a hint. Whenever you want your triangle pulse outputting, your timer needs to run continuously, and self-reset when timed out. Now let's make a list of steps of operation for our program (This is the most important step in writing code)
Step 1: Start RampSetpt at Begin_Point.
Step 2: Begin Timer
Step 3: As timer times, RampSetpt increases from Begin_Point to End_Point
Step 4: Timer completes
Step 5: Reset Timer
Step 6: Invert Begin_Point and End_Point
Step 7: As Timer times, RampSetpt decreases from Begin_Point to End_Point.
Step 8: Timer completes
Step 9: Reset Timer
Step 10: Invert Begin_Point and End_Point.
Step 11: Rinse, Repeat. Go to Step 1
Try to turn these steps into ladder. You should only need a couple more rungs added to what you already have. You're going to need a couple of holding registers for your Begin_Point and End_Point as they swap places. Post back with your results when/if you get stuck.