lamboom

Sine Wave Motion .. problem with "FOR" statement

6 posts in this topic

Hi... Trying to keep it simple:

Want to make a G5 incremental motor wiggle, CW/CCW in a sine wave motion, Thought this might work:

                                                  58ae24464ae23_STRandomtest_003.jpg.aabb4

The variable,  "Angle" is REAL, Phase1 is REAL, AMP1 is LREAL, CSINE is LREAL .. Sysmac doesn't like "Angle" in the FOR statement .. Anyone know why..?

Thanks Much, Regards, Michael

Share this post


Link to post
Share on other sites

Hiya,

Perhaps because it is a Real, and FOR loops are normally INT?

Or maybe "Angle" could be a reserved word? Worth trying to rename it. 

BB

1 person likes this

Share this post


Link to post
Share on other sites

Probably a reserved word as it is for motion.

1 person likes this

Share this post


Link to post
Share on other sites

It has to be an integer:

IntST.thumb.jpg.1eabbff0b2b48fece4353169

Try this though:

SuggestionST.jpg.a4b114b7db24921ce1679e2

i is an integer and Angle is a REAL.  You can then use Angle in the loop as desired.

1 person likes this

Share this post


Link to post
Share on other sites

Wow!   Thanks all for the great input.  I suspected something was goofy with the data types... 

        Berti Baker - I could swear I read the data types for FOR had to be "REAL"  ..  I'm gonna go back and find  it again...Thanks

        BobB - I thought that too.. so I changed it to Just "A" .. an' got the same result .. (again wrond data type)  .. back to the books...thanks

        Michael Walsh - again, you have made my life happy... Thanks...       again ... :-) 

PS;   Is this really the best way to create a sine wave motion?    methinks, it's over when we get to 360  ... what if I would like it to continue forever?

 

Edited by lamboom

Share this post


Link to post
Share on other sites

OK... The  FOR loop runs .. (had to see that work...)  But  It really can't do this job .. at least not the way I have it:   

                                             58af7fb517a26_PriortoStartWave_002.jpg.2

When I look at this .. It doesn't look to me like this will make a sine wave .. If it did, it would be faster than the servo could follow...  Ya gotta have time in there somewhere.  The CPU is going to cycle every 1ms ... 360 ms later, the FOR loop would have completed...  This is not the way to make sine waves... unless you're working with radio frequencies or are Tesla.

I'm starting to think the FOR loop is not even necessary for this... I'm going back to square one.. an' just do it with the main equation, using cycle time .. standby..   :-)

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now