Categories

Counter project recorded in C

Posted on Wednesday, June 11th, 2014 in hacks by DP

counter44

Ricardo of Electropepper writes:

So i’ve decided to rewrite the code in C language using the MikroC compiler for the Counter project.
I have chosen MikroC compiler for its easy of use and good documentation, unfortunatelly the IDE editor simple sucks big time, so it really is good for me to tolerate it.
I also got recently some professionally finished PCB’s.
This is a part of the Counter project.

Check out the video after the break.

This entry was posted on Wednesday, June 11th, 2014 at 7:00 pm and is filed under hacks. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

5 Responses to “Counter project recorded in C”

  1. KH says:

    I would like to point out a subtle I/O detail with the counter code. When switching between digits, the digit lines (DECIMALS and UNITS) should be switched off before the segments (PORTA) are changed. If not, you might see some ‘off’ segments lighted at a very low intensity (look at it in the dark). I have encountered it when driving 7-segment displays like this. It’s not a big deal, but a subtle detail.

  2. Ricardo says:

    Thank you very much for pointing out that detail KH, its indeed a very subtle detail that i will try to fix and i have notice that extra bright which i tought it was the display being very bright.

  3. octal says:

    I checked your code, you systematically write counter value at addr 0x10. This is not good for long term running, as the EEprom part of your mcu is not inifinite lifetime. You better choose a more saving scheme, for example, before writing a value, check if the already written value is different or not instead of rewriting same value, and eventually using incremental address range when writing, i.e. write first value at adr 0x01, when user try to store new value, writes it at adr 0x02, and so on… by doing that, you increase the lifetime of your eeprom part by nn times (where nn is the interval range you use to store your values before rolling up to first adr of the range).

  4. KH says:

    Well, typical lifetime is 100K at commercial temps. I think it’s perfectly fine for “casual” hobbyists stuff, I’d do the same myself in this situation. But when it goes into long-lived projects, then we can code something to spread the writes. People don’t usually write perfect programs for hobbyist projects… (octal, you should look at the program for “ATtiny85 POV display” earlier ;-)) Perhaps it may be good to write a couple of functions to do that, then its implementation in a project would be a matter of mostly-cut-and-paste.

  5. Ricardo says:

    Those are all perfectly valid points, octal and kh, and of corse the final goal is perfection, comercial or not, i am very greatfull for this feedback now i can proceed to improve myself and even better, learn more ;) .

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recent Comments

  • Dave B: Got two of them. If you let the battery run flat, they don't charge! You have to pull the battery, and get enough charge in...
  • Bill F: My turn?
  • Chris: Ok!
  • Bob: Free PCB for me!
  • Blars: Yet another meaningless comment.