Go Back   IceInSpace > Equipment > Software and Computers
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread
  #1  
Old 06-10-2019, 08:47 AM
jwoody's Avatar
jwoody (Jeremy)
Registered User

jwoody is offline
 
Join Date: Aug 2011
Location: Ormeau Hills, Australia
Posts: 372
How to fully clear EEPROM of Arduino Leonardo

Hello all
I am having trouble with the software in my Nexdome. I have been playing with a rain sensor and sort of got it to work. Now the sensor is totally disconnected but now the Nexdome software always states that it is "Raining" so the shutter will not open properly.

I think the problem is that the EEPROM of the arduino has been written to saying it is raining but even after I clear the eeprom it is still there.
I have tried the EEPROMClear sketch and the EEClear.hex function in the nexdome control software but to no avail.

Does someone have a sketch that I can use to comprehensibly clear the EEPROM of the Arduino Leonardo?

Thank you
Jeremy
Reply With Quote
  #2  
Old 06-10-2019, 10:37 AM
redbeard's Avatar
redbeard (Damien)
Registered User

redbeard is offline
 
Join Date: Nov 2010
Location: Adelaide
Posts: 558
Hi Jeremy,

The EEPROM.write(i, 0); command is all you should need, (used in a loop with correct syntax of course), so if you have executed this code part correctly then that should work. If it does not as you say, then look elsewhere in your code for the issue.

I don't think any other examples or sketch's will help as that is the command they will be using.


You could also write a separate program to simply test the reading and writing to the eeprom, (disregard any other programming tasks), so you know that part works.

How are you keeping track of which eeprom byte is written to and also how you reset to 0.

The Leonardo also has 1K of eeprom, are you using this value to work from or 512 like on the UNO?

You could try a different version of Arduino IDE if you think your code is fine.

If you could, post your code so we can have a look, that would be great as without seeing the code, it's very hard to nail down this one as writing 0's to the eeprom is fairy straight forward.

These are a couple of starting places to help. If you are experienced in Arduino coding then apologies for the basics. If not and you are a newbie to Arduino coding then all the more reason to post your code so we can see how to help. Don't worry if you downloaded someone else's code and you are using some of that, most start that way. All good. Post your code.

Cheers
Damien.
Reply With Quote
  #3  
Old 06-10-2019, 10:43 AM
jwoody's Avatar
jwoody (Jeremy)
Registered User

jwoody is offline
 
Join Date: Aug 2011
Location: Ormeau Hills, Australia
Posts: 372
Hello Damien
I am not experienced in coding so the simpler the better
I have just been copying and pasting code then uploading it.

This is the one of the sketches I have been using -

/*
* EEPROM Clear
*
* Sets all of the bytes of the EEPROM to 0.
* Please see eeprom_iteration for a more in depth
* look at how to traverse the EEPROM.
*
* This example code is in the public domain.
*/

#include <EEPROM.h>

void setup() {
// initialize the LED pin as an output.
pinMode(13, OUTPUT);

/***
Iterate through each byte of the EEPROM storage.

Larger AVR processors have larger EEPROM sizes, E.g:
- Arduno Duemilanove: 512b EEPROM storage.
- Arduino Uno: 1kb EEPROM storage.
- Arduino Mega: 4kb EEPROM storage.

Rather than hard-coding the length, you should use the pre-provided length function.
This will make your code portable to all AVR processors.
***/

for (int i = 0 ; i < EEPROM.length() ; i++) {
EEPROM.write(i, 0);
}

// turn the LED on when we're done
digitalWrite(13, HIGH);
}

void loop() {
/** Empty loop. **/
}


I kind of know what I am looking at in the code. I also read somewhere that rather than a zero being used to replace the values it should be a 1 or 255?
Thanks for your help
Jeremy
Reply With Quote
  #4  
Old 06-10-2019, 10:55 AM
redbeard's Avatar
redbeard (Damien)
Registered User

redbeard is offline
 
Join Date: Nov 2010
Location: Adelaide
Posts: 558
The code is good and should work. The issue might be this: The example code you posted is in the 'setup' section of the IDE and will only run at startup, once, when the Arduino boots up. Unless you are using this code elsewhere in your main loop then it will never run again and therefore not reset the eeprom. You could write a small subroutine with that code in it and call it from anywhere in your code.

If that answers your question, great, if not, post all your code.
Reply With Quote
  #5  
Old 06-10-2019, 11:04 AM
redbeard's Avatar
redbeard (Damien)
Registered User

redbeard is offline
 
Join Date: Nov 2010
Location: Adelaide
Posts: 558
Quote:
I also read somewhere that rather than a zero being used to replace the values it should be a 1 or 255?
Thanks for your help
Jeremy
I don't think the value is the issue, a byte is a byte. 0 is fine.
Cheers.
Reply With Quote
  #6  
Old 06-10-2019, 11:08 AM
jwoody's Avatar
jwoody (Jeremy)
Registered User

jwoody is offline
 
Join Date: Aug 2011
Location: Ormeau Hills, Australia
Posts: 372
The above code is all I am using. All I have been doing is uploading the above code, and then just resetting the arduino. Then I upload the dome firmware.
Once I upload the eepromclear sketch is there a command in the serial monitor I should use to execute the code or just resetting should do the trick?

I did suspect that I wasn't properly executing the eepromclear sketch but I am still not sure.

Thank for your help
Reply With Quote
  #7  
Old 06-10-2019, 11:10 AM
jwoody's Avatar
jwoody (Jeremy)
Registered User

jwoody is offline
 
Join Date: Aug 2011
Location: Ormeau Hills, Australia
Posts: 372
This is the dome firmware
https://github.com/nexdome/Firmware
Reply With Quote
  #8  
Old 06-10-2019, 12:59 PM
redbeard's Avatar
redbeard (Damien)
Registered User

redbeard is offline
 
Join Date: Nov 2010
Location: Adelaide
Posts: 558
Quote:
Originally Posted by jwoody View Post
The above code is all I am using. All I have been doing is uploading the above code, and then just resetting the arduino. Then I upload the dome firmware.
Once I upload the eepromclear sketch is there a command in the serial monitor I should use to execute the code or just resetting should do the trick?

I did suspect that I wasn't properly executing the eepromclear sketch but I am still not sure.

Thank for your help
Bear with me as I'm trying to piece together what you are actually doing.

OK, from what I can see from the link to that code is a complete program for running the dome etc, and it was programmed very professionally using Visual Studio 2017 & Arduino plugin, and then downloaded to the Arduino. It's quite in depth.

So step 1 would be to download this code/firmware to the Arduino to get dome control, (forgetting about the rain sensor for now). Is that correct?

The next step is to add the rain sensor code in a way that it works with the already downloaded code, Is that correct?

If both the above are correct then it appears that you have 2 programs, one for the dome, and the other for the rain sensor, is that correct?

If so, and you are using 1 Arduino then there is one of your issues.

You can only download 1 program to the Arduino at any given time, so it is either the dome code, or it is the rain sensor code.

What you need to do, I think at this stage, is edit the Visual Studio/Arduino code and add your working rain sensor code to that and then download the 1 program to the Arduino.

If you have downloaded the dome code and then you download the rain sensor code, then you are overwriting the dome code with the rain sensor code.

I'm just trying to piece together what you are doing and at this stage, it looks like the above. Your clarification will help.

Are you using 1 or 2 Arduinos?

Resetting an Arduino to make code work and run once is NOT the way to program these devices, but hey, depending on the project maybe so, but I don't think in your case. I still need to understand all you are doing.

I can show you how to call code to reset the eeprom's values to 0 within your program by adding some things in the loop section but first I need to know more.

So, at this point, going on what you have said so far, it looks like you have 2 separate programs, 1 Arduino and a bunch of sensors etc. Is that correct?

I'm sure we will get to fully understand what you are wanting to do and it is either a lot simpler than I think at the moment or it might be an extreme learning curve for you.

Happy to chat on the phone to save on typing if you want. :-)

Cheers,
Damien
Reply With Quote
  #9  
Old 06-10-2019, 05:51 PM
jwoody's Avatar
jwoody (Jeremy)
Registered User

jwoody is offline
 
Join Date: Aug 2011
Location: Ormeau Hills, Australia
Posts: 372
Thanks very much for your help Damien.
Unfortunately still a no go and just to really frustrate me now the Leonardo on the rotator has died
Just keeps coming up USB not recognized now. Oh well. I have a new one on the way so hopefully that will solve all
Time for several large scotches
Thanks again for your time
Reply With Quote
  #10  
Old 06-10-2019, 08:47 PM
Ukastronomer (Jeremy)
Feel free to edit my imag

Ukastronomer is offline
 
Join Date: Jan 2019
Location: Llandysul, WALES, UK
Posts: 1,381
https://arduino.stackexchange.com/qu...learing-eeprom

https://www.techwalla.com/articles/h...the-eprom-chip


May help
Reply With Quote
  #11  
Old 06-10-2019, 09:55 PM
jwoody's Avatar
jwoody (Jeremy)
Registered User

jwoody is offline
 
Join Date: Aug 2011
Location: Ormeau Hills, Australia
Posts: 372
Thanks for that Jeremy
Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +10. The time is now 09:02 PM.

Powered by vBulletin Version 3.8.7 | Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Advertisement
Bintel
Advertisement
Testar
Advertisement