You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old February 13th, 2021, 10:25 AM   #46
parky
Member
United Kingdom

parky is offline
 
parky's Avatar
 
Join Date: Oct 2004
Location: Midlands
Posts: 3,084
Not sure what you mean, there is only one shift register, so can only have one divert, if a box has a "6" in it then it can only go down one cross lane (Lane6).
  Reply With Quote
Old February 13th, 2021, 10:44 AM   #47
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 2,587
Quote:
Originally Posted by parky View Post
Not sure what you mean, there is only one shift register, so can only have one divert, if a box has a "6" in it then it can only go down one cross lane (Lane6).

yeah, I know, my bad, my brain turned off for a bit there.
  Reply With Quote
Old February 13th, 2021, 10:54 AM   #48
parky
Member
United Kingdom

parky is offline
 
parky's Avatar
 
Join Date: Oct 2004
Location: Midlands
Posts: 3,084
We all get that, in my case it's old age lol,
  Reply With Quote
Old February 16th, 2021, 03:21 PM   #49
kalabdel
Member
Canada

kalabdel is offline
 
Join Date: Feb 2015
Location: Ontario
Posts: 720
I don't have TIA14 loaded on my laptop so I put it on TIA13SP2, man was that primitive compared to 16.
I imported a tested code but I couldn't test the simulation blocks on TIA13 because PLCSIM crapped out for some reason.


So instead of just checking for duplicates I decide to test for count values that are too close based on a settable value.
The justification for that is that depending on how fast things are moving and encoder resolution I may a get two values that are too for the scan time. LINK
  Reply With Quote
Old February 16th, 2021, 05:45 PM   #50
kalabdel
Member
Canada

kalabdel is offline
 
Join Date: Feb 2015
Location: Ontario
Posts: 720
Oops

Quote:
#tmp_dintAverage := #st_arrPendingPOS[1, #cst_COUNTER_VALUE]/2 + #st_arrPendingPOS[#st_iNumOfPending, #cst_COUNTER_VALUE]/2;
  Reply With Quote
Old February 17th, 2021, 04:07 AM   #51
parky
Member
United Kingdom

parky is offline
 
parky's Avatar
 
Join Date: Oct 2004
Location: Midlands
Posts: 3,084
I had some time on my hands, just done some experiments (Mitsubishi Q series), used the block move for 500 registers just made the destination +1 from the source, no other program and the scan time was 0.6ms, Tried with shift register, & the scan time went up to 2.4ms. Then tried a for next loop & same result 2.4ms, so as for scan time it only makes just less than 2ms above the scan time of the block move, in reality this is not going to cause a major difference unless the pulses are less than the scan time. but block move in this case was certainly the fastest, I tried adding the block move to a reasonable sized program & the scan time only increased by 0.4ms.
Not been able to try this on any other platform so cannot verify what functions will increase the scan time more, It appears on Mitsubishi the block move compiled code is the most efficient, however, it appears that the shift function must be producing similar code to the for next loop which is in ladder.
  Reply With Quote
Old February 19th, 2021, 07:19 AM   #52
Bcurry135
Member
United Kingdom

Bcurry135 is offline
 
Join Date: Dec 2020
Location: Mid Ulster
Posts: 36
Quote:
Originally Posted by parky View Post
Here is my suggestion, I have based it on what I understand, basically the code is no more than 50 lines I did in a bit of ST for the shift (although on my Mitsi simulator could have done it in all ladder or FBD & it could have been smaller as it has word and bit shift that's easy to use.
Not going to post the code as it is only a test but here is what I consider a one lane to 6 take off conveyors, the operator decides where the pack is going to be diverted to and presses one of the six buttons, this loads the shift register with the lane number, when it reaches that lane the register at that position is compared with the lane number an diverts the pack down that lane, not bothered to delete the value in the shift register as it falls off the end of the shift eventually.
As I said this is only a test and is limited to 28 shifts on the screen for demonstration but the shift register is currently 1000 words.
Here is a screen shot taken during the running & a couple of diverts working shown by a lamp being green.
This is exactly the way I have been looking to implement the control, did you do this in a similar way to @drbitboy’s code?
  Reply With Quote
Old February 19th, 2021, 07:35 AM   #53
parky
Member
United Kingdom

parky is offline
 
parky's Avatar
 
Join Date: Oct 2004
Location: Midlands
Posts: 3,084
No I wrote it before he did, but never posted it, and I never bothered to save the code,
Here is a homemade shift register using pointers
SET(Trigger,Pulse); (*Set the bit to run the logic *)
IF Pulse
THEN
Index:= 63;
FOR Loop_Count:= 0TO 63 DO;
Last_Index:= Index-1; (* need to point to the array - 1 as well as the array pointer *)
My_Array[Index ] := My_Array[Last_Index];
Index:= Index -1; (*Decrement the index pointer *)
END_FOR;
Pulse:= FALSE; (* Reset the trigger & pulse flags *)
Trigger := FALSE;

END_IF;
Also,
Here is a quickie I did in FBD that shows a simple (only two diverts shown).
Attached Files
File Type: pdf Shift1.pdf (83.1 KB, 9 views)
  Reply With Quote
Old February 19th, 2021, 07:48 AM   #54
parky
Member
United Kingdom

parky is offline
 
parky's Avatar
 
Join Date: Oct 2004
Location: Midlands
Posts: 3,084
Here is another way of doing it using block copy, only thing is you have to zero the first word in the array or every shift would put the same number in.
By copying the block from word zero to word one shifts the data by one all down the line, not sure if this works on all platforms as will depend on how it copies it but in theory it does it in reverse order you would need to try it on S7.
Attached Images
File Type: png Shift using a block copy.png (56.6 KB, 19 views)
  Reply With Quote
Old February 19th, 2021, 08:23 AM   #55
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 2,587
Quote:
Originally Posted by Bcurry135 View Post
This is exactly the way I have been looking to implement the control, did you do this in a similar way to @drbitboy’s code?

It looks like @parky is shifting integer valuess through the position in an integer shift register, which values may be a code for a lane number. Each code will trigger a divert when it is in only one constant position (index) of the shift register.



My implementation was based on bits; bits in integers to be sure, but bits nonetheless. Because my non-shifting register is static and the code is incrementing ("moving") the index, my code

  • assigned 1-bits at an offset from the index
    • @parky's code always writes the code at Register[0] at a certain time
  • triggered divert(s) when 1-bit(s) were found in the integer at the varying index
    • @parky's code triggers a divert when the value at a non-zero index (position, offset in the shift register) matches the code for a divert, and that index for each diverter is constant for each diverter
  • had to clear any bits after they triggered a divert, or else those bits would still be 1 the next time the index rolled around
    • @parky's code did not have to clear the non-zero codes as they were ignored at all indices other than the index for the divert for which they were intended, and would eventually drop off the end (be overwritten, actually).
  • had to use one bit per divert line, not (bar) codes, because multiple diverts could be stored in each integer
    • @parky's code could use multi-1-bit codes
Other than that, they are basically the same.
  Reply With Quote
Old February 19th, 2021, 02:09 PM   #56
parky
Member
United Kingdom

parky is offline
 
parky's Avatar
 
Join Date: Oct 2004
Location: Midlands
Posts: 3,084
DR: not bits words so the operator enters the lane number on the HMI (for convenience I have put 7 buttons so each button will put 1-7 in the array at position 0, when the shift is triggered this shifts the data down the array If you think about the conveyor just being a load of words in the array i.e. one foot of the conveyor = one location in the array so if the diverts were spaced every 20 feet then divert 1 = array[20]. divert 2 = array[40] & so on. so by comparing say array[20] with 1 if true then run divert code & the same goes for the other 6 diverts.
I have done a number of ways to create a "WORD" shift register, i.e. Use in-built (but I don't think S7 1200 has one), the other is to use a loop in ST.

SET(Trigger,Pulse); (*Set the bit to run the logic *)
IF Pulse
THEN
Index:= 63;
FOR Loop_Count:= 0TO 63 DO;
Last_Index:= Index-1; (* need to point to the array - 1 as well as the array pointer *)
My_Array[Index ] := My_Array[Last_Index];
Index:= Index -1; (*Decrement the index pointer *)
END_FOR;
Pulse:= FALSE; (* Reset the trigger & pulse flags *)
Trigger := FALSE;

END_IF;
;

The other is to use MOVE_BLK this could copy say 500 words of array to the same array but shifted by one location
i.e.

MOVE_BLK
IN = Source address (Array[0])
IN = Count (500_
OUT = Dest (Array[1])
So many ways to achieve the same thing
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Siemens or Omron? Gromit LIVE PLC Questions And Answers 35 November 14th, 2017 10:44 AM
Siemens S7 300 Shift Register Dean1278 LIVE PLC Questions And Answers 12 September 20th, 2011 04:39 PM
help with shift register saleshark LIVE PLC Questions And Answers 4 December 8th, 2009 07:50 AM
FTSR-IN & OUT (Fall Through Shift Register) ilikbeer LIVE PLC Questions And Answers 5 January 19th, 2005 03:14 PM
Shift register Divad016 LIVE PLC Questions And Answers 6 November 11th, 2003 08:52 PM


All times are GMT -4. The time now is 10:52 AM.


.