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

micro pic VW golf project.

Discussion in 'Microcontrollers' started by jay543_uk, Nov 23, 2007.

  1. jay543_uk

    jay543_uk New Member

    Joined:
    Oct 31, 2007
    Messages:
    107
    Likes:
    0
    Location:
    uk
    Hi all
    I'm new to pic's and no alittle about electronics.I do no quite abit about vehicle sensors and signals.

    I'v played around with flashing led's and even got a lcd working showing me a/d voltages,now i wanna make a project for a car i work on.

    iv got a lcd connected to my 16f876a which iv got displaying the time and date from a ds1302, im planing on doing a a/d convertion on the cars battery through a voltage divider to drop 15v to 5v so i can monitor the battery voltage.

    my next part of the project is to display the vehicle speed. the car has a vehicle speed sensor which is a hall effect sensor which when scoped displays a square wave form, im guessing i use a op-amp between the pic and the sensor but how do i get the pic to monitor the input signal and work out the speed.I'm guessing i measure the time between the pulses, but would that work at high speeds because the pulses would be so close.

    please let me no what you think of all my ideas as i am new to all this and am just using the internet to work out how to do things.

    thanks for any help you can give me

    jason
     
  2. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    Don't worry about that. PICs (computers/microcontrollers in general) are much faster than you think. :D Those pulses are actually very far apart in computer terms. It'll be no problem whatsoever to use them to calculate speed.

    There's nothing mechanical in a car that could possibly generate pulses fast enough to be too fast for a micro to handle, unless the micro is clocked ultra slow, and even then they're very very fast compared to mechanical things.
     
    Last edited: Nov 24, 2007
  3. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    Exactly, everything in a car runs really slowly, as the mechanical world does - there won't be any problem with the time required.
     
  4. dave

    Dave New Member

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


     
  5. picbits

    picbits Well-Known Member

    Joined:
    Jan 29, 2007
    Messages:
    2,003
    Likes:
    95
    Location:
    Northants, United Kingdom

    As a clue - I'm working on a speedo/HUD which takes an input from a speedo pulse sender that gives out 28800 pulses per mile. It needs to work accurately at up to 180MPH.

    There are two easy ways to do this - either count the pulses in a period of time i.e. 1/2 or 1/4 second or count the interval between the pulses.

    A better and more accurate way of doing it is to sample at half a second from 0-30mph, 1/4 second from 31mph to 60mph and 1/8th second from 61mph+

    You could also sample the pulse period from 0-30mph and then use fixed 1/4 second counting sampling from 31mph+

    Gives a much more stable reading doing it by the above methods
     
  6. jay543_uk

    jay543_uk New Member

    Joined:
    Oct 31, 2007
    Messages:
    107
    Likes:
    0
    Location:
    uk
    Thanks alot, sounds like i should be able to work this out,after iv done the speed side of things im gona add a MAP sensor on to the car and use that to measure turbo boost pressure.I wanna end up with a little onboard computer which can measure different senors on the car and do 0-60mph time etc, also wanna be able to do a kinda datalogger so i can record track runs.Have i set my goal to high for a first manor project so is most of this stuff quite easy to work out.Iv not had to may problems so far, just working it out from info on the net.


    The other thing i wanna be able to do is to programme the pic in the vehicle so i can update the software, Should i use a bootloader or what else could i do

    many thanks for any help any one can give me.

    jason
     
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    Either a bootloader or add an ICSP socket.
     
  8. jay543_uk

    jay543_uk New Member

    Joined:
    Oct 31, 2007
    Messages:
    107
    Likes:
    0
    Location:
    uk
    what are the good and bad points of both of them, which is easyist to do.

    i dont realy no what a bootloader is??????
     
  9. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    A bootloader is a program running in the PIC that allows you to transfer a program from the serial port of a PC - so there's no programmer required (except for initially loading the bootloader in the PIC). It requires either one or two port pins, with one usually being the UART pin, and the other (optionally) a switch to initiate bootloading.

    ICSP requires a suitable programmer (like the ICD2 or clones) and access to three specific pins of the PIC.
     
  10. jay543_uk

    jay543_uk New Member

    Joined:
    Oct 31, 2007
    Messages:
    107
    Likes:
    0
    Location:
    uk
    iv got plans for most of the pins on my pic so a bootloader is probly the one for me.

    Are there different types of bootloader??

    can you recommend one or should i just search the net??

    sorry if these are silly questions

    many thanks jason
     
  11. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
  12. jay543_uk

    jay543_uk New Member

    Joined:
    Oct 31, 2007
    Messages:
    107
    Likes:
    0
    Location:
    uk
    cheers nigel for all your help.i will try and get the speed sensor up and running over the next few days and then move onto the Map sensor after, Iv had an idea to maybe add some sort of sensor to measure how many G's you are pulling when accerating,would that be hard??? just trying to add different gagets to my car.
     
  13. picbits

    picbits Well-Known Member

    Joined:
    Jan 29, 2007
    Messages:
    2,003
    Likes:
    95
    Location:
    Northants, United Kingdom
    Make sure you can walk before you start trying to run on project in the car. I'm working on quite a few products for in car use and some of the gotchas and pitfalls would put off someone with a relatively small knowledge of microcontrollers from building stuff for cars for life lol.

    Bear in mind that spikes on the electrical system of 20-30 volts are quite normal and you can also get a phenomenon called "Load Dump" which will put a voltage of 80+ volts (sometimes up to 200 volts) on the electrical system for a fraction of a second. You need to make sure that anything you put on a PIC input is adequately protected and buffered.

    Also consider moving to the 18F range of PICs - much easier to use, program, use bootloaders on and the newer ones will run at 32Mhz on their own internal oscillator with a 4x PLL activated. I use the good old cheapo 18F1320 for development with a bootloader on to test code for the new stuff I'm building. Once I've got it all running correctly I port the code onto one of the bigger PICs (18F4520 or similar) and build my code in modules.
     
  14. jay543_uk

    jay543_uk New Member

    Joined:
    Oct 31, 2007
    Messages:
    107
    Likes:
    0
    Location:
    uk
    can you just give me an example of what you mean by protecting and buffing.
    has the 18f got the same 35 instruction set as 16f or is it all new stuff.

    i'm a master ford tech so i work with car sensors all day and from it iv just had loads of ideas of things i wanna add to my car, i think i need to slow down and get the basics up and running first.

    many thanks for any help you can pass on to me

    jason
     
  15. picbits

    picbits Well-Known Member

    Joined:
    Jan 29, 2007
    Messages:
    2,003
    Likes:
    95
    Location:
    Northants, United Kingdom
    If you put more than 5 volts into the input of a PIC pin you run the risk of killing it.

    If you are using a voltage divider to get a signal from 15v down to 5v (max) but get a spike of 30 volts on the sensor input then you will be putting 10v into the PIC input pin which could easily kill it. You need some kind of circuit to stop this from happening. A simple zener diode with a series resistor would give the most basic protection - this would be classes as the protection definition. An opamp with a 1/3rd gain would be classed as a buffer.

    Get the basics running first and read a lot on sensors etc as well as automotive electronics and you'll get there eventually.

    As for the 18F vs 16F, the 18F is far easier to use, has less "gotchas" i.e. page and bank selects, enhanced instruction set, better internal oscillator support, hardware 8x8 multiplier, generally more program and variable ram and is generally a nicer PIC to use.

    Since moving to the 18F series a few years ago I've rarely used a 16F series PIC.
     
  16. jay543_uk

    jay543_uk New Member

    Joined:
    Oct 31, 2007
    Messages:
    107
    Likes:
    0
    Location:
    uk
    can you tell me how you would get a 1/3 gain from a opamp, iv just been using opamps as followers. are you saying that if you have an input of 3v into the opamp it will only have 1v coming out

    sorry if this is a stupid question.

    regards

    jason
     
  17. Diver300

    Diver300 Well-Known Member

    Joined:
    Oct 19, 2007
    Messages:
    3,066
    Likes:
    101
    Location:
    England
    ONLINE
    The only stupid question is the one you don't ask.

    You can often use a voltage divider made from resistors to reduce the voltage like that.
     
  18. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    You simply use an inverting opamp, this can give positive or negative gains - a non-inverting one can't go below a gain of one. Not that it's a problem, you just use an attenuator to drop the gain.
     
  19. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    You simply use an inverting opamp, this can give positive or negative gains - a non-inverting one can't go below a gain of one. Not that it's a problem, you just use an attenuator to drop the gain.
     
  20. jay543_uk

    jay543_uk New Member

    Joined:
    Oct 31, 2007
    Messages:
    107
    Likes:
    0
    Location:
    uk
    so is it better to use a opamp instead of a voltage devider to measure sensor signals over 5v, i think they are all 5v but i want to measure battery voltage so i will have to use a opamp or voltage devider to do that as the voltage can go up to 15v when the engine is running.

    is there a formula to calculate the resistors to be used in the opamp circuit to get the correct inverted voltage output

    many thanks

    jason
     
  21. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    No point using an opamp, a simple voltage divider is all you require - it's a VERY low impedance source, so you can use fairly low value resistors, and keep the impedance to the PIC low.

    Yes, it's VERY, VERY simple - try googling for "741 tutorial" if you know absolutely nothing about opamps.
     

Share This Page