473,383 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

serial port servo control

So I ordered a mini SSC II (the servo controller), in order to
control some servos from the computer. I was hoping to use python to
do the control but have two questions...

1) How should I write to the serial port with python? I found the
module "pyserial":
http://pyserial.sourceforge.net/
on the python cheeseshop, and it looks solid but I thought you might
have a better suggestion.

2) To control the servos I have to send the SSC II a string of 3
numbers, 3 bytes long (so 3 numbers in the range 0 - 255, each as a
single byte, one after another). In C I'd do this by sending 3
char's, as they're only 1 byte, but i'm not exactly sure how to do it
in Python.

Jun 22 '06 #1
4 2344
bo****@llnl.gov schrieb:
So I ordered a mini SSC II (the servo controller), in order to
control some servos from the computer. I was hoping to use python to
do the control but have two questions...

1) How should I write to the serial port with python? I found the
module "pyserial":
http://pyserial.sourceforge.net/
on the python cheeseshop, and it looks solid but I thought you might
have a better suggestion.

pyserial is what you need.
2) To control the servos I have to send the SSC II a string of 3
numbers, 3 bytes long (so 3 numbers in the range 0 - 255, each as a
single byte, one after another). In C I'd do this by sending 3
char's, as they're only 1 byte, but i'm not exactly sure how to do it
in Python.


Strings in python are byte-strings. So you can use them. Additionally, I
recommend looking into the module struct.

Diez
Jun 22 '06 #2

<bo****@llnl.gov> wrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
1) How should I write to the serial port with python? I found the
module "pyserial":
I don't think there is any need to hunt for anything better.
In C I'd do this by sending 3 char's, as they're only 1 byte,
but i'm not exactly sure how to do it in Python.


Use a string type. output = chr(x) + chr(y) + chr(z) for example.
There is no restriction on null bytes in strings, so they are
appropriate for binary data.
Jun 22 '06 #3
On 22 Jun 2006 08:18:08 -0700, bo****@llnl.gov wrote:
So I ordered a mini SSC II (the servo controller), in order to
control some servos from the computer. I was hoping to use python to
do the control but have two questions...

1) How should I write to the serial port with python? I found the
module "pyserial":
http://pyserial.sourceforge.net/
on the python cheeseshop, and it looks solid but I thought you might
have a better suggestion.

2) To control the servos I have to send the SSC II a string of 3
numbers, 3 bytes long (so 3 numbers in the range 0 - 255, each as a
single byte, one after another). In C I'd do this by sending 3
char's, as they're only 1 byte, but i'm not exactly sure how to do it
in Python.


Maybe a little off topic, but I've got a page below with some mini ssc
control info.

http://www.geocities.com/zoomkat/index.htm

Jun 23 '06 #4
Several have suggested struct, I'd suggest you look at array:
import array
v = array.array('B', [1, 2, 3])
for i in range(17):
v[i % 3] *= max(1, i // 3)
v.tostring()

--Scott David Daniels
sc***********@acm.org
Jun 23 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ^CeFoS^ | last post by:
Hello to everybody, I've done an application that draws in a frame the trajectory of a robot. The robot position is readed through the serial port, and several commands are wrote through the...
3
by: rusttree | last post by:
Many moons ago, I took a class in embedded control at school. The course focused on a micro-controller mounted on a small electric car that was programmed using simple C code. The...
6
by: Peter Krikelis | last post by:
Hi All, I am having a problem setting up input mode for serial communications. (Sorry about the long code post). The following code is what I use to set up my comm port.
13
by: Al the programmer | last post by:
I need to access the serial ports on my webserver from an asp.net page. I have no problem accessing the serial ports from a windows form application, but the code doesn't work in asp.net. I have...
4
by: joe bloggs | last post by:
I am writing a mobile application to interface with a legacy system and I am planning to use web services to communicate with this system. The legacy system receives data through a serial port. ...
1
by: henrycortezwu | last post by:
Hi All, I'm trying to connect to a virtual port (COM19, OUTGOING, "Bluetooth Serial Port") using VS2005 System.IO.Ports. When I ran the ff code below here's what happens. 1) VS2005 Compiles w/o...
7
by: davetelling | last post by:
I'm a newbie that is still struggling with OOP concepts & how to make things work they way I want. Using Visual C# Express, I have a form in which I added a user control to display a graph, based...
2
by: evle | last post by:
haw to read data from an Infrared Infrared Remote Control
13
by: Rob | last post by:
Hi all, I am fairly new to python, but not programming and embedded. I am having an issue which I believe is related to the hardware, triggered by the software read I am doing in pySerial. I...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.