Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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
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..
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,221
Helped
1,147
Reputation
2,313
Reaction score
1,123
Trophy points
1,403
Location
Brazil
Activity points
53,678
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.

+++
 

klystron

Advanced Member level 4
Joined
Jul 11, 2002
Messages
1,014
Helped
192
Reputation
384
Reaction score
180
Trophy points
1,343
Location
South Africa
Activity points
4,515
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:

qwertyuiop415263

Full Member level 4
Joined
Mar 26, 2010
Messages
232
Helped
50
Reputation
102
Reaction score
39
Trophy points
1,308
Location
Pakistan
Activity points
2,414
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

RobotHeart

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
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.
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
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
 

RobotHeart

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
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..
 

klystron

Advanced Member level 4
Joined
Jul 11, 2002
Messages
1,014
Helped
192
Reputation
384
Reaction score
180
Trophy points
1,343
Location
South Africa
Activity points
4,515
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
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,221
Helped
1,147
Reputation
2,313
Reaction score
1,123
Trophy points
1,403
Location
Brazil
Activity points
53,678
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]

+++
 

RobotHeart

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
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
 

vysakhpillai

Junior Member level 2
Joined
Jun 10, 2008
Messages
23
Helped
5
Reputation
10
Reaction score
4
Trophy points
1,283
Activity points
1,375
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
 

srizbf

Advanced Member level 5
Joined
Apr 3, 2010
Messages
1,995
Helped
417
Reputation
840
Reaction score
328
Trophy points
1,363
Activity points
10,985
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.
 

srikanthsamaga

Full Member level 3
Joined
Dec 14, 2008
Messages
179
Helped
12
Reputation
24
Reaction score
2
Trophy points
1,298
Location
12°52′N 74°53′E
Activity points
2,022
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 webpage in which I have breifed about accessing serial port using hypertermial.

This link contains some related threads.

Hope this helps :)
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
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

Top