UART error with holding registers

Any bugs you encounter with Flowcode should be discussed here.
Post Reply
flowcode-developer
Posts: 37
http://meble-kuchenne.info.pl
Joined: Thu Feb 02, 2023 9:32 pm
Has thanked: 19 times
Been thanked: 3 times

Flowcode v10 UART error with holding registers

Post by flowcode-developer »

Hi,
I made a program that sends a command to a device, the device returns a string that is cleaned and put into a holding register. I am doing this to get three different strings.

The issue I am having is that after I get the model number from the device the other items I get from the device (serial number and ch4) take a while to show up on the hold register and will update a couple of times. I want all variables to be constantly updating. It must be something in my logic but I haven't a clue. I am calling the devices from the inspectra model. I hope I made sense with my issue. Feel free to ask.

I have attached my code below

Thank you,
Attachments
inspectra4.fcfx
(44.39 KiB) Downloaded 38 times

BenR
Matrix Staff
Posts: 1759
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 447 times
Been thanked: 606 times

Re: UART error with holding registers

Post by BenR »

Hello,

For your inspectra rs232 communications, you send out a "G00\r" string and then wait for the reply, i'm guessing the reply also contains a \r to signify the end of the reply. I have adjusted your program so that the modbus communications can happen seperatley from the RS232 communications and also adjusted the RS232 communications to try and action the reply as it comes in rather then relying on delays.
inspectra4.fcfx
(45.15 KiB) Downloaded 41 times

flowcode-developer
Posts: 37
Joined: Thu Feb 02, 2023 9:32 pm
Has thanked: 19 times
Been thanked: 3 times

Re: UART error with holding registers

Post by flowcode-developer »

Thank you. I tried out the code. I was getting 0 in the 100 register. i used my LCD to diagnose the issue. I am getting back a string "00200E". See image below. I am supposed to get "H00200\r" I did try other strings and numbers all didn't have any issues. I can't figure out what is removing that first character when it polls the device.
Attachments
string returned
string returned
MicrosoftTeams-image (4).png (639.24 KiB) Viewed 766 times

BenR
Matrix Staff
Posts: 1759
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 447 times
Been thanked: 606 times

Re: UART error with holding registers

Post by BenR »

Hello,

The three horizontal lines at the end of the string are the \r character.

You're code was pulling out the first byte and I kept this in in the example I posted. Just remove this icon to avoid removing the 'H' character.

Example.jpg
Example.jpg (59.53 KiB) Viewed 755 times

Post Reply