Menu

Resolved: as5600 I2c Magnetic encoder problems

Manuel
2022-03-09
2022-03-26
1 2 > >> (Page 1 of 2)
  • Manuel

    Manuel - 2022-03-09

    Resolved - see https://sourceforge.net/p/gcbasic/discussion/579125/thread/2615c66e2e/?limit=250#0389


    Estoy intentando comunicar con este dispositivo con un Arduino Uno, desde el programa en arduino no hay
    problemas y lee el dispositivo correctamente, pero cuando intento hacerlo desde GCB no funciona. El programa demo que GCB incluye para busqueda de dispositivos I2C encuentra dos dirrecciones que no tienen nada que ver este dispositivo segun el fabricante tiene la direccion 0x36 mientras que el programa de escaneo que incluye GCB muestra dos direcciones 0x6C y 0x6D. Y repito, el mismo montaje desde el programa de arduino que usa la dirreccion del fabricante funciona correctamente. Saben ustedes porqué puede ser ?

     

    Last edit: Anobium 2022-03-24
  • Anobium

    Anobium - 2022-03-09

    The I2C address... Ardunio uses 7bit address. And, we use an 8 bit adr

     
  • Manuel

    Manuel - 2022-03-09

    entonces ... existe algun remedio posible desde GCB o debo simular una comunicacion i2c para este dispositivo ?

     
  • Anobium

    Anobium - 2022-03-09

    then... is there any possible remedy from GCB or should I simulate an i2c communication for this device ?

    Yes. Use the two 8 bit addresses.

    0x36 is 7 bit address. When you change to a n 8 bit address it is 0x6C. I have no idea why Arduino use 7 bit addressing and Microchip uses 8 bit - hence, the confusion.

    To change a 7 bit address to an 8 bit? Shift the 7 bit value to the Left (or multiple by 2 )

    :-)

     
  • Manuel

    Manuel - 2022-03-13

    Al compilar el programa adjunto me genera el siguiente error, alguien sabrií decirme porque ?

    Error: GCASM: Symbol [SFR]HI2CACKPOLLSTATE has not been defined. Inspect ASM
    file to determine error at LDS SYSTEMP1,HI2CACKPOLLSTATE Hexfile
    address(see lst file): 00004A

     
  • Anobium

    Anobium - 2022-03-13

    Hardware I2C2 is not supported. But, does the Mega328p have a second I2C?

    You have a mix of I2C and I2C2. Replace all I2C2 with I2C and all should be good.

     
  • Manuel

    Manuel - 2022-03-14
                he compilado este programa y funciona correctamente pero solo tras el reset y solo una vez . No entiendo porqué
    
     
  • Anobium

    Anobium - 2022-03-14

    Not a lot of information to go on.

    You said 'it compiles'. and that you get some results on the terminal display. So, I am now guessing, it was a non zero value for the variable valorW, Was valorW a non zero value? Did you get a real read?

    Things we know.
    - We know I2C works. There are 1000s of solutions working.
    - We know I2C discovery worked.. or, did it ? Load the I2C discovery program, loop through the discover process every 3 seconds... does the I2C discovery work more that once ? If this fails then we have a better idea to isolating the issue.

    Things I am guessing.
    -With the power turned off the ohms between the SCL to 5v is greater then 4k.SDA to 5v is greater then 4k. What is the actually ohm reading?
    -Operating voltage 5v ? is it?

     
    • Anobium

      Anobium - 2022-03-14

      And, very important, where did you buy this IC? AliExpress... as AliExpress can supply IC/chips that seems to respond but they are NOT real chips.

       

      Last edit: Anobium 2022-03-14
  • Manuel

    Manuel - 2022-03-14

    Cuando giro el mecanismo que aloja el chip puedo ir leyendo una vez el valor entre 0 y 4096 para 360 grados, la variable valueW almacena correctamente la posición del sensor el problema es que a pesar de estar metida dentro de un bucle do forever...loop solo se ejecuta una vez y debo reseat el micro para que repita la lectura de nuevo. por mas que reviso el programa no encuentro una razón para ello. Las rresistencias para bus I2c son de 10k pero la distancia del cableado es de unos 20 cm

     
  • Manuel

    Manuel - 2022-03-14

    El mismo montaje en arduino funciona correctamente. El tema es que entiendo mejor los programas en basic que en c

     
  • Manuel

    Manuel - 2022-03-14

    Ya he conseguido que funcione.
    Adjunto programa.

     
    • Anobium

      Anobium - 2022-03-14

      NOT SORTED...

      See later post .

      Well done! All sorted.

       

      Last edit: Anobium 2022-03-14
    • Anobium

      Anobium - 2022-03-14

      Sorry, I have looked at your solution.

      It is working - yes.
      Is this a valid solution - no.

      You are calling I2CAckpoll which polls the I2C address, and when the I2C interface gets ANY result it, it send a I2CStop and exits... your solution is just not valid.

      I2CAckPollState is NOT the answer. It is just luck.


      However, this does show me the error in your code.
      Try this... Note the correctly placed hI2CReStart

          hI2CStart
          hI2CSend(0x6c) 
          hI2CSend(0x0C)        'registro de angulo filtrado
          HI2CReStart
          hI2CSend(0x6c +1)
          hI2CReceive(valorH)   'lee el byte mas significativo
          hI2CReceive(valorL)   'a continuacion el byte bajo
          hI2CStop
      
       

      Last edit: Anobium 2022-03-15
  • mmotte

    mmotte - 2022-03-14

    Manuel,
    Happy you got it going! I was looking for the problem.

    Thanks for the program. i have as5600 chips coming on Thursday. Going to make dish antenna position sensors with them.

    73
    Mike

     
  • Anobium

    Anobium - 2022-03-14

    Pretty odd that the ACK state is not working ... it would be good to get a full analysis on a protocol analyser to see what is really happening.

    Can anyone send me one of these device to analyse?

     
  • Manuel

    Manuel - 2022-03-15

    Buenos dias a todos.
    1/ Tras apagar el arduino y volver a reiniciar la comunicacion el circuito deja de responder.
    Manda valores dispares. Tiene Usted razón Mr. Evan pero he probado su ejemplo y tampoco funciona.
    2/ Me voy de nuevo a Arduino y programo el ejemplo....y va perfecto.
    Con el mismo montaje improvisado. Funciona ok.
    3/ Sinceramente creo que hay algún problema entre la libreria I2C y este circuito
    (no lo he probado con otros circuitos I2C)
    4/ No se podrían usar las librerias de Arduino en GCB ?. Sería un avance extraordinario.

     

    Last edit: Manuel 2022-03-15
  • Manuel

    Manuel - 2022-03-15

    Las resistencias incorporadas en el propio circuito i2c son de 10 k y la tensión medida de alimentación es de 4,85v. Existen dos condensadores de desacoplo en el propio circuito.

     

    Last edit: Manuel 2022-03-15
  • Anobium

    Anobium - 2022-03-15

    There is nothing wrong with the libraries. Please send me a device and I will test.

     
  • Anobium

    Anobium - 2022-03-15

    And, post your latest program and the ASM generated, Please attached as a ZIP.

     
  • Manuel

    Manuel - 2022-03-15

    como puedo enviar a usted el circuito ?

     
  • Anobium

    Anobium - 2022-03-15

    Not needed. This is simply a protocol error in your program.

    Post your latest program and the ASM generated, Please attached as a ZIP.

     
  • Manuel

    Manuel - 2022-03-15

    Saludos de nuevo
    Aqui le envio el archivo ASM,

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.