Hello, I'm new to arduino. I need to know if there's already a library or whatever to do the following:
I want to receive a string from which I will take several variables. I'll explain in an example:
I receive "27469384"
that means 3 variables:
var1: 27 (integer)
var2: 469 (integer)
var3: 384 (integer)
the variable map would be: 11222333
It should be taken in consideration that I will receive constantly 20 of these strings per second, while doing other calculations, so it must be Interrupt driven.
The target board I got is an Arduino MEGA 256
PD:
I already did this in a PIC32 (microchip 80Mhz 32-bit microcontroller) but limited to only 5 pwm's.
The serial thing i did it Interrupt driven over DMA's. Actually it can easily receive strings (of 22 chars each) 100 times per second while doing floating point math and other heavy calculations at the "same time", while other timer based processes also run in backround.
I don't know if the arduino microprocesor has the balls to do this (i mean computation power), but I must start with the basics which is communications.
Originally it was OK, but as proyect grew, needed more PWM that PIC32 doesn't have.
I want to receive a string from which I will take several variables. I'll explain in an example:
I receive "27469384"
that means 3 variables:
var1: 27 (integer)
var2: 469 (integer)
var3: 384 (integer)
the variable map would be: 11222333
Why are the values not comma-separated (or space, or something useful)? How do you know the "map" isn't 1112223 or 12222223?
It should be taken in consideration that I will receive constantly 20 of these strings per second, while doing other calculations, so it must be Interrupt driven.
What is "it" that must be interrupt driven? What is going to generate the interrupt?
I just posted this code for someone else. Customized just for you:
int xtract(char *s,int n)
{ int v = 0;
while (n--) v = 10 * v + *s++ - '0';
return v;
}
char *input = "11222333";
int v1 = xtract(input,2);
int v2 = xtract(input+2,3);
int v3 = xtract(input+5,3);
The arduino serial port is already interrupt driven with a buffer (you can increase if you want). All you need to do is to periodically check the buffer and parse the inputs. Do the inputs have to be processed on the spot when they arrive or not?