The datas are quite a lot of parameters for a time being I want to plot nine parameters. My question is I would like to know if I can take a selected datas to plot a real time graph.
Visual basic serial port example serial#
I have a kind of problem on filtering data´s which were recorded through serial port. Because you know my earlier message, I guess you can guess my thoughts. I have written it quickly without much thought to clarity of idea. 'draw set of lines correspoinding to x and y values in the collection Private sub DisplayValues(c as collection)ĭim x0 as integer 'x value at left of graph 'you have a max of 1000 points in a collection, 'on the first call, create a new collection
![visual basic serial port example visual basic serial port example](https://bytes.com/attachments/attachment/1772d1235224570/msg_1.jpg)
'class module CPointĬreate a collection in your code to store instances of this class. Create a class with two values, one for x and one for y. Collections maintain data in a linked list, so deleting and adding is easy but it is some what slow. You should have a structure to store the values in say, a collection. Scrolling is also very difficult and slow in VB. I have some ready code, I can share with all. Trick is writing on the y axis because you need to rotate text. By the way, what is the end use of the program? Pic1.line (count, lastvalue)-(count+1, i) 'if you need to draw line graph, use this 'rest of initialization code, like opening com port etc. toredraw = true 'you can set it in properties as well We will call the com control as comm1.Īs you get more readings, you may simply change the x-axis scale. Say, your data has a range of -100 to 100, and you wish to display next 1000 readings, you can initialize the picture box in the form load event.Īlso, place a command button named cmdRefresh. Scale the picture box to the required coordinates.
![visual basic serial port example visual basic serial port example](https://www.xanthium.in/sites/default/files/site-images/serial-prog-visual-basic/serial-port-programming-debugging-vb.png)
'txtRecieved = Format(CLng(s) / 1000, "00.000")Ĭreate a picture box on the form you are using.
Visual basic serial port example mod#
TxtReceived = txtReceived & Chr(&H30 + (i Mod 16))
![visual basic serial port example visual basic serial port example](https://i.ytimg.com/vi/sFJ9LnhMqvE/maxresdefault.jpg)
TxtReceived = txtReceived & Chr(&H30 + (i / 16)) MsgBox Err.Description & vbCrLf & "Try Again" If you have problems, I can send the full app. To use it, create a form with all controls used in this code and associate the sub wit a command button. Here is some code (live copy) from a small RS232 tester I use.