Dear All,
I want to ask something about speed. My teacher asked me to make a software in C# that acquires 1000 data per second, or 1ms per data. The data is a string with 16 characters (16 bytes). The data itself is coming from a microcontroller with USB communication. I am still working on the USB.
What I saw first is the timer1 from .Net framework. Its properties explains that I can do the tick event from 1ms (CMIIW). I never tried this before. I am just playing with C# like 2 months ago, I am still a newbie.
Any idea(s)? Whether the speed proposed is able to be handled with C#, and is it sufficient to use the timer1? Or I need special things to make it happen.

1 answers
Okay, this will probably need some one like Vulpes to sort it for accuracy but....
The USB device I'm guessing emulates a Com port (Jan Axelson USB Complete book also her LVR website is good for finding hardware designs)
On the timer front try to stear away from the tool box stop watch timer as these can be very inaccurate (they will fire but who knows!) the best bet is to use
NoDataAtPort = new System.Timers.Timer(5000);
NoDataAtPort.Elapsed += new ElapsedEventHandler(OnTimeOut);
the System timers give better accuracy I use them for talking to hardware at the speeds you are talking about (and a touch faster). Also the board you are interfacing to do anything interesting from your desscription it sounds like something I did when I first started with VB! (is the door closed!!)
Glenn
answered 2 years ago by:
329
301
Indeed, the easiest way to do it is with COM PORT emulation, thereby, the FTDI ICs are really handy. Wow, you did this before? I have just asked, at least he wants 800data per second. What's the difference(s) between System.Timers.Timer and With the timer from toolbox? I have been thinking about reading it every seconds.. so I read 1000 data every second, and then send an acknowledge back to the microcontroller and then the microcontroller can send it back to me,,so in this case I am using the microcontroller timer that is really fast.. sounds good isn't it? But the problem lies on its memory, 1000*16 bytes = 16000 bytes of RAM needed, and the transmission data from the microcontroller to the PC will also cost time... can I use the timer tick event every 1ms? then I will read from serialport and send acknowledge back to the microcontroller, and then the microcontroller will send the next data
329
Again, as I said (typed ?) before the Windows timers can be over looked by Windows they also can really only be considered for use in human delays (message displayed type of thing) the only reliable way of doing this I have found is using the System.Timers on the help page: ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/fxref_system/html/f2837689-ab7f-82a0-3dfd-279fd03db871.htm thats for the timer method the other means is via the approach of using the interrupt method, is there data there if so do something, else wait. The wait I find you can use for processing the data but if you are using the SerialDataReceivedEventHandler(port_DataRecieved) just make sure that what ever you are doing can be done with out locking the process or can be interrupted without problems avoid searching strings or you might have problems! So what are you doing it sounds like a safety system (ahh!!! Uni projects where your neck was not on the line, those were the days!) Glenn