Is its possible

hi all

I was wondering if it is possible to send multiple analog signal via xbees from a uno to mega adk and identify them on the other end to control multiple motors. I haven't posted a code because i really dont know where to start, does anyone have any examples to point me in the right direction. Ive been trying for a few weeks now and just cant seem to find any examples to reference from. Any help is much appreciated. Ive even bought 3 books but none seem to demonstrate this they all just seem to use char to turn on and off a motor but i want to control speed.
thank you.

hi all

I was wondering if is possible to send multiple analog signals via xbee s1 from a uno to mega adk and identify them on the other end to control multiple motors. Ive been trying for a few weeks now but cant seem to find examples to reference from. Ive even bought 3 books none of which help, they all just show code for turning on and off motors via char values. does anyone know of or have any examples i could reference from or have any examples.this is my first project and im really stuck and don't want to lose interest with arduino before ive started because its been fun so far. i haven't posted a code because i really have no clue of how to send or identify signal so other than setup and loop it would be pointless posting it. any help is really appreciated. Thank you

You have to digitize the signals first, using ADC, send them, then undigitize them (DAC) to use them.
Or, use them as PWM signals (analogWrite) to control motor drives.

Does that help?

thanks for the reply
i get the pwm part to control a motor but its sending the signals with a identifier of some discription. if i send the two analog signals via serial/xbee how do i know which is which im really struggling with the code for sending and identifying the signals. thanks

Not sure if it works with XBee but take a look at the VirtualWire examples (I think VirtualWire is now also called RadioHead but its basically the same thing)

Using old industrial numeric control codes, our numbers were like so,

Where the machine could run from 0.000" to 200.000" the decimals were dropped and leading zeros used instead because of advantages.

So 15.430" would be 01543

You don't need a decimal point with that. You know that the first character is 100's without waiting for the decimal to be read.

The machines ran on punched tapes with each digit a row of holes -- it is a version of serial data.
This scheme is easy for a program to read quickly, much simpler, easier and faster than buffering a string like "12.345" and running a function to interpret that.

So we had codes like

X00125Y028G01

to set the machine to coordinate X 1.25" Y 28.0" and punch the hole.

That technology goes back to 19th century card looms. It doesn't get simpler. Coding for that is matching simple once you get the "buffer then parse then convert" paradigm they teach in books and schools out of your head.

Nick Gammon's serial input tutorial covers the basic Arduino sketch to read that kind of encoding in his State Machine example. I wonder if Nick worked in production?

State Machine

Another way of processing incoming data, without blocking, is to set up a "state machine". Effectively this means looking at each byte in the input stream, and handling it depending on the current state.

As an example, say you had this coming into the serial port:

R4500S80G3

Where Rnnn is RPM, Snnnn is speed, and Gnnnn is the gear setting.

The state machine below switches state when it gets a letter "R", "S" or "G". Otherwise it processes incoming digits by multiplying the previous result by 10, and adding in the new one.

When switching states, if first handles the previous state. So for example, after getting R4500 when the "S" arrives, we call the ProcessRPM function, passing it 4500.

This has the advantage of handling long messages without even needing any buffer, thus saving RAM. You can also process message as soon as the state changes, rather than waiting for end-of-line.

Here's the full tutorial with the State Machine part pretty near the top:

ONUONIUDRA:
I was wondering if it is possible to send multiple analog signal via xbees from a uno to mega adk and identify them on the other end to control multiple motors.

Of course you can send values of different ADC channels over the same communication channel.

You just have to invent your "transmission protocol" as you like it.

For example you can send data records like that:
Single digit ==> ADC channel number
First seperating char ==> seperates channel number from value, i.e. "*"
1 to 4 digits ==> ADC value number (0...1023)
Second seperating char ==> seperates value from the next data record, i.e. ";"

So perhaps you could send 4 ADC channels in a row:

0*123;1*75;2*444;3*1005;0*126;1*73;2*495;3*900;0*111;1*65;2*429;3*800;

etc. etc. etc. The receiver must tokenize and evaluate what he receives.

You also can send the channel mixed, such like three times ADC-A0, two times ADC-A4 or as you like.

If the transmission might be disturbed, you'd perhaps also include a CRC-value or checksum with each data record, so that the receiver can validate the data. It's all possible.

Threads merged.