Arduino Example AGC Enable

598 views
Skip to first unread message

Ole Quedens

unread,
Dec 14, 2015, 5:13:50 PM12/14/15
to Flir Lepton
Hello,

I`m trying to enable AGC Mode in the Arduino example and I have some Questions:

In the interface_design_document it is said that "To set the AGC enable state to enabled, the command type is 0x1 and thus the Command ID is 0x100 + 0x00 + 0x1 + 0x0000 = 0x0101"

So I would say that if I want to enable AGC I have to do something like this:

        Wire.write(0x00); //Register Address first Byte
Wire.write(0x04); //Register Address second Byte
Wire.write(0x01); // Command Id first Byte
Wire.write(0x01); // Command Id second Byte

but in the example it is done like this:

        Wire.write(0x01);
Wire.write(0x05);
Wire.write(0x00);
Wire.write(0x01);

both are not working.. there are still results >255

What am I doing wrong or what do I have to do?

I thought I have to set the Scale factor (Page 33) but it says that the default is LEP_AGC_SCALE_TO_8_BITS

but if I would want to set it, do I think I have to do like this:


        Wire.write(0x00); //Register Address first Byte
Wire.write(0x04); //Register Address second Byte
Wire.write(0x01); // Command Id first Byte
Wire.write(0x45); // Command Id second Byte

but this freezes the programm on the arduino...

Thanks in Advance

don felipe

unread,
Dec 17, 2015, 1:35:37 PM12/17/15
to Flir Lepton
I'm pretty certain that demonstration code is incorrect. This has caused me many headaches, and a ton of wasted time. In fact, most of that arduino code is quite bad. Which Arduino are you using?
When entering a set command that is expecting a value, the camera looks in the DATA registers for said value. So you have to write a value there first.
The process is outlined on page 15 of the interface description document. Which I feel is confusing and probably incomplete.

The process is:
Read the status register, 0x2,
Write to the data register, starting at 0x8 but if the value is larger you are going to have to use successive registers, the values of what you want.(in agc enable case you are probably looking to put a 0 or a 1)
Write the # of bytes into the length register, 0x6(i think it is 2 in the case of this command)
and then write your command ID into the command register, 0x4(0x0101 for the agc enable)

The registers are outlined on page 9 which might give you a clearer picture. If you look at the lepton SDK, which is also poor, check out the I2C protocol, aardvark_i2c, and i2c reg code. If you can follow that code(which is written for a specific microprocessor but still translatable) it should help.

Hopefully this helps. I'd post some code but I haven't implemented it well yet and won't get back to it until next month. Let me know how it goes!

Kim Janson

unread,
Apr 11, 2016, 10:52:43 AM4/11/16
to Flir Lepton
Any progress on this, Over all, is there any simple documentation how to send commands to lepton. The Lepton IDD :D no I am not really laughing. it is sad how difficult it has been made, anyway it is no IDD, more a SDK...

Simple example would be much appreciated. I do not mind if there is long waits etc. not to poll the lepton if it is ready etc. but something working and understandable.

Kim Janson

unread,
Apr 12, 2016, 3:46:35 AM4/12/16
to Flir Lepton
This works

  Wire.beginTransmission(0x2A); //ADDRESS
  Wire.write(0x00);
  Wire.write(0x08);//DATA0
  Wire.write(0x00); //data byte 1
  Wire.write(0x01); //data byte 2
  Wire.endTransmission(); 
  
  Wire.beginTransmission(0x2A); 
  Wire.write(0x00);
  Wire.write(0x06);//DATALEN_REG
  Wire.write(0x00);
  Wire.write(0x02);//Data lenght bytes //IDD says words.
  Wire.endTransmission();  

  Wire.beginTransmission(0x2A); 
  Wire.write(0x00);
  Wire.write(0x04); //COMMANDID_REG
  Wire.write(0x01); //Command ID is 0x100 + 0x00 + 0x1 + 0x0000 = 0x0101.
  Wire.write(0x01); //Command ID is 0x100 + 0x00 + 0x1 + 0x0000 = 0x0101.
  Wire.endTransmission(); 
  wait_to_complete();

TBA

unread,
Apr 24, 2016, 4:29:54 PM4/24/16
to Flir Lepton
Kim's didn't work for me; I was still getting 14-bit data. Prefixing the following:

Wire.beginTransmission(0x2A); //ADDRESS
  Wire.write(0x00);
  Wire.write(0x0A);//DATA1
  Wire.write(0x00); //data byte 1
  Wire.write(0x00); //data byte 2
  Wire.endTransmission(); 
    ...

to the beginning of Kim's very helpful post above solved it, as the AGC write needs to be 2 16-bit words rather than 1, and a read of the AGC enabled register was returning "01 2F" rather than "01 00" as well.

Kim Janson

unread,
Apr 24, 2016, 4:35:10 PM4/24/16
to Flir Lepton
I do not remember now exactly, but I think you will always receive 16 bits, just the amount of 0's vary.

I am geting 8 bit readings and works fine.

It requires powering down the Lepton and restarting when changing the mode.

Kim Janson

unread,
Apr 24, 2016, 4:38:04 PM4/24/16
to Flir Lepton
Note, you need to wait to complete the command, I do not exactly remember how I did it but try 100 ms wait.
Reply all
Reply to author
Forward
0 new messages