BS1 code to BS2 code
Emery Wayman
Posts: 18
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
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
·· 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
·· 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
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
·· A 3055?· Do you need that much current capability?· What are the ratings for this bulb?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
·· 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
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
Does this incandescent lamp·run from·low-voltage AC or from DC?
·· 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
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 -->
· 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.]
·
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
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 -->
C'mon, Emery Wayman -- spill the beans, bro'.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Thanks,
Emery
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (Chris Savage (Parallax)) : 6/28/2006 4:11:43 PM GMT
·· 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
Thanks again,
Emery
I love it. It works great. You are a GENIUS. Thanks for helping me out.
Best wishes now and for always.
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
If I take the LED out of the circuit then the incandescent flickers so I leave the LED in the circuit. Go figure.
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
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 Savage
Parallax Tech Support
csavage@parallax.com
I tried sending the schematic. Did it get there?
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
·· 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