Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

C Program Help

My hardware setup is as follows: I have a SCXI-1000 chassis with a 1520 card in slot 1 and a 1102 card in slot four. The chassis is plugged into an E-series daq board (PCI-6052E). I have written a program in C to scan a set of channels (10-17) on the 1102 board. On channel 16, I have a dc power supply hooked up that is generating 4.3 volts. If I go into the test panel in MAX, I can read this value no problem. If I run my program, I get floating values that are either 0.0 or + or - 4.99 V. For that matter, when I run any C code sample (SCXI_AIOnePoint, etc.) I get these floating values. I have attached a sample of my code. What am I doing wrong?
0 Kudos
Message 1 of 7
(3,847 Views)
It looks to me like you may just be reading from the wrong channel with your C program. You say that you are trying to read from channel 16 on a module that is in slot 4; however, I don't see this in the code you attached. It looks like you are reading from the SCXI-1520 in slot 1. Even when I look at your code under DAQ_PROGRAM == 3, which appears to discus the SCXI-1102 module, you still aren't referening slot 4 channel 16.

You will need to change the MainDlg.cpp file you attached, or a simple example such as SCXI_AIOnePoint, to reference the correct module and channel number. The example you attached points to slot 1 channel 0, which if nothing is connected, will show a floating voltage.

Regards,
Justin Britten

Applications Engineer
National
Instruments
0 Kudos
Message 2 of 7
(3,847 Views)
I must've mistakenly put those values in before I uploaded it. To simplify things, I have revised the continuous acquisition routine (the one I am most interested in) and attached it. If you want, I can pass you a C-compatible version. Since I added the track and hold function call, I am seeing what I think are good values on the 1520 channels (slot 1) and still getting junk on the 1102 channels (slot 4). Thanks for looking into this.

-drew
0 Kudos
Message 3 of 7
(3,847 Views)
Drew,

Can you try running one of the examples, such as SCXI_AIOnePoint, just with the 1102 module. I know you mentioned earlier that you can read values fine in MAX from the 1102 and that you tried example programs, but did you try the example just with the 1102 or with the 1520 as well?

If measurements are fine within MAX, then the problem must exist in software. Let's start with just the example program and the 1102 and see what the problem could be.

Regards,
Justin
0 Kudos
Message 4 of 7
(3,847 Views)
Problem solved, I got it to work I think. Thanks for the help though. There were several things i was doing wrong, including not calling SCXI_Get_Status and SCXI_MuxCtr_Setup. I can post the code for posterity.

There is one last thing that puzzles me however. It seems as though my 1520 voltage readings differ from the ones I see in MAX by an offset value of about 0.003. Any ideas as to what could cause this?

-drew
0 Kudos
Message 5 of 7
(3,847 Views)
Drew,

One method for noise reduction is to take many samples and average over time. The readings in MAX are averaged and you can do the same in software.

Also, it is an excellent idea to perform a null in the SCXI-1520 before taking an acquisition if this measurement is from strain guages, load cells, etc. This can prevent any offset. This null can be performed in software or in MAX via a strain virtual channel.

Regards,
Justin
0 Kudos
Message 6 of 7
(3,847 Views)
My feeling is that averaging won't overcome the ~0.003xx difference between the two values. I tried performing a null and I just get 0.0000 readings. I've got a decade resistor hooked up to a channel on the 1520 and there must be some way to take the same voltage reading in both MAX and my C program. What could be the cause of the consistent difference?

-drew
0 Kudos
Message 7 of 7
(3,847 Views)