Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: DLTimmons on February 20, 2013, 02:14:26 PM

Title: Moving serial input data between Do-More CPU's
Post by: DLTimmons on February 20, 2013, 02:14:26 PM
Hi

I have a conveyor system that will have 4 do-more's in it, one working as a master that is connected to a pc by a rs-232 link. The other three will be controlling a section of the system. Two sections will have a bar code scanners  one of these scanner will read three bar code label back to back the other will be just one label the third section will have two scanners one read one label the other reading 3 labels. Each label will have 12 charters to read on each label keeping track of where each label is very important as this how an ASRS crane knows where to pick the bin from. I need to get this bar code info to the master CPU. I am trying to find the cleanest way to pass this data to the master any suggestions. I will need most of the peerlink for hand shaking between sections and the master. Is modbus the best way?

If Rel 1.1 will let you use Ctrio's and Serio's in remote racks that would be the way to do it.

Donnie
Title: Re: Moving serial input data between Do-More CPU's
Post by: DLTimmons on February 20, 2013, 02:43:58 PM
If using Modbus how do you move the string data to Modbus server data registers and back to a string on the receiving side?
Title: Re: Moving serial input data between Do-More CPU's
Post by: Greg on February 20, 2013, 05:07:50 PM
Modbus TCP would certainly be a good way to move this data. The question is, do you want your 3 "slaves" to send data to your "master"? Or do you want your "master" to poll the slaves? There are many ways to do this, but here's a possible outline:

Slaves send data:
1. In slave read barcode data using STREAMIN and store in a byte structure you created or simply N-memory, D-memory or V-memory
2. In slave use MWX to write this memory to holding registers (MHR-memory) in the master
3. In master use STRPUTB to move the MHR-memory bytes (characters) to SS-memory (short string).

Master polls data:
1. In slave read bardcode data using STREAMIN and store directly in MHR-memory.
2. In master use MRX to read slave's MHR-memory and store in N-, D- or V-memory.
3. In master use STRPUTB to move the N-, D- or V-memory to SS-memory (short string).

Technically, you could use a custom UDP protocol (using PACKETIN/PACKETOUT) to send from the slave to the master as well instead of MRX/MWX.
Title: Re: Moving serial input data between Do-More CPU's
Post by: plcnut on February 20, 2013, 05:33:28 PM
What kind of speeds are you talking about? How far apart are the barcodes? How fast are they moving? Do you have to trigger the reader: serial, discrete, or is does it stream data constantly?
And then how much time do you have to do something with the data?
Title: Re: Moving serial input data between Do-More CPU's
Post by: ATU on February 20, 2013, 06:38:06 PM
Which DoMore CPU are you using?
Title: Re: Moving serial input data between Do-More CPU's
Post by: DLTimmons on February 21, 2013, 10:31:28 AM
Greg

I was thinking of polling based of a peerlink bit to request a read from the master CPU. That is the slave would set a bit once the master saw that bit it would read the data from the slave. once confirmed the slave could clear the data till the next read
Each of the three slave CPu would handle the local control of the bar code scanner's that are rs232 into a Serio card

I have two ways the barcodes are read one reads only one bin label then there several minutes before a new read happens the other reads three bins a couple of seconds apart then does not see any other bins for sereval minutes.

I currently have one set of the barcodes being read by a WinPLC One one end of the system I will be changing this over to a Do-more as the two end will be running off the same master.

plcnut

the two ends are about 300 foot apart

ATU

I'm using the DM1E
Title: Re: Moving serial input data between Do-More CPU's
Post by: plcnut on February 21, 2013, 11:02:41 AM
You shouldn't have any problem with handling the data at those speeds. The system I'm working on now scans codes on a conveyor at approx 12" apart at 120fpm and has plenty of time. I trigger the reader via rs232 and then receive the response at 115 kbaud. 
Title: Re: Moving serial input data between Do-More CPU's
Post by: DLTimmons on February 21, 2013, 12:12:14 PM
I'm using an external trigger on the scanner

What is more a problem now is moving the string into the modbus register on one CPU and retreiving it on the other. STRGETB works on the front end but the back STRPUTB works but you have to know the number of bytes. You can use a fixed number of byte but it adds A lot of ..... to the end of the string that will kind of mess with the PC. Looks like I will have to pass a string length along with the string byte data.

Is there a way to convert decial to hex? My PC passes a checksum value as Hex in the string. CHECKSUM give a decial value.

Donnie
Title: Re: Moving serial input data between Do-More CPU's
Post by: BobO on February 21, 2013, 12:36:12 PM
Is there a way to convert decial to hex? My PC passes a checksum value as Hex in the string. CHECKSUM give a decial value.

There is no difference in the data encoding of 0xA and 10. If you are referring to conversion of the string data to it's numeric value, then you will need to do a STR2INT instruction and specify hex.
Title: Re: Moving serial input data between Do-More CPU's
Post by: DLTimmons on February 21, 2013, 01:08:10 PM
Bob

I was just about to reply and you beat me to it.  How to a turn a integer into a hex string to send the proper reply is the next step?

Big program one step at a time :)
Title: Re: Moving serial input data between Do-More CPU's
Post by: plcnut on February 21, 2013, 01:13:00 PM
STR2INT is great, It will give you the length in the instruction as well.
Title: Re: Moving serial input data between Do-More CPU's
Post by: ATU on February 21, 2013, 03:28:38 PM
How large are the data strings from each reader?
Title: Re: Moving serial input data between Do-More CPU's
Post by: DLTimmons on February 21, 2013, 04:27:39 PM
10 Readable charaters
Title: Re: Moving serial input data between Do-More CPU's
Post by: ATU on February 21, 2013, 04:54:04 PM
Why couldn't you use Peerlink for all the coms between PLC's?
Title: Re: Moving serial input data between Do-More CPU's
Post by: DLTimmons on February 21, 2013, 05:52:14 PM
I will be needing most of the peerlink for control interlocks between the 4 cpu's I would have to have over 80 bytes for the scanner data along.
Title: Re: Moving serial input data between Do-More CPU's
Post by: ATU on February 21, 2013, 06:10:09 PM
What if you broadcast the scanner data 1 character at a time?
Title: Re: Moving serial input data between Do-More CPU's
Post by: plcnut on February 21, 2013, 07:33:08 PM
10 Readable charaters
That only requires a 14 byte string. And with as much time as you have you only need to move one code at a time. If you posted the string into peer link with an identifier to tell which scanner it came from, and have the Plc that is receiving it turn on an acknowledge bit. I believe you could easily move the data with peer link.
Title: Re: Moving serial input data between Do-More CPU's
Post by: DLTimmons on February 22, 2013, 10:08:23 AM
I would much reather have each scanner read in it own location much easier to keep track of and match to proper location. Plus why waste the peerlink band with with something that only needs to be read every few minutes.

I was working with serial port reading strings and noticed that each string has a leading period and a trailing period is this the do=more way of showing nonreadable charters. If so how do I strip them from the leading edge?
Title: Re: Moving serial input data between Do-More CPU's
Post by: franji1 on February 22, 2013, 11:01:04 AM
I was working with serial port reading strings and noticed that each string has a leading period and a trailing period is this the do=more way of showing nonreadable charters. If so how do I strip them from the leading edge?
Yes, it's impossible to display non displayable characters (e.g. CR/LF etc.), so in Ladder Status it replaces those characters with a PERIOD.

I recommend looking at DataView where it has multiple display formats for STRINGs.

* ASCII (default, also same format as what is displayed in Ladder Status) - all displayable ASCII characters are shown, non-ASCII and control characters get replaced with a "."
* Quoted - handles anything/everything, just as if you had to enter a string literal containing THAT character sequence in an instruction.  Hence, it uses the $-based escape sequence for non-displayable characters (e.g. Hello<CR><LF> is shown as "Hello$0D$0A"
* Hexadecimal - dumps the characters in groups of 4 as their hex equivalent, e.g.
48 65 6C 6C   6F 0D 0A
* 4/8/16/24/32 Hex/ASCII - both Hexadecimal and ASCII.  If you've ever seen binary editors or debuggers where you see raw bytes followed by their ASCII equivalent, that's what this is.  You can display 4, 8, 16, 24, or 32 characters per line (so you can view long strings in your Data View as either tall/thin or wide/short).

Attached is a screen shot showing those formats of the STRING Hello<CR><LF> with the last two being 4 Hex/ASCII and 8 Hex/ASCII

Look at the Data View to see if these are non-critical data.  If so, then use the STRSUB instruction to EXTRACT the "middle" out of the string.  Offsets are 0-based, so to skip the first character, you would use STRSUB with Starting Offset of 1, whth a Length of 10 (you mentioned 10 readable characters), or possibly 8 if that length of 10 also included these two extra control characters.
Title: Re: Moving serial input data between Do-More CPU's
Post by: DLTimmons on February 22, 2013, 11:54:38 AM
" Offsets are 0-based, so to skip the first character, you would use STRSUB with Starting Offset of 1, " Visual Basic uses base 1

Ok that along with the fact the pc that is sending the command string I decodeing is send the following "TxString = Chr(10) + TxString + Checksum + Chr(13)"

That is why I see the leading period in the string in the Do-More

This is turning into one big tought elephant, alot of chewing ::)
Title: Re: Moving serial input data between Do-More CPU's
Post by: plcnut on February 22, 2013, 12:09:02 PM
String manipulation in the DoMore is really quite easy. Have you looked at any of the examples posted in the forum here? Bobo posted one for a GET request that may help you see how some of it works.