how can I fill an array with RS232 data?
Moderator: Benj
-
- 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?
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
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
-
- 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?
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 ...
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 ...
- 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?
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- 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?
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
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
-
- 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?
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.
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
-
- 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?
U kunt gebruik maken van een "tabel" of array.
Bekijk de help-files van Flowcode om te zien hoe dat ze die maken.
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.
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).
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
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
Once the counter is equal to 6, get out of the loop and start again (I suppose).
-
- 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?
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)
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)
-
- 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?
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 ?
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 ?
-
- 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?
Thanks for your tips. This I really need. I'm really new to flow code and have the Pro version only since FridaySpanish_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 ?
I'm German, I thought so as you answered in Dutch
-
- 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?
My bad, I saw "eigen_test" on your flowcode file name .Rolf1402 wrote:I'm German, I thought so as you answered in Dutch
Learning a bit of C programming will help you alot in making programs with flowcode.
-
- 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?
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 UARTSpanish_dude wrote:My bad, I saw "eigen_test" on your flowcode file name .Rolf1402 wrote:I'm German, I thought so as you answered in Dutch
Learning a bit of C programming will help you alot in making programs with flowcode.
- 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?
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.
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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- 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?
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
Thank you so much