LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI myDAQ to acquire digital signal

Hello:

 

I'm new Labview user and now I have got a NI myDAQ white box.  I have already use this box to generate and acquire analogue sigals successfully. What I want to know is that whether I can use this box to acquire digital signals from an accelerometer module as well. This accelerometer belongs to the “nano” family, with digital I2C/SPI serial interface standard output. There are eight pins on this device:

 

1: VCC 2. GND

 

3. CS: SPI enable, I2C/SPI mode selection (1: I2C mode; 0: SPI enabled)

 

4. SDA: I2C serial data (SDA)

 

5. SA0: I2C less significant bit of the device address

 

6. SCL: I2C serial clock

 

7. INT1: Inertial interrupt 1        8.  INT2: Inertial interrupt 2

 

I need to measure the acceleration but I cannot find the example for acquire digital signals like this. Could you please tell me whether I can use this white box to achieve the goal? Cheers

 

Best Regards

 

Jeff

 

 

0 Kudos
Message 1 of 10
(5,564 Views)

Hi Jeff,

 

I don't think this would work too well with I2C, even if the MyDAQ was the master providing the clock it would ideally need to be at a set rate which software timing cannot provide (1-2ms of jitter). Does your I2C device have a minimum speed for the clock?

 

If you take a look here for more information on I2C: http://en.wikipedia.org/wiki/I²C

It may be worth taking a look on the web to see if you can find a device that provides you this feedback as an analogue signal that fits the voltage range and resolution of the MyDAQ.

 

Kind Regards, 

Applications Engineer
0 Kudos
Message 2 of 10
(5,542 Views)

Thanks so much for your kind reply. Could I use SPI mode instead? I have checked the datasheet it shows that there is no minimum frequency for I2C clock. I would like to know whether NI myDAQ can achieve the goal and I also have another white box USB-6008. If they can do the job, I will not buy the USB-I2C convertor because I hope my work can be done on Labview. I'm looking forward your suggestions.

 

Kind Regards

 

Jeff

0 Kudos
Message 3 of 10
(5,538 Views)

Dear Sir:

 

The datasheet of that device is in accessary. Would you mind helping me? I made a mistake to choose an accelerometer for my project so I hope I can use it to acquire the acceleration. I cannot find anyone to help me so I'm really worried about the project.

 

Best Regards

 

Download All
0 Kudos
Message 4 of 10
(5,531 Views)

Hi Jeff,

 

Looking at the datasheet SPI is out as it has a minimum clock frequency, theoretically as the I2C doesn't have a minimum then it should work, however I've found that I2C to be tricky expecting a stable clock source that you just can't achieve from software timing under a non real-time system, you may need a pull up resistor as well if the electrical characteristics don't match the requirements for I2C.

 

We have a reference set of VI's here that may help, but I must stress this hasn't been tested from MyDAQ (that I know of) and you might find using something along the lines of an 8451 with the internal pull up resistors for I2C communication.

 

Thanks,

 

Rob 

Applications Engineer
0 Kudos
Message 5 of 10
(5,517 Views)

Dear Sir:

 

Thanks very much for your professional answer. Do you mean that I cannot use NI myDAQ to achieve the goal (even use I2C mode)? What I can do is only asking for a USB-I2C converter, isn't it?

What I tried before is generating a count signal for SCI and acquiring digial signals from SP0..

 

 

Kind Regards

 

Jeff

0 Kudos
Message 6 of 10
(5,512 Views)

Hi Jeff,

 

You will probably not need this any longer but FYI and others who google this topic.

If you didn't manage to understand the I2C lib previously mentioned you could always build your own daqmx I2C or SPI messages. I did 😄

 

All those serial communication protocols are just PISO registers, it doesn't really matter what clock you attach. Lukily because using a myDAQ I only get speeds of 2.5ms a single R/W action. You will only have a few Hz update rate!!!

 

Attached you can find some inspiration. It will probably contain some imperfections but nevertheless it might be useful.

 

Regards,

 

Gorik

Download All
Message 7 of 10
(5,214 Views)

Just wanted to add that the second set of programs uses:

* GYRO: MLX90609

* ACC: LIS302

 

I quickly verified the programs this morning and added some additional info.

 

Cheers,

 

Gorik

 

Message 8 of 10
(5,201 Views)

Hi Gorik,

 

I am confused with the your i2c code. You mention it does not matter what clock one attaches however a serial clock is still required in order to read/write/go to the registers. I don't see the clock set in the vi. According to the code you are setting the SDA lines with the appropriate address, however what clock is associated with this? In the code, SDA outputs to mydaq1/port0/line1 and SCL outputs to mydaq/port0/line0. If I connect an i2c chip on these lines I get no acknowledge when I run WHO I2C.vi. If I switch line 1 and line 2, i.e. on the mydaq line0 is connected to SDA and line1 is connected to SCL, I get an acknowledge. 

 

Any help would be much appreciated. 

 

Thank you for posting the mydaq i2c labview code. I did find it when I googled it.

 

Rampal

0 Kudos
Message 9 of 10
(5,079 Views)

Hi Gorik, I am working to get raw data from MPU6000, gyro/accel using MyDAQ but i am new to labview and not strong in programming also. I was searching for solution about I2C and spi and came to your to your code. Can you please guide me a little. I will be really obliged. Thank you.

 

0 Kudos
Message 10 of 10
(2,518 Views)