adccommunitymod (AutomationDirect) asked a question.

F2cp128 & plc

Created Date: June 03,2013

Created By: hoejinkim

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

Hi, I am amateur of PLC. F2CP128 module has to send data of Bar code reader to CPU of PLC. and I want to check if CPU(ladder logic) receives data of Bar code from the module(F2CP128). I am not quite sure if ladder logic code and F2CP128 code are right or not. Code of F2CP128 module, example of Fact engineering website. ________________________ 10 REM *** 12 REM Example Communication Program for F2-CP128 14 REM 16 REM This is a generic example showing how to read data 18 REM from a serial device (scale, bar code, etc), parse numeric 20 REM data from the string and write the numeric data to the PLC 22 REM 24 REM This example assumes that the data is in the following format: 26 REM +####.##CRLF 100 REM *** 102 STRING 2551,254 : REM Allocate String Space 10*254 Strings 104 SETPORT 1,9600,N,8,1,N : REM Programming/Monitoring 106 SETPORT 2,9600,N,8,1,N : REM Scale 108 SETINPUT 1,1,10,0,1000,20 : REM Define how INPUT will work 110 REM --- 112 PRINT1 "Waiting for Data " 130 REM --- 132 INPUT2 ,$(0) : REM Input Data to String 0 ($(0)) 134 IF INPLEN=0 THEN PRINT1 "Device Timed Out " : GOTO 130 136 SDTA=VAL(MID$($(0),1,8)) : REM Parse Data from String 138 S205_VB(2000)=INT(SDTA) : REM Write Data to PLC 140 PRINT1 "Data= ",SDTA 160 REM --- 162 GOTO 130 : REM Loop __________________________ Ladder Logic is in attached file


  • adccommunitymod (AutomationDirect)

    Created Date: June 03,2013

    Created by: scott.lawrence

    F2CP128 module has to send data of Bar code reader to CPU of PLC.

    and I want to check if CPU(ladder logic) receives data of Bar code from the module(F2CP128)

    You don't really need to write to the CP128 with the PLC.. it's easier & faster to do all two-way reads/writes with the CP128... You can set a bit in the PLC using the CP128 to do so once the port receives data & BMOVEs the data to the PLC.

    EXAMPLE:

    132 INPUT2 ,$(0) : REM Input Data to String 0 ($(0))

    134 IF INPLEN=0 THEN S205_C(0)=1 : GOTO 164

    136 PRINT1 "Received> ",$(0)

    140 FOR X=1 TO INPLEN STEP 2

    142 SHARED((128+X-1),H)=ASC($(0),X)

    144 SHARED((128+X-1),L)=ASC($(0),X+1)

    146 NEXT X

    150 BMOVE W,VH(2000),K(LEN($(0)))

    160 S205_C(1)=1

    162 REM ---

    164 GOTO 130 : REM Loop

    line 132 takes the data & stores it in string 0.

    line 134 turns on bit C0 in the PLC if there is no data in string 0, then jumps to line 164.

    line 136 prints the data to port 1, usually for troubleshooting.

    line 140 begins the for/next to change the data to ASCII & store it in the SHARED memory portion of the CP128

    line 150 begins the block data move to the PLC

    line 160 lets the PLC know that data has been written to the PLC by the CP128

    line 162 is null

    line 164 tells the CP128 to loop back to line 130

    remember to turn off any bits in the PLC turned on by the CP128 once you either have the data you want, or when you know it wasn't received.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: June 04,2013

    Created by: hoejinkim

    You don't really need to write to the CP128 with the PLC.. it's easier & faster to do all two-way reads/writes with the CP128... You can set a bit in the PLC using the CP128 to do so once the port receives data & BMOVEs the data to the PLC.

    I have no idea what you mean sorry about that,

    I really want to see bar code data showing up on Direct soft5 program to check if the data is received from bar code reader. and after that, i want send this data from PLC to C-more panel to show up the bar code on C-more screen.

    What should I have to do?

    I am amateur of PLC.

    Thanks

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: June 04,2013

    Created by: scott.lawrence

    there is no need for the PLC to 'check ' if the data was received. Using the above example...

    134 IF INPLEN=0 THEN S205_C(0)=1

    this statement means if the input length from port2 = 0, then no data was received, and C0 will be on in the PLC, so the PLC 'knows ' no data was received

    160 S205_C(1)=1

    this statement turns on C1 after the BMOVE, so this happens after the data is received, changed to ASCII, then stored in the PLC, so the PLC 'knows ' it received the BC data

    to 'see ' the bar code in DS, open Data View & choose the V address you sent the BC to with the Co-Pro.

    If you open the Data View, choose V2000, and select Text from the drop down menu, it will show the BC data. Remember, DS will allow only two digits of ASCII data in a single register, so when the data is moved to the PLC, it will take a series of registers, i.e, v2000-v2006 for 14 ASCII characters.

    In the C-More software, choose ASCII string for the tag type and use V2000 as the address. Set the character length to accommodate the string length. The C-More will display what is in V2000 thru what the character length is set for.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: June 10,2013

    Created by: hoejinkim

    QUestion

    Thanks, and i understood what you said

    I am still struggling to get a bar code data to PLC.

    I programmed in CP128 module and run it but it seems PLC doesn't get a data from Bar code reader. but I pretty sure that PLC and module can communicate. but the way I programmed may cause failure to communicate bacode reader with PLC.

    SO, I am wondering if the way that I connected on CP128 module is right or wrong. One cable for programming from PC to CP128 module is connected to

    Port 1(RS232) and the other connecting to Barcode reader is connected to Port 1(RS422/485) at the same time.(Attached file)

    Where should i connect barcode reader to CP128 module?

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: June 10,2013

    Created by: scott.lawrence

    if the BC reader is RS232, then you have to use ports 1-3, if it's RS422/485, then use ports 1 or 2. Check the jumper settings on the F2-CP128, in the manual, on page 3.3 here...

    http://www.facts-eng.com/manuals/f2cpm.pdf

    then test the connection using hyperterminal or some other serial comms program. You should be able to read & write to the CP-128 from the port the BC reader is intended to connect to.

    after looking at your picture, you ARE tied into the wrong port... the port you have the BC in now, Port 1 RS422/485 is only active if the jumpers on pg 3.3 are set for RS422/485

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: June 10,2013

    Created by: hoejinkim

    if the BC reader is RS232, then you have to use ports 1-3, if it's RS422/485, then use ports 1 or 2. Check the jumper settings on the F2-CP128, in the manual, on page 3.3 here...

    http://www.facts-eng.com/manuals/f2cpm.pdf

    then test the connection using hyperterminal or some other serial comms program. You should be able to read & write to the CP-128 from the port the BC reader is intended to connect to.

    after looking at your picture, you ARE tied into the wrong port... the port you have the BC in now, Port 1 RS422/485 is only active if the jumpers on pg 3.3 are set for RS422/485

    SO then where can i connect BC reader to?

    And I don't understand page 3.3. is there button or wire??

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: June 10,2013

    Created by: hoejinkim

    Here is thing i did

    ______________________

    Code

    10 REM ***

    12 REM Example Communication Program for F2-CP128

    14 REM

    16 REM This is a generic example showing how to read data

    18 REM from a serial device (scale, bar code, etc), parse numeric

    20 REM data from the string and write the numeric data to the PLC

    22 REM

    24 REM This example assumes that the data is in the following format:

    26 REM +####.##CRLF

    100 REM ***

    102 STRING 2551,254 : REM Allocate String Space 10*254 Strings

    104 SETPORT 1,9600,N,8,1,N : REM Programming/Monitoring

    106 SETPORT 2,9600,N,8,1,N : REM Scale

    108 SETINPUT 1,1,10,0,1000,20 : REM Define how INPUT will work

    110 REM ---

    112 PRINT1 "Waiting for Data "

    130 REM ---

    132 INPUT2 ,$(0) : REM Input Data to String 0 ($(0))

    134 IF INPLEN=0 THEN PRINT1 "Device Timed Out " : GOTO 130

    136 SDTA=VAL(MID$($(0),1,8)) : REM Parse Data from String

    138 S205_VB(2000)=INT(SDTA) : REM Write Data to PLC

    140 PRINT1 "Data= ",SDTA

    160 S205_C(3)=1

    162 GOTO 130 : REM Loop

    _______________________________________

    In ladder logic, C3 should turn on when BC reader scans a bar code, but it didn't turn on.

    Also, in the programming, 140 line should print out barcode in ABM but it didn't.

    And In ladder loggic, V2010 shows 4155 as status. what does this mean?

    Is this programming problem or cable connection problem???

    Thanks

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: June 11,2013

    Created by: scott.lawrence

    page 3.3 in the manual shows the jumper settings to configure the ports. There are plastic/metal jumpers, and they slide onto the prongs on the module. How you set this up will dictate how your ports will function.

    I'm not sure what the rest of your program is doing, maybe something else is writing to V2010.......

    The Co-Pro is telling you that no BC was received by printing "Device Timed Out ". Move the BC cable up to Port 2 (See your previous picture) and test it again.

    in your code, the CP128 will turn on C3 AFTER it moves the data to the PLC... since the device timed out (no data in buffer) in line 134, the GOTO instruction made the program loop back to line 130 to check the input buffer again, never going past line 134, so lines 136-162 were not processed.

    Let's take this one step at a time..first the BC reader & CP128

    verify that the BC is RS232, and if so, plug it into the port second from the top.

    verify that the BC is indeed sending the CRLF termination character (found in BC documentation). Modify your code to fit the response from the reader.

    attempt to read a bar code, and verify that you "see " the data when connected to the CP128. If not, verify all cables & wiring. I know this part is frustrating, but wiring really is the big "gotcha " for 99.99% of all electrical errors.

    Once you can "see " the data in the CP128, the way your BASIC is written, you will see the data change and C3 come on.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: June 11,2013

    Created by: hoejinkim

    page 3.3 in the manual shows the jumper settings to configure the ports. There are plastic/metal jumpers, and they slide onto the prongs on the module. How you set this up will dictate how your ports will function.

    I'm not sure what the rest of your program is doing, maybe something else is writing to V2010.......

    The Co-Pro is telling you that no BC was received by printing "Device Timed Out ". Move the BC cable up to Port 2 (See your previous picture) and test it again.

    in your code, the CP128 will turn on C3 AFTER it moves the data to the PLC... since the device timed out (no data in buffer) in line 134, the GOTO instruction made the program loop back to line 130 to check the input buffer again, never going past line 134, so lines 136-162 were not processed.

    Let's take this one step at a time..first the BC reader & CP128

    verify that the BC is RS232, and if so, plug it into the port second from the top.

    verify that the BC is indeed sending the CRLF termination character (found in BC documentation). Modify your code to fit the response from the reader.

    attempt to read a bar code, and verify that you "see " the data when connected to the CP128. If not, verify all cables & wiring. I know this part is frustrating, but wiring really is the big "gotcha " for 99.99% of all electrical errors.

    Once you can "see " the data in the CP128, the way your BASIC is written, you will see the data change and C3 come on.

    Hi

    BC reader is using RS422 cable, so I put that into Port 1 RS422, and put another cable for programming into Port 1 RS 232.

    Do i have to put both cable into the same number port, Port 1 or Port 2?

    What is RT2 red light on CP 128 module? I jut got it after changing jumpers.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: June 11,2013

    Created by: scott.lawrence

    if the BC is indeed RS422, then it should go into the bottom port in your picture, but the module jumpers should be set (pg 3.3, F2-CP128 manual) for RS422 as well for that port.

    Port 1 should be as it is, just for programming/troublshooting

    the lights on the CP128 are indicators of data movement... the RX is for Receive, the TX is for transmit, the CTS is Clear to Send, the RTS is Request to Send.

    Expand Post
10 of 27