Routing data from the Serial port to ICs

In summary: Jason ORS-232 is called the SCI interface, and is different from the SPI serial communication standard. SCI has no clock, just the data. The sender and receiver must have accurate time bases, and use a baud rate that both the sender and receiver agree upon. SPI uses a separate clock line, and the data rate can vary. The master generates the clock, and transmits data on the MOSI (master out, slave in) line. The slave drives data back to the master on the MISO line. If you are trying to drive an SPI interface from a RS-232 port, you would need to bit-bang both a clock and a
  • #1
Jdo300
554
5
Hello All,

I am currently trying to figure out how to program the AD9959 IC using a serial connection to my PC.

From reading through the datasheet for this chip, I learned that it uses the serial SPI interface to send and receive instructions and data. This chip has four channels of DDS and allows you to program the frequency (32-bit), phase-shift (14-bit), and amplitude (10-bit). The chip has a lot of other, more advanced features (like modulation and frequency sweeps) that I don't care to make use of.

My circuit board will also have some other digital inputs to control separate chips on the board that control the pulse width of the output signal (the DDS outputs sine waves but I will be using logic chips to convert them to short adjustable duty cycle square waves).

I'm just wondering how to use the serial port to select which chips I send data and instructions to. I *think* that I want to use the MAX3110E IC which can convert the RS232 level signals into the SPI compatible ones. The problem is that everything coming out of that chip is now serial and I'm not sure how to control where the bits go.

I was trying to come up with some kind of scheme where I could input the serial data into a shift register to control the lines of a multiplexer or something to route further bits to either the AD9959 or the chip that would control the pulse width.

As for the pulse width chip, I'm still looking into different ways to do it but I know I will want some kind of digital input to control it. To keep the complexity of the circuit down, I have decided to control all four channels with a single data input. I'm thinking I'll use either four or eight-bit input to control the duty cycle. Is there any simple method for routing the bits without using a microcontroller?

Thanks,
Jason O
 
Engineering news on Phys.org
  • #2
The RS-232 standard defines a lot of signals that you're not actually going to use to send data to the SPI interface. The signals like CTS/RTS, for example, are going to be unused. These signals can be easily set with software on the PC, and thus can be used to select which device you want to talk to.

The SPI interface includes an enable signal; use one of those control lines to enable each chip on the bus. If you have a ton of chips, use a 3-to-8 decoder or something to expand the number of selection lines available.

- Warren
 
  • #3
Hi Warren,

Thanks for that. That (once again) simplifies things tremendously. Now all I have to do is figure out how to program the individual pins directly. Also, would you happen to know of any good websites with an in-depth discussion on working with the RS232/SPI interface?

Thanks,
Jason O
 
  • #4
Jdo300 said:
Hi Warren,

Thanks for that. That (once again) simplifies things tremendously. Now all I have to do is figure out how to program the individual pins directly. Also, would you happen to know of any good websites with an in-depth discussion on working with the RS232/SPI interface?

Thanks,
Jason O

RS-232 is called the SCI interface, and is different from the SPI serial communication standard. SCI has no clock, just the data. The sender and receiver must have accurate time bases, and use a baud rate that both the sender and receiver agree upon. SPI uses a separate clock line, and the data rate can vary. The master generates the clock, and transmits data on the MOSI (master out, slave in) line. The slave drives data back to the master on the MISO line.

I don't think you will be able to easily drive an SPI interface from your RS-232 port. You would need to bit bang both a clock and a data line, and the RS-232 serial SCI UART is not going to be able to receive data on its RX line from the MISO line, since the UART is assuming some baud rate.
 
  • #5
You can't drive an SPI from a rs232 port.
You can with either a realtime os or a very low baud rate bit-bang an spi interface from the parralel port ( bit-bang = change the state of a single wire at the right pattern to simulate a serial interface)


Some dev kits include an SPI-serial converter, otherwise they are quite expensive. The easiest way to do SPI-serial is with a PIC.
If you are in the UK give these people a call they are very helpful http://www.milinst.com/
 
Last edited by a moderator:
  • #6
I think mgb_phys is on the right track with the PIC suggestion. If you can find a cheap PIC with an SCI serial port (maybe somebody makes a small module like that?), the PIC may have an SPI serial port as well. Then you could program the PIC to receive your commands over the SCI serial port from the PC (you can just send them using hyperterminal), and write the appropriate config register data to the AD9959 via SPI.
 
  • #7
Hi Guys,

Thanks for the suggestions. I guess that I ultimitely could just use a PIC but I was trying to find a way to do this without needing to program one. As for the RS232 to SPI interface, I thought that this chip, MAX3110E, was supposed to handle the conversion?

- Jason O
 
  • #8
Jdo300 said:
Hi Guys,

Thanks for the suggestions. I guess that I ultimitely could just use a PIC but I was trying to find a way to do this without needing to program one. As for the RS232 to SPI interface, I thought that this chip, MAX3110E, was supposed to handle the conversion?

- Jason O

No, the MAX3110E is an SPI slave, it cannot function as an SPI master. Look at the block diagram at its info page:

http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2052

The part can be an SPI slave for a uC to use as a serial SCI UART. It is not intended to be used to convert SCI to an SPI master.
 
  • #9
Ohhhh ok I see now.

Well, I guess I'll have to use the uC then. I was able to find an interesting article online where this guy used a BASIC Stamp to interface with the Maxim chip:

http://www.wd5gnr.com/suart.htm

The code looks like goo gaa to me though. I do know Visual Basic very well but I have 0 experience with basic stamps (or any microcontroller for that matter). Would you happen to have any recommendations for a tutorial or something I could read to learn how to program one? What kind of basic stamp should I use?

Thanks,
Jason O
 
  • #10
You can use a Stamp and manually set one pin high/low to simulate the SPI port ( see bit-banging) the Stamps have a serial port included.

Basic Stamps are a cheap and easy way into uC programming if you don't know C or don't want to buy a development kit, milinst in the link above list some books.
But they are expensive if you want to use them in production and are very slow compared to even a PIC.
 
  • #11
I think bit banging would be perfectly sufficient for this application. I see no reason to include a microcontroller.

- Warren
 
  • #12
chroot said:
I think bit banging would be perfectly sufficient for this application. I see no reason to include a microcontroller.

- Warren

I can see maybe bit banging the SCLK and MOSI downlink signals, but how do you read the uplink MISO signal? I guess if you go slowly enough, it might work. I guess you would just use all SCI control lines for the bit banging, and avoid the TX and RX SCI signals altogether?
 
  • #13
This is a write-only application; he does not need to read back from his devices at all.

You all bring up some good points, though. It might even be easier to just use the parallel port to bit-bang SPI signals.

- Warren
 
  • #14
Could you guys elaborate more on this "bit-banging" idea? What is it and how does it work? If I wouldn't need a microcontroller to do it, how would I do the communications?

Thanks,
Jason O
 
  • #15
They're basically saying the clocking mechanism in RS-232 is not directly compatible with the clocking mechanism for SPI.

To communicate with an SPI device, you have to produce your own clock. They're talking about driving a control line high and low over and over to "simulate" a clock. That's "bit banging:" drive 1, drive 0, drive 1, drive 0...

In retrospect, I suppose using a parallel port would be significantly easier. I believe the voltages on the parallel port are already compatible with CMOS.

- Warren
 
  • #16
chroot said:
This is a write-only application; he does not need to read back from his devices at all.

Ah, good point about the write-only aspect. I guess there are no registers that he needs to read for anything after all.

I went back and skimmed through the datasheet -- not all SPI slaves have a fully static SPI interface. Some will time out the transaction if the clock stays static for too long (around 100us is a common number, IIRC). But I didn't see anything about a timeout on SCLK (I could have missed it), so even if the bit banging gets wobbled around by Windows scheduler jitter, it looks like bit banging could work.
 
  • #17
Ok, so if I use the the parallel port to do this, but I want to use a serial connector on the board (to save space) could I just use a parallel to serial converter jack to still wire the pins in and only use the pins from the parallel port that I need? Also, what chip should i use to interface the port with the port?

I am still considering using a BASIC Stamp to do this just for the learning experience. I was looking at Parallax's website at this basic Stamp II OEM board which has a serial port built into it already:

http://www.parallax.com/detail.asp?product_id=27290

I call the tech support people and they said that you could also communicate through the serial connection as well as program the chip. The only thing I don't know is how to do SPI to the AD9959 with it...

But I am interested in knowing how I would pull this off without one using the bit-banging method :smile:

Thanks,
Jason O
 
Last edited by a moderator:
  • #18
You will probably get the most useful learning experience with the Basic Stamp and serial port thing. Does the Basic Stamp also have an SPI port on some of it's other IO pins? If not, you can still bit-bang the SPI interface to the AD9959. Just look at the SPI waveforms shown in the AD9959 datasheet, and think about how you would do writes to a byte-wide output register to generate the SCLK and MOSI (and CS) signals to the slave AD9959. Does that make sense?


EDIT -- One reason I say this is that the current trend in operating systems like WinXP, etc., is to give you less programmatic access to hardware resources like the serial and parallel ports. It has gotten harder to bit-bang those IO ports over the years, and is very difficult now. The trend is to use USB or other standard interface out of the PC/laptop, and have some intelligence (usually uC based) out at the end of the cable that serves as the interface to whatever is external that you want to communicate with.


EDIT2 -- Not too many years ago at my work, we based an important internal R&D Lab test IO interface to a new chip on bit-banging the parallel port of PCs. Well, the timing varied based on the PC brand and model, and the interface was only reliable on a few select machines. Doh! So we learned our lesson and based the 2nd generation of those chip test devices on a National Instruments DIO card family, which had reliable timing (independent of Windows XP/whatever OS scheduling jitter, and with reliable IO timing specifications).
 
Last edited:
  • #19
He doesn't need reliable timing for an extremely slow DC serial bus! If it's normally-implemented SPI, it's STATIC LOGIC anyway -- the clock needn't have any specific period or timing relationship at all, and there's no minimum clock period.

Again, there's no need for any kind of uC.

- Warren
 
  • #20
@berkeman,

Hmmmm that's very interesting :smile:. You know, that's the one thing I was worried about with the bit-banging idea. the output data would then be subject to the speed of the computer and what it is doing at the time.

I'm not sure if the basic stamp has a dedicated SPI output but I heard from reading that you use the BASIC SHIFTIN/SHIFTOUT commands to do SPI communications. So it doesn't look too horrible once I figure out how to do it :smile:

@all,

So at this point, its looking very doable to use the basic stamp. Now the big problem I'm facing is how to setup the AD9959...

I've been staring at the datasheet for several days now and I'm still confused about what settings and pins to set to make it do what I want... There's just so many features and options in it, I'm not sure where to start. How would you approach this?

- Jason O
 

Related to Routing data from the Serial port to ICs

1. What is the Serial port and why is it important in routing data to ICs?

The Serial port is a physical interface on a computer that allows data to be transmitted and received one bit at a time. It is important in routing data to ICs because it serves as a communication channel between the computer and the IC, allowing for the transfer of data and instructions.

2. How do you route data from the Serial port to ICs?

To route data from the Serial port to ICs, you will need to use a Serial communication protocol, such as RS-232, RS-485, or USB. This protocol will define the rules for how data is transmitted and received between the Serial port and the IC. You will also need to use appropriate hardware, such as a Serial to USB adapter or a Serial interface chip, to convert the electrical signals between the Serial port and the IC.

3. What is the role of ICs in routing data from the Serial port?

ICs, or integrated circuits, are responsible for processing and storing data in electronic devices. In the context of routing data from the Serial port, ICs act as intermediary components between the Serial port and other electronic components, allowing for the transfer of data and instructions between the computer and the device.

4. Are there any limitations to routing data from the Serial port to ICs?

Yes, there are some limitations to consider when routing data from the Serial port to ICs. These can include the maximum data transfer rate of the Serial port, the compatibility of the Serial communication protocol with the IC, and the reliability of the hardware used to convert the signals between the Serial port and the IC. It is important to carefully select and test all components to ensure efficient and accurate data routing.

5. Can data be routed from the Serial port to multiple ICs simultaneously?

Yes, it is possible to route data from the Serial port to multiple ICs simultaneously. This can be achieved by using a Serial communication protocol that supports multi-drop communication, such as RS-485. In this case, the data is transmitted to all ICs on the same bus, but each IC is assigned a unique address to receive and process the specific data meant for it.

Similar threads

  • Electrical Engineering
Replies
7
Views
3K
  • Electrical Engineering
Replies
6
Views
1K
  • Computing and Technology
Replies
11
Views
1K
  • Electrical Engineering
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Electrical Engineering
Replies
5
Views
4K
  • Electrical Engineering
Replies
6
Views
6K
  • Electrical Engineering
Replies
4
Views
1K
  • Electrical Engineering
Replies
2
Views
4K
Back
Top