1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

digital speedometer using AT90S2313

Discussion in 'Microcontrollers' started by fever, May 24, 2006.

  1. fever

    fever New Member

    Joined:
    Mar 5, 2005
    Messages:
    132
    Likes:
    0
    hello all
    i am thinkg of building digital speedometer published in edn.com link:(http://www.edn.com/article/ca529384.html)
    it uses AT90S2313 which is pretty old but i still wana go with it.
    before starting it,i want u people to have a look.
    is it worth making,imean is this really gona work? it looks ok to me.

    pls do post ur openion
    thanks
     
  2. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    I am just start learning AVR but these are my suggestions:

    1. Do not use a bridge rectifier before the 7805 on a +12V DC system in the car. You would create two different grounds which is not necessary and have no real advantages at all.

    2. The AVR reset pin should have a 10K resistor pull up to +5V.

    3. Consider using the ATTiny2313 instead, which is cheaper, easily available and pin/code compatible. Just remember to setup correctly the fuses for the proper clock speed.
     
  3. DirtyLude

    DirtyLude Well-Known Member

    Joined:
    Aug 5, 2003
    Messages:
    1,904
    Likes:
    56
    Location:
    Toronto, Canada
    It uses it's own wheel sensor for some reason, rather than just using the one already in the car. It would be easier to just tap the cars VSS line.

    Otherwise, it's a very simple design and project.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. fever

    fever New Member

    Joined:
    Mar 5, 2005
    Messages:
    132
    Likes:
    0

    well thanks for ur replies guys.
    i wanan use it for my bike which is powred by 12v 2.5Ah battery.so i'll use my bike battery using 7805 to power this circuit.
    @eblc1388
    is there any particular reason why i need 10k resistor for avr reset?
    and abt using ATTiny2313,i am afraid that it might need some circuit/code modification.
     
  6. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    Not particularily. The AVR itself already has a 100K internal pullup resistor at the reset pin but I usually use a 10K external resistor. You can say I don't trust/rely totally on the internal resistor when an external capacitor is also connected.

    As I have said, I'm learning AVR right now so I might be wrong. As far as I know, the Tiny2313 is pin/code compatible to 90S2313.

    Other AVR gurus in this forum will sure correct me if I'm wrong.
     
  7. mramos1

    mramos1 Active Member

    Joined:
    Sep 15, 2005
    Messages:
    2,403
    Likes:
    9
    Location:
    Boynton Beach, Florida USA
    You do not need the resistor. Though out of habit (from PICs) I sometime pop a 10K in on the AVR, though I can remove it and it works fine.

    Make sure you have decoupling. Some cellphone frequencies might be a problem. I did a circuit for a friends bike, and his Nextel would reset it until we added more caps. The circuit was in a compartment where he stored his phone.

    Circuit was to make his tag go up under the fender. He told me it was for when they do their trick riding videos, before you guys jump on me. hehehe.. And yea, I doubt that was what it was for, but a fun project.
     
  8. fever

    fever New Member

    Joined:
    Mar 5, 2005
    Messages:
    132
    Likes:
    0
    thanks guys
    i'll start making it soon.i hope it will work.
    main problem iam facing with it is pcb layout.that site is't providing any layout for this ckt,and my drawing skills sucks :-(
     
  9. mramos1

    mramos1 Active Member

    Joined:
    Sep 15, 2005
    Messages:
    2,403
    Likes:
    9
    Location:
    Boynton Beach, Florida USA
    Try Eagle CAD, it is nice, capture it, click board, drag parts on the work area, autoroute, then you move them parts and traces around. Also, you can SPLIT traces, and add jumpers and not have to mess with double sided boards.
     
  10. fever

    fever New Member

    Joined:
    Mar 5, 2005
    Messages:
    132
    Likes:
    0
    oooffff
    making PCB layout is not really that easy.any way i'll request someone on net to design it for me.

    and about the code.the default radius 0specified in the ASM is 25cm.
    i found only one place where this 25 is being used.is it ok or i missing something

    ;########Registers used for delays############
    .def low_del=r24
    .def hi_del=r25
     
  11. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    No. You have look at the wrong place. See the following code.

    Code (text):
    ;############For distance measurement################
    ;After every 100 m the registers holding distance values
    ;are incremented. For this we have used following formulae
    ; 2*pi*R*n/100 = 100
    ;R = radius of the wheel in cm (In this design R=25cm)
    ;n is the count which signifies that 100 m has been completed

    .equ n = $40
     
    Now $40 is a way hexadecimal number is represented so $40 is actually 64 in decimal. According to the formula, the required N is 63.66 so the author rounded it up to 64 instead.

    For different radius of wheel, use the following equation that I worked out for you from the same equation:

    N= 1591.54 / R ; Where R =radius of wheel (in cm)

    You do not have to convert the number N into hexadecimal as the assembler understands both format. Just write it without the "$" sign.
     
  12. fever

    fever New Member

    Joined:
    Mar 5, 2005
    Messages:
    132
    Likes:
    0
    ohh thanks for the new equation
    actaully my wheel size is 30cm so N=1591.54/30=53.051 or 53
    so the new code shld be
    Code (text):
    ;############For distance measurement################
    ;After every 100 m the registers holding distance values
    ;are incremented. For this we have used following formulae
    ; 2*pi*R*n/100 = 100
    ;R = radius of the wheel in cm (In this design R=25cm)
    ;n is the count which signifies that 100 m has been completed

    .equ n = 53
     
    is this right?
     
  13. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    Yes. But you should also change "in this design R=25cm" to R=30cm in the comment too to remind yourself later when you read back the code.
     
  14. fever

    fever New Member

    Joined:
    Mar 5, 2005
    Messages:
    132
    Likes:
    0
    @eblc1388
    thanks ur really helpfull.
    thanks a lot.

    i think what we modified above is only For distance measurement.then what abt speed measurement.do we have to change the code there also?
     
  15. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    Yes, you're right. I missed that.

    Code (text):
    ;############For speed measurement#################
    ;speed = 2*pi*R*3600*clk/time_count*1000*x
    ;R = radius of the wheel in cm (In this design R=25cm)
    ;time_count = value of timer counter in b/w
    ;two successive interrupts
    ;x = clock prescaler used (in this design x=1024)
    ;using this we have calculated the equivalent value of
    ;all the constants (except time_count all other parameters
    ;are constants)
    ;sh and sl are binary equivalent of this constant

    .equ sh = $56
    .equ sl = $49  
    .equ sht = $57      ;sht = sh + 1
     
    Now the above formula works out to be:

    Speed(Km/h) = 883.56 * R / time_count

    If r=25cm, then 883.56*25=22089 and that converted to hexadecimal is $5649.

    So in your case with r=30cm, 883.56*30=26507 =$678B

    Thus your new code shall be:
    .equ sh=$67
    .equ sl=$8B
    .equ sht=$68 ;sht=sh+1
     
  16. fever

    fever New Member

    Joined:
    Mar 5, 2005
    Messages:
    132
    Likes:
    0
    thanks.
    i compiled this code using wavrasm.and shows "2313def.inc" not found error.so i did some googling and found this file http://www.qsl.net/zl1vk/Atmel2313definc.txt
    i placed this file in same folder and compiled the speedometer ASM once again.now it created a hex file(i think this is what i needed to burn on chip directly).
    my doubt is is that Atmel2313definc.txt is universal.i mean can i use it for any source with AT90S2313 chip?
     
  17. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    The include file content seems to be created directly by Atmel back in 1998 so I think you are safe to use it for assembly codes targetting AT90S2313.
     
  18. fever

    fever New Member

    Joined:
    Mar 5, 2005
    Messages:
    132
    Likes:
    0
    hey thanks once again.

    while searching for the simple programmer for AT90S2313 chip i found this programmer(http://www.serasidis.gr/circuits/avrprog/avrprog.htm).which looks very simple to me.is it really gona work and safe.can i program AT90S2313 directly without destroying it.i don't want any in system programer.
    just burning the chip in programmer and placing it in speedometer board.thats all i need.
     
  19. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    Can't advise you on that.

    The programmer I built uses 74HC244 as buffer, which is also a very common design you'll find on the net. There is certainly no harm whatsoever trying the above circuit first.
     
  20. mramos1

    mramos1 Active Member

    Joined:
    Sep 15, 2005
    Messages:
    2,403
    Likes:
    9
    Location:
    Boynton Beach, Florida USA
    posted on last post of page 1 I guess, as I saved and wound up on last post of page 2 to see eblc1388 answered it a couple posts ago... Sorry.
     
    Last edited: May 29, 2006
  21. fever

    fever New Member

    Joined:
    Mar 5, 2005
    Messages:
    132
    Likes:
    0
    just setting up the fuses will do the work?i heard that AT90s2313 contain 2 fuses where as ATTiny2313 has lot of fuses.
     

Share This Page