Hello,
I would like to run the LTC6903 from the arduino but i'm a little stuck in the SPI section. How do i write the 16bits every time i want a frequency to change?
thanks in advance
Ronald
Hello,
I would like to run the LTC6903 from the arduino but i'm a little stuck in the SPI section. How do i write the 16bits every time i want a frequency to change?
thanks in advance
Ronald
Load in the SPI library.
Initialise it.
Put the enable low,
transfer most significant 8 bits
transfer least significant 8 bits
Put enable high.
Thanks for the reply,
I got the whole thing working. But now i want to add in the exact number for getting the exact frequency out off the LTC6903.
I have a calculator (found in the Liniear website) that gives me values for the DAC and OCT settings.
I want the CP0 and CP1 always to be both ON (value 0 0) according to the datasheet.
But this calculator gives me DEC values so for a 10kHz fequency i get:
DAC = 346
OCT = 3
Now how do i get this nicly in the MSB and LSB transfer.
Hope you understand what i'm asking.
best regards
Ronald
assuming that 'value' is an int then:-
most Significant byte = value >> 8;
least Significant byte = value & 0xff;
So if i understand this write "value" could be the DAC ? and maybe a second int Value1 for the OCT?
The strange thing is that i tried entering the SPI_TRANSFER with binary coding and that worked but when i want to add the value 346 in binary code this is 9bits long and not 10bits as the datasheet says.
thanks in advance.
Ronald
and maybe a second int Value1 for the OCT?
Yes if they are treated as two separate 16 bit values.
the value 346 in binary code this is 9bits long and not 10bits as the datasheet says.
It is 10 bits long if you include the leading zero. ![]()
So it can be as many bits long as you want if you include as many leading zeros as you want / need.
Thanks i understand that part now.
The problem is that i can't use 2 seperate 8bit codes.
the first 4 bits of the MSB are the OCT settings, the next 10 bits (scalled over MSB and LSB) are the DAC settings and then there are the last 2 bits for the clock output settings (witch always will be 00).
Is there a way to use DEC values for the OCT and DAC settings in this setup?
the first 4 bits of the MSB are the OCT settings, the next 10 bits are the DAC settings
OK so you have variables oct and value:-
most Significant byte = (value >> 8) | (oct << 4);
least Significant byte = value & 0xff;
This ORs together the oct and value after first shifting them into the right place.
That's great, thanks.
Now for a really noob question.
How do I set this up in the spi_transfer ???
This is my first time working with SPI so it's a little new for me.
How do I set this up in the spi_transfer
You have lost me here. I thought I said in my first post and then in your replay you said:-
I got the whole thing working.
I am not sure what you are asking?
sorry, my mistake,
I got the spi working with the binary number in there.
But not with you code above, that's why i asked how to implement this in my code.
i now do this:
spi_transfer(10101010);
sp1_transfer(11001010);
but i want the DEC numebrs in there
Just pass the values over:-
spi_transfer((value >> 8) | (oct << 4));
spi_transfer(value & 0xff);
by the way
spi_transfer(10101010);
spi_transfer(11001010);
Is not exactly what you did is it? As the C code would take this to mean the decimal number 10101010, to use binary you should write B10101010
Thanks MIke,
You really helped me on this.
I will try this next week.
and post my results.
Ronald
Firsties - I needed a couple of frequency ranges: 22000khz - 27000khz and 26000khz-33000khz with good resolution such as 0 -1000.
I had mistaking thought the Arduino could easily do this but no way just 0 - 5 different frequnecies per range using the counter/timers. So I did some Googling and found AD9835 - too expensive and some other device also but just as costly and then I found ltc6903 with no external parts with more resolution than my 0 -1024 input potentiometer could produce, yeah! Datasheet, Chipcatalog - der Katalog für Cannabidiol und seine Komponenten - Chipcatalog
Wanting to get up and running quickly, I searched the web for Arduino and ltc6903. I found some blogging of how neat the ltc6903 was but no pde coding. Since have had great success with the Arduino and the ltc6903 here the link to my code,http://www.eastco-inc.com