Hi,
I'm French and new to Flowcode. I'm programming Flowcode 11 for an ATMEGA32L.
The program's goal is to run a motor for 9 products per line. When a line is empty, I switch to a different line.
My program uses a counter. I want this counter to be saved even if the power is cut.
I can't seem to save it to the EPROM. I'm not even sure I've configured it correctly.
The program and screenshots are in a Google folder: https://drive.google.com/drive/folders/ ... sp=sharing
Thank you for your help.
Anthony
Save counter
-
lavomatique
- Posts: 4
- http://meble-kuchenne.info.pl
- Joined: Wed Oct 27, 2021 10:25 am
-
medelec35
- Matrix Staff
- Posts: 2186
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 663 times
- Been thanked: 740 times
Re: Save counter
Hi Anthony.
One issue with your flowchart is you are using & for AND.
That is for bitwise compare instead of logical compare.
Bitwise is comparing bits and logical is for comparing variable values.
As a gude take a look at our Flowcode Wiki page on Mathematical Functions
You need to take into account that EEPROMS have a limited number of write cycles, before it gets worn out.
A way to get around saving the EPROM when there is a power cut see this post.
You find the who topic interesting
As you are new to flowcode you might find this very useful, especially the Examples and Tutorials section.
One issue with your flowchart is you are using & for AND.
That is for bitwise compare instead of logical compare.
Bitwise is comparing bits and logical is for comparing variable values.
As a gude take a look at our Flowcode Wiki page on Mathematical Functions
You need to take into account that EEPROMS have a limited number of write cycles, before it gets worn out.
A way to get around saving the EPROM when there is a power cut see this post.
You find the who topic interesting
As you are new to flowcode you might find this very useful, especially the Examples and Tutorials section.
Martin
-
lavomatique
- Posts: 4
- Joined: Wed Oct 27, 2021 10:25 am
Re: Save counter
Hi Martin, and thanks for your reply.
I corrected my & to "AND," thank you.
I've looked through the forums and various examples. I downloaded the "EEPROM" program directly from the website, using the same syntax, but I still lose the counter when powering off.
To program my ATMEGA32L, I use the "AVRDUDESS" software. Perhaps I have a setting I'm using incorrectly?
In the folder, I've included the "EEPROM" program that I used as an example, my modified program, and a screenshot of the AVRDUDESS. I'm open to any advice.
https://drive.google.com/drive/folders/ ... sp=sharing
My latest program is "OMO5x9 BIO1x15 SOUP1x19 V0.4"
Thank you
I corrected my & to "AND," thank you.
I've looked through the forums and various examples. I downloaded the "EEPROM" program directly from the website, using the same syntax, but I still lose the counter when powering off.
To program my ATMEGA32L, I use the "AVRDUDESS" software. Perhaps I have a setting I'm using incorrectly?
In the folder, I've included the "EEPROM" program that I used as an example, my modified program, and a screenshot of the AVRDUDESS. I'm open to any advice.
https://drive.google.com/drive/folders/ ... sp=sharing
My latest program is "OMO5x9 BIO1x15 SOUP1x19 V0.4"
Thank you
-
Steve-Matrix
- Matrix Staff
- Posts: 1633
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 227 times
- Been thanked: 385 times
Re: Save counter
"&" and "AND" are equivalent and both represent a bitwise operator.
So "5 AND 2" is actually false (zero) because the bitwise of 5 (0b101) and 2 (0b010) is 0 (0b000).
The "&&" is the logical-and operator. This is used when comparing 2 things that might be true or false. In this case, "5 && 2" is true because 5 and 2 are both true (non-zero).
I've not looked at your project, but I think Martin was suggesting you need to use the logical-and (i.e. "&&") rather than the bitwise-and ("&").
So "5 AND 2" is actually false (zero) because the bitwise of 5 (0b101) and 2 (0b010) is 0 (0b000).
The "&&" is the logical-and operator. This is used when comparing 2 things that might be true or false. In this case, "5 && 2" is true because 5 and 2 are both true (non-zero).
I've not looked at your project, but I think Martin was suggesting you need to use the logical-and (i.e. "&&") rather than the bitwise-and ("&").
-
lavomatique
- Posts: 4
- Joined: Wed Oct 27, 2021 10:25 am
Re: Save counter
Okay, thank you, I understand about the logical operators.
But my main problem is saving my "Compteur_lessive" to the EEPROM and reading it when the power is turned on. My counter always starts at 0.
But my main problem is saving my "Compteur_lessive" to the EEPROM and reading it when the power is turned on. My counter always starts at 0.
- Attachments
-
- Write EEprom.png (6.72 KiB) Viewed 84 times
-
- Read data.png (7.33 KiB) Viewed 84 times
-
medelec35
- Matrix Staff
- Posts: 2186
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 663 times
- Been thanked: 740 times
Re: Save counter
Hello.
You could create a simple EEPROM test project.
first read from an unused EEPROM address and send the value via UART.
Then Write to the same EEPROM address with a value, e.g. 4.
The value should sent should be 255.
Now restart the hardware and check to see if the value sent this time is the saved EEPROM data.
If you don't have a way of viewing the data at the start of main before the EEPROM, toggle a pin a few times to make sure it working.
The pin then should be left as low.
After reading the EEPROM, have a decision branch that sets the same pin high, if value is correct and low if its not.
The pin should stay low when hardware is first started.
Then on the next restart, the pin should go high, indication EEPROM is correct.
You could create a simple EEPROM test project.
first read from an unused EEPROM address and send the value via UART.
Then Write to the same EEPROM address with a value, e.g. 4.
The value should sent should be 255.
Now restart the hardware and check to see if the value sent this time is the saved EEPROM data.
If you don't have a way of viewing the data at the start of main before the EEPROM, toggle a pin a few times to make sure it working.
The pin then should be left as low.
After reading the EEPROM, have a decision branch that sets the same pin high, if value is correct and low if its not.
The pin should stay low when hardware is first started.
Then on the next restart, the pin should go high, indication EEPROM is correct.
Martin