Trail Plug to Basic Stamp ({$STAMP BS2} ' {$PBASIC 2.5}) Chip
Jeff2
Posts: 46
What I am looking to do is, Use the pulses coming from the trailer plug, going into the Basic Stamp, if Brake Light is On. It will make A set of 6 Led's come on. If the Right Turn Light (flashing), it will make the same set of 6 Led's sequence or Left to right.
On your stander trailer plug there is, (USA) White wire, Brown wire, Yellow wire and Green wire). I am going to hook up the (Green wire is Brake Light and Right Turn Light In one wire) coming from the trailer plug to (Pin1) of the Basic Stamp. There will
Resistor's So the (V) will be right. What I don't know how to do is? Program the Basic Stamp, so it knows then the Brake Light is on, or the Right Turn Light is flashing.
So is there A way I can make A (Pulsin to tell the time from one to the other one.
Brake (111111111111111111111111111111) ((1=on and 0=off))
Right Turn Light (001001001001001001001) ((Brake and Turn pulses are coming from the same Wire, green))
This Is A program to Show you what I am looking for? I don't know how to find the time the brake light and turn light is on for.
'{$PBASIC 2.5}
time VAR Word(2)
FREQOUT 4, 2000, 3000
DO
DO
PULSIN 9, 1, time(0)
LOOP UNTIL time(0) > 1000
PULSIN 9, 0, time(0)
PULSIN 9, 0, time(1)
(Brake Light).......IF (time(1) < 500) AND (time(0) < 500) THEN
High Pin 4
High Pin 5
High Pin 6
High Pin 7
High Pin 8
(Right Turn Light)........ELSEIF (time(1) < 500) AND (time(0) > 500) THEN
Low Pin 4
Low Pin 5
High Pin 6
Low Pin 7
ENDIF
LOOP ' Repeat main loop.
if you can help great
On your stander trailer plug there is, (USA) White wire, Brown wire, Yellow wire and Green wire). I am going to hook up the (Green wire is Brake Light and Right Turn Light In one wire) coming from the trailer plug to (Pin1) of the Basic Stamp. There will
Resistor's So the (V) will be right. What I don't know how to do is? Program the Basic Stamp, so it knows then the Brake Light is on, or the Right Turn Light is flashing.
So is there A way I can make A (Pulsin to tell the time from one to the other one.
Brake (111111111111111111111111111111) ((1=on and 0=off))
Right Turn Light (001001001001001001001) ((Brake and Turn pulses are coming from the same Wire, green))
This Is A program to Show you what I am looking for? I don't know how to find the time the brake light and turn light is on for.
'{$PBASIC 2.5}
time VAR Word(2)
FREQOUT 4, 2000, 3000
DO
DO
PULSIN 9, 1, time(0)
LOOP UNTIL time(0) > 1000
PULSIN 9, 0, time(0)
PULSIN 9, 0, time(1)
(Brake Light).......IF (time(1) < 500) AND (time(0) < 500) THEN
High Pin 4
High Pin 5
High Pin 6
High Pin 7
High Pin 8
(Right Turn Light)........ELSEIF (time(1) < 500) AND (time(0) > 500) THEN
Low Pin 4
Low Pin 5
High Pin 6
Low Pin 7
ENDIF
LOOP ' Repeat main loop.
if you can help great
Comments
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
Post Edited (W9GFO) : 2/18/2010 1:16:19 AM GMT
No doubt there is more than one way to accomplish this; however are the values for brake (111111111111111111111111111111) and turn (001001001001001001001) the value you see on the signal pin? Is it always the same value? ie if the brake is pressed does the value always match 111111111111111111111111111111? or is the pin held HIGH for a certain period? If the values are the same, I would imagine you could use either·COUN or just take a small sample since (like W9FG0 suggested) the signal looks like it repeat and compare it to a known value for BRAKE, TURNL, TURNR, NONE and so on; If you can verify the signals are the same, then that would be a good point to build from.
For the programming syntax, I would recommend downloading the BASIC Stamp Syntax & Reference Manual; the PDF has the commands, how to use them and even some samples to help learn faster. This will help with formatting the IF...THEN statements, HIGH/LOW command and many others.
BASIC Stamp Syntax & Reference Manual:
http://www.parallax.com/Portals/0/Downloads/docs/prod/stamps/web-BSM-v2.2.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
I think Your way over thinking this project.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
duration as MS. Is there any way that I can save the time as Seconds? Then I can hook it up to my trail plug and tell the second's, and make A program to run. There is About 3 seconds between one flash to the next flash.
The second Program I how I would know if it were the brake or Right Turn Light Flashing.
Thank you very much
Again, PULSIN will not work for pulses of such long duration. Look at this table - the maximum pulse length (for a BS2) is 131.07 mS.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
The data pulse would be something like (Current Duration of 500 microseconds on and then off). So if you the brake light were on the data pulse
would be on for a long time, and if the turn light were on, the data pulse would be on for 3 sec. and off for 3sec.
Could the basic stamp tell if Brake was on or Right Turn was on....
Do you·know what the voltage is of the signal pin? Is the signal·part·of the·cars·CAN protocol?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
An option would be to use an opto-isolated circuit to use 12 V and BS2 safely. If the 12 V signal is used as the input the BS2 can watch an I/O pin to see if it's either high or low. That is just one option, no doubt there are many ways to tackle this situation. There is a module I used that was really easy to use but it was for higher voltages; but was still only about .25-.50 cents each. Do you have any opto-isolated IC?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
Brake and Right Turn, is one the same wire,
Brake is (1111111111111111111111111111111) (1 = 12V) (0 = off)
Right Turn is (1001001001001001001001001001) Both are on the same wire or input. So how does the BS2 read one from the other one.
It may look like this from the green wire (1111111111111111111111Brake then it may switch to (100100100100111111111111111111).
Thank you
A option would be to watch the I/O pin and see if there is a transition in a known time frame; for example there is a timed transition that the blinker will have on and off time; since this time is slow enough to see the transition visually, you can take a sampling of that to see if the pin is always HIGH or toggling. Do you know the amount of time the pin takes to completed the transaction? For example, does the pin remain low for 1/2 second, then toggle, then remain high for 1/2 second and so on?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
I put A pic, of A Timing Diagram, to help people out, to know what I am trying to do.
How do I program the BS2 to read the input, coming into it..........
Post Edited (Jeff2) : 2/24/2010 1:24:21 AM GMT
In that case you should be able to sample the signal pin to determine if the pin is toggling or remains at 12VDC. For example, once the I/O changes state (low/high); you can wait for 4 seconds and sample the I/O pin again; if it's HIGH then you can assume brake condition if it's low than a blinker condition. Would that delay be acceptable?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
could you send me some code for
program this, just to help me
get started, or tell me A place to
look for this.
Thank You. Jeff2
Post Edited (Jeff2) : 2/25/2010 10:53:56 PM GMT
Let me see if I can get an example up for you; it will be a little bit (day or 2) because of other projects, but I will try to have something up as an example by the end of this week.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
could you send me some code for
program this, just to help me
get started, or tell me A place to
look for this.
Thank You.
_G__Y__Out
_0__0__Off
_1__0__Right turn
_0__1__Left turn
_1__1__Brake
Jeff T.
Unsoundcode has a good idea, that actually would be much faster if you could use those wires. Can you verify if those wires can be used?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
If the right light is off and the left one is on, then the left one will be blinkig.
If the right one is on and the left one goes off and on, then it is blinking.
If both go on and off at the same time, then emergency flashers are on or the driver is pumping the brakes.
I use a 4N32-Short opto to read up to 24 volt signals with my stamp designs.
I think Toshiba makes them. They are not too fast, but rugged.
A 1-2 k resistor will work fine.
You can get them fom Dikey fairly cheap.
Good Luck,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Alan Bradford ·N1YMQ
Plasma Technologies
Canaan NH 03741
www.plasmatechnologies.com
www.digikey.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Alan Bradford ·N1YMQ
Plasma Technologies
Canaan NH 03741
www.plasmatechnologies.com
_G__Y__Out
_0__0__Off
_1__0__Right turn
_0__1__Left turn
_1__1__Brake
I think this will work, but how do you program it, so when the (_1__0__Right turn) is on
and the brake is off. Right turn light would be flashing, on and off, on and off, that
mean's that the input to the 4N32 to the BS2, the data would be (0101010101) not A
(1111111) like the Brake was on. So my LED-sequence, would be on for A bit and then off
for A bit. I what them to run like A sequence. I think you still need A way that you can
tell what the input is comming from the 4n32 to the BS2 is. So kind of timing program. That
will tell the Brake light from the Right turn light. (Brake11111111) (Turn1 3sec. 1 3sec.)
Maybe this will work......
If the Brake is pushed on, it will send 12V on the green wire to the 4n32, From the 4n32 it
will go to the BS2. From the BS2, it will tell if it is Brake or Right Trun. In this case
it is Brake, so all led are on. Next if I turn on the Right Turn, it will allso send 12V to
the 4n32, but it will be on 12v and off 12v and on 12v off 12v on 12v, and so on. From the 4n32 it will
go to the BS2. The BS2 tell it is the Right Turn, becasue of the timming or the pulse. Then
it would make the LED-sequence. That's what I need help with. Is there A Program or A way to program
to tell the timming or pulse.
So if I can get the Right side working, the other side willbe easy.
Once a condition has been met and the output detected then you can let your program go do something and then check back to see if the condition has changed or not.
The above opens up a multitude of·possibilities for light sequencing.
The 4 inputs to the truth table·could be converted to numerical values 0,1,2 & 3 and used in a simple program like the one attached , try entering those values in the debug panel.
Jeff T.
_G__Y__Out
_0__0__Off
_1__0__Right turn
_0__1__Left turn
_1__1__Brake
I am not sure how you·deal with this ....>>>>>>>
IF the BRAKE and the TURN·SIGNAL on at the same time because you only have two wire
This part is going to hard to deal with
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 4/4/2010 4:32:49 PM GMT