Red Lion and Serial Trigger for Microscan

Damaged

Lifetime Supporting Member
Join Date
Oct 2008
Location
Alabama
Posts
43
Hello guys,

Red Lion - DSPGT000 using RS232 raw driver for port 1 and 2.

I am trying to send a serial trigger to 2 microscan barcode (1 on port 1 and the other on port 2) scanners without any luck. I can set up the scanner to use the external trigger and capture the string using the programs 1 and 2 below. But I would like to use the serial trigger. The microscan is setup to start a read using these settings:

Serial Trigger
Character (Delimited) - SP
Start Character (Non-Delimited) - 0x21 (!)
Stop Character (Non-Delimited) - 0x00 (NUL)

I have a flag bit from a plc when high triggers Program 4 (or a fifth program that will be used for port 2 if I can get port 1 working) then the second trigger for the same flag bit is set to 1 sec later that triggers Program 1 (or 2, depending on the flag/port).

When Program 4 is called, the micrsscan just sits dead. I can connect to the microscan and use the terminal with a "!" trigger and it works all day long.

If you see below in Program 4 I am using the "portprint (1, "!")" and I cant seem to understand why this is not working.

The next issue I have is using Program 3. After Program 1 and 2 have run and set flags (PORT1_COMPLETE = 1;) that they have completed then Program 3 is called and always get the "PASS" string in tag COMPARE_STATUS. The compare program 3 is not as important as the serial trigger as I can do this in the PLC but I would like to find out what I am doing wrong.

I have also pasted (at the bottom) a command that TWControls posted early but didnt understand the structure.

Any help would be greatly appreciated. I can provide Project files if needed.

Program 1

cstring INPUT1 = PortInput (1, 0, 13, 500, 0);

if(INPUT1 != "")
PORT1_STRING = INPUT1;
INPUT1 = "";
PORT1_COMPLETE = 1;
PORT1_TRIGGER = 0;



Program 2

cstring INPUT2 = PortInput (2, 0, 13, 500, 0);

if(INPUT2 != "")
PORT2_STRING = INPUT2;
INPUT2 = "";
PORT2_COMPLETE = 1;
PORT2_TRIGGER = 0;


Program 3

COMPARE_STATUS = "";


if (PORT1_STRING == PORT2_STRING && PORT1_STRING == "NOREAD")
COMPARE_STATUS = "BC NO READ";

if (PORT1_STRING == "NOREAD" && COMPARE_STATUS == "")
COMPARE_STATUS = "BC1 NO READ";

if (PORT2_STRING == "NOREAD" && COMPARE_STATUS == "")
COMPARE_STATUS = "BC2 NO READ";

if (PORT1_STRING != PORT2_STRING && COMPARE_STATUS == "")
COMPARE_STATUS = "MISMATCH";

if (PORT1_STRING == PORT2_STRING && COMPARE_STATUS == "")
COMPARE_STATUS = "PASS";

if (COMPARE_STATUS != "")
START_COMPARE = 0;
PORT1_COMPLETE = 0;
PORT2_COMPLETE = 0;


Program 4

PortPrint(1, "!");






// declare locals
cstring line;
line = "!";
line += DecToText(PORT_WRITE_TAG, 0, 2, 1, 0, 0);
line += " to the serial port";

PortPrint(1, line);
 
I do something similar on some weight controllers. I do not have the code in front of me right now but What I do I Clear the buffer then send my command to my device. I then read back after this.

I have my port clear and write in one program and my read in another so I have separation.

The Clear function makes sure there is no data from a previous read. Doing a write directly after means the next thing to fill my buffer is what I want.

Sorry I cannot give you exact code but if you are still having issues Monday bump this thread and I will post what I do.
 
Clay B,

I was reading your thread on your scales trying to figure this out. So, is the PortPrint in program 4 correct? I will try the clear function as soon as I get a chance, had to move on to another project today.

thanks for you reply!
 
Clay B,

I was reading your thread on your scales trying to figure this out. So, is the PortPrint in program 4 correct? I will try the clear function as soon as I get a chance, had to move on to another project today.

thanks for you reply!

Yes it is correct if you want to send an ! to your device. In my case I send a P to get data .

While reading this I realized there is no actual clear buffer Command. These is however there is a way to read everything in the buffer just prior to sending the write command basically your transmit program will look something like this:

// clear out Port 2 buffer by reading until there is nothing left. The trick is the
//while loop. The loop keeps running until a -1 is returned. The -1 means the
//buffer is empty. Since my wait time is zero I am not waiting on any data in
//transit.

while(PortRead(2, 0) != -1) {}

// send out command for data

PortPrint(2,"P");
Yes it looks bizarre, but it does work.

Now that you have sent your command you need to listen. I listen a certain way and that is below. Also even though I have these in separate programs, I call them with the same trigger. Because of the way subroutines work separating them guarantees things are done the way I want. I just call the transmit before the receive.

cstring P2data;
//Read the data on Port 2. First character I am looking for is an Hex 20
// End character I am looking for is a Hex 4E (the 0x tells the program your
//using hex numbers) I want to wait for 1500 milliseconds to go from my first
//to last character and if I don't get there I close the port (keeps things from
//locking up but will slow things down so you know when you have a Comm
//problem). My length is zero because I want every character of the string
//coming back. I could tell it to end after a certain length but with the zero if
//I get noise I will just time out.

P2data := PortInput(2,0x20,0x4E,1500,0)

On your reads it is a good idea to know what you are expecting. It is real handy if you know what your leading character is. This way you yank out only the data you want without the wrappers. Because I know the beginning and ending characters I can slice and dice my incoming data even though the numbers will vary with the amount of weight on the scale and also I can switch back and forth between zero, one and two decimal places on my scales without headache.
 
Last edited:
Clay B

Finally got the Red Lion installed. Here was the problem.

I had 2 microscan scanners that I was using to test with. Once I had everything reading I downloaded the customers microscan file to the scanner I was working with. That is when I setup the serial trigger and it never worked, ......(tail tucked between legs) I never checked the port settings in the new file and they were different from what I had the G3 setup for.

So the "portprint" would have worked out of the box if I had the correct setting on each port. So Once I changed the port settings to match WHA LA....worked.

The only thing is that I could not get the compare program working.
 
Glad to here you got it talking. For me getting the Comms to work is where I spend most of my time on new systems.

As far as your Compare Program The reason you got "Pass" and nothing else is kind of obvious to me. Mainly because I do it all the time.

You have a NOREAD but I see no where that you put that into either of your Port1_String or Port2_String so that line will never work.

By that logic the next 2 lines will not work either.

The 4th line with the mismatch is a bit of a puzzle. Unless you fat fingered the "" and put a space in there either in the compare or at the beginning of the program it should work

The 5 line was set when you first fired the system up since everything equaled "".

Another bit of advice: When you run your read programs place something into PORT1_String and PORT2_STRING before you do the data compare to load the data from INPUT1 and INPUT2. That NOREAD string would work.
 
Clay B

The "NOREAD" is a string that will populate the tags by the barcode scanners on a no read (timeout).

The 4th line:

if (PORT1_STRING != PORT2_STRING && COMPARE_STATUS == "")
COMPARE_STATUS = "MISMATCH";

If barcode scanner string 1 is not equal to barcode scanner 2 AND compare status equals null (blank, nothing) then populate compare status with "MISMATCH".

Good point on line 5. How can I loop the first 4 compares 5 or 6 times then run the compare on line 5? hmmmmmm

The program is called after the port read so the port string tags should be populated by the time it runs.

Thanks for your replies Clay B!!!!
 

Similar Topics

Hi All, I am looking to install a Red Lion CR3000 HMI and connect it to a Mitsubishi FX3u 64M PLC via Serial. I cannot find confirmation on...
Replies
8
Views
2,768
Hi, has anyone ever setup an Adam 4572 Modbus TCP/IP to Modbus serial convertor? I am trying to use one with a Red Lion DSPSX but cannot...
Replies
5
Views
4,391
I am trying to do my initial download to this Red Lion Kadet (G307K200), and because we didn't purchase Red Lion's specific cable, I made my own...
Replies
8
Views
3,229
Hello, I am attempting to set up a database using a DSPSX000. I am connecting to a device that outputs a results file via RS232 at the end of a...
Replies
17
Views
7,612
Hi, I am going to try and download a database to a G308 via the serial port. Reading the Crimson 3.0 manual I cannot find anything about port...
Replies
5
Views
2,778
Back
Top Bottom