Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: EDurako on July 10, 2018, 10:01:37 AM

Title: BRX Hex out via RS-485
Post by: EDurako on July 10, 2018, 10:01:37 AM
Hello,

I would like to store 2 hex strings in my BRX BX-DM1E-M-D and then based on sensor input, output the strings without converting the bits via the RS-485 port. My current Serial Port Protocol is 'Program Control' and the port type has been set to RS485. Enable 120 Ohm Termination option is false.

My strings are as follows:

02 00 08 30 3D 01 05 41 41 41 41 41 C0 03

02 00 10 30 3D 01 0C 31 32 33 47 34 35 36 37 2D 41 32 33 10 03

I have tried the following commands, COPY, MEMCOPY, Move. I am fairly sure I want to output via the IntSerial.OutQueue or STREAM.

I am having trouble getting all the targets to line up. Any help would be appreciated.
Title: Re: BRX Hex out via RS-485
Post by: BobO on July 10, 2018, 10:25:47 AM
You can write the values to a string using STRPRINT SS0 "$02$00$08$30$3D$01$05$41$41$41$41$41$C0$03"

Send to port with STREAMOUT.

Be sure the port is set to Program Control.
Title: Re: BRX Hex out via RS-485
Post by: franji1 on July 10, 2018, 11:00:27 AM
When using STRPRINT with raw hex string literal, make sure you UNcheck the "Automatically insert space after each term" because it is checked by default  (if you actually do want a space at the end, just add a $20 to the end of your string literal!)
Title: Re: BRX Hex out via RS-485
Post by: BobO on July 10, 2018, 11:07:48 AM
When using STRPRINT with raw hex string literal, make sure you UNcheck the "Automatically insert space after each term" because it is checked by default  (if you actually do want a space at the end, just add a $20 to the end of your string literal!)

Oops...good catch.
Title: Re: BRX Hex out via RS-485
Post by: EDurako on July 10, 2018, 11:10:26 AM
Thanks I really look forward to trying this out as soon as this meeting I got called into is over
Title: Re: BRX Hex out via RS-485
Post by: BobO on July 10, 2018, 11:19:25 AM
That looks great, but be sure to uncheck "Automatically insert space after each term". If you don't there will be a space appended to the end of SS0, which probably shouldn't be sent to your device.
Title: Re: BRX Hex out via RS-485
Post by: EDurako on July 10, 2018, 12:38:34 PM
I have made sure the Add Space Box is UNchecked.

My printer is still not responding to the Hex string.

I ran "$02$00$08$30$3D$01$05$41$41$41$41$41$C0$03" and I also tried "02 00 08 30 3D 01 05 41 41 41 41 41 C0 03"

Both with no luck.

However, with the $ signs in the script it changes the readout so I can see what the Hex string says. I'm not sure if it is then being transferred back to Hex before going to the printer.

I don't quite understand what the $ signs are doing in this script. I am poor with script writing.
Title: Re: BRX Hex out via RS-485
Post by: BobO on July 10, 2018, 12:45:22 PM
$ is an escape character. When you follow it with 2 hex digits, it translates into that exact value. So the character '1' has a hex value of 0x31. If you stuck $31 in the string it is the same as '1'.

Check the serial settings. Baud dates and data bits much be the same at both ends.

Make sure the port is in RS485 mode with the terminator enabled.

Check the wiring. + to + and - to - is normal, but we have seen cases where they are labeled in reverse.

Does your device need any form of command delimiter, like a carriage return / line feed?
Title: Re: BRX Hex out via RS-485
Post by: BobO on July 10, 2018, 12:51:35 PM
And one more thing, when you enter $31, the script parser generates 0x31, and when it re-displays that, it uses the displayable character. That why it comes back with 'A' and other characters.

Another approach would be to create a BYTE buffer and then use the INIT instruction to assign individual hex values to each byte. STRPRINT produces the exact same result though.
Title: Re: BRX Hex out via RS-485
Post by: EDurako on July 13, 2018, 01:34:21 PM
Ok, Sorry for the late response. I had some other things pop up.

When I send the following code from my laptop, the printer responds and prints as anticipated

02 00 0D 00 CA 00 00 04 00 00 00 00 42 55 4E 4E 0E 03

When I put the following script into the STRPRINT command and send via STREAMOUT, there is no response from the printer.

"02$00$0D$00$CA$00$00$04$00$00$00$42$55$4E$4E$0E$03"

I feel like its a simple fix somewhere that I'm just overlooking. Also, I will do multiple posts to convey all the screen shots.

Title: Re: BRX Hex out via RS-485
Post by: franji1 on July 13, 2018, 01:37:13 PM
Looks like you are missing the dollar sign from the first character in STRPRINT.  You are actually dumping two characters "02", not the STX char, which is "$02"
Title: Re: BRX Hex out via RS-485
Post by: EDurako on July 13, 2018, 01:40:15 PM
Looks like you are missing the dollar sign from the first character in STRPRINT.  You are actually dumping two characters "02", not the STX char, which is "$02"

Nice! I fixed that, still no response. I'm having some real trouble getting these screen shots to upload
Title: Re: BRX Hex out via RS-485
Post by: franji1 on July 13, 2018, 01:41:27 PM
Those still don't have the $
Title: Re: BRX Hex out via RS-485
Post by: EDurako on July 13, 2018, 01:43:30 PM
Those still don't have the $

I picked the wrong screen grab. Can you tell I'm ready for the weekend? I get to go home if I get this printer up and going, and I mean the proverbial "I" that actually means "the nice folks in this forum"
Title: Re: BRX Hex out via RS-485
Post by: EDurako on July 13, 2018, 01:45:06 PM
updated. Any thoughts at what I'm still doing wrong?
Title: Re: BRX Hex out via RS-485
Post by: franji1 on July 13, 2018, 01:50:20 PM
I would do the following:
1. Power down the PLC and the Printer
2. Power up the Printer and wait for it to fully power up.
3. Power up the PLC

The printer may get confused if it receives something wrong.  The fact that you are sending something every second (not sure how fast your printer is) may be confusing it even more.  Until you get it working, don't do a STREAMOUT continuously every second - tie it to a C bit you can control from a Data View when it is appropriate (e.g. after the printer has powered up, reset, and is ready to receive commands).

Once you get it working that way, then you can tie STREAMOUT to something real (although I still would not do it every second).
Title: Re: BRX Hex out via RS-485
Post by: b_carlton on July 13, 2018, 02:34:45 PM
You may have done this but I didn't see a confirmation from you. Did you enable the termination and try swapping the RS485 leads?
Title: Re: BRX Hex out via RS-485
Post by: EDurako on July 13, 2018, 02:46:31 PM
I just enabled the 120Ohm termination and tried, no luck, swapped leads, no luck.

Power cycled like suggested, no luck. The printer is pretty quick but I updated the logic to have a controllable C5 bit for STREAMOUT and still no luck. I can see the TX light flash when I toggle C5.

It feels like a problem with the printing script or the PLC settings for the RS-485 port. but I also am not an expert.

The Hex code works great when I send it through the USB to Serial adapter, maybe there is a hint?

I do appreciate everyone's help thus far.

BobO mentioned that the $ in the script was an escape character, I'm not using those when sending via my laptop serial port. Maybe I need to send a literal code to the STREAMOUT?
Title: Re: BRX Hex out via RS-485
Post by: b_carlton on July 13, 2018, 02:56:11 PM
Which application are you using on the PC? Exactly how do you enter the characters? Maybe it is expecting the exact ASCII characters you wrote.
Title: Re: BRX Hex out via RS-485
Post by: EDurako on July 13, 2018, 03:08:36 PM
Which application are you using on the PC? Exactly how do you enter the characters? Maybe it is expecting the exact ASCII characters you wrote.

I am using the Hercules SETUP utility by HW-group.com to send it.

The printer manufacturer has specifically said that is looking for HEX
Title: Re: BRX Hex out via RS-485
Post by: franji1 on July 13, 2018, 03:11:27 PM
BobO mentioned that the $ in the script was an escape character, I'm not using those when sending via my laptop serial port. Maybe I need to send a literal code to the STREAMOUT?

Do not confuse a PRINTER ESCAPE CHARACTER (e.g. to change color or font) with a programming languages escape character for entering non-ASCII characters e.g. STRPRINT escape character value in hex.  Code comes from source files that are in ASCII, so to represent the character A, you type "A".  To represent the character 0, you type "0".  What if you want a carriage return (CR).  How do you type that in a quoted string?
"
"
or a STX
"<IBMPCSMILEYFACE>"?

No.  Programming languages have an "escape sequence" for string literals for entering non-ASCII (or non-printable) characters.  C/C++/Java use backslash followed by 3 octal digit characters, so "\002" is STX.  It also has backslash "x" followed by 2 hex digits, so "\x02" is STX.  In Do-more (and IEC-61131) it is dollar-sign followed by 2hex-digits, so STX is "$02".  CR is "$0D".
Title: Re: BRX Hex out via RS-485
Post by: franji1 on July 13, 2018, 03:13:53 PM
I am using the Hercules SETUP utility by HW-group.com to send it.

The software appears to be dumping raw hex.  I bet there is a radio button next to it that is ASCII (or TEXT).

I bet it's something with wiring/grounding/physical layer.
Title: Re: BRX Hex out via RS-485
Post by: BobO on July 13, 2018, 03:31:46 PM
Serial comms and grounding can be stupid at times. That should be less an issue with RS485 than RS232, but might want to make sure the PLC and device it is talking to are on the same ground. DC powered CPUs seem particularly sensitive to this issue. Never really understood why.
Title: Re: BRX Hex out via RS-485
Post by: EDurako on July 13, 2018, 03:35:36 PM
Serial comms and grounding can be stupid at times. That should be less an issue with RS485 than RS232, but might want to make sure the PLC and device it is talking to are on the same ground. DC powered CPUs seem particularly sensitive to this issue. Never really understood why.

I am using the Hercules SETUP utility by HW-group.com to send it.

The software appears to be dumping raw hex.  I bet there is a radio button next to it that is ASCII (or TEXT).

I bet it's something with wiring/grounding/physical layer.

I am using the Hercules SETUP utility by HW-group.com to send it.


I will add a ground wire in, right now I am using a custom made wiring setup. Photo attached. The printer has its own power supply but both it and my plc power supply are plugged into the same 120VAC circuit.
Title: Re: BRX Hex out via RS-485
Post by: EDurako on July 13, 2018, 03:50:01 PM
Can I use the USB out on this BRX and send it through the serial converter that my laptop is using?

Below is the pin out diagram from the printer for the serial port
Title: Re: BRX Hex out via RS-485
Post by: ADC Product Engineer on July 14, 2018, 09:58:07 AM
You really need to be using twisted shielded pair cable made for RS-485.  Single wires won't cut it.  There is a very close relationship to impedance and capacitance that must be maintained in order for a communications signal to work properly.

You can't use the USB port, it is for programming only.
Title: Re: BRX Hex out via RS-485
Post by: EDurako on July 16, 2018, 05:41:29 PM
You really need to be using twisted shielded pair cable made for RS-485.  Single wires won't cut it.  There is a very close relationship to impedance and capacitance that must be maintained in order for a communications signal to work properly.

You can't use the USB port, it is for programming only.

Any idea where I can buy one of these twisted shielded pairs? Automation Direct?
Title: Re: BRX Hex out via RS-485
Post by: Controls Guy on July 16, 2018, 07:10:57 PM
Yeah, ADC has that.  Also, you can try just twisting the wires (done it many times with a cordless).  That'll help with differential mode noise.