Oh thank you rmteo! I had just found the timer, but didn't get the interval part. That works awesome!!
Ok, now to convert those 2's complimented numbers to show negative values instead of 65533 and such.
Oh thank you rmteo! I had just found the timer, but didn't get the interval part. That works awesome!!
Ok, now to convert those 2's complimented numbers to show negative values instead of 65533 and such.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Hi cncmachineguy;
To receive data from the serial port you should always use SerialPort Event Trigger like the one i posted.
Don't use timers to poll the serial port, it is not very efficient!!Code:Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived Dim recepcao As String recepcao = SerialPort1.ReadExisting If recepcao = "%TE" Then GetCursorPos(rect) SetCursorPos(rect.X - 1, rect.Y) End IF End Sub
If you want to send data to PIC, like a press of a button, then you can use the timer. just put the code that you have inside the button, inside of the timer, and choose the interval!
I wrote this post in a little hurry, later i have more time and i came back here!
Thanks and Regards;
Gadelhas
Thanks gadelhas, point taken. Right now the pic is not allowed to send data unless asked for it. The pic side code is modified from the CDC for dummies thread. This part is working great. Thanks to all of you.
Now for the next part (this seems like it should be easy, but of course not). The 18 bytes sent from the pic represent 9 words. From here on, I will just refer to 1 word. The rest will be the same action.
Let's call them data(0) and data(1). To put them together I did this:
this works fine with 1 problem. It is really a signed number, so 65533 should read -2.Code:detain =(data(0)*256)+data(1))
I have tried all sort of ways to get here, but continue to fail. I am sure it has to do with dim as or the way I am putting the word back together, but I am at a loss.
Anyone know how?
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
What do you receive from PIC, and what do you want to do, can you give me a full example, its just because english is not my native language, and perhaps i'm not understand something
Last edited by gadelhas; - 30th May 2011 at 22:42.
Thanks and Regards;
Gadelhas
From PIC:
data(0) and data(1). these 2 bytes are the highbyte and lowbyte of a word. -32768-32767
I need to see the word like that. for example the word may equal 3, or it may be -3. right now I will see 3 or 65533.
So how to put the bytes back together and show signed integer?
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
I never had any purpose to justify the use of signed<->unsigned conversion myself, but you may have a look at
http://support.microsoft.com/kb/189323
It's all about how you interpret/display the numbers... like Floating point in PBP... or show decimal on a LCD
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I would normally side with you steve, but on this one I am having issues. The numbers bounce around zero, so I get to watch 3,3,4,2,1,65533,65534,4,1,.....
Seems like it would be better to have the numbers more right
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Last edited by gadelhas; - 30th May 2011 at 22:51.
Thanks and Regards;
Gadelhas
Ok, different question. How do I put 2 received bytes back together to make 1 word?
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Like you did have to be fine.
WordOut=(MSByte*256)+LSByte
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks