-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Burn functions not working? #38
Comments
Thanks for opening this issue. Can you share the typo, so I can fix? |
The register write values were "x0x40". They had an extra hex prefix.
Thanks for your help
…On Tue, May 30, 2023, 21:14 Rob Tillaart ***@***.***> wrote:
Thanks for opening this issue.
I have never burned the angles so no experience.
Unfortunately this means I don't know the answer
Can you share the typo, so I can fix?
—
Reply to this email directly, view it on GitHub
<#38 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABNZ6DYL5JLDMQS3PPG46ZTXI3ARLANCNFSM6AAAAAAYU3MBBU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
OK, I had a quick look in the datasheet and saw there are two methods to burn the angle.
Which method did you use? Datasheet (page 21) Burn_Angle Command (ZPOS, MPOS) Did you check if the magnet was see? Datasheet (page 22) Step 7. Verify the BURN_ANGLE command: The library has not support for this step directly as writeReg() is private, Although verify does not sound like a mandatory step, it might be |
I saw that as well. Maybe I'll try to add that to the burn function, as
well as a verification.
…On Wed, May 31, 2023, 00:53 Rob Tillaart ***@***.***> wrote:
The register write values were "x0x40". They had an extra hex prefix.
OK,
I added that one (in fact two) as an extra safety so people must change it
after uncommenting.
This reduces the chance of people using it by "accident".
(so it will stay).
------------------------------
I had a quick look in the datasheet and saw there are two methods to burn
the angle.
- I2C
- OUT pin
Which method did you use?
------------------------------
Datasheet (page 21)
*Burn_Angle Command (ZPOS, MPOS) The host microcontroller can perform a
permanent programming of ZPOS and MPOS with a BURN_ANGLE command. To
perform a BURN_ANGLE command, write the value 0x80 into register 0xFF. The
BURN_ANGLE command can be executed up to 3 times. ZMCO shows how many times
ZPOS and MPOS have been permanently written. This command may only be
executed if the presence of the magnet is detected (MD = 1).*
Did you check if the magnet was see?
------------------------------
Datasheet (page 22)
*Step 7. Verify the BURN_ANGLE command: Write the commands 0x01, 0x11 and
0x10 sequentially into the register 0xFF to load the actual OTP content.*
The library has not support for this step directly as *writeReg()* is
private,
By making this function public you should be able to do this step.
Although verify does not sound like a mandatory step, it might be
—
Reply to this email directly, view it on GitHub
<#38 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABNZ6D3YBK5N6B4UZEPU6YDXI32JHANCNFSM6AAAAAAYU3MBBU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
If it works I will be happy to include your final code. Commented as it is "dangerous" and not to be used without warning. |
Well, I finally figured it out. It turns out that it is important to write the MANG register when you burn the config since they are burned together in the burn conf command. Then, you can burn the ZPOS. In my case I was trying to burn the CONF with MANG set to zero, and then set both ZPOS, MPOS and then burn angles. That does not appear to work. The correct order is: set configs I hope this helps someone. |
Some questions pop up
|
Good questions. My sketch is a monster right now. I have not minimized it yet. I need to move on to the next step in my project... You can still re-write temporarily, and then burn new ZPOS (3 times) after the config burn. The important step I had not initially realized is that if you want to burn the config, it appears you must write a MANG, and it will be permanently written. |
Thanks for these additions, very valuable. |
I'd be happy to review and test it. |
@cedricjeanty
Some lines need to be uncommented for safety. See comments in sketches. There is at least one improvement to make.
I created a branch https://github.com/RobTillaart/AS5600/tree/burntest Please let me know your comments. //
// FILE: AS5600_burn_conf_mang.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo
// DATE: 2023-06-18
// WARNING
// As burning the settings can only be done once this sketch has to be used with care.
//
// You need to
// - uncomment burnSettings() in AS5600.h and AS5600.cpp.
// - adjust settings and MaxAngle in burn_mang() function below ==> line 77++
// - uncomment line 107
#include "AS5600.h"
#include "Wire.h"
AS5600 as5600; // use default Wire
// AS5600L as5600;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("AS5600_LIB_VERSION: ");
Serial.println(AS5600_LIB_VERSION);
// ESP32
// as5600.begin(14, 15);
// AVR
as5600.begin(4); // set direction pin.
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
if (as5600.isConnected())
{
Serial.println("Connected");
}
else
{
Serial.println("Failed to connect. Check wires and reboot.");
while (1);
}
Serial.println("\nWARNING WARNING WARNING WARNING WARNING WARNING\n");
Serial.println("This sketch will burn settings to your AS5600.");
Serial.println("Adjust the settings in the sketch to your needs.");
Serial.println("Press any key to continue.");
Serial.println("\nWARNING WARNING WARNING WARNING WARNING WARNING\n\n");
while (Serial.available()) Serial.read();
while (!Serial.available());
Serial.read();
while (Serial.available()) Serial.read();
Serial.print("Are you sure to burn settings + maxangle? [Y for Yes]");
while (!Serial.available());
char c = Serial.read();
if (c == 'Y')
{
burn_mang();
}
Serial.println("\nDone..");
}
void loop()
{
}
void burn_mang()
{
bool OK = true;
OK = OK && as5600.setPowerMode(0);
OK = OK && as5600.setHysteresis(0);
OK = OK && as5600.setOutputMode(0);
OK = OK && as5600.setPWMFrequency(0);
OK = OK && as5600.setSlowFilter(0);
OK = OK && as5600.setFastFilter(0);
OK = OK && as5600.setWatchDog(0);
OK = OK && as5600.setMaxAngle(0);
if (OK == false)
{
Serial.println("\nERROR: in settings, burn_mang() cancelled.");
return;
}
Serial.println();
Serial.println("burning in 5 seconds");
delay(1000);
Serial.println("burning in 4 seconds");
delay(1000);
Serial.println("burning in 3 seconds");
delay(1000);
Serial.println("burning in 2 seconds");
delay(1000);
Serial.println("burning in 1 seconds");
delay(1000);
Serial.print("burning ...");
// uncomment next line
// as5600.burnSettings();
Serial.println(" done.");
Serial.println("Reboot AS5600 to use the new settings.");
}
// -- END OF FILE --
and //
// FILE: AS5600_burn_conf_mang.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo
// DATE: 2023-06-18
// WARNING
// As burning the settings can only be done once this sketch has to be used with care.
//
// You need to
// - uncomment burnSettings() in AS5600.h and AS5600.cpp.
// - adjust settings and MaxAngle in burn_zpos() function below ==> line 77++
// - uncomment line 100
#include "AS5600.h"
#include "Wire.h"
AS5600 as5600; // use default Wire
// AS5600L as5600;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("AS5600_LIB_VERSION: ");
Serial.println(AS5600_LIB_VERSION);
// ESP32
// as5600.begin(14, 15);
// AVR
as5600.begin(4); // set direction pin.
as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit.
if (as5600.isConnected())
{
Serial.println("Connected");
}
else
{
Serial.println("Failed to connect. Check wires and reboot.");
//while (1);
}
Serial.println("\nWARNING WARNING WARNING WARNING WARNING WARNING\n");
Serial.println("This sketch will burn settings to your AS5600.");
Serial.println("Adjust the settings in the sketch to your needs.");
Serial.println("Press any key to continue.");
Serial.println("\nWARNING WARNING WARNING WARNING WARNING WARNING\n\n");
while (Serial.available()) Serial.read();
while (!Serial.available());
Serial.read();
while (Serial.available()) Serial.read();
Serial.print("Are you sure to burn zpos? [Y for Yes]");
while (!Serial.available());
char c = Serial.read();
if (c == 'Y')
{
burn_zpos();
}
Serial.println("\nDone..");
}
void loop()
{
}
void burn_zpos()
{
// ADJUST ZPOS
if (as5600.setZPosition(0) == false)
{
Serial.println("\nERROR: in settings, burn_zpos() cancelled.");
return;
}
Serial.println();
Serial.println("burning in 5 seconds");
delay(1000);
Serial.println("burning in 4 seconds");
delay(1000);
Serial.println("burning in 3 seconds");
delay(1000);
Serial.println("burning in 2 seconds");
delay(1000);
Serial.println("burning in 1 seconds");
delay(1000);
Serial.print("burning ...");
delay(1000);
// uncomment next line
// as5600.burnAngle();
Serial.println(" done.");
Serial.println("Reboot AS5600 to use the new settings.");
}
// -- END OF FILE -- |
@cedricjeanty |
@cedricjeanty done. |
- add **void burnSetting()** improvements from #38 - use with care - add sketches to burn settings (use with care!) - minor edits.
@cedricjeanty Thanks for the insights in the "burn process". |
Hello, I'm assembling the AS5600 sensor programming code on my arduino. when I request the compilation of the error code on this line: // as5600.burnSettings(); // as5600.burnAngle(); |
To get access to the burn commands you need to uncomment them. AS5600.h file you need to uncomment some lines so it looks like: // BURN COMMANDS
// DO NOT UNCOMMENT - USE AT OWN RISK - READ DATASHEET
void burnAngle();
void burnSetting(); AS5600.cpp file you need to uncomment: /////////////////////////////////////////////////////////
//
// BURN COMMANDS
//
// DO NOT UNCOMMENT - USE AT OWN RISK - READ DATASHEET
//
void AS5600::burnAngle()
{
writeReg(AS5600_BURN, x0x80);
}
// See https://github.com/RobTillaart/AS5600/issues/38
void AS5600::burnSetting()
{
writeReg(AS5600_BURN, 0x40);
delay(5);
writeReg(AS5600_BURN, 0x01);
writeReg(AS5600_BURN, 0x11);
writeReg(AS5600_BURN, 0x10);
delay(5);
} |
I have burned the zero and max angles, no verification was required, I just used: |
I successfully permanently changed the address on AS5600L using this code: Thanks for the library!! |
Thanks for reporting, appreciated! |
Thanks @RobTillaart! btw, in this line of code there is one extra x before 0x80. |
It is an extra safety net to prevent accidental burning :) |
oh I see! :) I hope it would be helpful. |
C:\Users\SS\AppData\Local\Temp\arduino\sketches\CD03BF04600DA408FABC0FBF8D3F40B3\sketch\AS5600_burn_zpos.ino.cpp.o:(.literal._Z9burn_zposv+0x2c): undefined reference to I am getting the above error while uploading in Arduino ide, I made the changes mentioned in previous comments. I just want to know first I have to execute this AS5600_burn_zpos.ino file and then AS5600_burn_conf_mang.ino Thank you in advance. |
The IDE caches libraries.
you best check the datasheet on this. From my head I thought it is order independent, however check the datasheet. |
I have been working with your library and a handful of AS5600s to try and program them to generate a PWM output signal with permanently burned zero and max angle settings. I can get the PWM to work, and can confirm the settings I write are working, but when I try to burn them (CONF first, and then ZPOS, MPOS). The angles seem to change after burning. I had to uncomment the burn functions, and correct a small typo. Do you have experience burning the angles? What did you do to make it work?
The text was updated successfully, but these errors were encountered: