02-19-2009 01:37 PM
This is going to be a long question so please bear with me!
I am trying to program a few digital step attenuators manufactured by Minicircuits using the serial ports on the NI USB-232/4 device and so far haven't been successful in making them work. I shall explain you the steps that are required to program the attenuators followed by how I am trying to realize it through LabVIEW. I would appreciate if anyone could please correct me wherever possible to help me interface this device. I'd basically like to understand how to program the serial port to suit my needs.
Programming the digital step attenuator
The detailed programming steps are described in pages 8 and 9 of the attenuator spec sheet attached in the zipped folder. Following is the summary of it.
1. The attenuator has a serial interface which takes in 6-bit serial data and controls the 6 attenuation switches in a parallel fashion with the help of a latch.
2. The 6-bit data is fed into the shift register while the Latch Enable (LE) input is kept low. After the data is fed in the LE is made high followed by changing back to low to ensure the appropriate attenuation value is fed.
3. The attenuator can change from 0 to 31.5 dB by feeding appropriate bits. The format is as follows:
Value in dB 16 8 4 2 1 0.5
bit5 bit4 bit3 bit2 bit1 bit0
MSB LSB
4. There are 3 main signals which feed into the attenuator using different pins on the serial interface - Data, Clock and LE. These three are respectively connected to the RXD, TXD and RTS pins of the serial port 232 connector based on the mappings obtained from page 10 of the specs document and the pin mapping between 25 pin connector and 9 pin connector available at http://www.lammertbies.nl/comm/cable/RS-232.html.
LabVIEW programming script
We made two versions of the serial write VI to check the functionality of the attenuators. Both are attached in the zipped folder.
1. SerialPortWriteTestv1.vi configures the serial port on the USB-232/4 as DTE and writes the 6 bits to it without asserting/unasserting the RTS pin which realizes the LE input.
2. SerialPortWritev2.vi is same as the first version with added provision to assert/unassert the RTS pin as necessary.
3. The serial port is configured as DTE with following parameters:
baud rate = 9600
data bits = 6 (since we need to send 6 bits to the attenuator)
parity = none
stop bits = 1 (not sure if this is messing up our data as it is part of the frame)
flow control = none (as we are doing it manually)
4. Data is written in hexadecimal format representing the attenuation. E.g. To attenuate to 31.5dB we write 0x3F (111111 as six bits) and for 17dB we write 0x22 (100010) and so on.
5. We have tried changing the write modes to both Synchronous and Asynchronous in each of the two versions but never able to talk to the attenuator effectively. In all of our tests the attenuator goes down to some arbitrary value on writing a specific hex data and then on writing the same data it comes back up a bit and on doing it the third time it comes back to original 0dB level. After that the attenuator freezes in that state and any change can be made only after doing a hard reset on the attenuator.
02-19-2009 02:06 PM
02-20-2009 12:21 AM
The attenuators work with the cable that come with it and the parallel port (LPT) on the computer and the software application provided by minicircuits. But they don't give any information on how that program works. I want to integrate many such attenuators for my setup in LabVIEW and hence decided to go for a multiport serial connector box. I am not aware of a device which gives me access to multiple parallel ports. Please correct my undersanding if I am wrong. Is the clock signal only transmitted through the pins on parallel port? Can I not do it using a RS-232 port?
Thanks for your input.
02-20-2009 09:25 AM
The clock signal is generated by their software and output from the parallel port. The RS-232 port has no clock signal and to provide it, you would have to manipulate a control line (assert/deassert it) and wire that to the device's clock input. You would also have to provide some level shifters to make the RS-232 signals TTL compatible.
I might be possible to use the parallel port for multiple devices. You could possibly use a single clock for all devices and then dedicate a data line and enable for each device. The software would probably be a bit complicated since I don't think you can independently address certain lines of the parallel port. A better option, imo, would be a digital I/O card from NI. Depending on the card and the number of I/O, you could have a dedicated or common clock signal and dedicate a data input and enable for each attenuator.
02-20-2009 11:01 AM
You can use the parallel port on your machine in LabVIEW to communicate with your device. It looks like you have 8 pins you can use for DIO on your PC's parallel port. Take a look at these two articles :
KnowledgeBase 42BIT2C5 : Using the Parallel Port in LabVIEW
Developer Zone Tutorial: IEEE 1284 - Updating the PC Parallel Port
01-04-2010 03:30 PM
To: LViewCoder
Did you develop a VI to use the Parallel port with multiple attenuators? I want to do the exact same thing.
Gretchen
01-04-2010 11:07 PM
03-08-2011 12:18 PM - edited 03-08-2011 12:22 PM
According to the spec for the part you are trying to use the logic input is from 0-5vdc on the data control lines. RS-232 is an interface that runs from +/-6vdc to +/- 25 vdc. From a pc this is typically +/- 12 vdc. you wil need an rs-232 to ttl convertor chip between the pc snd the RF attenuator. Their are 5vdc chips availlable with an internal boost convertor to derive the +/- 12 vdc needed in the chip. This is why not all data gets through and the device locks up only the signals from 0-5vdc are being seen. Another thing -12vdc is a 1 (+5vdc) and +12 vdc is 0 (0vdc) when the data is converted. So you send 0 which goes to +12 vdc, the rf atten see a 1, when you send 1 the signal goes below 0 and is not seen.