how can I fill an array with RS232 data?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Rolf1402
Flowcode V4 User
Posts: 9
Joined: Sat Oct 16, 2010 4:53 pm
Location: Germany
Has thanked: 4 times
Been thanked: 1 time
Contact:

how can I fill an array with RS232 data?

Post by Rolf1402 »

Hi,

I'm new to this and need your help!
I currently work on a project where I via the RS232 a lot of data (20 byte's) receive, but the details are not all needed.
My problem is that I would just like the last 6 Bytes Received's use. I thought I'd write the 20 byte's into an array,
then I would have all available individually.
The question is how can I fill an array with RS232 data?

Rolf

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: how can I fill an array with RS232 data?

Post by Spanish_dude »

Use the RS232 component from Flowcode and read 20 bytes, that's it ^^.

Don't forget that the RS232 data needs to be "converted" to a TTL data. If you don't do this, you can throw your microcontroller away as it won't work anymore, like I did, once ...

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: how can I fill an array with RS232 data?

Post by Benj »

Hello,

Alternatively you could create a loop to run 14 times with a single RS232 read byte inside, after the loop read the RS232 another 6 times to collect the data you require. This way you only have to store the data you need.

Rolf1402
Flowcode V4 User
Posts: 9
Joined: Sat Oct 16, 2010 4:53 pm
Location: Germany
Has thanked: 4 times
Been thanked: 1 time
Contact:

Re: how can I fill an array with RS232 data?

Post by Rolf1402 »

Thanks for the quick reply. The loop worked immediately.
Could you tell me how I now save the 6 remaining bytes to go.
Thanks in advance
Sorry this text is form a translator :?
Attachments
loop_14Times.fcf_avr
(7 KiB) Downloaded 274 times

Rolf1402
Flowcode V4 User
Posts: 9
Joined: Sat Oct 16, 2010 4:53 pm
Location: Germany
Has thanked: 4 times
Been thanked: 1 time
Contact:

Re: how can I fill an array with RS232 data?

Post by Rolf1402 »

sorry, does not work as I thought. The data I receive from view as follows.
LED on
F5 FF 57 F7 5F 55 D5 D5 D5 57 57 7F 55 55 D5 57 75 FD F5 7D
LED off
F5 FF 57 F7 5F 55 D5 D5 D5 57 57 7F 55 55 55 D7 F5 FF F5 7D
here you can see that the first 14 bytes are always the same.
The only change is the last 6 bytes.
Attachments
rs_eigen_test.fcf_avr
(14 KiB) Downloaded 258 times

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: how can I fill an array with RS232 data?

Post by Spanish_dude »

U kunt gebruik maken van een "tabel" of array.
Bekijk de help-files van Flowcode om te zien hoe dat ze die maken.

Code: Select all

char array[6] = {0}; // dit is een tabel van 6 bytes
Om de verschillende bytes in het tabel te kunnen inlezen of schrijven moet u gewoon het getal tussen de vierkante haakjes veranderen.
Deze is nu ingesteld op 6, d.w.z. dat het tabel van array[0] tot array[5] gaat.

Bij het inlezen van de 6 laatste bytes, maak gebruik van een lus en een teller (ingesteld op 0).
U leest het data in en schrijft het in "array[teller]". Dit gaat het ingelezen data "opslaan" in u tabel.

Na dat u een byte ingelezen hebt moet u de teller met één optellen.

Nu moet u gewoon (in het lus nog altijd) het teller vergelijken met 6, als deze 6 (of groter) is dan moet u uit de lus komen.

----

You'll need to use an array to store de 6 bytes you want.
Look at the help files, they'll tell you how to make an array.

Code: Select all

char array[6] = {0}; // an array of 6 bytes
Use a loop and a "counter". Each time you read a data from the RS232, store it in the array and increase counter with one.
Once the counter is equal to 6, get out of the loop and start again (I suppose).

Rolf1402
Flowcode V4 User
Posts: 9
Joined: Sat Oct 16, 2010 4:53 pm
Location: Germany
Has thanked: 4 times
Been thanked: 1 time
Contact:

Re: how can I fill an array with RS232 data?

Post by Rolf1402 »

I'm totally confused. :? :? Since this morning I have concentrated on the filling of array's, but again without success.
It would be really nice if someone could tell me how I can implement the following routine in my top gepost project and Flowcode.

int array [incom];

for (int i = 0; i <incom; + + i)

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: how can I fill an array with RS232 data?

Post by Spanish_dude »

Make a new variable named 'i' and another one named 'array[X]'. X is the size of the array, it needs to be a value, not another variable.

Then use a while (i < incom) and add a calculation icon with "i = i + 1" in it.

PS: Do you speak Dutch or am I wrong thinking you do ?

Rolf1402
Flowcode V4 User
Posts: 9
Joined: Sat Oct 16, 2010 4:53 pm
Location: Germany
Has thanked: 4 times
Been thanked: 1 time
Contact:

Re: how can I fill an array with RS232 data?

Post by Rolf1402 »

Spanish_dude wrote:Make a new variable named 'i' and another one named 'array[X]'. X is the size of the array, it needs to be a value, not another variable.

Then use a while (i < incom) and add a calculation icon with "i = i + 1" in it.

PS: Do you speak Dutch or am I wrong thinking you do ?
Thanks for your tips. This I really need. I'm really new to flow code and have the Pro version only since Friday
I'm German, I thought so as you answered in Dutch

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: how can I fill an array with RS232 data?

Post by Spanish_dude »

Rolf1402 wrote:I'm German, I thought so as you answered in Dutch
My bad, I saw "eigen_test" on your flowcode file name :P .

Learning a bit of C programming will help you alot in making programs with flowcode.

Rolf1402
Flowcode V4 User
Posts: 9
Joined: Sat Oct 16, 2010 4:53 pm
Location: Germany
Has thanked: 4 times
Been thanked: 1 time
Contact:

Re: how can I fill an array with RS232 data?

Post by Rolf1402 »

Spanish_dude wrote:
Rolf1402 wrote:I'm German, I thought so as you answered in Dutch
My bad, I saw "eigen_test" on your flowcode file name :P .

Learning a bit of C programming will help you alot in making programs with flowcode.
It seems to be very difficult to fill an array via the RS232. In my books It will only explain how I fill the array in C program, but not USART or UART

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: how can I fill an array with RS232 data?

Post by Benj »

Hello,

Its very simple. Here is a quick program that reads data from the RS232 and stores into an array until a time out is received or the array is filled. The array is then sent back out over the RS232.
Attachments
loop_14Times.fcf_avr
(7.5 KiB) Downloaded 232 times

Rolf1402
Flowcode V4 User
Posts: 9
Joined: Sat Oct 16, 2010 4:53 pm
Location: Germany
Has thanked: 4 times
Been thanked: 1 time
Contact:

Re: how can I fill an array with RS232 data?

Post by Rolf1402 »

Benj wrote:Hello,

Its very simple. Here is a quick program that reads data from the RS232 and stores into an array until a time out is received or the array is filled. The array is then sent back out over the RS232.

This is exactly what I need :D :D

Thank you so much :D

Post Reply