go away spammer

Author Topic: Serial communication.  (Read 5999 times)

0 Members and 1 Guest are viewing this topic.

Offline hazzer123Topic starter

  • Supreme Robot
  • *****
  • Posts: 460
  • Helpful? 3
Serial communication.
« 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
Imperial College Robotics Society
www.icrobotics.co.uk

Offline ed1380

  • Supreme Robot
  • *****
  • Posts: 1,478
  • Helpful? 3
Re: Serial communication.
« Reply #1 on: April 23, 2007, 02:17:37 PM »
do you need to test the com 1 port?
if so do a loopback test
Problems making the $50 robot circuit board?
click here. http://www.societyofrobots.com/robotforum/index.php?topic=3292.msg25198#msg25198

Offline hazzer123Topic starter

  • Supreme Robot
  • *****
  • Posts: 460
  • Helpful? 3
Re: Serial communication.
« Reply #2 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
Imperial College Robotics Society
www.icrobotics.co.uk

Offline snow

  • Full Member
  • ***
  • Posts: 73
  • Helpful? 0
Re: Serial communication.
« Reply #3 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.

Offline snow

  • Full Member
  • ***
  • Posts: 73
  • Helpful? 0
Re: Serial communication.
« Reply #4 on: April 24, 2007, 03:31:39 AM »
And some example class that uses above stuff: http://www.bbdsoft.com/win32.html (com port).

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Serial communication.
« Reply #5 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 . . .

Offline Kohanbash

  • Supreme Robot
  • *****
  • Posts: 430
  • Helpful? 1
Re: Serial communication.
« Reply #6 on: May 01, 2007, 08:47:44 PM »
How do you directly save hyperterminal data to csv?
Thanks
Robots for Roboticists Blog - http://robotsforroboticists.com/

Offline hazzer123Topic starter

  • Supreme Robot
  • *****
  • Posts: 460
  • Helpful? 3
Re: Serial communication.
« Reply #7 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
Imperial College Robotics Society
www.icrobotics.co.uk

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Serial communication.
« Reply #8 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

 


Get Your Ad Here