Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

NICard 6031E Acquisition too slow when synchronisation with ATMEGA128

Hello:

 

I have an NI Card 6031E acquiring in HARDWARE SAMPLE CLOCK timing mode which means I supply a clock from an ATMEGA128 and the card acquires a value after each CLOCK high from another ASIC (Multiplexer chip).

 

The clock comes from a microcontroller ATMEGA128.

 

PROBLEM: I send an ' r ' character to the ATMEGA128 and subsequently I call the SAMPLE CLOCK timing read function in my user interface Visual C++ 6.0 on the PC. I am trying to synchronise PC with ATMEGA and NICARD data read, BUT I CANT DO IT.

 

The thing is when the ' r ' char is received at the ATMEGA128 this one does what it has to do just ONCE and may be does it too fast for the NICARD to read the values supplied by the CLOCK from the ATMEGA128.

 

The ATMEGA128 supplies a few digital binary signals (0 or 1) to the ASIC and the ASIC having received that particular sequence or digital waveform it sends the data (128 values one after each CLOCK high) to the NICARD.

 

Therefore, each CLOCK high delivers a value to the NICARD from the ASIC. The problem is that it seems I loose the data on the NICARD because the sequence is done very fast at the ATMEGA128 and the NICARD takes 480us I think to perform an instruction. I tried placing the READ function before sending the r char but it blocks.

 

I need SYNCHRONISATION between the NICARD acquiring values and the ATMEGA128 sending the clock and the ASIC sending data. Can I use other CHARS. I am lost! HELP! -)

 

Thanks,

 

Javi

0 Kudos
Message 1 of 10
(6,918 Views)

Hi Javi,

 

What is the frequency of the clock sent by the Atmega128?

0 Kudos
Message 2 of 10
(6,912 Views)

 

The ATMEGA128 code structure and CLOCK signal is as such:

 

1 - FOR loop, therefore repeats itself always until you come out of the program execution.

 

INSIDE FOR LOOP:

 

2 - wait 1 microsecond, CLOCK HIGH, wait 1 micro second and CLOCK LOW

 

3 - wait 26.4 microseconds, another FOR loop and inside it, (128 times CLOCK HIGH, wait 1 micro second and CLOCK LOW, and wait 26.4 micro seconds).

 

4 - Once finished program goes back to 1

 

---------------------------------------------

 

So therefore the frequency of the CLOCK is of 37878.78 Hz or 37878.78 HIGH CLOCKS or samples per second which comes from 1/26.4microseconds.

 

However, the initial first CLOCK on the FOR loop starting in section 1 is HIGH after 1 microsecond as described in section 2.

 

The sampling frequency is set at 50000 samples per second on the NICARD, so therefore it is a sufficient setting for a 37878.78 Hz CLOCK.

 

I acquire the data via an NICARD and my code sends an "r" character from the VISUAL C++ user interface to the ATMEGA128 and when the ATMEGA128 receives the "r" char it SENDS the CLOCK (and relevant waveform) to an ASIC. Then when the NICARD receives the CLOCK it acquires 1 sample on every CLOCK HIGH.

 

I noticed a few days ago that when I start the CLOCK from the ATMEGA (same as sending an "r" char to the ATMEGA) on another Visual C++ application without the NICARD acquisition software functions and at the same time I start the Visual c++ application with the NICARD functions, I get almost the correct data.

 

It seems that separating both Visual C++ applications PARTIALLY works but it does not make much sense.

 

The difference between both is just having the NICARD functions present or not present, it seems, although it could be something else too.

 

As you can see the synchronisation between the NICARD (HARDWARE TIMING CLOCK) data acquisition and the ATMEGA128 or ASIC sending data is performed via the sending of the "r" char to the ATMEGA128.

 

Thanks.

 

Javi.

 

 

 

0 Kudos
Message 3 of 10
(6,901 Views)

Javi,

 

Thanks for this informations, could you send us your code in order to understand more precisely your application?

 

Thank for advance

JB

 

 

0 Kudos
Message 4 of 10
(6,886 Views)

 

Thanks for your reply.

 

I send you an earlier version of the ATMEGA128 C code when I tried in the past with no success to synchronise the ATMEGA128 and the NICARD by detecting the NICARD sync (any output pin) PIN high.

 

It did not work. But now I have all devices workign at 4Volts so may be I should try again.

 

As soon as I can I will send you the lastest ATMEGA128 C code which is working. This one is just to give you an idea.

 

I also send the USER INTERFACE .cpp file (Visual 6.0 C++) and the NICARD .cpp

 

The email system does not allow more than 3 attachments so I did not include the nicard .h file for now

 

Thanks and regards,

 

Javier.

 

Download All
0 Kudos
Message 5 of 10
(6,874 Views)

 

Hi!

 

I add the latest CODE which seems to work PARTIALLY and at least delivers correct data for various channels.

 

Thanks for your help.

 

Javier.

 

Download All
0 Kudos
Message 6 of 10
(6,866 Views)

 

I forgot to attach the latest ATMEGA128 code!

 

Thanks.

 

Javier.

0 Kudos
Message 7 of 10
(6,864 Views)

Hi Javi,

 

In order to make sure of your configuration I attached you a scheme. Please, could you confirm me if I have correctly understood your problem?

 

Thanks for advance

Regards

JB

0 Kudos
Message 8 of 10
(6,854 Views)

 

Hi JB,

 

That is correct. You understood it correctly.

 

The ASIC receives the CONTROL (HIs and LOWs) waveform and provides data which it has acquired from an ANALOG sensor connected to it. The ASIC is fast enough for data delivery and acquisition.

 

However, I am thinking now that when I send the CONTROL waveform from the ATMEGA128 to the ASIC I am also sending the clock to the NI at the same time. However, NICARD instructions take at least 480us each to execute (this is what I think).

 

Recently, as I say, I tried a different visual C++ application sending the r char to the ATMEGA128 without the nicard .cpp and .h files while the main C++ application was running with nicard.cpp and .h files and I seemed to get partially CORRECT data from the ASIC.

 

Thanks and regards,

 

Javi.

 

 

 

 

 

 

0 Kudos
Message 9 of 10
(6,850 Views)

 

Hello!

 

Did you manage to check out my code, etc and have a look at the issue in general?

 

Thanks and regards,

 

Javi.

 

0 Kudos
Message 10 of 10
(6,833 Views)