We have a set of five Arduino Uno’s attached to a control PC via USB. The Arduinos are send out data to LED’s strips and receiving data from IR sensors. We are using the RS232 node as we have loaded up our own code to the Arduino.
I have created a patch with separate RS232 nodes setting the ComPort to control/listen to each Arduino. The software works fine when one RS232 node has the comport set, but as soon as I bring in a second or third, etc. vvvv starts to really slow down.
Are there any known issues with with virtual comports and serial data rates?
knock together a dynamic plugin that comms / buffers in a separate thread?
// This is a new namespace in .NET 2.0
// that contains the SerialPort class
using System.IO.Ports;
private static void SendSampleData()
{
// Instantiate the communications
// port with some basic settings
SerialPort port = new SerialPort(
"COM1", 9600, Parity.None, 8, StopBits.One);
// Open the port for communications
port.Open();
// Write a string
port.Write("Hello World");
// Write a set of bytes
port.Write(new byte[]() {0x0A, 0xE2, 0xFF}, 0, 3);
// Close the port
port.Close();
}
In his last moments before doom sugokuGENKI wrote the below code shortly before disappearing in to thin air - the plugin code enables me to communicate with the Arduinos (I can see the TX RX lights flashing), but they do not respond to the messages I am sending them. Anyways, someone may find it useful =)
region usings
using System;
using System.ComponentModel.Composition;
using System.IO.Ports;
using System.Threading;
using VVVV.PluginInterfaces.V1;
using VVVV.PluginInterfaces.V2;
using VVVV.Utils.VColor;
using VVVV.Utils.VMath;
see, that’s just what i’m talkin about. damn, mrboni how many times do i have to tell you that it’s not fair to users who try to contribute original silly jokes??!?
And yes, Sugo^Ahhem^ Elliot’s idea of multi threading the RS232 node works really well! I have four processors and five Arduinos though, so a bit of jiggle should get it working from one machine.
Elliot if you have the time to develop or anyone else for that matter has the time to finish off this plugin I will happily pay for development then it can be released to the community =)
Ok I’ve found I don’t need to use setprocessaffinitymask-(windows) simply setting the args.txt to /allowmultiple then opening up a second instance of vvvv works the same if using setprocessaffinitymask-(windows) or not. Then again the vvvv patches I’m running are not heavy!
@gaz - by default vvvv is allowed to run across all threads
e.g. on my i7 quad, when using EmguCV i can have activity on all 8 virtual cores without any special setup of the vvvv executable
secondly
you can have more threads than processors
in fact, rs232 communication is exactly the type of application which threads were originally invented for (long before muilti-core processors).
if a task involves running something that the cpu has to wait for (e.g. a serial port), then it’s a good idea to put that in a seperate thread so that your main app can get on with what its doing whilst it’s waiting for the serial port.
in this instance, the serial port is not necessarilly taking up any CPU, but in that thread the CPU is being blocked waiting for something.
i.e. you’ve not used up 100% of that cpu, so you can put more threads on the same cpu without any performance hit
the only reason why you’d need to worry about needing more cpu is if task manager was reporting that all your cores had 100% activity
in fact, a screen shot of task manager when it’s running slow would be useful!
Then it’s a case of doing some trivial wiring
The rs485 device appears as a serial device (e.g. COM4)
Whenever you send on that, it’ll receive on all of your arduino’s Serial.Read()
thanks a lot for your help and easy to understand explanations! I am sending the same data to all Arduino’s and having them choose which part of the data to use. However, the input data coming from the Arduinos is different - so not sure if your RS485 method would work or not?
We’re running out of time on the project, and I’m getting good results by opening up multiple instances of vvvv to run the RS232 node in a separate thread and then sending the data to the main patch via UDP.