473,395 Members | 1,537 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,395 software developers and data experts.

pyparallel and MAKE controller board for CRYDOM AC/DC switches

Greetings. I am trying to write a small application for controlling CRYDOM
AC and DC switches from the parallel port using pyparallel. The project is
described in the latest issue of MAKE magazine Vol.3 pg 86. All of the
examples are in C, VB, Linux, Unix but not a thing in Python. Seems like a
perfect application for a Python program or even a simple windowed app.
Problem is I'm stuck. How, for example, would I format the setData() to
turn off data PIN 3? If I knew that then.. Life, the Universe and
Everything would be better.

Progress so far:

import parallel, time, ctypes
p=parallel.Parallel(1)
p.setData(0)
p.setDataStrobe(0)
print "Boy are you stuck!"

THANKS for any help!!
Oct 11 '05 #1
2 2275
Recalling the parallel pinout, pin 3 is data bit 2. Have you tried
def BIT(x): return 1<<x
p.setData(BIT(2))
?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDSxgTJd01MZaTXX0RArpjAJ44vuU/eHMH24514JMWg5iDsAxeXwCcC3qf
N2s6xRrC5SUmnvyaqF0t9U8=
=a5SZ
-----END PGP SIGNATURE-----

Oct 11 '05 #2

Richard Siderits wrote:
Greetings. I am trying to write a small application for controlling CRYDOM
AC and DC switches from the parallel port using pyparallel. The project is
described in the latest issue of MAKE magazine Vol.3 pg 86. All of the
examples are in C, VB, Linux, Unix but not a thing in Python. Seems like a
perfect application for a Python program or even a simple windowed app.
Problem is I'm stuck. How, for example, would I format the setData() to
turn off data PIN 3? If I knew that then.. Life, the Universe and
Everything would be better.

Progress so far:

import parallel, time, ctypes
p=parallel.Parallel(1)
p.setData(0)
p.setDataStrobe(0)
print "Boy are you stuck!"

THANKS for any help!!


Here is some code that may do what you want:

from parallel import *
class P:
def __init__(self, port):
self.dataReg = 0
self.p = Parallel(port)

def setData(self, value):
self.dataReg = value
self.p.setData(value)

def setDataBit(self, bit, value):
assert 0 <= bit <= 7
assert 0 <= value <= 1
mask = 1 << bit
self.dataReg = (self.dataReg & ~mask)
if value:
self.dataReg += mask
self.p.setData(self.dataReg)

if __name__ == '__main__':
import msvcrt, time
bit = 1
pyp = P(LPT1)
pyp.setData(0xff) # set all bits high
print 'all bits high'
while not msvcrt.kbhit():
time.sleep(0.1)
ch = msvcrt.getch()
while 1:
pyp.setDataBit(bit, 0) # set bit <bit> low
print 'bit %d low' % (bit, )
while not msvcrt.kbhit():
time.sleep(0.1)
ch = msvcrt.getch()
if ord(ch) == 27: # esc
break
pyp.setDataBit(bit, 1) # now high
print 'bit %d high' % (bit, )
while not msvcrt.kbhit():
time.sleep(0.1)
ch = msvcrt.getch()
if ord(ch) == 27: # esc
break

Oct 12 '05 #3

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

Similar topics

1
by: Brian | last post by:
When using this: import parallel p = parallel.Parallel() #open LPT1 p.setData(0x55) I get this:
3
by: Michel LE VAN KIEM | last post by:
Hi everybody ! I'm trying to install the pyparallel module for my Python 2.3.4 (runs on a FC3) but I do have some troubles. When I import the parallel module, python shows the following...
2
by: garyr | last post by:
I'm using py2exe to create a standalone program that uses pyparallel. When I run the created program an error occurs and a message directs me to the log file which contains: Traceback (most...
4
by: Griff | last post by:
Two questions really, the first one "conceptual" and the other more involved with design: 1 - There are two schools of thought where I work on the role of the "controller" task. The first is...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
6
by: Radium | last post by:
I have the following problem: I have written a class which works on image data. To be precise.... the class applies smoothening on the image with filters. I want to visualize this proccess....
0
by: juncus | last post by:
Hi, Perhaps this is not the right forum to post this, but I am having trouble installing pyParallel. When I try to do the usual "python setup.py build" or "python setup.py install", I get the...
1
by: db2admin | last post by:
Hello, I am interested in capturing snapshot information using SQL functions or views but i can not reset monitor switches when i use following command. db2 "reset monitor for database...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.