In over my head (ladder logic) Horner PLC, serial Barcode scan

I still do not think the read loop is robust as it is implemented now; relying on reading exactly 29 characters will eventually fail and hang up the process.


This is correct.


1. As of now, When i scan a good code, it does as expected.


2. When i scan a correct length bad code, the red light illuminates.
If i scan a good code after (without breaking PART_POS1) red and green illuminate and the cyl retracts.


(this is alright, but should switch from red to green, not both)




3. When an incorrect, mismatch length barcode scans, it does nothing, Then a good code scanned does nothing. (light should illuminate red)


Then if i break contact with PART_POS1, make and rescan, it does as expected.




So as of now, the logic cannot robustly verify good and bad codes.


What's next? I have this almost wrapped, this last bit and i believe im set. I am going to build one more assembly to practice on and work at fully understand the logic we've come up with here


** IS this code from post #60 http://www.plctalk.net/qanda/showpost.php?p=895960&postcount=60
still possibly the way to get this more robust?
 
Last edited:
This should fix the two-lights-on-at-the-same-time issue.
xxx.png
That 251-byte read *might* work, but I expect the most robust algorithm will be the one suggested in the Horner video i.e. wait for a time period where the number of characters read (RX Count) is non-zero (in our case, greater than two) and constant.

Btw, I would not bother with a timer as they did in the video; a counter that increments by 1 on each scan cycle should be adequate, probably about 250 to 25, assuming a scan time of 1ms to 10ms; you might have to find the best value empirically.

The increment would be unconditional whenever the counter is less than 251 (or 26).

The counter would be assigned a value of 0 if either the [RX Count] value was less than 3, or the [RX Count] value was not the same as the [RX Count] value saved from the previous scan.

When the counter is 250 (or 25), that is the scan which is the equivalent of the Read_Complete bit being one in the current code, so remove the [Normally Open Coil Read_Complete] from the output rung of the [RECV] instruction, and add a rung comprising

  • [EQ_INT %R00100(RX Count) 250] => [Normally Open Coil Read_Complete]
after the RECV.
 
Last edited:
This should fix the two-lights-on-at-the-same-time issue.That 251-byte read *might* work, but I expect the most robust algorithm will be the one suggested in the Horner video i.e. wait for a time period where the number of characters read (RX Count) is non-zero (in our case, greater than two) and constant.

Btw, I would not bother with a timer as they did in the video; a counter that increments by 1 on each scan cycle should be adequate, probably about 250 to 25, assuming a scan time of 1ms to 10ms; you might have to find the best value empirically.

The increment would be unconditional whenever the counter is less than 251 (or 26).

The counter would be assigned a value of 0 if either the [RX Count] value was less than 3, or the [RX Count] value was not the same as the [RX Count] value saved from the previous scan.

When the counter is 250 (or 25), that is the scan which is the equivalent of the Read_Complete bit being one in the current code, so remove the [Normally Open Coil Read_Complete] from the output rung of the [RECV] instruction, and add a rung comprising

  • [EQ_INT %R00100(RX Count) 250] => [Normally Open Coil Read_Complete]
after the RECV.


Alright, That fixed my light issue.


If an incorrect barcode is scanned, it doesn't turn red (ie, water bottle, chip bag, etc)


If i break PART_POS1 then scan a good or bad correct length code after re-making PART_POS1 then all works correct...


I am not finding that Horner video at this time, Do you have the link?


I can attempt to do whats in there, Or if you don't mind a little more assist...
 
I am looking at this today.


While reading, i see that i can program the scanner to add a prefix/suffix to the data on scan. Would it be easier to have a known end character on all scans?

I think the carriage return, that is already the suffix/terminator, is all that should be needed.
 
Even for scans where the code isn't expected length? (i assumed CR was from the code im scanning, It must come from the scanner?)

Yes, the scanner itself adds the CR, and by default, if I remember the documentation correctly.

So a CR will, usually I assume, will be followed by a pause (the scanner has an inihibit-duplicate-code timeout, again IIRC); the example in Horner's youtube video detects that pause. So if you do the same thing, all your code has to do is check the last three characters - 'BC<CR>' nominally - and act accordingly. N.B. that does not check the length of the scanned code!
 


I'll get this right one of these days... I am still unable to get a red light on a bad, unknown length code (ie doritos bag, water bottle, etc)



I'm back to your barcode_time.pdf for ref...


I'm not getting a green on good scan.
I see that the data comes into Rx_buf %R00101, But our compare string is using Cmp_Buf %R00501 as its source.... Im not seeing how we moved the data from 101 to 501, Or is there a typo here i'm catching?

11022021a.jpg
 
I'll get this right one of these days... I am still unable to get a red light on a bad, unknown length code (ie doritos bag, water bottle, etc)


I'm back to your barcode_time.pdf for ref...


* this code is not working much at all * I thought it was, I'm back to grasping at straws i think. going back to the code that i had working a few days ago and see if i can implement the counter or timer (attached.... This one is working, except rejecting bad codes)


Guess @L33R is right. I should stick to mechanical things :(

10222021a.jpg
 
Last edited:
Rung 5, grid positions 11/I and 12/I, should be transferring the data, which was read from the scanner and placed in [%R00100 through %R00127] by the RECV instruction, both to [%R00300 through %R00427] and to [%R00500 through %R00627].


I notice the TON has a 0.1s in it; that should be 0.01s, IIRC, so the timer expires after a quarter-second (twenty-five 0.01s steps), not after two and a half seconds (twenty-five 0.1s steps), although that may not matter.


Update: if the scanner sends another code before the timer expires (2.5s after the last code), then the [RX Count => RX_Cnt] may continue to increment, which will keep the timer from ever completing, so maybe that 0.1s/0.01s is the problem.
 
Last edited:

Similar Topics

Good Afternoon , I'm sure there are many Ishida Muti-Head Weigh Systems . We have a Ishida CCW-M-214W Multi-Head system . We are...
Replies
1
Views
525
Hi all, have a project which requires reading a weigh head weight over ASCII. Never really touched ascii so struggling a bit. The weigh head is in...
Replies
11
Views
1,241
Good Morning , We have a Ishida Multi-Head Scale . I had experiece with them for chips , crackers , etc. , but now we are using them for...
Replies
7
Views
457
Hello expert I have migrate legacy project that use Applicom OPC DA with 3rd client and S7-400. I see in client code add item string call...
Replies
0
Views
364
Got another one a whole team of us and the OEM cannot figure out. Powerflex525, 20HP VFD, commanded over Ethernet won't turn a motor it's turned...
Replies
32
Views
7,898
Back
Top Bottom