Stamp2 and pwm control
ROSWELL
Posts: 2
·Hello,
·I would like to know. What would be the best way using the stamp 2, to created a 35Hz square wave signal
and keeping that frequency as a constant, and vary the mock to space ratio.
·Example: Time = 35Hz fixed
············· Change duty cycle (using a pot) between 17.5% and 95%.
·Any help/schematics· would be much appreciated. Thankyou
·I would like to know. What would be the best way using the stamp 2, to created a 35Hz square wave signal
and keeping that frequency as a constant, and vary the mock to space ratio.
·Example: Time = 35Hz fixed
············· Change duty cycle (using a pot) between 17.5% and 95%.
·Any help/schematics· would be much appreciated. Thankyou
Comments
Heres some code that lets a 10k POT adjust the flash rate of a LED, but the code is really BAD..
DO
HIGH 13 'turns pin 13 High when the ForNext is done.
FOR mycounterOff = timeOff1 TO 1 ' updates timing so when you change your POT, the change is immediate
HIGH 9 'charges capacitor
PAUSE 10 'lets the capacitor charge, adjust for your cap
RCTIME 9, 1, timeOff 'calculates the amount of time it takes your cap to discharge thru your 10k POT
LOW 13 ' makes sure pin 13 is low for length of time off.
timeOff1 = timeOff / 50 'makes the POT range not as wide.
IF timeOff1 = 0 THEN timeOff1 = 1 ' makes sure 0 isn't used as a time.
NEXT
LOOP
If you would like to adjust the on and off times, copy above code, rename variables, and pins for the on time POTl, and capacitor.
Post Edited (BPM) : 6/25/2005 5:55:45 PM GMT
But when using pause times, obviously this uses your BS2 to waste processing time. Thats why external clock sources are better.
They don't require you to stop the BS2 using pause to make the proper 35hz signal. Once you have a stable reference input for the BS2 you can use math to make a 35hz do loop to one of your output pins.
BE AWARE THAT I MAY BE TALKING OUT OF MY REAR. Sometimes I think I know what im saying, but after trying it, 3 other problems pop up. [noparse]:)[/noparse]