Continue to Site

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.

  • 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.

Need guidance for automotive related project

Status
Not open for further replies.

AltairDusk

New Member
Hello all, let me start off by saying that I'm a computer science major which means my knowledge of the actual hardware is limited when it comes to small electronics.

I've had the idea for awhile to use a small LCD or VFD display coupled with a microcontroller and a few push button switches to display some rudimentary information such as system voltage and a clock and also allow me to control fog lights, interior LED lighting, etc... in my truck. The programming side of things I'm pretty confident I can handle but when it comes to figuring out what hardware I need I think I'm in over my head.

I know that I will need a way to output enough current to control a relay and I will need at least 4 outputs with this capability (preferably more for expandability). I would like to have 3 or four push buttons and a rotary dial as inputs for control (though I may drop the rotary controller idea if that proves too expensive). I'm not sure if I would need any special input to measure the voltage my vehicle's system is currently running at or if I would need any special setup to regulate power to the microcontroller (since I know voltage can vary in a vehicle).

My goal is to set this up where I will mount the screen somewhere in the dash with the push buttons below and a rotary dial next to it which I can then use as my input controls for the software. I hope to implement a menu that will let me cycle through what I want to display as well as control the devices I have hooked up to the relays the system is controlling. My hope is that this will give me a clean looking all-in-one expandable system rather than having to install a voltage gauge, a clock (due to the stereo I am using I have no clock), and loads of extra switches to control lights etc... I also think it would be a pretty unique addition and hopefully teach me a lot in the process. I'm hoping I can do this within the $100-$150 range, as I've been looking at prices I realize I have no idea what I should be looking for.

Any help or advice is greatly appreciated.
 
A project like that sounds fairly major.

Automotive electrics are very noisy, and you want some protection against load dump. A zenner limiter followed by a voltage regulator is a good idea. If you want the display to function while the engine is cranking, that makes the design more difficult. The current taken by the electronics will determine the power supply design, so it might be worth getting them working from a 5V supply and then finding what current they take first.

You will need a transistor or relay driver to power each relay from the output of a microcontroller.
 
Given that you can already program this is reasonable first project. But you do have some learning to do. We can help with that here.

Tools
-------
First you will need a programer. As a CS major you should have used a debugger. I suggest a PICkit2 or the Junebug (a PICkit2 clone with a built in tutor/target).

Hardware
----------
Getting a clean voltage supply in a car used to be a big deal. But since they put electronics in every car that coems off the line you can buy regulators for automotive use as standard and inexpensive parts. So start with a regulator designed to automotive use. Look at mouser, newark, or digikey. You need to start looking at datsheets for most every part you use.

For a processor I suggest you use a 18F PIC. An 18 pin unit should have enough IO pins to do what you need. If not step up to a 28 pin. I like the 18F1330 because it has 3 breakpoints instead of 1 like the 18F1320.

A graphic LCD display would be nice but start with a 4 line character display because they are easier to interface. You can upgrade latter.

To energize a relay you need a transistor to provide enough current to drive the coil.

Each switch input is connected to VDD (microprocessor power, +5V) through a pullup resistor. A switch between the resistor and the micro controller pin is used to ground the pin when pressed.

The rotory input is just a pot (variable resistor) connected to the micro controller analog to digital input. Think about useing a slide control instead of a rotory.

For the clock the easy way out is to use a I2C or SPI interfaced clock chip.

Parts cost should be about $30 excluding relays and the variable resistor/pot. Depending on you choice of relay I would expect an average of about $5 each. I would use a 500 mA automotive regulator maybe $3. The cost of LCD displays vary a lot. You may get buy with $5 to $10 for a surplus unit. The wrong new one could break the bank. Be sure to get one with a LED backlight. The clock chip is about $4. The PIC18 will be about $5 to $7. Newark has good prices on PICs.

Programming
--------------
I suggest the free student C18 compiler from Microchip.

This is simple enough that it can be written without interrupts.

Code:
...
void main(void)
{
   // setup ports, ADC, and SPI or I2C
  
  while(1)
  {
      // read clock chip
      // display time
      // read switches and other inputs
      // set relays and any other outputs
      // tickle watch dog timer
  }
}

I suggest you start by getting a PICkit2, PICkit3, or a junebug. The Junebug has a 18F1320 (you can replace it with a 18F1330) with switches LEDs, and pots for working with adc. It would be a good choice for learning. blueroomelectronics - Smart Kits Build Smart People

If you do not get a Junebug you will need an 18F target of some sorts. The PICkit's often come bundled with a target, make sure it is one you can use.

Once you have a programmer and target write a simple program to turn an LED on and off. The same code will turn on a relay. Learn to read a switch. Learn to send text to the LCD. Stir add a bit of salt.

EDIT: To monitor the cars working voltage you will also use the micro controllers ADC. You will either need a voltage divider to scale the voltage or maybe an opamp and some form of overvoltage protection. That can be ironed out after you make some progress.

3v0
 
Last edited:
Wow, thanks for the info it looks like I have some research to do :)

I do have a small bit of programming experience on embedded devices from one of my courses. We used a handyboard for that course which I had looked into for this project but it seemed far more expensive and overkill than what I needed. I probably should have explained the rotary control better, I was hoping to have something more like the digital volume knobs on most newer stereos where it "clicks" as you turn it and the device can read how many times it clicked and in which direction. I was thinking it could be an easy way to navigate menus and adjust values if I end up with a pretty large menu in the future (maybe I'm going overboard, I tend to do that :eek: ). Is that difficult to implement?

Is there anyplace in particular you would recommend looking for surplus LCDs? I've found new ones pretty easily but not much luck finding surplus ones, it also seems like 4x40 is a harder find but I'm not sure if 4x20 is big enough. I had originally been wanting a VFD for the look but I've seen some negative LCDs that look pretty good and the VFD's seem prohibitively expensive. Is something like this a decent LCD to use? (I would probably try to find it with blue or white text though) **broken link removed**

I'm a bit confused about the target in reference to the kits, is the target the PIC chip? After looking at the pricing on the chips I'm thinking I might as well go with a 28 pin since I'd rather have more inputs/outputs than I need than end up wishing I had more later on. Also should I be worried about memory/processor speed limitations for what I'm planning on? I would like it to store some variables "permanently" (not lose the values when the truck is off) and if I can get it working well with a more basic setup I'm thinking it would be cool if I could program in some flashing patterns for the interior LEDs I am planning on installing. Basically I plan to expand on it and run with the idea as much as I can but for now I'm more concerned with figuring out the hardware and getting it all working which you've been very helpful with so far. Is the controller that comes with the PICkit3 (PIC18F45k20) ridiculous overkill?

Sorry I'm asking so many questions, I know it can be a pain trying to explain things to someone who doesn't know half the terms :D
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top