PDA

View Full Version : CAR Systems control with TEENSY (ROOPOD)



Roodesign
03-18-2013, 04:22 PM
HI there, I am going to use a teensy to control some of the systems on a little car that I am building...
you can see it at www.roopod.com (http://www.roopod.com) It is almost done, in fact have been driving it around for a couple of years, but wanted to finally finish off the interior, and upgrade the all-manual controls.
some of the things that I want to do are: (with the teensy)

-control the headlight switch and dimmer, and PWM the headlight output for daytime running lights.
-use a tmp-36 temp sensor to control PWM on the fans for the Radiator and heater.
-switch a bunch of relays that control all the other lights and acessories:

I have chosen a High-Side Mosfet switch: http://www.irf.com/product-info/datasheets/data/ir3313pbf.pdf to switch the bigger loads...

I am trying to figure out how to switch these mosfets with the I/O pins on the Teensy...I suspect that I need another little fet or NPN transistor to do it. Please advise how this should be done!
also, I want to build an electronic self-canceling turn signal system using some kind of sensors on the steering column to detect rotation and direction...instead of the ratchety thing on regulars cars...I was thinking of trying a couple of reed switches right next to each other with magnets on the steering shaft. this would show rotation, and direction...any thoughts?
well, I am sure, as I try to learn the programing and all, I will have lots more questions...but thanks in advance!

PS high side switches are need because almost all the loads in the car are - ground and would be very difficult to switch to ground.

Thankyou!

-roo

PaulStoffregen
03-18-2013, 08:04 PM
I am trying to figure out how to switch these mosfets with the I/O pins on the Teensy...I suspect that I need another little fet or NPN transistor to do it. Please advise how this should be done!


I'm pretty sure you'll need a NPN or N-Channel transistor. The datasheet says "The input signal is referenced to Vcc". Do not connect a Teensy pin directly.

I'd use a 2N3904 and a 10K resistor. Connect the resistor to a digital pin on Teensy, and the other side of the resistor to the 3904's base. Connect the emitter to ground and the collector to the IR3313 input. The block diagram on page 4 shows a 3 mA current source, so you probably do not need another resistor between the collector and +12V. Then again, adding a 10K resistor there wouldn't hurt. When testing, I'd use a voltmeter on the collector to check if the voltage really does go close to zero (0.3 volts is probably what you'll see) when the digital pin is high, and close to +12V when the Teensy's pin is low.



also, I want to build an electronic self-canceling turn signal system using some kind of sensors on the steering column to detect rotation and direction...instead of the ratchety thing on regulars cars...I was thinking of trying a couple of reed switches right next to each other with magnets on the steering shaft. this would show rotation, and direction...any thoughts?


As we've seen from another recent thread, I'm not very familiar with car systems. Others here certainly are! :-)

However, I can tell you that rotary encoders are typically used to measure the amount and direction of shaft rotation. Normally they're used with the Encoder library.

http://www.pjrc.com/teensy/td_libs_Encoder.html

Qumefox
03-18-2013, 08:21 PM
One thing i'll mention about turn signal cancels.. One of the reasons cars still use mechanical cam based cancels is that it's still the cheapest and easiest way to go about it, especially when your turn signal switch is mechanical as well, as it is in pretty much every car i've ever seen.

To do it electrically, you'll have to be able to track both wheel position in relation to it's centerline (even over the course of the teensy getting powered off) as well as direction of rotation.

Roodesign
03-20-2013, 03:59 PM
One thing i'll mention about turn signal cancels.. One of the reasons cars still use mechanical cam based cancels is that it's still the cheapest and easiest way to go about it, especially when your turn signal switch is mechanical as well, as it is in pretty much every car i've ever seen.

To do it electrically, you'll have to be able to track both wheel position in relation to it's centerline (even over the course of the teensy getting powered off) as well as direction of rotation.

Hmm...
I think that I have a good grasp on how Mechanical turn signal cancel switches work.
1 you set the switch either way, and it engages a ratchet that allows the wheel to rotate in the turning direction without tripping the switch off.
2 when you turn the wheel back towards straight it will eventually run into a notch in the ratchet wheel (on the steering column) and trip the lever off. Most assemblies have 4 "pawls" per revolution of the steering shaft. so 1/4 turn of the the wheel before it cancels.
the way that I see it...
if I have two reed switches right next to each other above the steering shaft and a series of magnets around the shaft, I will be able to tell which way the shaft is turning by which switch triggers first, and depending on the number of magnets around the shaft, I will be able to see if the shaft has turned, and what direction...

now here is the part that I have absolutely no idea how to do...Program this!

sequence is like this:


1 engage either (L) or (R) turn signal switch (momentary) turn on that output on the teensy.
2 look to see if reed switches are closed (if so, ignore till they go off once)
3 either if they have been ignored once, or are open, start to look at the two reed switch inputs and analyze which one hits first...that gives me direction wheel is turning.
4 ignore signals from the reed switches that are in the same direction as the turn signal switch that is set.
5 look for signals from the reed switches that are in the opposite direction of the set turn signal switch, and cancel the turn signal.

now depending on how many magnets are around the shaft, I could use software to count a certain number of pulses from the reed switches and have an adjustable threshold for how quick the signal cancel (something that is annoying with the mechanical ones (they can only have a whole number of pulses on their' ratchet wheel.

if anyone has ideas how to program this, please let me know!
(I am just learning the programing part)

-roo