| | |
reading data using serial port
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2006
Posts: 14
Reputation:
Solved Threads: 0
Shefali
Your data has a neat pattern and VB is just one of the best languages to handle that kind of stuff
say you have read one line of input
I assume addPoint2Plot will plot the data as I has explained in previous example.
Am I clear?
Uday Wali
Your data has a neat pattern and VB is just one of the best languages to handle that kind of stuff
say you have read one line of input
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
dim s as string dim line as string dim i as integer dim p2 as string dim v as integer s = "" s = s & comm1.input do while (1) 'get one line do while instr(s, chr(10)) > 0 'get one line of data line = left(s, instr(s, chr(10)) -1) s = mid(s, len(s1)+1) 'remaing part of input 'get first comma i = instr(s, ",") p2 = instr(i+1, s, ",") v = val(p2) addPoint2Plot v loop 'append comm1 input to any remaining trailing chars of last input s = s & comm1.input 'add some kind of exit code here. loop
I assume addPoint2Plot will plot the data as I has explained in previous example.
Am I clear?
Uday Wali
•
•
Join Date: Apr 2006
Posts: 36
Reputation:
Solved Threads: 0
hello again
udaywali thanks so much for ur help. ur code has been very helpful for me. i have used the split function to get the particular value of a string. but i used ur code for plotting the stuff and it worked nicely. thanks so much for showing me the way.
a small question.. will it be possible to give titles to the axis? i mean as i get more data the axis shud also get changed accordingly. is that possible? can u give me any code samples?
and one more thing i wanted to ask u is.. as of now the graph needs to refreshed... is it not possible that it automatically shifts towards left and the axis and the grid re-adjust automatically. something like the task-manager (performance) graph in windows.
thanks a lot again
regards.
shefali.
udaywali thanks so much for ur help. ur code has been very helpful for me. i have used the split function to get the particular value of a string. but i used ur code for plotting the stuff and it worked nicely. thanks so much for showing me the way.
a small question.. will it be possible to give titles to the axis? i mean as i get more data the axis shud also get changed accordingly. is that possible? can u give me any code samples?
and one more thing i wanted to ask u is.. as of now the graph needs to refreshed... is it not possible that it automatically shifts towards left and the axis and the grid re-adjust automatically. something like the task-manager (performance) graph in windows.
thanks a lot again
regards.
shefali.
•
•
Join Date: Oct 2006
Posts: 14
Reputation:
Solved Threads: 0
Shefali,
Writing text on X axis is very simple.
will print on the x axis. Trick is writing on the y axis because you need to rotate text. If you need help on that, let me know. I have some ready code, I can share with all. It is big, so i have not included here.
Scrolling is also very difficult and slow in VB. You should have a structure to store the values in say, a collection. Collections maintain data in a linked list, so deleting and adding is easy but it is some what slow. Create a class with two values, one for x and one for y. You could use CPoint for example.
Create a collection in your code to store instances of this class.
I have written it quickly without much thought to clarity of idea. Because you know my earlier message, I guess you can guess my thoughts.
If it is not clear, let me know again.
Regards
Uday
Writing text on X axis is very simple.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
picture1.currentx = 500 picture1.currenty = 10 picture1.print "1000"
will print on the x axis. Trick is writing on the y axis because you need to rotate text. If you need help on that, let me know. I have some ready code, I can share with all. It is big, so i have not included here.
Scrolling is also very difficult and slow in VB. You should have a structure to store the values in say, a collection. Collections maintain data in a linked list, so deleting and adding is easy but it is some what slow. Create a class with two values, one for x and one for y. You could use CPoint for example.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
'class module CPoint 'declarations section Public x as single public y as single
Create a collection in your code to store instances of this class.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Public sub Timer_time() static dataPts as collection static cnt as integer private p as CPoint if dataPts is nothing then 'on the first call, create a new collection set dataPts = new collection cnt = 0 end if cnt = cnt + 1 set p = New CPoint p.x = cnt p.y = ReadPort() dataPts.add p if dataPts.count > 1000 dataPts.remove 1 endif 'you have a max of 1000 points in a collection, 'which you may now display DisplayValues dataPts End sub Private sub DisplayValues(c as collection) dim i as integer dim x0 as integer 'x value at left of graph if c.count > 0 then x0 = c(1).x endif 'clear the screen and display grid picture1.cls drawGrid 'draw set of lines correspoinding to x and y values in the collection for i = 1 to c.count -1 picture1.line (c(i).x - x0, c(i).y)-(c(i+1).x - x0, c(i+1).y) next end sub
I have written it quickly without much thought to clarity of idea. Because you know my earlier message, I guess you can guess my thoughts.
If it is not clear, let me know again.
Regards
Uday
•
•
Join Date: May 2009
Posts: 10
Reputation:
Solved Threads: 0
I have a kind of problem on filtering data´s which were recorded through serial port. My question is I would like to know if I can take a selected datas to plot a real time graph. The datas are quite a lot of parameters for a time being I want to plot nine parameters. If you want the data format is like this
‹...‚.10D20®B...‚B01DA,20,2,L,49.98,11.96,3.35,2.35,2.55,890,264,93,1205.006,860,P\..
.‚.20D20¨G...‚B02DA,20,2,L,50.06,11.96,3.30,2.45,2.65,865,255,93,1205.008,928,P.ñ..
.‚.10D30«D...‚?01DA,30,2,S,P,L,P,S,P,M,P,P,R,N,N,D,E,S,80010.,99.999,0.08333¾Ÿ..
.‚.20D30¥I...‚?02DA,30,2,L,P,L,P,N,P,M,P,P,R,N,N,D,E,S,1457.6,99.994,0.08333.W..
.‚.10D31©E...‚101DA,31,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,M,0,1¥:...‚.20D31£J..
.‚102DA,31,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,M,0,1vh...‚.10D32§F..
.‚P01DA,32,0,1.00,15,85,31,27,2¬C...
from these datas I only want to read the type of values B01DA,20,2,L,49.98,11.96,3.35,2.35,2.55,890,264,93,1205.006,860, and
B02DA,20,2,L,50.06,11.96,3.30,2.45,2.65,865,255,93,1205.008,928
for information these datas are sequential and they start after three dots and a coma as you can see so I want to select the above ones only. Any information would be greatly appreciated
‹...‚.10D20®B...‚B01DA,20,2,L,49.98,11.96,3.35,2.35,2.55,890,264,93,1205.006,860,P\..
.‚.20D20¨G...‚B02DA,20,2,L,50.06,11.96,3.30,2.45,2.65,865,255,93,1205.008,928,P.ñ..
.‚.10D30«D...‚?01DA,30,2,S,P,L,P,S,P,M,P,P,R,N,N,D,E,S,80010.,99.999,0.08333¾Ÿ..
.‚.20D30¥I...‚?02DA,30,2,L,P,L,P,N,P,M,P,P,R,N,N,D,E,S,1457.6,99.994,0.08333.W..
.‚.10D31©E...‚101DA,31,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,M,0,1¥:...‚.20D31£J..
.‚102DA,31,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,M,0,1vh...‚.10D32§F..
.‚P01DA,32,0,1.00,15,85,31,27,2¬C...
from these datas I only want to read the type of values B01DA,20,2,L,49.98,11.96,3.35,2.35,2.55,890,264,93,1205.006,860, and
B02DA,20,2,L,50.06,11.96,3.30,2.45,2.65,865,255,93,1205.008,928
for information these datas are sequential and they start after three dots and a coma as you can see so I want to select the above ones only. Any information would be greatly appreciated
![]() |
Similar Threads
- Send data on a serial port (C++)
- How to copy data from serial port to notepad (Visual Basic 4 / 5 / 6)
- Problem with real-time app reading from serial port (ASP.NET)
- Serial Port (C++)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Vbcombobox problem...........
- Next Thread: Can you help me with visual basic code?
Views: 21444 | Replies: 13
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
6 429 2007 access activex add age append application basic beginner birth c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





