Shop OBEX P1 Docs P2 Docs Learn Events
BS1 code to BS2 code — Parallax Forums

BS1 code to BS2 code

Emery WaymanEmery Wayman Posts: 18
edited 2006-07-05 19:52 in BASIC Stamp
Hi Can anyone covert a BS1 code so that I can load it on my BS2

BS1 code is:·

'This BS1-IC program generates a PWM signal on an I/O pin to make a light
'turn on and off in a "Brightening/Dimming" motion.· The speed of the
'bright/dim cycle is determined by a potentiometer dial.
SYMBOL Duty······· = B0······ 'The duty value of the PWM signal
SYMBOL StepVal···· = B1······ 'The number of steps of "duty" to skip
SYMBOL SpeedDivisor = 20····· 'This is the number of divisions for the
····························· 'POT.· A highere value here will make the
····························· 'dial less sensitive.· A lower value will
····························· 'make the dial more sensitive.
SYMBOL PotScale··· = 32······ 'After the circuit is wired, press ALT-P
····························· 'then press Enter in the Stamp I editor.
····························· 'Turn the potentiometer dial all the way
····························· 'from one side to the other and find the
····························· 'smallest number displayed for SCALE.
····························· 'Enter this value in place of the current
····························· 'number in the PotScale line
'I/O pin 0 goes to the potentiometer
'I/O pin 1 goes to the Solid State Relay
Loop:
'First, we'll read the value of the POT
POT 0,PotScale,StepVal
'Now, we'll divide it down to calculate the duty stepping value
StepVal = StepVal MIN SpeedDivisor / SpeedDivisor
'Generate the "brightening" PWM signal
FOR Duty = 0 TO 150 STEP StepVal
· PWM 1,Duty,6
NEXT Duty
'Generate the "dimming' PWM signal
FOR Duty = 150 TO 0 STEP -StepVal
· PWM 1,Duty,6
NEXT Duty
GOTO Loop

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-26 17:12
    Emery,

    ·· The·attached code will do what you ask using the attached schematic.· This is merely one way of accomplishing this task.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Emery WaymanEmery Wayman Posts: 18
    edited 2006-06-26 22:16
    Hi Chris,· Thank you for the reply and attachments.· I hooked it up the way it shows on the site and the LED does turn off and on very nice just like I like it to, but I can't get it to control my solid state relay to the 12 volt incandescent light.· Maybe I'm hooking the relay up to the wrong place on the output of the circuit.· Can you help me on that?·· Thanks,· Emery
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-27 00:15
    Emery,

    ·· An SSR is not designed to work that way...They're either on or off...The PWM command on the BASIC Stamp is designed to generate an Analog Voltage which is powering the LED.· This just isn't possible with the SSR.· About the only way you could simulate it is using high-speed PWM, which the BASIC Stamp is not going to do.· Even then it will be difficult.·

    ·· If I were you I would use a power-transistor to drive the 12V lamp instead of the SSR...That way you have full analog control of it and could probably use the circuit I posted with very little modification.·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Emery WaymanEmery Wayman Posts: 18
    edited 2006-06-27 01:07
    Hi Chris,
    I could probably use a 3055 transistor. Would you please show me how to interface it with the BS2 circuit that you posted, so it would do as you say?
    Emery
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-27 03:21
    Emery,

    ·· A 3055?· Do you need that much current capability?· What are the ratings for this bulb?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Emery WaymanEmery Wayman Posts: 18
    edited 2006-06-27 14:00
    The bulb is a 20 watt 12 volt halogen so I guess that it would need about 2 amps. Is that right?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-27 14:13
    Emery,

    ·· About 1.67A...I will see if I have a comparable bulb in my automotive drawers and see what I can come up with.· I don't have one here at the office like that so it will be a few hours before I get to it.· I will post what I come up with here.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Emery WaymanEmery Wayman Posts: 18
    edited 2006-06-27 18:43
    Hey Chris,

    Thank you so much for taking the time to help me with this project. It's really important to me that I get this circuit to operate properly. I've been struggling wtih it for about 3 weeks now so I really appreciate your extra support.

    Emery
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-28 13:38
    A solid-state relay, SSR, cannot be used to switch a DC output (unless it is something special.)·

    Does this incandescent lamp·run from·low-voltage AC or from DC?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-28 14:00
    PJ,

    ·· There are DC versions of an SSR just as there are AC versions.· Control-wise they work the same...But most of the newer AC units have zero-crossing detectors in them that only allow the OFF-ON transition at the zero-crossing point.· This can hinder high-speed PWM of the SSR.· To be honest I don't know inner-working details of the DC versions, but I would guess they're MOSFET-based, using an opto as a trigger (for the gate).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-06-28 14:03
    P J -

    I don't mean to dispute what you say, but I don't read this as you seem to:
    http://www.crydom.com/products/productFamilyList.aspx?idProductLine=2

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-28 14:44
    · Emery Wayman hasn't specified what/which "SSR" he was trying to use.· I suspect it is a typical AC Switching sort.· Most all of the units in Bruce's list are "AC Switching".·
    · Additionally, CS & BB, if you all will read my (un-edited) previous post I mentioned that the SSR would have to be something special (I caveated, didn't I) to switch DC.· Does Parallax sell a DC-switching SSR?

    · N.B. -- with regard to Bruce's link (http://www.crydom.com/products/productFamilyList.aspx?idProductLine=2)·and they way that I read it:· 14 of 'em are described as "AC switching"; 3 are described as "DC switching"; and 4 are not so specified.

    · So, what's the deal, Emery Wayman?· Which SSR were/are you trying to use?· [noparse][[/noparse]I bet it's a AC-switcher.]
    ·
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-06-28 14:56
    PJ -

    I wasn't meaning to "bust your chops" in any way, shape, or form. I'm a software guy, and always look for a chance to learn more about what you anal-og guys seem to know smile.gif

    It LOOKED to me like they had AC and DC control circuits, and AC and DC swtching. I'm a electro-mechanical relay man by trade!

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-28 15:05
    No harm, No foul.

    C'mon, Emery Wayman -- spill the beans, bro'.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-28 15:31
    PJ has a good point...When Emery said 20 Watt 12V I assumed a DC bulb like in an automotive application.· Is this the case?· We used to carry both AC and DC SSR Modules from Opto22, but they were discontinued about 1 year ago.· I have used the DC units only a few times.· Jameco, Digi-Key, Mouser, etc. all sell them.· They look the same as their AC counterparts.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Emery WaymanEmery Wayman Posts: 18
    edited 2006-06-28 15:47
    Hi Guys, The beans are, it's a CRYDOM ODC 5 thats 3-8 vdc control, 60 dc 3A out. I have a BS1 that has the code loaded in it that I posted on the beginning of this discussion. It's been slowly turning on and off a 12 volt 20 watt halogen spotlight for 8 years. I am just trying to get a BS2 to do the same thing as the BS1, with no results. I can get the BS2 to turn a single LED slowly on and then turn it off slowly in a continuous cycle, but the BS2 won't control the CRYDOM relay I have in the same way that the BS1 does. I thought if there was a way to convert the code I have on my BS1 to a code that would operate my BS2 the same way as the BS1 does that it would solve my problem. Please illuminate me.

    Thanks,
    Emery
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-28 16:02
    Okay, so the bulb is 12V.· I will test 2 circuits when I get home to see if this can be done using either the power transistor or possibly a MOSFET.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com


    Post Edited (Chris Savage (Parallax)) : 6/28/2006 4:11:43 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-29 05:00
    Emery,

    ·· Because of the differences between MOSFETs and Power Transistors, and me not having a darlington at home, I decided to use a MOSFET.· Now, there are always going to be variances between components.· The following schematic and code provided a nice (BRIGHT) fade from off to on to off cycle.· Because of the way the MOSFET works it will get very hot running like this so you will need to heatsink it.· You may need to adjust the values in the FOR...NEXT loop to get exact on/off values for your setup.· Doing this with power transistors would require a good darlington so as not to draw too much current from the Stamp I/O pin.· I took the easier road.· Besides, this MOSFET can handle 50W (or 9A).· Sorry for the rough schematic I drew it in like 2 minutes.· I hope this helps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Emery WaymanEmery Wayman Posts: 18
    edited 2006-06-29 14:28
    Thank you very much Chris. I'll give it a go and report back to you. I really appreciate the fact that you have spent some of your own time at home to help me solve this problem. I saw that you posted this to me at 10 PM last evening. That's definitely, 'Above and Beyond the call'.

    Thanks again,

    Emery
  • Emery WaymanEmery Wayman Posts: 18
    edited 2006-06-30 04:21
    Hi Chris, I put the circuit together with the CMOS like you suggested. It works great. There is a little flicker in the LED just as it's turning on and off but the Incandecent light is smooth as silk with no flicker.
    I love it. It works great. You are a GENIUS. Thanks for helping me out.

    Best wishes now and for always.

    Emery
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-01 02:21
    Emery,

    ·· I didn't realize you still had an LED hooked up.· The threshold for ON/OFF on the LED will definately be different than the ON/OFF threshold for the lamp through the MOSFET or Power Transistor.· That is likely why you're seeing that, but I'm glad you got it working.· Enjoy!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Emery WaymanEmery Wayman Posts: 18
    edited 2006-07-01 04:03
    Thanks again,

    If I take the LED out of the circuit then the incandescent flickers so I leave the LED in the circuit. Go figure.

    Emery
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-01 05:44
    Emery,

    ·· I'm curious, how do you have your circuit wired?· Can you post a schematic or wiring diagram?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Emery WaymanEmery Wayman Posts: 18
    edited 2006-07-02 01:03
    Hi Chris,

    I don't know how to draw one and send it to you without faxing it to you. You want me to do that?
    Emery
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-03 05:53
    I'm just not clear on how the LED and 12V bulb are connected to the same circuit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Emery WaymanEmery Wayman Posts: 18
    edited 2006-07-03 15:15
    Hi Chris,
    I tried sending the schematic. Did it get there?

    Emery
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-03 18:29
    Emery,

    ·· Yes, I received it...I am curious though...Your circuit doesn't look like mine.· You have a 1MOhm resistor from the Gate to ground (which I didn't use) and you do not have the 10K resistor between the Stamp I/O pin and the Gate.· The capacitor is technically missing, except that the way your circuit is configured it is leeching from the LED circuit for that.· This may be why the LED circuit is required for it to work properly.· The circuit I sent you worked fine with the MOSFET I listed and should work with most with only minor changes.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Emery WaymanEmery Wayman Posts: 18
    edited 2006-07-03 18:53
    OK Chris,· Thank you.· I will rewire the circuit and let you know.

    Emery
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-05 19:52
    Emery,

    ·· Regarding your phone question, we got off-track for a second and I never got to ask.· What did the BS1 code do that the BS2 code doesn't do?· There may be a way to do it.· But I haven't seen the BS1 code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.