Society of Robots - Robot Forum

Software => Software => Topic started by: hazzer123 on April 23, 2007, 01:37:37 PM

Title: Serial communication.
Post by: hazzer123 on April 23, 2007, 01:37:37 PM
I need to be able to quickly write some code that can write 2 bytes to the COM1 port and then wait to receive 2 bytes back. I dont need any fancy GUI, just the windows console is fine.

Do any of you have any source code you could let me see? Or any recommendations for software?

I have used Hyperterminal so far, but i need to perform maths calculations on the incoming bytes, and so need to write it myself.

My programming knowledge is mainly c++ but basic will also do.

Thankyou
Title: Re: Serial communication.
Post by: ed1380 on April 23, 2007, 02:17:37 PM
do you need to test the com 1 port?
if so do a loopback test
Title: Re: Serial communication.
Post by: hazzer123 on April 23, 2007, 02:23:55 PM
Nope, i am communicating with a PIC. I am sending it a byte for the speed of the motor it is controlling, and a byte for the direction.

Then, when the PIC gets interrupted, the PIC sends out 2 bytes which are the total number of steps performed.

These are what i need to use in my calculations.

I have the whole thing setup, I just want to embed the communication into my app.

Thanks
Title: Re: Serial communication.
Post by: snow on April 24, 2007, 03:26:59 AM
Here you have a nice tutorial about serial port programming in windows enviroment: http://www.robbayer.com/files//serial-win.pdf (http://www.robbayer.com/files//serial-win.pdf).
Title: Re: Serial communication.
Post by: snow on April 24, 2007, 03:31:39 AM
And some example class that uses above stuff: http://www.bbdsoft.com/win32.html (http://www.bbdsoft.com/win32.html) (com port).
Title: Re: Serial communication.
Post by: Admin on May 01, 2007, 07:48:52 PM
Quote
but i need to perform maths calculations on the incoming bytes, and so need to write it myself.
im guessing no, but does it need to be a realtime calculation? i always save my hyperterminal data as a .csv and postprocess it in excel . . .
Title: Re: Serial communication.
Post by: Kohanbash on May 01, 2007, 08:47:44 PM
How do you directly save hyperterminal data to csv?
Thanks
Title: Re: Serial communication.
Post by: hazzer123 on May 02, 2007, 12:43:25 AM
Hey its ok i managed to do i tusing the tutorials posted, they were fantastic!

BTW, the calculations were not needed real time, so it was easy.

Thanks for your replies
Title: Re: Serial communication.
Post by: Admin on May 02, 2007, 05:02:10 AM
I perfer to do my postprocessing outside of the microcontroller to improve decimal accuracy and processing speed.

Quote
How do you directly save hyperterminal data to csv?
first, make sure you output data with either a tab or comma to space it

then in hyperterminal, click Transfer -> Capture Text

save the data however you want. you can also save it as a .txt file, then just rename the file to .csv

in excel, you need to reorder everything to be comma/tab delimited