useing a BS-2 to drive 3 relays w/ commands from the com port...
freek
Posts: 22
Hello fellow BS'ers ,
I have an interesting project here at work that I would like to get some help on.
I opperate a CMM(coordinate measuring maching), and am trying to monitor its status.· I decided to use a 'christmas tree', a bunch of lights stacked on a pole, to visually show me whats going on.· I want to send 3 commands out the serial port of the cmm to the BS-2: scaning, finished, error.
1st, shut all lights off before lighting any light, then when the stamp gets the 'scaning' command, i want it to flash a yellow light, 'finished' flash a white light, 'error' flash a red light.· the stamp can do the flashing, or just close a relay to a strobe/flasher unit.
i looked at Ex31 - PollStamp.BS2, and tried to hack it to my needs.· needless to say that didn't work very well.
If you guys could point me in the right direction, that would be great.· sample code is great, but no compleate projects please.· i would like to try this myself.
i'll put what i have sofar..
thanks a lot.
Will
I have an interesting project here at work that I would like to get some help on.
I opperate a CMM(coordinate measuring maching), and am trying to monitor its status.· I decided to use a 'christmas tree', a bunch of lights stacked on a pole, to visually show me whats going on.· I want to send 3 commands out the serial port of the cmm to the BS-2: scaning, finished, error.
1st, shut all lights off before lighting any light, then when the stamp gets the 'scaning' command, i want it to flash a yellow light, 'finished' flash a white light, 'error' flash a red light.· the stamp can do the flashing, or just close a relay to a strobe/flasher unit.
i looked at Ex31 - PollStamp.BS2, and tried to hack it to my needs.· needless to say that didn't work very well.
If you guys could point me in the right direction, that would be great.· sample code is great, but no compleate projects please.· i would like to try this myself.
i'll put what i have sofar..
thanks a lot.
Will
Comments
Shawn Lowe
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Shawn Lowe
Remember - No matter where you go
There you are.
Will: Use PBASIC 2.5 syntax and the PIN definition so that you can use the "= On" and "= Off" constructs with the LEDs.· See my edits (attached).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Ummm, why yes....right there in the help file....hem *cough*.
Your right, of course, silly me.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Shawn Lowe
Remember - No matter where you go
There you are.
Say you·want to respond to "G", "Y" or "R"
Get_Cmd:
· SERIN Sio, Baud, [noparse][[/noparse]cmd]
· LOOKDOWN cmd, [noparse][[/noparse]"gGyYrR"], cmd
· IF (cmd > 5) THEN Get_Cmd
· cmd = cmd / 2
At the end of this routine, cmd will contain a value from 0 ('G') to 2 ('R') that you can use in your BRANCH instruction.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Will
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Post Edited (Jon Williams) : 4/6/2005 5:55:02 PM GMT
Will
<edit> nevermind </edit>
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
I'll attach the file.
SERIN RxD, Baud, TmOut, Toggle_Leds, [noparse][[/noparse]BIN4 cmd]
-- with PBASIC you can move the individual bits from cmd where the need to be used. With a small micro like the BASIC Stamp learning to conserve variable space is an importannt tool, even if you don't need it at the momemt.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
to get this ready for shop use, or is there a better board?
I have also attached the final code.
Thanks again,
Will
You've got a couple small errors in your program. Change....
cmd(4) = 0 to cmd = 0
and...
DEBUG STR cmd to DEBUG BIN4 cmd
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Will
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
in my code i have:
i can receive my "ready..." prompt, but the BS2 dosen't want to receive.
is the serial port on the module only for programing...?
thanks,
Will
However, you need to use "16" for both SERIN and SEROUT. Really, the I/O pins go from 0 to 15. The I/O pin 16 is only used for SERIN/SEROUT, and indicate that the BS2 should use the programming port.
SERIN 16 ... reads the 'RX' pin (physical pin 2?). SEROUT 16 ... writes the 'TX' pin (physical pin 3?).
Thanks,
Will
Have a look at this: http://www.parallax.com/dl/docs/cols/nv/vol1/col/nv6.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
I had a 2n2222 to the relay, to protect the stamp, should I just use the transistor?· Maybe not the 2222, cause my load draws 150mA @ 12v.· Those relays have built in diodes.· I'm still trying to figure out why they are staying latched.
Thanks again,
Will
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
I am driving it high, w/ a 1k resistor in line w/ the base.
Will
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
And of course as Jon mentioned, what are doing to turn off the transistor?
simpilied code:
1 = +5vDC and 0 = 0v, right...?
·
You can use the schematic program that comes with ExpressPCB -- it's free, and will let you move your projects to a PCB more easily.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Comments, thoughts...?
Will