News:

  • July 25, 2026, 12:00:19 AM

Login with username, password and session length

Author Topic: BRX internal serial port basics  (Read 10433 times)

RaymondC

  • Full Member
  • ***
  • Posts: 27
BRX internal serial port basics
« on: November 06, 2020, 06:44:56 PM »
Howdy,

Some questions on the basics of using the BRX's internal serial port to send ASCII text to an LCD character display.

1 - If I configure the serial port settings through the dashboard, do I still need to use the SETUPSER instruction?
2 - Is the OPENDEV instruction required or only needed if I want to assign a nickname to @IntSerial?
3 - I set the serial port protocol to "Program Control" so I believe that means I now use the STREAMOUT instruction to send ASCII strings to the display?
4 - I believe that before using the STREAMOUT instruction, I first have to use STRINSERT to put the desired data into the string parameter? Should I also use STRCLEAR before each time I change the data in the string parameter or does STRINSERT automatically overwrite the previous value?
5 - This question may be specific to my display but I suspect it is probably similar to most displays. My display says to send the hex value for each character. So how do I format this data in the STRINSERT instruction? For example, if I want to send "ABC" do I enter "414243" or "0x410x420x43" or "0x41 0x42 0x43"?

Thank you.

Ray

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3835
    • Host Engineering
Re: BRX internal serial port basics
« Reply #1 on: November 07, 2020, 09:31:10 AM »
1. No
2. No
3. YES
4. Just use STRPRINT and look at the Help for the scripting language.  There is a button in the STRPRINT editor for bringing it up.
5. It is probably ASCII, so STRPRINT does that.  It can do raw binary also, e.g "$0D$0A" is CR/LF using $ escape sequence inside the double quotes.  See the Help topic.
« Last Edit: November 07, 2020, 10:17:21 PM by franji1 »

RaymondC

  • Full Member
  • ***
  • Posts: 27
Re: BRX internal serial port basics
« Reply #2 on: November 09, 2020, 02:25:24 PM »
Thanks for the suggestion to use the STRPRINT instruction. I like it.

I am now having a problem with the STREAMOUT instruction: A multiscan instruction was forcibly terminated to prevent a hung device - $InstrTerminated (ST147)


franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3835
    • Host Engineering
Re: BRX internal serial port basics
« Reply #3 on: November 09, 2020, 02:32:44 PM »
I am now having a problem with the STREAMOUT instruction: A multiscan instruction was forcibly terminated to prevent a hung device - $InstrTerminated (ST147)
STREAMOUT must continue to execute while the asynchronous instruction executes (think 2048 baud on a PLC running ladder logic scans sub milliseconds).  It could take a while for the STREAMOUT to complete successfully.  The STREAMOUT byte streaming is asynchronous to the PLC scan.

Are you using the STREAMOUT in $Main or another code block?  Which one?
Are you using STREAMOUT in a Stage and JMPing out prematurely?

RaymondC

  • Full Member
  • ***
  • Posts: 27
Re: BRX internal serial port basics
« Reply #4 on: November 09, 2020, 02:41:22 PM »
Thank you! I was jumping out of the stage prematurely.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3835
    • Host Engineering
Re: BRX internal serial port basics
« Reply #5 on: November 09, 2020, 04:55:11 PM »
Thank you! I was jumping out of the stage prematurely.
If STREAMOUT is used in a Stage, it's best to use STREAMOUT's built-in OnSuccess/OnError JMP to Stage mechanism rather than setting a bit and using normal RLL to figure out when to JMP.  Stages should be relatively small, doing 1 thing, with simple transition logic.  If you try to do too much in one stage, especially w/asynchronous instructions, you end up with situations like a premature instruction termination.

RaymondC

  • Full Member
  • ***
  • Posts: 27
Re: BRX internal serial port basics
« Reply #6 on: November 09, 2020, 07:35:57 PM »
Thanks again. I am no longer getting any errors from the BRX but neither am I getting any characters to display. To be honest, I'm not even sure I have the darn thing wired up correctly.

I'm not even sure trying to send text to this display ( https://www.newhavendisplay.com/nhd0216k3znswbbwv3-p-5739.html ) is possible from the BRX.

Does anyone have any experience using a character LCD display from a BRX? Perhaps a sample program?

RaymondC

  • Full Member
  • ***
  • Posts: 27
Re: BRX internal serial port basics
« Reply #7 on: November 11, 2020, 12:32:50 PM »
After some more research, it turns out that the BRX PLC's serial port is a standard RS-232 port so I need a TTL Converter to be able to communicate with the LCD display.