Shop OBEX P1 Docs P2 Docs Learn Events
Trail Plug to Propeller Chip — Parallax Forums

Trail Plug to Propeller Chip

Jeff2Jeff2 Posts: 46
edited 2010-02-10 23:27 in Propeller 1
HI


I will explain the big picture to you. There is A kit that
you can buy for your truck. It plugs into your trail light plug, on the
Truck side.(A led light bar).
It goes below the tailgate and it consists of A bank of led light's. The led's
go from one side of the tailgate to the other side. About 4 feet.

When you step on the brake pedal, all
the led's turn on. When you step off the brake pedal, all led's turn off.
When you use the right turn single. The right side of the led's bar
(witch is half of the led's), turn's on and off, like your turn light does.
When the turn single flasher is switched off the led's are off.


What I am looking to do with the Propeller Chip is.

I want to make the same thing, but I want to change the way the flashing is done. Not on
and off, like A flasher. My way, left to right or one at A time.
I want to use A reed relay, as A switch. The coil part will plug
into the 12v comming from the traler plug,
(witch is both Brake light and turn light). The switch part will have 3.3v
and going into the Propeller Chip as pin (23).

(Trail Plug = Reed Relay = Propeller Chip (23) = Led's)





Propeller Chip Programing.


So when the switch is held down. The (brakelight) program will run untill the switch is let go.
(IN the program now, When you push the switch down the brakelight turn's on, then when you
let go of the switch it turn's off,
then it run's the rightturnlight program). I what it only to run the brakelight program, when
the switch is held down, then let go. This is what I need help with. Is there I way to jump from the
end of the (brakelight) program to the end of the (rightturnlight), so the Led's will just
turn offff.

So you hold down on the button, all the led's come on. When you let go of the button, all
the led's go off.

When you press the button down and released continously, it will run the (rightturnlight) and
only it. Then when you stop pressing it. All led's are off.


1.) button is left alone =(all led's are off)
2.) button is pressed down continoulsy = (brakelight)
3.) button is pressed down and released continously = (rightturnlight)






Last thing is...............................

If you leave the button alone might be caused by the lack of a Pull-down-resistor
between Propeller-IO-Pin 23 and ground. (I have A resistor there.)

This is what someone told me, to fix it.
The next issue is that a switch will bounce when it changes state. So you need some debounce code.
The simplest form is a delay after it switches state. Start with 1 second so you can see the change in your leds.
Will this work as A delay (waitcnt(clkfreq/4 + cnt)?????



Thank you








CON
     _clkmode = xtal1 + pll16x
     _xinfreq = 1_000_000


LEDpin1 = 0 
LEDPin2 = 17
SwitchPin = 23



OBJ   led: "BreakandRightlights"
Var

long    LastSwitchChange
long    RateThreshold
long    LastCNTValue
long    ResultCNT
byte    SwitchStatus


Pub start

Dira[noparse][[/noparse]LEDPin1]~~
Dira[noparse][[/noparse]LEDPin2]~~
Dira[noparse][[/noparse]SwitchPin]~

RateThreshold := 001_000_000
LastCNTValue := cnt

repeat
    waitcnt(clkfreq/1000 + cnt)
  ResultCNT := cnt - LastCNTValue  
 
  if Ina[noparse][[/noparse]SwitchPin] <> SwitchStatus 
                                            'is the state of the switch different from the last time it changed?
    LastCNTValue := cnt
                                             'lets record this time
    SwitchStatus := Ina[noparse][[/noparse]SwitchPin]
    

                                         'store this as the current switch status
    
  if ResultCNT > RateThreshold            'we have gone over our threshold with no change in the SwitchStatus

                                             'this means either the switch was held down or not pressed
    outa[noparse][[/noparse]LEDpin1]~   
   
           
    If SwitchStatus == 1
    
                                          'Switch was held
     
               
      outa[noparse][[/noparse]LED.BrakeLight]~~
    
      
    else                        'switch was not pressed
         
      
      outa[noparse][[/noparse]LEDpin2]~
      
    

    
                                        'the switch is changing faster than the threshold r
  else                                    'the switch is changing faster than the threshold rate
      
   outa[noparse][[/noparse]LED.RightTurnLight]~~










PUB RightTurnlight

dira[noparse][[/noparse]0..19] := %11111111111111111111
outa[noparse][[/noparse]0..19] := %00000000000000000000
waitcnt(clkfreq/4 + cnt)
outa[noparse][[/noparse]0..19] := %00000000000000000000
waitcnt(clkfreq/4 + cnt)
outa[noparse][[/noparse]0..19] := %10000000000000000000
waitcnt(clkfreq/4 + cnt)
outa[noparse][[/noparse]0..19] := %11000000000000000000
waitcnt(clkfreq/4 + cnt)
'(N100)


PUB BrakeLight

dira[noparse][[/noparse]0..19] := %11111111111111111111
outa[noparse][[/noparse]0..19] := %11111111111111111111
waitcnt(clkfreq/4 + cnt)
outa[noparse][[/noparse]0..19] := %00000000000000000000
'(N10)


512 x 384 - 27K
720 x 450 - 19K
720 x 450 - 22K
«1

Comments

  • hover1hover1 Posts: 1,929
    edited 2010-02-07 04:09
    I guess you didn't get an answer so enough as "Jimm2" so you made a new name?
  • Jeff2Jeff2 Posts: 46
    edited 2010-02-07 04:12
    I guess No one can help me, or it just can't be done...........................
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-02-07 05:42
    What you are trying to do can be done, but not with the circuit you have shown.

    LED's require current limiting resistors to set the current (and hence intensity) of the LED. Different LEDs have different intensity outputs and the LEDs used in cars and trucks are the high power LEDs. I have not looked at their specifications, but they are usually driven with a switching circuit, and require much more current than the prop can safely output. This is an area you will have to look at. For testing, try a 330R (minimum) to the LED (if grounded) to limit the current so you will not destroy your prop. But I am sure you will require a driver per LED to use a much higher current. You will probably need to put the LED to +12V instead of ground and switch with a transistor driver or·other. This depends on the LEDs used and you will need to check this out. If you do not have 12V permanently available, use a diode (1N4004 will only handle 1 Amp max) from each pin capable of being switched on to a common 12v point to power the LEDs or drivers.

    Next thing is a question. Does your trailer connection have 12V always available? You will need something to power the propeller when the brake/indicator/tail lights are off.

    Now for your indication. Since you are showing lights for safety, you should keep them on while debouncing. That is, the brake light should go on without any debounce delay, and you should only debounce to turn it off. Rather than 1 switch, you should be looking at the brake, the left indicator, and the right indicator. Perhaps even the reverse could flash the LEDs too. What are you doing about the tail lights (for night-time) or is this in addition to normal trailer lights? Don't forget about the legal requirements.

    For sensing the inputs, just use 2 x 10K per input pin. Connect the·prop pin to 2 x 10K, one to ground, and one to the car/truck connector pin. When the connector is +12V, a "1" will be at the prop pin, and when 0V (or open), a "0" will be at the prop pin. No coils required.·You could use a·small cap across the 10K (needs reducing to maybe 1K)·to ground to serve as a debounce (needs calculation).

    Once you are sensing all the inputs, it is a simple matter to drive the appropriate LEDs (prop output pins) as you desire.

    Once you work out what is required, then we can talk about the code.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • Jeff2Jeff2 Posts: 46
    edited 2010-02-07 19:47
    What I am look for help on, IS there A way that the Propeller Chip can tell, between the Break Light and Right turn light.


    So the brake light will have 3.3v. The Right Turn Light will have 3.3v on and off 3.3v on and off going into the Propeller Chip.
  • Jeff2Jeff2 Posts: 46
    edited 2010-02-07 19:50
    What I am look for help on, IS there A way that the Propeller Chip can tell, between the Break Light and Right turn light.


    So the brake light will have 3.3v. The Right Turn Light will have 3.3v on and off 3.3v on and off going into the Propeller Chip.
    512 x 384 - 27K
    512 x 384 - 21K
  • Jeff2Jeff2 Posts: 46
    edited 2010-02-07 20:07
    This is what I want to make, but when the right turn light is on and flashing. I want to make is do my own design.


    http://www.customdynamics.com/truck_led_light_bar.htm

    Post Edited (Jeff2) : 2/10/2010 12:34:53 AM GMT
  • Cole LoganCole Logan Posts: 196
    edited 2010-02-07 20:50
    For what your wanting to do I don't see the need for using the prop. If you want it to work the way that the show on the website you would just hook the brake/turn wire from each side of the vehicle to each side of the light bar.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1986 Chevy EL Camino·· No prop yet

    1984 Suzukie GS1100GK No prop yet
  • hover1hover1 Posts: 1,929
    edited 2010-02-07 21:04
    OK, based on the link that you provided, the product does eveything you want. I just watched the video. Why would you want to introduce a Propeller into the mix when it's all being done brute force 12 volts?
    I'm a liitle confused at what you are looking for, because the product does what you have explained you want.

    Also check local laws as to the legality of lighting add ons.
    Jeff2 said...
    Is is what I want to make, but when the right turn light is on and flashing. I want to make is do my own design.


    http://www.customdynamics.com/truck_led_light_bar.htm
    Post Edited (hover1) : 2/7/2010 9:12:10 PM GMT
  • Cole LoganCole Logan Posts: 196
    edited 2010-02-07 21:19
    Ok Looking at your other post I know see what you want to do. You want the lights to sequence when they come on. I've attached a drawing that explains one way to hook your trailer plug to the prop. This by no means is a complete circuit because you will need to supply a constant power to the prop and you'll need some hardware to go between the prop and your LEDs

    As far as how to have it tell the difference between whether your braking or turning that will be a little harder and personally I wouldn't worry about it. I would let it sequence every time power is applied and just make sure it happens before the light would turn off and back on. That way if your just applying the brake it sequence and as long as the input to the prop stays high it will stay on fully. But if the pin cycles high to low then back high it would restart the sequence.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1986 Chevy EL Camino·· No prop yet

    1984 Suzukie GS1100GK No prop yet
    640 x 360 - 23K
  • hover1hover1 Posts: 1,929
    edited 2010-02-07 21:21
    I just re-read the original post and I THINK what you are trying to do is a sequential turn signal. You should re-write the original post so it is a little more readable. It is very hard to understand what you are trying to accomplish.
  • Jeff2Jeff2 Posts: 46
    edited 2010-02-08 00:36
    Have the Propeller Chip programed so, it will know if the brake light or the right turn light is on. If the brake
    light is on, turn all the led's. If the right turn light is on make the Right side of the led's sequential to the right. I don't know how to program this. I wish I did. I do know how to hook up the Propeller Chip, and all the led's, don't need help with this, ((Just the Programing to the Propeller Chip.))
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-02-08 02:23
    I misunderstood your original post and thought you were adding it to a trailer (not the existing truck).
    OK, a few more questions...

    Do you have to use this trailer plug or can you have a different plug ?
    If you can use a different plug, then just tap off 3 wires via 10K as shown. You do not require reed relays.
    Otherwise, just use·the two wires as you have shown and the circuit with the reed relays.

    The rest can be achieved in software for either case.
    In the case of 2 wires, if both inputs are on then you turn on all leds and it is a brake signal. Otherwise check each input to see if either is on, and flash the appropriate leds.

    You are going to have to show how many leds you have and how you are driving them from the prop as this effects how you program the prop.
    What you can do is something like this...
    var
      long  leds          'P23-16 = left, P15-8 = centre, P7-0 = right
    PUB RightIndicator
      dira[noparse][[/noparse]0..7] := %11111111       'make outputs
      leds := 0                     'preset all off (forced on later)
      repeat                        'also check using "until" that input is still on
        leds := leds >> 1           'move the on led 1 right
        if leds := 0
          leds := %10000000         'if none on then set leftmost led on (of rightmost 8 leds)
        outa := leds                'turn on the appropriate led.
        'some delay here for flashing
    
     
      
    



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz

    Post Edited (Cluso99) : 2/8/2010 2:41:16 AM GMT
    321 x 223 - 9K
  • Jeff2Jeff2 Posts: 46
    edited 2010-02-08 03:16
    Do you have to use this trailer plug or can you have a different plug ?

    I want to use the trailer plug comming from the truck. Because it's easy to plug into, it's in the back, of the truck......



    What you people are missing, Is. (The Right Turn Light and the Brake Light, are on the same Light bulb.) So if pin23 has 3.3v going to it, for A long time. The brake light is lit. If that same pin has 3.3v and it goes on and off, on and off. Then the Right Turn flasher is on. So some how the Propeller Chip need to know how much time pin23 is on for. So if pin23 has 10s that it is on for, then make it sequential to the right.
    If pin23 is on for 100s, then make the brake light led's come on.
  • BradCBradC Posts: 2,601
    edited 2010-02-08 03:30
    Jeff2 said...

    What you people are missing, Is. (The Right Turn Light and the Brake Light, are on the same Light bulb.)

    Worth emphasizing this bit. Quite a lot of US made vehicles use combined Brake/Indicator lights. No separate indicators. So when the plonker in front of you has a brake light out, you never know if he's indicating or just tapping the brake pedal.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life may be "too short", but it's the longest thing we ever do.
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-02-08 04:00
    OK, missed that combined light function. Not allowed in Australia!

    Well, it is easy with software to detect... 1=on

    L R
    0 0 = Off or else in off state for L or R flashing
    0 1 = R flashing or Brake & L flashing and in off cycle
    1 0 = L flashing or Brake & R flashing and in off cycle
    1 1 = Brake

    You just need to store the previous state to decode the current state. Also have a minimum debounce time to ignore glitches. But you do not want to have a big delay as you want the leds to come up quickly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • Jimm2Jimm2 Posts: 16
    edited 2010-02-09 02:23
    How do you make A program, for
    just the right side. Bake and right
    turn light. So pin23 will be the only
    one hooked up to tailer plug, the right
    side.
  • grouchygrouchy Posts: 16
    edited 2010-02-09 13:10
    brake and turn signal combined into one light??? I don't think so. It may be one light bulb, but it's got two filaments.

    what would happen if you turn and brake at the same time?




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Rudy's CNC Freeware·· http://www.enter.net/~schleinkofer
  • BradCBradC Posts: 2,601
    edited 2010-02-09 15:17
    grouchy said...

    what would happen if you turn and brake at the same time?

    It flashes. What did you think it would do?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life may be "too short", but it's the longest thing we ever do.
  • Jimm2Jimm2 Posts: 16
    edited 2010-02-09 23:06
    On A usa made truck, the plug for the trailer Light, is in the back of the truck. There is 4 wire's (white,brown,yellow,green).
    The green and yellow are for the turn and brake light. The brown, is for the running light's and the white is ground.

    All I need help with, is the programing of the Propeller Chip. I will try to make this easy.....

    (1=on)
    (0=off)

    If pin23 has A input of (1111111111111111111) Then goto (PUB BrakeLight)
    If pin23 has A input of (1001001001001001001) then goto (PUB Turnlight)
    If pin23 has A input of (0000000000000000000) Then nothing.








    PUB Turnlight

    dira[noparse][[/noparse]0..19] := %11111111111111111111
    outa[noparse][[/noparse]0..19] := %00000000000000000000
    waitcnt(clkfreq/4 + cnt)
    outa[noparse][[/noparse]0..19] := %00000000000000000000
    waitcnt(clkfreq/4 + cnt)
    outa[noparse][[/noparse]0..19] := %10000000000000000000
    waitcnt(clkfreq/4 + cnt)
    outa[noparse][[/noparse]0..19] := %11111111111000000000
    waitcnt(clkfreq/4 + cnt)
    outa[noparse][[/noparse]0..19] := %00000000000000000000



    PUB BrakeLight

    dira[noparse][[/noparse]0..19] := %11111111111111111111
    outa[noparse][[/noparse]0..19] := %11111111111111111111
    waitcnt(clkfreq/4 + cnt)
    outa[noparse][[/noparse]0..19] := %00000000000000000000



    Thank you if you can help.
  • Jeff2Jeff2 Posts: 46
    edited 2010-02-10 00:28
    Here is one more example of what I am looking for..........I found it on YouTube














    But I only what the Propeller chip to run the right side of the car..............

    Brake and right turn light..........

    Post Edited (Jeff2) : 2/10/2010 12:33:41 AM GMT
  • hover1hover1 Posts: 1,929
    edited 2010-02-10 01:25
    Jimm2 said...
    ·I will try to make this easy.....


    If pin23 has A input of (1111111111111111111) Then goto (PUB BrakeLight)·· ?524287
    If pin23 has A input of (1001001001001001001) then goto (PUB Turnlight)······· ?299539
    If pin23 has A input of (0000000000000000000) Then nothing.







  • hover1hover1 Posts: 1,929
    edited 2010-02-10 01:41
    A pin can only read a singular 1 or a 0 at any given time, unless you are reading a serial data stream, which is not what I think you are doing.

    I would suggest doing a flow chart http://en.wikipedia.org/wiki/Flowchart to make it easier to arrive at your goal and make it easier for other people to read.

    I think after you made a flowchart, you should see that this could be done with a handfull of descrete components. There is no need for a microcontroller. There are many examples of this on the web.

    Post Edited (hover1) : 2/10/2010 1:51:25 AM GMT
  • mparkmpark Posts: 1,305
    edited 2010-02-10 01:49
    I think I finally understand what Jimm/Jeff2 wants!

    When his turn signal is on, the Propeller will see a pulse train on pin 23. For concreteness, let's say 1 second high, 2 seconds low.

    If the brake light is on, pin 23 will be high for longer than 1 second.

    If neither the brake nor turn signal is on, pin 23 will be low for more than 2 seconds.

    The challenge is to watch pin 23 and figure out if he's turning/braking/neither.

    Is that correct, J2?
  • tonyp12tonyp12 Posts: 1,951
    edited 2010-02-10 01:51
    It's a little comlicated:

    You would power the prop and LEDs from the brown wire.

    If you brake the light have to come on right way.
    If you use the turn signal the prop would have to figure that out by timing the signal.

    And how does it know that you are not pumping the brake pedal etc?


    I would try to get a turn-signal from the truck somewhere
    that have not been muxed with the brake signal.
  • kf4ixmkf4ixm Posts: 529
    edited 2010-02-10 01:51
    i think the propeller is way too much over-kill for this type of circuit, not to mention the learning curve for the programming. the basic stamp2 would be PLENTY powerful enough for something like this, not to mention easier to code and troubleshoot (just my opinion). why do you just want just to effect the brake and just right flasher?
  • Jeff2Jeff2 Posts: 46
    edited 2010-02-10 01:54
    Yes.......how do I make the propeller read this.......mpark
  • Jeff2Jeff2 Posts: 46
    edited 2010-02-10 02:02
    kf4ixm........If I can get the Brake and right to work on the programming, the left and the brake will be easy.

    Because I want to some day use 2 Propeller chip. One for the right side and one for the left side. But I don't think it's going to be easy.......
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-02-10 07:50
    It would be easier to sample both inputs, even if you use 2 props.
    Otherwise, you are going to either...
    * Have to delay long enough (by skipping the first flash) to determine if it is a brake or flash
    * Show the brake (all leds on one side) until it goes off indicating a flash.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • kf4ixmkf4ixm Posts: 529
    edited 2010-02-10 09:51
    program your logic in your code so that if BOTH green and yellow (on the 4-wire plug) are on, then goto brake, if only green is on, then goto right turn, if only yellow is on, then goto left turn, (i'd throw in a 1.5 (more or less)·second pause in here so that whenever the program checks the state of the yellow or green,·the on-off signal is captured during the flashing). im just starting with the prop, so im not able to come up with any useable code for you that i can say 'will work'.·if the signal drops out on one·of the wires when both are high, (as in brake applied with turn signal on) have a gosub check for the flash pulse and goto the cooresponding rt or lt turn signal.·id work on getting the the program working first to detect the logic of the two wires and flashing what you want, then move onto the gosub's (or whatever) to detect the flash during braking.

    White: Ground
    Brown: Running
    Yellow: LT and Stop
    Green: RT and Stop

    1157 bulbs (brake light) has a dual filament , one for turn/brake (bigger filament), the smaller filament is for the running/side marker lights (brown wire).

    wiredtrailer_7way_600.jpg

    Post Edited (kf4ixm) : 2/10/2010 10:26:22 AM GMT
Sign In or Register to comment.