Author Topic: barcode  (Read 11089 times)

leonstonebank

  • Newbie
  • *
  • Posts: 5
  • I'm a llama!
    • View Profile
barcode
« on: April 22, 2010, 12:23:44 AM »
hi i am trying to read in barcode scanners into the 2 ports thats the easy bit

needed the first scanner to go into a shift register and cycle down the register until a position it matchs the data from the second

i am used to programming omron plc and cannot find a way to create a shift reister moving the A$ registers

or moving the input data to a DM or A$ area

i am used to the omron commands

any help would be very helpfull

regards

leon

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:barcode
« Reply #1 on: April 22, 2010, 05:02:24 AM »
If you are using the T100MD+, Nano-10 or F-series PLC you can simply use an index to store the input data into the DM area.

E.g.  if you use N as an index:


A$ = INPUT$(1)
IF LEN (A$) <> 0
  N = N+1
  IF N > 100    ' create a circular buffer from 1 to 100.
      N = 1
  ENDIF
  DM[N] = VAL(A$)
ENDIF

A custom function containing the above code will read barcode input into DM[1] to DM[100] and then wrap around back to DM[1].

If you are to access the last read data you can simply read from DM[N]


Email: support@triplc.com
Tel: 1-877-TRI-PLCS

leonstonebank

  • Newbie
  • *
  • Posts: 5
  • I'm a llama!
    • View Profile
Re:barcode
« Reply #2 on: April 22, 2010, 08:46:03 AM »
that makes sense but

i need to shift the new data into DM[1]

then as new data comes in move DM[1] to DM[10] them DM[10] to Dm[20] upto DM[160]

so there will be 16 registers(16 machine track cycles)

and at machine cycles, register cycle i will match the data form the second scanner


the data will be moving the same time as a machine cycle so to keep track of the barcode as it moves down the track  


hope i have explaned but better

i have some T100MD 888+

regards

leon

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:barcode
« Reply #3 on: April 22, 2010, 06:28:21 PM »
I am not sure why you must shift the data instead of using the index ( you can use one or more indices to keep track of the DM that you program is working with). But if you really must shift data, you can write a FOR NEXT loop.

E.g. The following routine shift data from DM[N-1]  to DM[N], then DM[N-2] to DM[N-1] and so on until DM[1] to DM[2] .    

The new data is stored into DM[1]. You have to test the       condition of N = 160 and decide what you want to do when it reaches 160.

E.g.
     
A$ = INPUT$(1)
IF LEN (A$) <> 0
  N = N+1
  ' IF N = 160 THEN...... ELSE...ENDIF
  FOR I = N to 2 STEP -1
       DM[N] = DM[N-1]
  NEXT
  DM[1] = VAL(A$)
ENDIF
Email: support@triplc.com
Tel: 1-877-TRI-PLCS