Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How can I control the serial port ?

Status
Not open for further replies.

RobotHeart

Junior Member level 3
Junior Member level 3
Joined
Apr 8, 2010
Messages
25
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Malaysia
Activity points
1,505
Good day every1

What is the simplest way to control the serial port ? I would like to use the serial port to control 4 motors through a microcontroller, so its gona be like:
PC -> serial port -> Microcontroller -> motor.

please guide me..
 

RobotHear

The scheme you presented is correct but don´t bring important details ( i.e.: the control to mottoer is to speed level or just On/Off ? . It affects the type of power driver ).

What is exaclly your doubt ?
We can provide a more precise help according you post each problem you find.

+++
 

You must be more clear of your requirement before you start with a solution:
What are the four motors doing ?
What do you mean with the word control ?

One scenario is that the four motors are AC induction motors driving fans.
The pic processors (or single processor) controls the speed.
The PC instruct the PIC for a certain speed and reads back and display the actual speed

Another senario is that for stepper motors and angle control?
 
Last edited:

if you specify the device and software you are using it become easier for the people here to understand your problem and give the better solution.

there is a built in USART module in Pic16f877 use for serial communication. You have to first connect your serial port of you pic to max232 IC(Voltage Translator IC) than you can connect the output of Max232 directly to the serial port of your PC. so now whatever you will send to serial port of pic, pic can recieve that data and on the base of that data you can turn on and off any motor. You have to do all this in your coding part.
 

    V

    Points: 2
    Helpful Answer Positive Rating
    V

    Points: 2
    Helpful Answer Positive Rating
I am very sorry for my unclear request. its actually a mobile robot that i would like to control its speed and direction. the 4 motors are servo motors (360 angle) 9V (or maybe 5V). microcontroller used is PIC16F877A. my biggest problem is that I dont do PC programming, I do microcontroller programming in C language. which means my problem now is in the PC part of the project. please guide me on my next step.
I hope my questions are clear now.
thank you.
 

I assume you are using windows ? If you wish to control the serial port the simplest thing is to use Microsoft Visual Studio or one of the Express editions (which come in various editions VB, C++, C#, etc)
Microsoft Express Downloads - Visual Studio Express and SQL Server Express

if you look in the Tollbox under Components you will find a SerialPort component which can use to send data to and reveive data from your microcontroller.

if you program your microcontroller to respond to simple commands (e.g. R to turn right) you could use Hyperterm of some other terminal emulator to control the robot. This will save you writing the PC code.

if you are to contol a robot I would have thought some form of wireless communication would be more suitable then RS232

for motor control have a look at
Microsoft Express Downloads - Visual Studio Express and SQL Server Express
 

you see...its a laptop not a PC, and it'll move along with the mobile robot while the serial port is connected to the laptop, remote desktop will be used to control the robot wirelessly, other core features will be added later on but now I want to finalize is part if possible.
So how can I use the RS232 for this purpose, I know RS232 alone is not enough, I need the "algorithm" of how the whole process will go in details.

regards..
 

Start of by writing all the user stories of what this system will do . Short English sentences. (Or in you language and then you translate it for Edaboard)
The user stories must only contain the requirements and no solutions

---------- Post added at 16:18 ---------- Previous post was at 16:09 ----------

As a <type of user>, I want <some goal> so that <some reason>
examples
As the robot operator, I want to instruct the robot to turn right so that I can steer it
As the robot operator, I want to control the robot without wires so that I can control the robot remotely
 

RobotHear


The procedure present by klystron is a good start to you know better the problem.
We can advance that you must create a protocol at serial communication in order to encapsulate several comands at same transmission.

Follows a simple sugestion :
Code:
[Start_Byte][SpeedMottor1][SpeedMottor2][SpeedMottor3][SpeedMottor4][End_Byte]

+++
 

ok...
As the robot operator, I want to use Windows Remote desktop to so that I can control the robot (laptop on wheels) without wires from other computer.
As the robot operator, I want to use C or C++ language to control the serial port so that I can use laptop's serial port.
As the robot operator, I want to use Laptop's serial port to connect with the microcontroller through RS232 so that I can control the speed and direction of 4 motors.
As the robot operator, I want to use microcontroller to control the motors (wheels) so that I can move the robot to any direction.
As the robot operator, I want to instruct the robot to move forward so I can make it accelerate.
As the robot operator, I want to instruct the robot to move backward so I can reverse its direction.
As the robot operator, I want to instruct the robot to turn right so I can steer it.
As the robot operator, I want to instruct the robot to turn left so I can steer it.

:)

---------- Post added at 19:57 ---------- Previous post was at 19:45 ----------

could you please give me more details on how to create that protocol and how to use it..
thank you

---------- Post added at 19:58 ---------- Previous post was at 19:57 ----------

yes...just like how I described it
 

write a C program that transmits the commands for each of the motor for each key press.

i.e: if you press up, transmit commands over RS232 for the 4 motors in the format suggested by andre_teprom.
From the microcontroller, take corresponding actions for the motor control.

There are many free serial control libraries available in the internet like the one at Windows Serial Communication Component Library for serial port communication; modem library, serial port component, serial control, RS232, RS422, RS485
 
you can make use of serial port library available as a dll to send any data to the port.

a minimal c program can be written to send your data to the serial port.
 
I suggest you to start with Hyperterminal on PC side, later you can develop your own code using c, cpp or vb.
Also windows xp and later versions, have some restrictions for using the serial and parallel ports, if you are using vb you will get dlls for accessing the port, if you are using c or cpp you should use some softwares to gain access to the ports.

I have a **broken link removed** in which I have breifed about accessing serial port using hypertermial.

This link contains some related threads.

Hope this helps :)
 

if you are using Microsoft Visual Studio or Express there is a SerialPort component in the Toolbox under Components
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top