Talking to SPI devices from parallel port

Thread Starter

HalfMadDad

Joined Jun 10, 2016
30
Hi Everyone

I have pretty much done my research but I am not confident that what I am setting out to do is correct, I was hoping to post here and double check my logic.

I want to wire wrap circuits that will have either no firmware or will have a microcontroller set up as a SPI slave.

I can control my parallel port with inb, outb and ioperm or with ioctr. I am still investigating ppdev.

If I toggle the data lines up and down and read the signal on my oscilloscope the square wave "digital-like" signal is not regular. This is expected as I am running a regular Linux distro, Trisquel and I am not expecting real-time performance.

My question, if the PC is the SPI master, is it okay if the SPI bus is synchronous but has an inconsistent frequency?

If I use the strobe line,as the SPI clock, SCLK, both master and slaves will be using the same clock but if the those clock pulses are not equal, I don't know if bad things can happen.

If I had a microcontroller that was set up as a SPI slave, could it obey an on-board clock and also an SPI clock signal coming from the PC that was of a bit of an irregular frequency?

I will also be sending out a byte in parallel that will need to be processed by the SPI devices in a serial manner. If I bit mask out bits from a byte, one-by-one and send each bit at the same position in the parallel byte, will the SPI device respond once it was received 8 bits, assuming it has an 8 bit wide shift register?

If anyone has any general pointers about interfacing SPI and a PC, I would appreciate any time you can spare.

Thanks !
 

Picbuster

Joined Dec 2, 2013
982
You make life difficult. Why do you want SPI interface between PC and the 'outside' world?
SPI sort distance and very sensitive for external electrical noise.

Look at the microchip site there are some SPI timing descriptions available.

Most simple way is to use a PIC from PC => PIC parallel in SPI master / slave or serial ( data in or out or both.)
Picbuster
 

ericgibbs

Joined Jan 29, 2010
8,739
hi HMD,
I have used VB5 to control MCP3202/4 & 8 ADC, SPI devices via the 'old' parallel port, worked very well.
If it would help I could post a zip of the VB5spi folder, its messy, but if you look thru the *.frm extension files, it may give you a pointer.
E
 

Thread Starter

HalfMadDad

Joined Jun 10, 2016
30
Hi Eric

If you can manage it, I would love to see the folder sometime.

Thanks!

P.S, I will be out for the next 6 hours
 
Last edited:

Thread Starter

HalfMadDad

Joined Jun 10, 2016
30
Hi Andrew

I am not tied to this port and you are scaring me !

I did look into USB SPI solutions about a year ago and bought a book on building USB devices. It still seemed like too much embedded programing for my taste . I could have a look at it again.

I am going to see if I can create accurately timed pules from the parallel over the next few days. If I can't I probably should look into something else such as what you are suggesting.

Thanks
 

ericgibbs

Joined Jan 29, 2010
8,739
hi HMD,
Ref USB, there are low cost USB <> RS232 adaptors available from Amazon or eBay.
If you download a 'prolific' drive for this adaptor, you can communicate with your PC using RS232 protocols and the Prolific driver IDE.

If you want more info, just ask.
E
 

Thread Starter

HalfMadDad

Joined Jun 10, 2016
30
Hi again everyone

I had a weird idea this morning that just might work. I don't want to clutter the forum with all the details from my project but basically I want to be able to control passive circuitry to help scientist setup custom instrumentation. I also want to assist them to control instruments via GPIB and RS232 and possibly ethernet.

I was thinking about using a parallel port for passive stuff via SPI, a serial port and GPIB card.

While GPIB and parallel are different they have cross over concepts.

I think that if I put the GPIB bus in local mode, I can use the 8 data lines to control SPI. I could set this up so that once the local mode is switched to remote, the passive circuitry would be disabled.

this would mean that the passive circuitry and the GPIB instruments could not be controlled at the same time but I think this will be fine.

Thanks to everyone that posted. If you happen to have any parallel port goodies achieved on your hard drive, maybe please post them but if not, I have already received great help.

Thanks again to all
 

Thread Starter

HalfMadDad

Joined Jun 10, 2016
30
Hi Again Everyone

I gave up on the idea of using GPIB. One GPIB cable costs more than a PCI-E Parallel port card.

I am making progress but I want to leave a trail of breadcrumbs for other people that might be interested in this sort of thing.

Right now, I am looking into adding decoupling capacitors to cut down on noisy spikes and I am wondering if this is such a good idea as the parallel port works at TTL and I am not sure if this logic family is dying off.

-Patrick
 

Thread Starter

HalfMadDad

Joined Jun 10, 2016
30
Hi Eric

I was planning to use capacitors with all TTL lines. Things might work fine without them but I am seeing spikes that may be going up to 6V plus. I have to remeasure be sure.

Thanks
 

ericgibbs

Joined Jan 29, 2010
8,739
hi,
It is important not to degrade the rise/fall time of the clock/data edges.
Depending upon which of the four common SPI options you are using, data is clocked out/in on the clock edges.
You could consider say a Schottky diode clamp from the TTL signal line to +5v rail, in order to limit the overshoot.

Lets know what you actually measure, scope ground close the TTL line drive being measured, ideally the TTL output should be driving a load,
ie: another TTL or termination resistor.

E
 

Thread Starter

HalfMadDad

Joined Jun 10, 2016
30
Thanks yet again Eric

I don't think I have things setup right yet for valid measurements. I have floating lines and other things that I ought to fix first.

I will report back once I have these things done
 
Top