Receive string uart rs232

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
Ronnyvs
Posts: 10
Joined: Mon Mar 25, 2019 3:04 pm
Been thanked: 2 times
Contact:

Receive string uart rs232

Post by Ronnyvs »

Hello everybody!

I'm struggling for a long time to receive data from my serial laser unit which i use to measure distance.
I did a lot of programming in Bascom, and in Bascom it works perfect. i try to do the same in flowcode as i did in Bascom. but i don't get some values at all, and sometimes one or two bytes. But never more!

I sent an attachment which i use in Bascom where it works perfectly, and i sen my flowcode which doesn't work at all...

hopefully someone could help me...

Friendly regards

Ronny
Attachments
Serial_test.fcfx
Test program serial
(14.28 KiB) Downloaded 165 times
Bascom Code serial
Bascom Code serial
Bascomcode_serial_read.png (10.49 KiB) Viewed 3608 times

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Receive string uart rs232

Post by mnf »

Hi Ronny,

The isCharWaiting function doesn't really have an equivalent in FC - what to do is to have an Rx interrupt that puts received characters into a circular buffer (either the FC component or a simple array and counter)

There are examples here https://www.matrixtsl.com/mmforums/view ... rt+receive
and also here https://www.matrixtsl.com/mmforums/view ... rt+receive

Martin

Ronnyvs
Posts: 10
Joined: Mon Mar 25, 2019 3:04 pm
Been thanked: 2 times
Contact:

Re: Receive string uart rs232

Post by Ronnyvs »

Thank you Martin for the fast reply.

I did some tests yesterday and came a bit further. the uart-rx interrupt did the trick..
but still having some issues.

receive as string is (almost) working well"...
(F= fast measure commando)
when i transmit an "F" as string, the laser immediately sends back the "F" and when the data is there the string will be received to(overwriting the F)
not a big problem.. Parsing comes later, but for the loop through in the program, it delays a lot...



So this is why i like a byte after byte solution...
If i try to do that, only the last parts i see. not the first parts

examples:
distance should be:“12.345m, 0079”, i only see actual display" 0079”
version should be:"1702250029,29456" , i only see actual display"029,29456”
Temperature and battery should be:“18.0’C,2.7V” , i only see actual display",2.7”

it looks like the part before the "," is missing or at least a part of it... as you can see only at version the first few numbers are not displayed...

hope you could help me with this last (hard for me) piece of code...

already thanks a lot!!

regards

Ronny

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Receive string uart rs232

Post by mnf »

Hi Ronny,

Can you post your code to date? - and I'll try and see why it's just getting the tail of the string...

Martin

Ronnyvs
Posts: 10
Joined: Mon Mar 25, 2019 3:04 pm
Been thanked: 2 times
Contact:

Re: Receive string uart rs232

Post by Ronnyvs »

Hi Martin,

Of course i can...

this is the first try...
StringRX example_modified.fcfx
(13.45 KiB) Downloaded 185 times
this is the second try...
StringRX example_modified1.fcfx
(13.39 KiB) Downloaded 182 times
both are working a bit, but certainly not well

and a pdf of the lasermodule...
quickguide-lr-module-manuals.pdf
(1.24 MiB) Downloaded 171 times
already thanks,

Ronny

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Receive string uart rs232

Post by mnf »

A couple of ideas to try...

In the first program:

The max string length is limited to 10 chars (receive_pos = (receive_pos + 1) % 10 - receive_pos will go from 0..9 then back to 0 - so increase the 10 to allow for max length of string - might need to increase size of buffer (Data_string) too.

What is the end of string character sent by the laser - the program 'looks' for 0x0D (CR) - but I can't see mention in the pdf manual. It might use a different character (0x0A LF or 0) It might be necessary to change to allow for this - or look for a certain number of character received.

If possible try connecting the laser to a serial port on a PC - (might need to use an FDTI converter) - then using a terminal program (RealTerm for example) - you can send and receive strings from the hardware and look at the termination (or none) of strings. You can also test the receive routines by sending data to the Arduino via USB using the terminal.

Martin

Ronnyvs
Posts: 10
Joined: Mon Mar 25, 2019 3:04 pm
Been thanked: 2 times
Contact:

Re: Receive string uart rs232

Post by Ronnyvs »

Hi Martin,

First of all, i want to thank you for your support!
i couldn't really find out for sure what the problem was... It looked like that the program didn't had "enough time" to jump to subroutines and add the characters to the right string.
Now i do it manually end everything works very well. First i readout a serial number or battery status, later on it goes to the automated measurement modus. the serial readout wil later become a check for the right lasertype...
this is what i use now...
StringRX example_Char_test7.fcfx
(19.76 KiB) Downloaded 182 times
But maybe something you like, and i want to share it with others...
i made a bar graph display to be used with a value within value limits...
for example a value has a lower limit of 10 en an upper limit of 30, so the value can be in between these limits.
The Bar-graph shows graphicly "where " the value is. you can realy see if it is almost to the upper, lower or maybe in the middle of its range.
it calculates the usable bar graph positions of
example:
this is how it looks right now...
Bargraph_display.jpeg
Bargraph_display.jpeg (76.38 KiB) Viewed 3471 times
lower limit is 8, upper is 30...
upper line left is the real value
2.55 (string rounding 2 decimals), is 2.55/14 (14 usable digits) 2 markers at the side makes 16.
2 gives the number of the string
55 gives the decimals of the string as number.


I'm working on a project which also requires a menu, and i want to use it to see what the values are according to its limits...
of course the limits and parameters will be placed in the eeprom and can be modified from the menu.

I was searching for a site on matrix or flowcode where people can upload completed projects to share.
is there such a site , because i can't find it anywhere?
If you appreciate it i could also upload the files....

Friendly regards,
Ronny

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Receive string uart rs232

Post by mnf »

Glad to hear you got it working. That bar graph - graduated display looks great!

This forum doesn't have a specific section - I've posted stuff in the 'hints and tips' section....
The new v9 forum has a specific area https://www.flowcode.co.uk/forums/viewforum.php?f=10

Martin

Post Reply