Hiya, guys! On this undertaking I’ll attempt to clarify my experiments on PIC MCU and Python serial communication. Over the web, there are various tutorials and movies on tips on how to talk with PIC MCU over digital terminal which may be very helpful. Nevertheless, in my fundamental undertaking one of many necessities is to determine serial communication between PIC MCU and Python which I could not discover good tutorial. So, let’s get began 🙂
Academics! Did you employ this instructable in your classroom?
Add a Trainer Word to share the way you included it into your lesson.
Step 1: What Do We Want?
So, to start with let’s examine what we’d like. When it comes to :
- Absolutely, PIC MCU which is in my case PIC16f877a (You do not want that board. That is with a purpose to simplify some soiled connections)
- USB to TTL converter with a purpose to talk with PIC MCU over USB port through the use of TX and RX pins.
- MCU programmer which is in my case Okay150 programmer, however you should use PicKit 2,three or anything.
- And at last a pc 🙂
When it comes to software program:
- An IDE with a purpose to write python code which is in my case Pycharm, however you should use common Python IDE additionally.
- An atmosphere for programming the MCU which is in my case MPLAB X IDE with CCS C compiler.
Step 2: Connections
Within the image connected connections are given that are between PIC MCU and USB TTL converter as under:
RC7 (RX) —————> TXD
RC6 (TX) —————> RXD
GND —————-> GND
You need not join VCC pin of the USB TTL converter (Nevertheless, if you need you are able to do). These three connections are fairly sufficient.
Step three: Python Software program
Let’s begin to write software program for Python aspect which shall be transmitter in our case, as a result of it can ship the string to the MCU.
import serial #import serial library
knowledge = '24' #knowledge that we'll ship knowledge = a+' ' ser = serial.Serial('COM17', baudrate=9600, timeout=1) #connect with the port ser.write(a.encode()) #ship the info
To start with serial library is imported with a purpose to use its futures. We need to ship an instance string knowledge with a purpose to verify in MCU code that we accepted it. I would like right here to notice one factor. That is why we added ‘