LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-19-2009, 09:59 AM   #1
sagitalk
Member
 
Registered: Aug 2008
Posts: 38

Rep: Reputation: 15
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 ??
 
Old 02-19-2009, 10:51 AM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
---incorrect data in post---

Last edited by indienick; 02-19-2009 at 02:33 PM. Reason: See the post.
 
Old 02-19-2009, 10:53 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,232

Rep: Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217
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?
 
Old 02-19-2009, 11:19 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 17,232

Rep: Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217Reputation: 2217
Quote:
Keep in mind that the "parallel" port is actually just a serial port with more pins.
Not really.
 
Old 02-19-2009, 11:35 AM   #5
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
My bad - my friend mis-informed me, then.
 
Old 02-19-2009, 02:26 PM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
Old 02-25-2009, 09:54 PM   #7
sagitalk
Member
 
Registered: Aug 2008
Posts: 38

Original Poster
Rep: Reputation: 15
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 ??
 
Old 02-26-2009, 10:33 AM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by sagitalk View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
is there any shell command to read and write data from parallel and serial port? baosheng Linux - Hardware 2 01-13-2007 08:35 PM
Parallel Port & Serial Port device identification helpmeforlinux Linux - Hardware 3 01-02-2007 01:15 AM
Serial/Parallel/Game Port Interfacing sparkyssb Programming 8 06-29-2006 01:41 PM
serial and parallel port with DMESG command froglinux Linux - Hardware 1 06-16-2006 08:51 PM
serial/parallel port marco_aq Linux - Networking 1 10-12-2001 02:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration