How to use SIN in RSLogix

Correct scaling factor is 2PI/60 = 0.0147198; SIN SINE COS COSINE MicroLogix 1100

Below are two plots
  • [2PI/59=0.1064947] scaling with glitches,
  • [2PI/60=0.0147198] scaling with no glitches.
This was done on MicroLogix 1100 hardware, which has no sine function; it required implementing a Constrained Chebysev-derived algorithm (stolen from here).

The ladder code is available here; the sine function subroutine is limited to an input argument range of [0:2PI], but that could be easily expanded; adding a cosine subroutine is also straightforward. The sine function accuracy is around 1E-7, which is good enough for the single-precision IEEE-754 floats used by MicroLogix. The code also uses CTU instructions instead of the RTC seconds field, because the RTC on MicroLogix does not work normally; other than a phase shift, the results will be identical numerically to what is generated by a real RTC.

sine_plot_twopi_divby_59.png


sine_plot_twopi_divby_60.png
 
glitches taken to a whole different level ...

I haven't had time to follow this thread step-by-step – so please excuse me if I'm needlessly rehashing anything ...

my personal reason for generating a SINE wave in the first place was to then INTENTIONALLY impress noise signals (glitches) onto it – so that I could demonstrate how the various FILTER instructions work in RSLogix5000 systems ...

keep in mind that my classes were primarily focused on teaching "maintenance technicians" how to troubleshoot the existing control systems in their plants – and only extremely rarely on teaching "programmers" how to write the code in the first place ... my business manager (wife) realized that there are a LOT more folks needing "troubleshooting" skills – when compared to folks needing to learn "programming" skills ... (she's a lot smarter about money-matters than I am) ...

anyway - once in awhile a "boot camp" class would come across the use of FILTER instructions being used in the students' function block diagram code – and having a little dog-and-pony show handy allowed me to run a quick hands-on demonstration of what goes on under the hood of those mysterious little filter boxes ...

and incidentally, since I was working with an RSLogix system for these experiments, I was using a free-running timer with a preset of 2,147,483,647 milliseconds ... that meant that the SINE's "roll-over" glitch would only occur about once every 24 days or so ... looks like drbitboy has come up with an excellent solution for situations where a pure sine wave might be needed when working with less-powerful PLC platforms ...

a thread from the past in case anyone is interested ... (and yes, I'm finally starting to get used to being retired) ...

http://www.plctalk.net/qanda/showthread.php?p=705435&postcount=2

party on ...
.

low_pass_filter.jpg
 
Last edited:
short on time ... see if this helps ...

this pretty much duplicates the earlier examples - but in FBD programming ...

According to the trend, the sine wave is not smooth enough. could the plc handle higher frequencies ? e.g in order to perform frequency test of a closed loop system ?
 
According to the trend, the sine wave is not smooth enough. could the plc handle higher frequencies ? e.g in order to perform frequency test of a closed loop system ?
That is what motion controllers are for. Good ones can produce sine waves at very high frequencies because the loop time is 0.25 milliseconds. On top of that the amplitude, frequency, phase and offset can be changed smoothly on-the-fly unlike the above examples. Some can do swept sine waves that increase frequency from 0 to what ever.


Are controllers get used in many sinusoidal testing applications.
Sinusoidal testing applications are trickier than you may think.
 
That is what motion controllers are for. Good ones can produce sine waves at very high frequencies because the loop time is 0.25 milliseconds. On top of that the amplitude, frequency, phase and offset can be changed smoothly on-the-fly unlike the above examples. Some can do swept sine waves that increase frequency from 0 to what ever.


Are controllers get used in many sinusoidal testing applications.
Sinusoidal testing applications are trickier than you may think.

Thanks for your reply Peter
Saying frequency response tests are tricky confuse me a little bit. If i can generate sine wave With different frequencies and send it to my plant i just need to record the answer to that signal. Or what do you mean exactly with tricky. I have never perform such tests before so may be i am a bit naive ?
 
Thanks for your reply Peter
Saying frequency response tests are tricky confuse me a little bit. If i can generate sine wave With different frequencies and send it to my plant i just need to record the answer to that signal. Or what do you mean exactly with tricky. I have never perform such tests before so may be i am a bit naive ?
First, are you doing position or force sine waves?
Assuming you are doing position sine waves.
Usually people under estimate the acceleration rates required. The velocity goes up proportional to the amplitude and the frequency but the acceleration rate goes up proportional to the amplitude and the frequency squared. The power goes up proportional to the frequency cubed.
A sine wave with a 5mm amplitude at 10 Hz has peak acceleration rate over 2 g! I have had people ask about doing 5mm amplitude at 75 Hz. The peak acceleration would be 113 g. Clearly this won't work unless on has a lot of power or the mass is very small.

Force sine waves are a little easier because nothing should be moving.

Slow sine wave around 1 Hz are rarely a problem.

BTW, I like swept sine waves for testing. I shake my head when I see requests for square waves, triangle waves, saw tooth waves, etc. These were standard a long time ago because the signals could be generated using a signal generator but there is no way a physical device can follow these waves because that requires an infinite frequency response.
 

Similar Topics

Good morning everyone, I'm having difficulty using the "sin" and "cos" functions in sysmac, in particular the results of the functions are not...
Replies
15
Views
1,115
Hi, How to force analog I/O values in Proworx 32 Software (Modicon). Thanks.
Replies
2
Views
1,626
Is it even possible to conevert NB HMI program TO NC HMI programm or how to get .csv file from cx programmer for some reason program named tag...
Replies
3
Views
1,362
Twice in less than a week! Another former customer of mine has run into a problem. Their machine had a Red Lion Kadet HMI that went belly-up and...
Replies
3
Views
1,563
In Rslogix 5000, how to convert the angle of sin54 to degree? if i use SIN instruction,it converts as radian. Please help some one
Replies
3
Views
1,975
Back
Top Bottom