LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   serial v/s parallel port (https://www.linuxquestions.org/questions/programming-9/serial-v-s-parallel-port-705922/)

sagitalk 02-19-2009 09:59 AM

serial v/s parallel port
 
hello,

i am using the ADC inside atmega8535 that outputs 8bit data. i want to send this data to the computer and store it in a file. i am using 2.6.23.1 patched with RTAI-3.6.1.

i am debating upon how to send this data.............use the parallel port or the serial port......any suggestions ??

indienick 02-19-2009 10:51 AM

---incorrect data in post---

michaelk 02-19-2009 10:53 AM

My first thoughts would be via the serial port and send ASCII characters. Is the microcontroller on a circuit board? If so does the circuit board have a RS-232 converter chip of any kind?

michaelk 02-19-2009 11:19 AM

Quote:

Keep in mind that the "parallel" port is actually just a serial port with more pins.
Not really.

indienick 02-19-2009 11:35 AM

My bad - my friend mis-informed me, then.

theNbomr 02-19-2009 02:26 PM

From the Atmel data sheet, the microcontroller has a USART, so you should be able to communicate with the device via a serial interface. Your micro will probably need to have RS-232 level converters added, as a typical USART outputs only TTL level logic. As well, your micro will need to be programmed with some protocol that allows the Linux host to read and/or write to the micro over RS-232, and this should be done in accordance with the requirements of your project. Since you are apparently not experienced in these matters, I suggest using a protocol that sends ASCII formatted data, so that you can use standard serial comm's tools to observe the serial data. Linux examples of these would be minicom (typically included with Linux distros) and C-Kermit (my weapon of choice).
To confirm the comment of michaelk, parallel interfaces are absolutely not simply serial interfaces with more pins.
--- rod.

sagitalk 02-25-2009 09:54 PM

hello,

i ahve already programmed the atmega board. the adc in it gives an interrupt after each conversion and thus stores the data in the tx buffer of the UART. i have tested the program on the hyperterminal provided by the CVAVR and it worked.

but when i used minicom and set the correct parameter that is same baud rate and everything on both sides i see nothing in minicom. minicom shows the status as offline.

also i need a method to synchronize communication between the board and the computer's serial port.

any suggestions on how should i go about this ??

theNbomr 02-26-2009 10:33 AM

Quote:

Originally Posted by sagitalk (Post 3457674)
hello,

i ahve already programmed the atmega board. the adc in it gives an interrupt after each conversion and thus stores the data in the tx buffer of the UART. i have tested the program on the hyperterminal provided by the CVAVR and it worked.

but when i used minicom and set the correct parameter that is same baud rate and everything on both sides i see nothing in minicom. minicom shows the status as offline.

Well, you should try jumpering the Tx & Rx pins of the serial connector or cable on the Linux workstation, and see if you see characters being echoed in minicom. If not, you will need to figure out in what way you have misconfigured minicom or the serial port. Are you sure that you have RW access to the serial port, and that it is not configured for connection as a login tty? Check permissions on /dev/ttyS0 (or whatever serial port you are using). Also, check in /etc/inittab
I've always preferred C-Kermit for this type of work, as I feel it provides more fine-grained control of the serial port. Plus it is scriptable, and sometimes that can be useful.
Quote:

also i need a method to synchronize communication between the board and the computer's serial port.

any suggestions on how should i go about this ??
Are you writing some end-user type of application to run on the computer? The type of protocol you devise depends entirely on your application. A somewhat common approach would be to use some kind of command-response protocol, where the computer issues some command, and the board responds according to the command. Pay attention to things like end-of-line characters and timeouts in this kind of protocol. Consider following some form of industry standard for formatting and parameterizing commands and responses, such as SCPI, commonly used in GPIB interfaced instruments.
If you are writing code to communicate with your board via serial ports, you will probably want to consult some of the standard online tutorials and HOWTOs on the subject of serial comm's under Linux. If you aren't already acquainted with the use of the select() system call, it will probably be useful in this scenario.
Serial HOWTO
Serial Programming HOWTO
Linux Serial Console HOWTO (for sorting out serial console login issues)

--- rod.


All times are GMT -5. The time now is 03:47 AM.