data packet definition, data acquisition!

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Reading done!
I have a clear understanding of how it works now...
Now I need an algorithm or pseudo-code for the master and for the slave...
Actually I need to do a simulation using two PCs, one for the slave where I'll simulate the microcontroller code that send data over a separate serial port and another PC for the master

Now I need an algorithm that actually show how data is sent/requested and...

My packet definition will look like:

StarByte (SOH = x1) TempBytes (2) PulseRate (1) EndByte (EOT = x4) checksum (2) --> packet size is fixed at 7 bytes

Any comments?

Thanks!
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
What I need to do is to simulate the microcontroller code in another in another PC that sends data over a separate serial port...

A quick google telling me I must use a null modem connection...
I'm a bit confused here...should that cable a male - male?

My laptop serial port has 15 holes the one I'm thinkin of simute has 15 as well...does that mean that cable need to have 15 pin on both side or what?

Any light?

Thanks!
 

MrChips

Joined Oct 2, 2009
30,821
I don't know of any laptop that has a 15-pin serial connector.
Your best bet will be to get a serial to USB cable.
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Needed to attach a pic but its too big...
Google Toshiba NB255-NB245 notebook...

All laptop I've checked so far has 15 holes in their serial port...
 

MrChips

Joined Oct 2, 2009
30,821
That is not the serial port. That is the SVGA monitor output.
If your computer has a serial port it will be a 9-pin connector, with pins sticking out, not holes.
 

t06afre

Joined May 11, 2009
5,934
Most modern notebooks do not come with a serial port. But I am sure your school(as this is a school project I guess) have some USB to serial port converters you can use. This is the pinout
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Thanks MrChips and t06afre for your explaination...I got it!


Here's my understanding:


Given that the two laptops ima be doing the serial communication with have no serial port, I'll have two 'USB to RS232 Serial Adapter connected to both laptops then I'll use a 'null modem cable' to actually connect the two computers, am I correct?

I got a question though, in the internal connection of this 'null modem cable' (female to female) only pin2, pin3 and pin5 are connected together. i mean pin2 connected to pin3, pin3 connected to pin2 and pin5 connected to pin5. am I correct? And all I have to do is connect this 'null modem cable' on both side of the RS232 serial adapter


looking forward to your comments, thanks!
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Another concern regarding my second paragraph:

This 'null modem cable' have 9 holes on both side and I won't know how the internal connection has been set up...I'm saying this coz in a pdf file (got on google) I been reading, it describes 4 types of RS232 serial null modem cable wiring...(without handshaking, with loop back handshaking, partial handshaking and full handshaking)

Now the problem is I won't know the type of hanshaking the cable I will get is (unless clearly mentioned!). in case no description have been provided, wouldn't be wise to connect ONLY pin2 to hole2, pin3 to hole3 and pin5 to hole 5 on both sides between the RS232 adapter and null modem cable??

Thanks!
 

MrChips

Joined Oct 2, 2009
30,821
A NULL MODEM will cross connect the hardware handshake lines. You can ignore these connections or you can go to the Device Manager COM port hardware setup and select Flow Control: None.
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
allright, then I will connect the null modem cable as it is and NOT connecting individual pins, correct?

thanks!
 

t06afre

Joined May 11, 2009
5,934
allright, then I will connect the null modem cable as it is and NOT connecting individual pins, correct?

thanks!
If you do not use handshake. And also turn it off then using a terminal program like hyperterm. Or in your program. It will work using only pin 5, 3, and 2. Pin 2 and 3 must be crossed in the cable.
Hope this will help you
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Given that when you connect a cable to a computer port, the computer assigns a portname to in, correct?

now in my code, in order for my computer to be able to open that port it must have that port name (COMX), where X is the number assigned to the port...

but I don't want to assign the port name in my code because I want ti be able to run the program in any machine...so my understanding is that I have to program it, ie program it so that at program startup it automatically detects the COM port available in the computer and allow the user to select the port to which the cable has been connected to, am i making sense??

Also, for communication between the two PCs or between PC and microcontroller, they must have the same baudrate value. and it might happen cases whereby the baudrate value has to be change so if there is only one bauderate value in the code, it will make life complicated for changing that on PC side as at the end of the day the program will be an exe on.

To fix the above problem I was thinking of having a number of bauderate in the code (4 for instance) and allow the user to select the baudrate wanted in the graphical user interface, correct?

As for changing baude rate in microcontroller it easy as one will just have to re-program the chip with the PICkit.

Loking forward to your comments on this one!

Thanks!
 

MrChips

Joined Oct 2, 2009
30,821
Now you are getting complicated. Just stick to one baud rate and one COM port and be done with. Most PCs will default to COM1 as the first serial port.

No, this not like a USB port. The PC will not detect and assign a COM port. It defaults to COM1.
 
Last edited:

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Now you are getting complicated. Just stick to one baud rate and one COM port and be down with. Most PCs will default to COM1 as the first serial port.

No, this not like a USB port. The PC will not detect and assign a COM port. It defaults to COM1.

Thanks I will do as you said!:D
 

MrChips

Joined Oct 2, 2009
30,821
Oops, my mistake. I forgot you are using a USB to UART bridge.
The PC will assign a COMx port to the USB when the cable is connected.
Usually it is consistent but it can be any number on a different PC. So you have to allow the user to select the COMx port.
 
Top