serial communication

i have an idea but i am not sure if it is possible. what i want to do is have an arduino send serial data to multiple msp430 launchpads. so that when the msp430 gets a certain message it will start doing a pattern and it will take care of light control while the arduino can do other things. any helpp would be appreciated.

What have you done?

It seems possible, with a mux on the Serial lines or maybe even daisy chaining all devices together.

As bubulindo said, also if you only need to send data to the 340s you can multi drop them, just connect the Arduino Tx to all the 340 Rxs and send an address byte first (actually that's not strictly required).

Daisy-chaining or multi-drop is probably the simplest, probably no extra hardware required.

How many 340s and do you heed data back from them?


Rob

i do not need to send data back at all. i am looking to have about 7 430s. i am not sure how to really send data to them tho. the only thing serial that i have done is a little bit of shift registers.

i am not sure how to really send data to them tho

Easy,

multi-drop All 340 Rx pins connected together and also to the Arduino Tx pin

daisy-chain Make a line of 340s with the Arduino at the "start" of the line. Connect Arduino Tx to 1st 340 Rx, then

340 Tx -> Rx 340 Tx -> Rx 340 Tx -> Rx 340 Tx -> Rx 340 etc

software Assuming one byte is all that is needed by the 340s to do the job

Send 7 bytes out the Arduino serial port, each byte is the value to be used by the individual 340s

multi-drop All 340s read all 7 bytes, #1 uses the first byte, #2 the second etc

daisy-chain All 340s read all 7 bytes and pass them to the next 340, #1 uses the first byte, #2 the second etc

There are a 1000 variations but that's the general idea.

All in all I think multi-drop will be easier however there is a variation on the daisy-chain setup that allows every 340 to have exactly the same code with no addressing required, this can be very useful when burning code into several devices. As described above they will all need a way to tell which # they are, either a different value in the code or some DIP switches or something.

One more question,

How far from the Arduino are the 340s? How far apart are they" How fast/often do you need to update the 340s?

Ok so that's 3 questions.


Rob

it is all part of a light system each 430 will have basiclly the same code on them. they each will be controlling 8 rgb leds. so i am not sure how much data i will need to send them. the type of things the 430s will be doing is: all red, all blue, all green, (etc.) and also have a scanner pattern where both the background and the "marker" (the light that scans) colour is changeable. the distance between arduino and 430s is about 1 meter for most of them and about 2-4 meters for one of them. they dont need to be updated that often.

each 430 will have basiclly the same code on them

This makes a difference.

Does the application allow them to be exactly the same or are they different for other reasons?
Either way, do you care of you have to change the code 7 times whenever you update the 430s?

1 meter for most of them and about 2-4 meters for one of them. they dont need to be updated that often.

It doesn’t look like the distances and speed is an issue then.


Rob

yes the application does allow them to be exactly the same.

Either way, do you care of you have to change the code 7 times whenever you update the 430s?

What do you mean by this??

What I'm getting at is that with most networking systems (and that's what this is) the individual nodes have to know who they are. For example in the above scenarios how does a 430 know it's #3 and not #4?

If there's an on-board DIP switch then it can just read that. But if not you need something hard-coded in the program like

define MY_ADDRESS 3

but this means that every time you change the program you have to change that line of code for every 430 so they have different addresses.

This in turn means 7 edits and 7 compiles every time you make a change.

So my question is, does that bother you?

Personally I would find it a right PITA although I admit that if you do 99% of the development with a single unit and then seldom make changes it wouldn't be that bad.

With a multi-drop system I see no way around this, however there are variations on a daisy-chain protocol that don't need addressing.


Rob

ok. and no i dont mind having to reprogram each one

Then I'd go for multi drop and sending 7 bytes out with each 430 picking the byte they want.

I'd also add start and end of frame markers (if possible, depends on your data) and also a timer so each 430 resets it's byte counter if there hasn't been a transmission for X time.


Rob

my next question is how do i send data from the arduino. i am using a mega. also i think i might need to send more then one byte per 430. because as i said before each 430 is controlling 8 rgb leds via shift registers. they will be doing the following: all red, all blue, all green, (etc.) and also have a scanner pattern where both the background and the "marker" (the light that scans) colour is changeable.

so i would need 1 bit for address, 1 for red, 1 for blue, 1 for green, 1 to turn on the scanner/night raider effect, 1 for red background, 1 for blue background, 1 for green background, 1 for red marker, 1 for blue marker, and , 1 for green marker. and i am guessing 1 for end. that is 12 bits witch is more then a byte obviously

how do i send data from the arduino

Serial1.print(someData) to send one byte, do it again to send two bytes.

1 bit for address

Not much of an address, and I don't follow what it's for?

If I read you right you have three variables

Foreground Background Marker

Each of which can be R, G or B. Is that right?

Or can they be say purple by setting R and B?


Rob

You could get each device to read the first byte, use it, then drop it. Only pass on the subsequent bytes. A stop and start byte would help make it robust That way the code would be the same for all of them.

mmcp42: You could get each device to read the first byte, use it, then drop it. Only pass on the subsequent bytes. A stop and start byte would help make it robust That way the code would be the same for all of them.

I had thought about this before.

Or:

Graynomad: If there's an on-board DIP switch then it can just read that. But if not you need something hard-coded in the program like

define MY_ADDRESS 3

Why would it have to be hardcoded?

Imagine that there was a DIP switch connected to (for easiness) A0, A1 and A2.

in the setup function one would only have to call:

byte myAddress = PORTA & 7;

That way, the code would in fact be the same and myAddress would indicate the order of the desired value in the received string. :)

theshadowwalker91: my next question is how do i send data from the arduino. i am using a mega. also i think i might need to send more then one byte per 430. because as i said before each 430 is controlling 8 rgb leds via shift registers. they will be doing the following: all red, all blue, all green, (etc.) and also have a scanner pattern where both the background and the "marker" (the light that scans) colour is changeable.

so i would need 1 bit for address, 1 for red, 1 for blue, 1 for green, 1 to turn on the scanner/night raider effect, 1 for red background, 1 for blue background, 1 for green background, 1 for red marker, 1 for blue marker, and , 1 for green marker. and i am guessing 1 for end. that is 12 bits witch is more then a byte obviously

Didn't quite understood what you wanted, but if you're not daisy chaining the 430s and are communicating with the Arduino TX to all the 430s Rx, then you don't need to send bit by bit.

Why not send a string like:

[StartChar, eg: *][SlaveAddress (0 - 7 with 3 switches)][RColor][GColor][BColor][Mode][EndChar eg:#]

The reason for that is that packing all those bits will look a bit weird and there isn't much to gain I think. Or if you find that you use one type of commands more than others, you can create a command set so that you have more speed in all commands since you won't be adjusting all the settings on the MSP430.

I'm a visual kind of guy, and I haven't quite figured what you want to do, if you need any more help, can you make a drawing or something?

You could get each device to read the first byte, use it, then drop it.

That's where I was heading.

Imagine that there was a DIP switch connected to (for easiness) A0, A1 and A2.

That's why I mentioned DIP switches above. But it adds more hardware.


Rob

Maybe start looking into SPI bus or I2C. Bet you can get more speed and flexibility.

It's perfectly possible to use the same code with different data sets. Program = code + data.

1 bit for address

Not much of an address, and I don't follow what it's for?

i meant to say one byte not bit.

If I read you right you have three variables

Foreground Background Marker

Each of which can be R, G or B. Is that right?

Or can they be say purple by setting R and B?

Yes that is right. and yes if i send R and B i would like it to be purple.

I assume we’re going for the multi-drop option?

You could do this with two bytes but it does make it a bit harder in many ways, so I would have a frame format something like this

< A Fr Fg Fb Br Bg Bb Mr Mg Mb >

Start delimiter, being Address, Foreground RGB values, Background RGB values, Marker RGB values, end delimiter

For example

Serial1.print ('<');   //start
Serial1.print ('5');   // address
Serial1.print ("001"); // Foreground is Blue
Serial1.print ("010"); // Background is Green
Serial1.print ("100"); // Marker is Red
Serial1.print ('>');   // end

This keeps the characters as all ASCII and therefore ensures that you can always sync on the < and > markers because they can’t appear in the data.

Like I said you could do this with a lot fewer bytes but I don’t see it’s worth it for this application.

If you also want to turn on/off effects another byte can be added.


Rob

thanks for all your help. i have posted on the 43oh forums for help on the msp side of things but i am not getting to much help from them. if anyone is this forum has used the msp430 launchpad and can help with that end of thing it would be a real help.