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 ?
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 )
:-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
The I2C address... Ardunio uses 7bit address. And, we use an 8 bit adr
entonces ... existe algun remedio posible desde GCB o debo simular una comunicacion i2c para este dispositivo ?
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 )
:-)
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
Hexfileaddress(see lst file): 00004A
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.
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?
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
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
El mismo montaje en arduino funciona correctamente. El tema es que entiendo mejor los programas en basic que en c
Ya he conseguido que funcione.
Adjunto programa.
NOT SORTED...
See later post .
Last edit: 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
Last edit: Anobium 2022-03-15
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
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?
ok gracias Anobium lo probaré . Envio unas fotos de como he montado el circuito por si os sirve de sugerencia
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
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
There is nothing wrong with the libraries. Please send me a device and I will test.
And, post your latest program and the ASM generated, Please attached as a ZIP.
como puedo enviar a usted el circuito ?
Not needed. This is simply a protocol error in your program.
Post your latest program and the ASM generated, Please attached as a ZIP.
Here is the Amazon link to the part. https://www.amazon.co.uk/dp/B08NB3FHLW/?coliid=I19W6H1HSR96HZ&colid=1J8077VJC8K38&psc=1&ref_=lv_ov_lig_dp_it
Send one of these to me asap. Then, I can hook up my protocol analyser to resolve the issue.
Saludos de nuevo
Aqui le envio el archivo ASM,