Qt encoder with custom code

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
oldcoder
 
Posts: 7
Joined: Sat Dec 04, 2021 5:07 pm

Qt encoder with custom code

Post by oldcoder »

Hi,
I have a QT encoder board. I looked at your libs and wrote my own in 'c' for this particular project. Running on a samd20 board. NOT a novice here...

1 board + encoder, so I am ASSuming it is index '0' in I2C calls? Default address is 0x36.
I2C analyser shows it responds to a get delta or get position inquiry, but it always returns 0xff for 4 bytes..

Also trying to set the interrupt on for either keypress or position change and it does not set.. no leds flash...no ints generated

Init code is just set position to 0 and set interrupts on.

So what am I missing here? Is there something else that has to be done to initialize this?
A list of all the I2C commands it responds to would be nice in the user manual..just saying....

Thanks
Ken

User avatar
derKederer
 
Posts: 6
Joined: Sat Dec 11, 2021 5:53 am

Re: Qt encoder with custom code

Post by derKederer »

same problem - but in bascom
there is any magic in the seesaw-code...
use decimal 108 or hex 6C

User avatar
oldcoder
 
Posts: 7
Joined: Sat Dec 04, 2021 5:07 pm

Re: Qt encoder with custom code

Post by oldcoder »

I got some of it to work. The magic is that the default I2C address, 0x36 is not enough. You have to send the def I2C address+ the module address,(which for an encoder is i believe 0x10) then the register you want to access. i was able to read encoder position with this, but still cannot get the interrupt to go on. i can only assume there is another module address for this? Look in seesaw.h file for clues.

anybody?

Ken

User avatar
derKederer
 
Posts: 6
Joined: Sat Dec 11, 2021 5:53 am

Re: Qt encoder with custom code

Post by derKederer »

i only use one encoder - the adress is default - so no jumpers are connectet
the code to get the encoder position in bascom it looks like this - and it works:
rdata is an array of byte

I2cStart
I2cWbyte &6c
I2cWbyte &h11
I2cWbyte &h30
I2CRepStart
I2cWbyte &6d
I2cRbyte rdata(1) , Ack
I2cRbyte rdata(2) , Ack
I2cRbyte rdata(3) , Ack
I2cRbyte rdata(4) , Nack
I2cStop

please let me see your code!
for the interrups... i think you have to turn them on...

peter

User avatar
derKederer
 
Posts: 6
Joined: Sat Dec 11, 2021 5:53 am

Re: Qt encoder with custom code

Post by derKederer »

guess to told - if you do a scan for i2c-devices - what adress do you get for the encoder?

User avatar
oldcoder
 
Posts: 7
Joined: Sat Dec 04, 2021 5:07 pm

Re: Qt encoder with custom code

Post by oldcoder »

I'm using Atmel studio with a D20 xplained board for my tests, so doing this in 'C'

for encoder read my I2C code sends the same byte sequence as yours. 0x36,0x11,0x30, then read with 0x36,,,4 bytes returned

To turn the interrupts on I'm sending: 0x36,0x11,0x10. I get nothing for this... So I can only guess that the "0x11' byte is wrong?
FYI for the Atmel driver this would be the following:
enum status_code Rstat;
Rstat=i2c_master_write_packet_job(&i2c_master_instance, &wr_packet);

I have an I2C analyser and it looks fine, so it's just the board not responding.

I also tried using the neopixel and I get nothing with this too...

Ken

User avatar
derKederer
 
Posts: 6
Joined: Sat Dec 11, 2021 5:53 am

Re: Qt encoder with custom code

Post by derKederer »

hi ken

you´re sending 0x36,0x11,0x30, then read with 0x36 4 bytes
what happend when you send 0x6c,0x11,0x30, then read with 0x6c 4 bytes

please try

peter

User avatar
oldcoder
 
Posts: 7
Joined: Sat Dec 04, 2021 5:07 pm

Re: Qt encoder with custom code

Post by oldcoder »

0x36 is the 8 BIT I2C address. I2C is only 7 bit addressing so this driver does a left shift by 1,i.e 0x36<<=1 which is 0x6c out the door to the port. the LSB bit is read or write bit.

I haven't used bascom in a long time, check the i2c driver and see what it does with the address. Some drivers want you to pre-shift the address others do not.
Ken

User avatar
derKederer
 
Posts: 6
Joined: Sat Dec 11, 2021 5:53 am

Re: Qt encoder with custom code

Post by derKederer »

Hi Ken - ah okay - now i kow why i need 0x6c get the datas - my code is working very fine
is theire a repeatet start condition betwenn the wirte and read commands in your code? - some devices need it - take a look to my code above: in bascom it is the RepStart statemanet - please try this

User avatar
oldcoder
 
Posts: 7
Joined: Sat Dec 04, 2021 5:07 pm

Re: Qt encoder with custom code

Post by oldcoder »

there are repeated starts when needed. This still does not explain why I can't get the interrupt to turn on or change the neopixel. Both of these are straight writes of data.
Ken

User avatar
oldcoder
 
Posts: 7
Joined: Sat Dec 04, 2021 5:07 pm

Re: Qt encoder with custom code

Post by oldcoder »

Ok, out of ideas..

Need to get the interrupt pin to work and set the neopixel. Looked at all examples on net, no luck
So..ADAFRUIT?? what is the magic here

Ken

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”