Serial Port Programming Using Python in Windows
1 - Download and Install Python Installer from here. User the version according to your version of operating system.
2 - You can use python by running "Python (command line)" or "IDLE (Python GUI)" from All programs - Python.
2 - In order to invoke Python from the Command Prompt (cmd) you need to add ";C:\Python34" to the PATH environment variable.
To do this,
Right click on "computer" , go properties select "advance system properties" than "Environmental Variables". In the "System variables" variable list, select path from the list and add ";C:\Python34"
Now open command terminal and type python, you should see something like this
Now, come out of the python interpreter by typing the command
exit()
3 - Download pySerial from https://pypi.python.org/pypi/pyserial . Unzip and copy pyserial-2.6 folder into C:\Python27 directory
4- Navigate to C:\python27\pyserial-2.6 using cd command
cd c:\python27\pyserial-2.6
5 - To install pySerial, type the following command
python setup.py install
Now, to test the serial port interface with the micro-controller board, download term.py from the link "http://academy.cba.mit.edu/classes/embedded_programming/index.html". Navigate to the downloaded directory using the cd command. To run term.py type following command (replace COM10 by actual serial port number you find in device manager)
python term.py \\.\COM10 115200
You should get the following window and it should return what you have typed
/// Draft ///
Reciever
Code in the micro-controller board continuously monitor the Tx pin of transmitter and waits for start bit (logic low). Once the start bit is observed it continuously samples 8 data bits. After transmitting 8 bits the transmitter sends one (or more) stop bits i.e. Tx pin is logic high. The receiver again waits for logic low (start bit) and the process is repeated for every character byte.
PC COM Port
PC's serial port uses RS232 standard for communication. For RS232 standard logic high is
a signal voltage in the range of -3 V to -15 V (typically -12 V), and a logic low is between +3 V to +15 V (typically +12 V). On the other hand for micro controller board logic high is 5V and logic low is 0V. For this reason an FTDI cable is used which convert RS232 high (-12V) into micro-controller logic high (5V).
synchronous
(requires a synchronized clock between the transmitter and receiver) -
See more at: http://embedded-lab.com/blog/?p=1296#sthash.VjIImNKO.dpuf
two modes of operation: synchronous (requires a synchronized clock
between the transmitter and receiver) and asynchronous (no
synchronization clock required). - See more at:
http://embedded-lab.com/blog/?p=1296#sthash.VjIImNKO.dpuf
two modes of operation: synchronous (requires a synchronized clock
between the transmitter and receiver) and asynchronous (no
synchronization clock required). - See more at:
http://embedded-lab.com/blog/?p=1296#sthash.VjIImNKO.dpufsdsdsd
No comments:
Post a Comment