how to generate a train of bit pulses with RSLogix5000?

buhnen

Member
Join Date
May 2008
Location
Somewhereland
Posts
131
Hi to everybody here!

I'm a newbie in the Allen Bradley world, I've just come from Siemens S7-300 and though I'm getting well with RSLogix 5000 I still have some problems:

I want to do something very easy. The idea is next: An analogic input linked to a ControlLogix PLC must perform a set of serial readings each 10 minutes and simultaneously go saving the results within an array of 6 elements. After one hour (6 readings * 10 minutes = 60 minutes)the PLC must do a math operation AVE (average) with those 6 saved results...This is the general idea.

Normally in Siemens I'd use a special mark (an status bit SM0.1 and I'd get a train of pulses and with a counter I would manage)...but in RSLogix 5000 I can't find an equivalent status bit (like In SLC-500)that, for instance, be able to generate a train with step-rhythms of a minute.

I've thought of using the WALLCLOCKTIME + GSV but I'm not sure if that would be the more "professional" option in this case.

Other doubt is: How would I simulate an analogic input with values changing when for testing the program?

Thanks in advance for your help,

PS (excuse my english, I'm not native speaker)
 
Just create a periodic task, and put your counter in there. (Simple ADD 1 MyCounter MyCounter) would work)

Or, if you don't like periodic tasks, use a free running timer, with a period of 10 minutes. (XIO MyTimer.DN TON MyTimer 600000 0)
Use the XIC .DN bit to trigger your calculation.

Using the WallClockTime is also valid, if absolute accuracy is required. You can just use the minutes portion, and perhaps divide it by 10, then feed that into a DTR instruction. That will give you a one shot pulse every time 10 minutes goes by.

If using WallClockTime, I usually suggest making a global array for the received values, (DINT GL_WC_Time[7] for example) and using that anywhere you need to reference any time function.

I've seen some oddball programs where people retreive the WCT every time they need it, but that is generally silly unless you absolutely need millisecond accuracy.
 
If you have version 16 you can download a sample program from ab web page that contains all the AOI ( add on instructions), within that program you will see two AOI called TLES and TDIFF, use them and setup your plc for your ten minutes or other time that you desire, then use comparators to trigeer what you want, in your case you trigger your event every ten minutes.

This is the link for sample code:
http://samplecode.rockwellautomation.com/idc/groups/public/documents/webassets/sc_home_page.hcst

I´m not sure but it seems that inside the V16 CD there is also a sample of this program.

Let me know if i cal help you further.
 
Thanks to both of you for your tips,

What i finally did was a cascade sequence of a TON plus two CTU's and could manage. I haven't tested yet if the program works but I'll do it on Monday.

rdrast: I liked the idea of setting a pericodic task and I'll try it too in a future (this program is intended for learning RSLogix 5000 enviroment).

I didn't understand quite well the second strategy based on "feeding into" a DTR instruction with the result of the operation obtained by dividing the element [4] of the array (the minutes)by 10. I have checked the online help for the DTR instruction and I don't understand why should I use it for.

I didn't understand either when you say that

"If using WallClockTime, I usually suggest making a global array for the received values, (DINT GL_WC_Time[7] for example) and using that anywhere you need to reference any time function."


I think my programming level is still quite green
:)shoot: ...I'm just in a trainee program for students)...and I do not even work with structure text. But thanks anyway for your tips as well.


widelto: gracias as well for your tips. I clicked the link for trying to download those addon files but I couldn't...I typed TLES and TDIFF into the searcher findboxes but nothing appeared. DO you how could I get those two files?

And a question of any of you: Is it possible in the forum to exchange files with other users?(e.g if I want to send my RSLogix 5000 programs to other forum users to discuss about them)
 
DTR - Data Transition instruction

The rung following will go true, if the input value changes compared to a compare value...

Type the following rung in:

DTR My_Minutes 16#FFFFFFFF My_Minutes_Old MOV My_Minutes My_Minutes_Old OTE Minutes_Changed_Pulse

Make the tags My_Minutes and My_Minutes_OLD DINT's.

Now, every time My_Minutes changes, the output coil (Minutes_Changed_Pulse) will go true for one scan.

-------------

Part two, if you are going to be using the WallClockTime anywhere in your program, it's best to just make a global array of DINTS (7 elements) run the GSV in either the cyclic or a periodic task, and then jusr refer to the global array (controller scoped) anywhere you need to reference time. Often, I see many seperate calls to GSV WallClockTime, which is just wasteful mostly.

The values returned from wallclocktime:

Element 4 is the current RTC Minute value.
If you just want to look at every 10 minutes, you can use pure integer division:

DIV GL_WC_Time[4] 10 Tens_Digit_Of_Minutes

Then, you could use that in the DTR above, and get a one shot pulse, every time the real time clock increments by 10 minutes.
 
rdrast said:
DTR - Data Transition instruction

The rung following will go true, if the input value changes compared to a compare value...

Type the following rung in:

DTR My_Minutes 16#FFFFFFFF My_Minutes_Old MOV My_Minutes My_Minutes_Old OTE Minutes_Changed_Pulse

Make the tags My_Minutes and My_Minutes_OLD DINT's.

Now, every time My_Minutes changes, the output coil (Minutes_Changed_Pulse) will go true...

The DTR will write the source (thru the mask) to the reference, so your MOV is redundant, you just need the OTE. It is the only input instruction I know of that both controls program flow and is destructive in this manner.
 
buhnen said:
widelto: gracias as well for your tips. I clicked the link for trying to download those addon files but I couldn't...I typed TLES and TDIFF into the searcher findboxes but nothing appeared. DO you how could I get those two files?

Send me a PM with your email and I will send you the sample program. But look for it on the V16 CD first, if you do not find it let me know.
 
Thanks guys for all your tips,

I've been testing the programs in the RS Emulator 5000 and they work ok...Also starting to like AB, things seem to work in an easier way than Siemens, at least...

The only problem I'm having by now is that I've created a project with 2 periodic tasks, configured each with one and two minutes for their respective scan cycles. I've written identical programs in both tasks, very easy ones, just for testing, but I can't make this working.

The idea was trying RDRAST tip about periodic tasks. Program is as you can see in the screen capture . I download the project to the RS Emulator,

Complete - 0 error(s), 0 warning(s)

...and set to RUN the emulator controller and activate the XIC to go true. In that very moment, the CTU accum changes to 1 (First thing that it shouldn't happen cause it has not lapsed a minute yet)...Then I keep waiting but nothing happens, it doesn't count up....any idea about it mates?


I forgot to say that the watchdog is set to the same amount of time than the period cycle, this is, 60.000 ms in task one (one minute pulses) and 120.000 ms in task two (two minute pulses)
 
Last edited:
Changing topic...I don't know if I should start a new thread but other doubt I've got is about analog input simulation. I've seen that the RS Emulator 5000 doesn't include any analog I/O module. Do you know of an efficient way to simulate analog inputs in a program test?

I guess I could always use some MOV's for moving REAL values when any XIC condition is set to true, but still I was wondering if you know of any other more accurate way.
 
Solved problem!

I've got to solve the problem: you have to use the ADD instruction because the CTU doesn't work when trying to count up pulses generated by the scan cycle of the periodic tasks. I had also introduced mistakenly the cycle time like 60.000 instead of 60000.000 to refer to 1 minute
 
Correct, you don't want to use a CTU instruction there, regular ADD works fine.

The reason is, the CTU (and CTD) instructions have a built-in one-shot, and need to see their inputs go TRUE then FALSE then TRUE again in order to count. Keeping the input TRUE will fire it once, but never again, as the internal one-shot never sees a reset. ADD's are simpler anyway :)

In general though, I tend to make a general purpose 1 second periodic task, and then fire longer duration tasks off of that. I maintain a free-running counter, then anything I need to fire at 10 seconds is fired off at MY_Counter MOD 10 == 0, or for every minute, My_Counter MOD 60 == 0 etc.
 
mmmm....but I've realized of something....I was thinking to make a general purpose 1 minute periodic task and using it exclusively as RTC Minute (with the ADD instruction). Then, from a continuous task, I'd retrieve the ADD counting up data for using it on those timing related operations that I might need.... But that's not possible...It seems like instructions in continous tasks can't be defined with tags imported from periodic tasks. :-(

This restricts a lot the use of the periodic tasks.

I realized of this when I tried to make an operation in my continuous task: When My_counter.counter (from the ADD operation in the periodic task) be equal to 5, trigger an ote.
 
buhnen said:
mmmm....but I've realized of something....I was thinking to make a general purpose 1 minute periodic task and using it exclusively as RTC Minute (with the ADD instruction). Then, from a continuous task, I'd retrieve the ADD counting up data for using it on those timing related operations that I might need.... But that's not possible...It seems like instructions in continous tasks can't be defined with tags imported from periodic tasks. :-(

This restricts a lot the use of the periodic tasks...

Use Controller scope tags and it should work fine. By default, new tags within a program are given program scope (only useable within that program). Once created, the scope of a tag can't be changed as far as I know.
 
Thanks for the tip OkiePC, It has worked!! :)
I'm starting to understand more this thing of the tags...I see that it's better to define always the tags like controller scope tags....You can always access them from wherever.


And other last question ....Any suggested way to simulate an analog input?...I guess the easier way to do this can be to let some REALs steady to be triggered by some MOVs instructions...
 

Similar Topics

Hello Friends, I am looking for a way to take my PID Output( it is the result of my PI Algorithm in Real format) and generate a PWM Signal in...
Replies
16
Views
2,572
Does anyone know a way to dynamically generate a 2D barcode on a PanelView screen? An Activex Control maybe? If such a method is out there, it...
Replies
14
Views
3,014
Hi, I am trying to generate source file of OB1 including all dependent blocks. But i am getting a message which says-->>one or more blocks...
Replies
3
Views
1,265
Hello Everyone, I would like to know where to start when designing a HMI+PLC Allen Bradley based, that complies with CFR 21 PART 11, ALCOA...
Replies
4
Views
2,922
Hello, in iFix I want to do a boolean calculation with two values, and generate an alarm if the result is true. The calculation in my BL block...
Replies
3
Views
2,196
Back
Top Bottom