Monday, October 28, 2013

An AVR ATmega configurable production line counter

Updated to version 01b

This project here is a production line counter build on an ATmega 8 micro.



It has 4 digit seven segment display.
It can count from 1 to 9999 pieces.
(01b) Input can be delayed, so that every input recived will block the counter for an amount of time, to prevent double reading on too sensitive item sensors.

User can program it to emit an alarm when a number of items is reached.

Also a plus and minus button are present to adjust items count, if something has to be changed manually.
Holding the select button for a while make the counter reset.

To enter programming mode the select button have to be pressed while the device startup.

Setup parameters are contained in main.h, key.h and sevseg.h

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 8MHz.


Changelog
  • 01b: added the input delay capability
  • 01: first release


Code

Notes
  • read risk disclaimer
  • excuse my bad english

61 comments:

  1. Ebay search for character LCDs. They're as cheap as $3 - perhaps less than your 4x7-segment. Fewer wires too!
    http://www.ebay.com/sch/hd44780
    http://www.swharden.com/blog/2011-07-24-frequency-counter-gen2/

    ReplyDelete
    Replies
    1. led display deserve here to make counter more visible.
      of course you could adapt this code to any output you want :)

      Delete
  2. ...nm, I see on your G+ you've done this :)

    ReplyDelete
  3. Sir, can you send me hex file? I want build this project. Thanks

    ReplyDelete
    Replies
    1. Hello,
      yes, just send me your email address.

      Delete
    2. Thanks sir, this is my email.
      ulywae@gmail.com

      Delete
  4. Excute me,I can't compile this project source.can you send .hex file for me?
    wisitunlimitedjib@gmail.com is my email.Thank you so much.

    ReplyDelete
  5. Excute me,I can't compile this project source.can you send .hex file for me?
    saifudinho@gmail.com tanks

    ReplyDelete
  6. when I make you this product . I have trouble on the select button does not work when it is appropriate skema . please give solution

    ReplyDelete
    Replies
    1. I suppose it should be something to do with the ADC raw value read. You can enabled the BUTTON_TEST def, read the output on the sev segment display, and then set BUTTON_ADCUP, BUTTON_ADCDOWN, BUTTON_ADCSELECT according to that.

      Delete

    2. I do not understand . I give you my compiler link . will learn from your source . bicause i loking avrr gcc i not found . my you have link for me

      Delete
    3. Hello. If you give me your mail i can send you my compiled hex.

      Delete
    4. Saifudinho@gmail.com

      This my email sir

      Delete
    5. Sam sir.the buton select does not work.

      Delete
    6. Double check your wiring. It should be a wiring issue, or a ADC threshold value issue. To solve this, you have to debug it. Try to perform steps that i write down in my "March 24, 2016 at 7:55 PM" comment, what's the UART output for that test?

      Delete
    7. Sam sir.the buton select does not work.

      Delete
    8. I'm sorry but debugging from post comments it's difficult. You have to test it using at least an UART debug technique.

      Delete
    9. This comment has been removed by the author.

      Delete
  7. Great project which I was looking for, thanx for sharing

    ReplyDelete
  8. Davide, can't compile as well, I saw You sent hex files, may I got too? waldemar.beben@gmail.com
    May You modify displays to LCD? It's so easy for You. I'm sure, still black magic for me :)
    Also increase max value and implement reset port ?
    I just began my experience with ATMega processors, as I'm from times when TV were bulbs b/w and frst computer which I saw was ZX 80 with softwares saved into cassette tapes :)
    I have some experience with eproms, I like to learn more with flash technology
    Cheers :)

    ReplyDelete
    Replies
    1. Hello. You've got the hex in mail. It will be fairly easy to use an LCD instead of the seven segment, and to increase the intervall. You have just to add an LCD library. There are a few for ATmega. I like the Peter Fleury one. It's useless if i do it for you, here the matter is to learn.

      Delete
    2. Thank You Davide, yes, at that moment I'm still fighting with WinAVR, I would like to compile myself. Makefile is fine but still Process Exit Code: 2 :)

      Delete
    3. This comment has been removed by the author.

      Delete
    4. I've read from your post below you have finally make it works. I'm happy to hear this :)

      Delete
  9. Finally I built and all works great, many thanks Davide, for project, software and hex file :) Atmega8 programed by MkAvrCalculator http://www.atnel.pl/download.php?programy/SoftPack_ATB.zip and STK 200 which I built :) Cheers

    ReplyDelete
  10. Sir please send me hex file 01b, my email ulywae@gmail.com thanks

    ReplyDelete
  11. Sir, can you send me hex file? I want build this project?
    I am interested in the whole project as a teaching me.

    ReplyDelete
    Replies
    1. Hello, just tell me your email, i will reply you back with the hex.

      Delete
  12. ok thank you for your kindness, my email is ufyded27@gmail.com

    ReplyDelete
  13. Hi brother. I am Bangladeshi. Can you send .hex file of this project for me? my email:
    kaiyumhasanm@gmail.com

    ReplyDelete
    Replies
    1. Please give me hex file.My email:
      kaiyumhasanm@gmail.com

      Delete
    2. Hello, here you can find the hex compiled. Link expires in 2 days: https://expirebox.com/download/b09bf146b72f4f3cf91bd5cc000de104.html

      Delete
  14. This comment has been removed by the author.

    ReplyDelete
  15. I have flashed the hex on Atmega8A-PU. But When the select, Up and Down button press, the display turn off.Is it not suitable for atmega8a-pu?

    ReplyDelete
    Replies
    1. Hello, yes, it can run on a ATmega8, i suggest you to compile the project and debug it to understand this behaviour. It may be F_CPU and fuses settings.

      Delete
  16. This comment has been removed by the author.

    ReplyDelete
  17. Dear sir, Please give me the file for atmega8a. And F_CPU and fuses settings information link.I used Avr programer , Avrpal.net software and fuse bite H-D9, L-F1. And used hex file what you gave me.

    ReplyDelete
    Replies
    1. You already have got the ATmega8 file. For the fuse, take a look at the ATmega datasheet, or you can also look here: http://www.engbedded.com/fusecalc/. It's better if you understaind how fuses works, if I do this for you it will be pretty unusefull. Tips: Low:F1 is External Clock, I will try the internal oscillator for the frequency this hex is compiled againsta (i.e. 8Mhz).

      Delete
    2. Sir,Which is small to you, it's too big for me. I have tried a lot. But did not understand. Please Give me the right fuse information. Otherwise it would not be possible for me to do this project.Please help me sir.

      Delete
    3. There was a time when which is small to me, was big to ohers, but if I just follow other people checklist instruction I would never learn how to work on that and errors makes you grow. Said that, you can set the LOW fuse to E4 to use the internal 8Mhz ATmega8 crystal, and forget about any external crystal. But keep in mind that an incorrect fuse settings can "brick" your ATmega, then you will need something like the Atmega fusebit doctor to make it works again. Happy experiments.

      Delete
    4. Sorry Sir. Now All button are working but only select button does not work. I have checked the wearing, all is fine.So What could be the problem? Is it problem of hex file ?

      Delete
    5. It could be related to R15. For this design it si better if you compile it by yourself reading the raw values for button, you can find instruction inside the code.

      Delete
  18. Replies
    1. Hello. Please do not flood with messages.

      Delete
  19. Dear sir What is indl=0-50 in this option?

    ReplyDelete
    Replies
    1. Hello, it's just the input delay, it is a simple debounching method.

      Delete
    2. Many many thanks sir. I've completed three of your projects. I like all of your projects. I will try to create some more projects.

      Delete
  20. Dear sir, When the motor(A.c) is turn on or off in same line, the count number automatic resets or display off. I also used 10k resistance grand to pc6(reset) but same problem. What is the cause?

    ReplyDelete
    Replies
    1. Hello, I do not understaind what you mean with the motor turn on and off. I suppose you are using this with a motor attached on the same power supply, if so you should try using a current limiter, or a 100uF and a 100nF cap to filter the line, also a 100ohm resistor in series can help, if the motor is big enough it could also be caused by Electromagnetic Interference (EMI).

      Delete