LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating clock signal of KHz on Arduino digital output pin

Solved!
Go to solution

Hello everybody,

I started to work in an application that uses labview to communicate with arduino. The arduino board will be connected to several AD5204 digital potentiometers. This potentiometers are connected in serie and I want to use "Daisy Chaining" to program them.

My first idea was using SPI communication blocks of Arduino to send the information but, the problem is that I want to use "Daisy Chaining" and every potentiomenter needs 11 bits (address+data) to be programmed. As I saw using SPI communication I can send only messages of 8 bits and not of 11 bits. That will provoke a wrong receival of the information by the potentiometers, because of the "Daisy Chaining".

That's why I tried another thing. I tried to generate the clock, the data and the chip select signals directly without using SPI blocks, using some loops and common blocks to write a digital pin in Arduino. In that way I am able to send the information I need, but, the problem now is that the clock signal is only 18Hz. Is there a way to generate a clock signal that goes out through a determined pin of the Arduino of at least 100KHz?

If somebody knows that I would be very happy to receive and answer. Then I will be able to finish my application.

Thanks!

0 Kudos
Message 1 of 11
(26,957 Views)

Attached is sketch from the Arduino Cookbook by Mchael Margolis.   The sketch CH18r5.imo is a pulse generator. I tested it and it worked at 1 megaHz.  I don't know what the maximum frequemcy is. 

To use it copy TimerOne.h,  TimerOne.cpp and keywords.txt to a folder named TimerOne.  Then moved the folder to the Arduino libraries folder.  Next move ch18r5.imo to a folder named  ch18r5 and movee the folder to your collection of Arduino sketches.  Next compile and dowmload the sketch to you Arduino board. 

The sketch is designed to be controlled by Arduiino's serial monitor.  Use the command valuef to set the frequency.  For example 100000f generates a 100kHz square wave and 1000000f generates a 1 megaHz square wave. 

hrh1818

Download All
0 Kudos
Message 2 of 11
(13,914 Views)

Thanks hrh1818 for your answer.

I was trying the software and it works great. The problem is that this is a program to generate a clock directly from Arduino and controlling the frequency with the serial monitor of it.

What I would like is to be able to generate a clock around 100KHz on an Arduino digital pin, and send some information of 11 bits "packets" through another pin of Arduino, controlling/generating all this from Labview.

With the program that you sent me I can not send or control any information from Labview.

I hope somebody has a solution for this.

Thanks!

0 Kudos
Message 3 of 11
(13,914 Views)

You should do the SPI signal generation in the Arduino.

Just send 16 bit values to the Arduino from LabVIEW and then locally convert it into SPI 11 bits.

You get the best of both worlds.

greetings from the Netherlands
0 Kudos
Message 4 of 11
(13,914 Views)
Solution
Accepted by dp18

Hello,

Thanks Albert.Geven, that is a good idea.

The last days I was thinking on this problem and I am almost sure that I found a "easier" solution. The idea is to adapt the 11 bit "packets" into 8 bit messages.

For example, if I have 16 chips, we need to send 16 "packets" of 11 bits, that's 704bits. If I divide this 704bits into messages of 8 bits I will have to send 22 messages. If the number of 8bits messages is not a integer, we will have to fill the last message with as much 0 as necessary.

I still have to test this on the real chips, but I hope this will work.

Thanks,

0 Kudos
Message 5 of 11
(13,914 Views)

Hi dp18

Im working on a problem very similar to yours. I want to use labview to change PID parameters by changing the resistors sizes. Im planning to use three ISL22414 with SPI and therefore also need daisy chaining. Can I get you to send me the code you used for it?

Best regards

Jens

0 Kudos
Message 6 of 11
(13,914 Views)

Hello kuhr,

If you write me your email I'll send you the code.

Best regards,

0 Kudos
Message 7 of 11
(13,914 Views)
0 Kudos
Message 8 of 11
(13,914 Views)

hi dp18,

please send me the procedure to generate frequency in khz with sample code using arduino mega 2560

my email id: regs1613@gmail.com

thank you.

0 Kudos
Message 9 of 11
(13,914 Views)

i require 10 khz square output at pwm pin

0 Kudos
Message 10 of 11
(12,280 Views)