Bit-Bang using mscomm
Bit-Bang using mscomm
Bit-Bang using mscomm
Bit-Bang using mscomm
Bit-Bang using mscomm
Bit-Bang using mscomm Bit-Bang using mscomm Bit-Bang using mscomm Bit-Bang using mscomm Bit-Bang using mscomm Bit-Bang using mscomm Bit-Bang using mscomm Bit-Bang using mscomm
Bit-Bang using mscomm Bit-Bang using mscomm
Bit-Bang using mscomm
Go Back  Xtreme Visual Basic Talk > > > Bit-Bang using mscomm


Reply
 
Thread Tools Display Modes
  #1  
Old 05-22-2010, 08:37 AM
johnsmith123 johnsmith123 is offline
Newcomer
 
Join Date: Jan 2006
Posts: 20
Default Bit-Bang using mscomm


Hello Guys,
I am trying to write a program to communicate with an SPI device. I am using the serial port with MSComm & VB6.

The hardware is an avr programmer that uses 4 pins, RTS, CTS, DTR, and TXD.
I will not be using the hardware as an avr programmer, it will be used to communicate with another spi device.

I have the first three pins figured out, however I can't see how to send a "1" or a "0" out the TX pin using MSComm.

I am also wondering if there is another way other than MSComm?

Has anyone ever done this before?

I would appreciate any advice, links, etc.

Last edited by johnsmith123; 05-22-2010 at 08:56 AM.
Reply With Quote
  #2  
Old 05-22-2010, 02:50 PM
mkaras's Avatar
mkarasBit-Bang using mscomm mkaras is offline
Ultimate Contributor

Retired Leader
* Expert *
 
Join Date: Mar 2004
Location: Beaverton, OR
Posts: 1,874
Default

You can control the TXD output state of the PC serial port in the following way. Use a serial port that is associated with an instance of MSComm control. When the port is "open" and when there is _not_ any data transmission going out the output side of the UART it is possible to toggle the state of the TXD line through the use of the Break property of MSComm. Use MSComm1.Break=True and MSComm1.Break=False to toggle the state of the TXD pin.

mkaras
Reply With Quote
  #3  
Old 05-22-2010, 03:20 PM
mkaras's Avatar
mkarasBit-Bang using mscomm mkaras is offline
Ultimate Contributor

Retired Leader
* Expert *
 
Join Date: Mar 2004
Location: Beaverton, OR
Posts: 1,874
Default

Do note that setting the serial port control lines RTS and DTR via RTSEnable and DTREnable and the TXD line through the use of the Break properties is not the most speedy activity. If you write a program to toggle these lines and then observe the modulation rate on an oscilloscope you will be able to observe just how fast the hardware is able to respond to the toggle requests. (It will not be a speedster rate).

The behavior can be even slower if you are using a serial port implemented in a USB<-->Serial cable.

Keep in mind that if you are using a normal serial port interface the signal lines will have voltage swings that go both negative and positive with respect to the GND connection. The amplitude of the swing will vary depending upon the vintage and type of serial port hardware that you have. The signals could swing from +3 to -3 volts at the lowest up to +12 to -12 volts.

I bring up this bipolar voltage nature of the serial port signals because it is rather normal that a SPI device will use signalling that is incompatible with the negative voltages from a serial port. The SPI device may also be limited to signals that swing no more than +5 volts or +3.3 volts depending upon the device in use. In either case the negative voltages or serial port signals that are too high can and will damage or destroy your SPI device.

If you are set upon the idea to use a serial port for this application and do need to support SPI signalling at 0 to 5 volts or 0 to 3.3 volts then you should consider the use of one of the FTDI based TTL serial cable assemblies. These are designed to support serial port handshake signals that work at either 5 volts or 3.3 volts. If you use the specific cables shown they do not have the DTR signal pinned out on the cable. (The chip on the board inside the adapter does support the full complement of the UART signals but to keep the cable simple it is not wired out).

See at www.mouser.com --

http://www.mouser.com/ProductDetail/...3R5sMdbLgwj41z

http://www.mouser.com/ProductDetail/...DpPMdam%2fwe00

If you poke around a little at Mouser you can also find these adapters in several other forms with open wire ended cables and ones with open circuit board without the cable at all.

Michael Karas
Reply With Quote
  #4  
Old 05-22-2010, 08:47 PM
johnsmith123 johnsmith123 is offline
Newcomer
 
Join Date: Jan 2006
Posts: 20
Default

thanks for the help, it is working now. The hardware interface has been working well as an avr programmer for over a year now. I just wanted to use the same hardware for another device. Speed is not as important an issue as is the simplicity of the circuit.

I was really hoping there would be another way instead of using mscomm, however it is fine, since it is working.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Bit-Bang using mscomm
Bit-Bang using mscomm
Bit-Bang using mscomm Bit-Bang using mscomm
Bit-Bang using mscomm
Bit-Bang using mscomm
Bit-Bang using mscomm Bit-Bang using mscomm Bit-Bang using mscomm Bit-Bang using mscomm Bit-Bang using mscomm Bit-Bang using mscomm Bit-Bang using mscomm
Bit-Bang using mscomm
Bit-Bang using mscomm
 
Bit-Bang using mscomm
Bit-Bang using mscomm
 
-->