Weird Problem
Archiver
Posts: 46,084
Greetings,
I've encountered and interesting problem of sorts.
I'm using the PWM function to ramp up a LED so I can measure the
brightness via Stamp-Plot so I can better design an algorithm to
perform a consistent linear ramp instead of the fast start and slow
finish LEDs tend to produce. I'm trying to go beyond the "power"
type formulas and get things as consistant as possible.
I have 2 BS2-SX's, one ramps the LED up and the other has the CDS
cell sensor that is plugged in to Stamp plot.
I programmed each stamp initially from my laptop and it worked
perfect and I got the graph I was looking for, but it was a pain to
keep switching cables to make adjustments. So I hooked the LED ramp
Stamp to my desktop and ran the exact same program that was in the
laptop:
'{$STAMP BS2sx}
'{$PBASIC 2.5}
tip1 VAR Word
DO
FOR tip1 = 0 TO 255
PWM 1, tip1, 15
pause 1
NEXT
FOR tip1 = 255 TO 0
PWM 1, tip1, 15
pause 1
NEXT
LOOP
As you can see it ramps up and then ramps down and continues to
loop. (I do add in a few more things to slow the output down for the
light measurement activity)
The problem I've encountered while programming from the desktop is
that the first For-Next only goes to 64 and then resets itself back
to 0 and repeats. The ramp down never runs. I checked this with the
debug. On the laptop the exact same program ramps up to 255 and
then ramps back down to 0.
I tried it with a few different serial cables on both the laptop and
the desktop and the desktop always screws it up with the 64
problem. I tried different pins.. same results.
I tried: FOR tip1 = 66 to 255 and the desktop sits at 66 most of the
time and maybe a 67 every once in a while, and it runs perfect 66-
255 on the Laptop. I've also switched the Stamps around and same
problem occurs. I tried different variable declarations and names
and still no fix. I've tried DO WHILE LOOPS, GOTO's and just about
every variation I could think of but can't get the variable past 64.
The funny thing is that when I remove the PWM command and check the
For-Next variable with Debug, the desktop goes to 255 and then back
to zero, just as it should, just as it does on the laptop.
I quasi-fried my PAK V PWM co-pro last week so I've been stuck with
the stock PWM command until my new ones arrive. (Pak V's are the
only way to go with PWM, I highly recommend picking one up if you
mess with PWM's a lot)
Everything is exactly the same, with one exception, I run XP on the
desktop and Win98/SE on the laptop.
Suggestions?
Resc.
Ps. If anyone is interested I will have a bunch of data available on
a few types of LEDs in Excel and on a Stamp Plot Screen cap with
respect to the non-linear rampup/down measurements.
I've encountered and interesting problem of sorts.
I'm using the PWM function to ramp up a LED so I can measure the
brightness via Stamp-Plot so I can better design an algorithm to
perform a consistent linear ramp instead of the fast start and slow
finish LEDs tend to produce. I'm trying to go beyond the "power"
type formulas and get things as consistant as possible.
I have 2 BS2-SX's, one ramps the LED up and the other has the CDS
cell sensor that is plugged in to Stamp plot.
I programmed each stamp initially from my laptop and it worked
perfect and I got the graph I was looking for, but it was a pain to
keep switching cables to make adjustments. So I hooked the LED ramp
Stamp to my desktop and ran the exact same program that was in the
laptop:
'{$STAMP BS2sx}
'{$PBASIC 2.5}
tip1 VAR Word
DO
FOR tip1 = 0 TO 255
PWM 1, tip1, 15
pause 1
NEXT
FOR tip1 = 255 TO 0
PWM 1, tip1, 15
pause 1
NEXT
LOOP
As you can see it ramps up and then ramps down and continues to
loop. (I do add in a few more things to slow the output down for the
light measurement activity)
The problem I've encountered while programming from the desktop is
that the first For-Next only goes to 64 and then resets itself back
to 0 and repeats. The ramp down never runs. I checked this with the
debug. On the laptop the exact same program ramps up to 255 and
then ramps back down to 0.
I tried it with a few different serial cables on both the laptop and
the desktop and the desktop always screws it up with the 64
problem. I tried different pins.. same results.
I tried: FOR tip1 = 66 to 255 and the desktop sits at 66 most of the
time and maybe a 67 every once in a while, and it runs perfect 66-
255 on the Laptop. I've also switched the Stamps around and same
problem occurs. I tried different variable declarations and names
and still no fix. I've tried DO WHILE LOOPS, GOTO's and just about
every variation I could think of but can't get the variable past 64.
The funny thing is that when I remove the PWM command and check the
For-Next variable with Debug, the desktop goes to 255 and then back
to zero, just as it should, just as it does on the laptop.
I quasi-fried my PAK V PWM co-pro last week so I've been stuck with
the stock PWM command until my new ones arrive. (Pak V's are the
only way to go with PWM, I highly recommend picking one up if you
mess with PWM's a lot)
Everything is exactly the same, with one exception, I run XP on the
desktop and Win98/SE on the laptop.
Suggestions?
Resc.
Ps. If anyone is interested I will have a bunch of data available on
a few types of LEDs in Excel and on a Stamp Plot Screen cap with
respect to the non-linear rampup/down measurements.
Comments
unplug the serial cable? Does it run okay then? It sounds like the
Stamp is resetting. Put a 'DEBUG "top"' command before the do loops
to detect reset. Is this mounted on a Parallax BOE board, or
something like that, and powered with a wallwart? Try a
supplemental 10 uF capacitor across the 5 volt supply. I don't know
why, but there might be some interaction with the PC grounding or
something.
-- Tracy
>Greetings,
>
>I've encountered and interesting problem of sorts.
>
>I'm using the PWM function to ramp up a LED so I can measure the
>brightness via Stamp-Plot so I can better design an algorithm to
>perform a consistent linear ramp instead of the fast start and slow
>finish LEDs tend to produce. I'm trying to go beyond the "power"
>type formulas and get things as consistant as possible.
>
>I have 2 BS2-SX's, one ramps the LED up and the other has the CDS
>cell sensor that is plugged in to Stamp plot.
>
>I programmed each stamp initially from my laptop and it worked
>perfect and I got the graph I was looking for, but it was a pain to
>keep switching cables to make adjustments. So I hooked the LED ramp
>Stamp to my desktop and ran the exact same program that was in the
>laptop:
>
>
>'{$STAMP BS2sx}
>'{$PBASIC 2.5}
>
>tip1 VAR Word
>
>DO
>
> FOR tip1 = 0 TO 255
>
> PWM 1, tip1, 15
> pause 1
>
> NEXT
>
>
> FOR tip1 = 255 TO 0
>
> PWM 1, tip1, 15
> pause 1
>
> NEXT
>
>LOOP
>
>
>
>As you can see it ramps up and then ramps down and continues to
>loop. (I do add in a few more things to slow the output down for the
>light measurement activity)
>
>The problem I've encountered while programming from the desktop is
>that the first For-Next only goes to 64 and then resets itself back
>to 0 and repeats. The ramp down never runs. I checked this with the
>debug. On the laptop the exact same program ramps up to 255 and
>then ramps back down to 0.
>
>I tried it with a few different serial cables on both the laptop and
>the desktop and the desktop always screws it up with the 64
>problem. I tried different pins.. same results.
>
>I tried: FOR tip1 = 66 to 255 and the desktop sits at 66 most of the
>time and maybe a 67 every once in a while, and it runs perfect 66-
>255 on the Laptop. I've also switched the Stamps around and same
>problem occurs. I tried different variable declarations and names
>and still no fix. I've tried DO WHILE LOOPS, GOTO's and just about
>every variation I could think of but can't get the variable past 64.
>
>The funny thing is that when I remove the PWM command and check the
>For-Next variable with Debug, the desktop goes to 255 and then back
>to zero, just as it should, just as it does on the laptop.
>
>I quasi-fried my PAK V PWM co-pro last week so I've been stuck with
>the stock PWM command until my new ones arrive. (Pak V's are the
>only way to go with PWM, I highly recommend picking one up if you
>mess with PWM's a lot)
>
>Everything is exactly the same, with one exception, I run XP on the
>desktop and Win98/SE on the laptop.
>
>Suggestions?
>
>Resc.
>
>Ps. If anyone is interested I will have a bunch of data available on
>a few types of LEDs in Excel and on a Stamp Plot Screen cap with
>respect to the non-linear rampup/down measurements.
>
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the
>Subject and Body of the message will be ignored.
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Been there, tried it all. If I program it from the desktop and
remove the cable, it doesn't work. But if I plug the cable in from
the laptop and reprogram it with the exact same program and remove
the cable, it works. I have a server that stores all of my Stamp
file, so I know it's running the exact same program too. I've
reinstalled the Stamp software on the desktop, no help. The loops
seem to work but just not with the PWM command for some reason. I
give it a loop of 255 HIGH 1 LOW 1 and it works, but the PWM gives
it an ulcer for some reason.. It's powered from a Lab type power
supply and I've tried it with batteries too, same effect. So I'm
thinking it some kind of software problem on my desktop.
I've encountered a similar problem with a previous BS2SX when using
a ULN2803 Darlington and the PWM command. If I plumbed the 2803 with
5 Volts everything was perfect, it ramped to 255. But when I plumbed
the 2803 with 12 Volts the thing would puke and reset when the loop
go to about 128. I checked the specs on every 2803 spec sheet I
could find and read every Stamp doc on the subject twice, so I know
everything was wired right but it still puked for some reason.. I
don't know if it still acts weird with the 2803 as It kind of
spooked me and I haven't tried it with a 2803 since. I use the 2803
with a Pak V and everything runs perfect so I go that route with my
PWM stuff.
This time around it's doing something similar but there isn't a
2803. I've tried various boards in my collection and both 2SX's
(one is brand new) and same problem in every setup with every cable,
board and power system. I've debugged it to death at every possible
spot and still no clue as to what's happenen.
I usually run my for/next loops at 4 to 1020 and divide the result
by 4 to slow the thing down instead of using pause statements and
the desktop still pukes when the counter reaches 255-256, which is
about 64 to the PWM after the math..
I think my desktop is haunted by the ghost of my previous oopic..
Resc.
--- In basicstamps@yahoogroups.com, Tracy Allen <tracy@e...> wrote:
> What happens if you program the Stamp on the desktop machine and
then
> unplug the serial cable? Does it run okay then? It sounds like
the
> Stamp is resetting. Put a 'DEBUG "top"' command before the do
loops
> to detect reset. Is this mounted on a Parallax BOE board, or
> something like that, and powered with a wallwart? Try a
> supplemental 10 uF capacitor across the 5 volt supply. I don't
know
> why, but there might be some interaction with the PC grounding or
> something.
>
> -- Tracy
>
>
>
>
> >Greetings,
> >
> >I've encountered and interesting problem of sorts.
> >
> >I'm using the PWM function to ramp up a LED so I can measure the
> >brightness via Stamp-Plot so I can better design an algorithm to
> >perform a consistent linear ramp instead of the fast start and
slow
> >finish LEDs tend to produce. I'm trying to go beyond the "power"
> >type formulas and get things as consistant as possible.
> >
> >I have 2 BS2-SX's, one ramps the LED up and the other has the CDS
> >cell sensor that is plugged in to Stamp plot.
> >
> >I programmed each stamp initially from my laptop and it worked
> >perfect and I got the graph I was looking for, but it was a pain
to
> >keep switching cables to make adjustments. So I hooked the LED
ramp
> >Stamp to my desktop and ran the exact same program that was in the
> >laptop:
> >
> >
> >'{$STAMP BS2sx}
> >'{$PBASIC 2.5}
> >
> >tip1 VAR Word
> >
> >DO
> >
> > FOR tip1 = 0 TO 255
> >
> > PWM 1, tip1, 15
> > pause 1
> >
> > NEXT
> >
> >
> > FOR tip1 = 255 TO 0
> >
> > PWM 1, tip1, 15
> > pause 1
> >
> > NEXT
> >
> >LOOP
> >
> >
> >
> >As you can see it ramps up and then ramps down and continues to
> >loop. (I do add in a few more things to slow the output down for
the
> >light measurement activity)
> >
> >The problem I've encountered while programming from the desktop is
> >that the first For-Next only goes to 64 and then resets itself
back
> >to 0 and repeats. The ramp down never runs. I checked this with
the
> >debug. On the laptop the exact same program ramps up to 255 and
> >then ramps back down to 0.
> >
> >I tried it with a few different serial cables on both the laptop
and
> >the desktop and the desktop always screws it up with the 64
> >problem. I tried different pins.. same results.
> >
> >I tried: FOR tip1 = 66 to 255 and the desktop sits at 66 most of
the
> >time and maybe a 67 every once in a while, and it runs perfect 66-
> >255 on the Laptop. I've also switched the Stamps around and same
> >problem occurs. I tried different variable declarations and names
> >and still no fix. I've tried DO WHILE LOOPS, GOTO's and just about
> >every variation I could think of but can't get the variable past
64.
> >
> >The funny thing is that when I remove the PWM command and check
the
> >For-Next variable with Debug, the desktop goes to 255 and then
back
> >to zero, just as it should, just as it does on the laptop.
> >
> >I quasi-fried my PAK V PWM co-pro last week so I've been stuck
with
> >the stock PWM command until my new ones arrive. (Pak V's are the
> >only way to go with PWM, I highly recommend picking one up if you
> >mess with PWM's a lot)
> >
> >Everything is exactly the same, with one exception, I run XP on
the
> >desktop and Win98/SE on the laptop.
> >
> >Suggestions?
> >
> >Resc.
> >
> >Ps. If anyone is interested I will have a bunch of data available
on
> >a few types of LEDs in Excel and on a Stamp Plot Screen cap with
> >respect to the non-linear rampup/down measurements.
> >
> >
> >
> >To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@yahoogroups.com
> >from the same email address that you subscribed. Text in the
> >Subject and Body of the message will be ignored.
> >
> >
> >Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
>Greetings,
>
>I've encountered and interesting problem of sorts.
>
>I'm using the PWM function to ramp up a LED so I can measure the
>brightness via Stamp-Plot so I can better design an algorithm to
>perform a consistent linear ramp instead of the fast start and slow
>finish LEDs tend to produce. I'm trying to go beyond the "power"
>type formulas and get things as consistant as possible.
>
>I have 2 BS2-SX's, one ramps the LED up and the other has the CDS
>cell sensor that is plugged in to Stamp plot.
>
>I programmed each stamp initially from my laptop and it worked
>perfect and I got the graph I was looking for, but it was a pain to
>keep switching cables to make adjustments. So I hooked the LED ramp
>Stamp to my desktop and ran the exact same program that was in the
>laptop:
Just for kicks, try changing "tip1" from a WORD sized variable to a BYTE
sized variable, and see what happens. The value is limited to 255 by the
PWM Command.
>
>'{$STAMP BS2sx}
>'{$PBASIC 2.5}
>
>tip1 VAR Word
>
>DO
>
> FOR tip1 = 0 TO 255
> PWM 1, tip1, 15
> pause 1
> NEXT
>
> FOR tip1 = 255 TO 0
> PWM 1, tip1, 15
> pause 1
> NEXT
>LOOP
>
>
Bruce Bates
Been there tried that to. I declared 10 different variables 4
different ways and same result.
Resc
--- In basicstamps@yahoogroups.com, Bruce Bates <bvbates@u...> wrote:
> At 06:44 AM 11/1/03 +0000, rescme1 wrote:
> >Greetings,
> >
> >I've encountered and interesting problem of sorts.
> >
> >I'm using the PWM function to ramp up a LED so I can measure the
> >brightness via Stamp-Plot so I can better design an algorithm to
> >perform a consistent linear ramp instead of the fast start and
slow
> >finish LEDs tend to produce. I'm trying to go beyond the "power"
> >type formulas and get things as consistant as possible.
> >
> >I have 2 BS2-SX's, one ramps the LED up and the other has the CDS
> >cell sensor that is plugged in to Stamp plot.
> >
> >I programmed each stamp initially from my laptop and it worked
> >perfect and I got the graph I was looking for, but it was a pain
to
> >keep switching cables to make adjustments. So I hooked the LED
ramp
> >Stamp to my desktop and ran the exact same program that was in the
> >laptop:
> Just for kicks, try changing "tip1" from a WORD sized variable to
a BYTE
> sized variable, and see what happens. The value is limited to 255
by the
> PWM Command.
>
> >
> >'{$STAMP BS2sx}
> >'{$PBASIC 2.5}
> >
> >tip1 VAR Word
> >
> >DO
> >
> > FOR tip1 = 0 TO 255
> > PWM 1, tip1, 15
> > pause 1
> > NEXT
> >
> > FOR tip1 = 255 TO 0
> > PWM 1, tip1, 15
> > pause 1
> > NEXT
> >LOOP
> >
> >
>
> Bruce Bates
>thinking it some kind of software problem on my desktop.
Are you suggesting there might be a difference in the what ends up
burned into the Stamp eeprom by the same program code on your two
computers? That would be weird indeed, and especially that it would
affect only the PWM command.
You can test that theory (that the code burned is different), by
prefacing your PWM DO loop with an eeprom readout, as follows:
'
'{$STAMP BS2pe}
'{$PBASIC 2.5}
tip1 VAR Word
idx VAR Word
code VAR Byte
PAUSE 512
FOR idx=$7a0 TO $7ff ' dump 6 blocks eeprom contents
READ idx,code
IF idx//16=0 THEN DEBUG CR,IHEX4 idx 'address per block
DEBUG 32,HEX2 code
NEXT
DO
FOR tip1 = 0 TO 255
PWM 1, tip1, 15
PAUSE 1
NEXT
FOR tip1 = 255 TO 0
PWM 1, tip1, 15
PAUSE 1
NEXT
LOOP
When you have the whole thing programmed, look at the CTRL-M memory
map screen and write down or screen capture the whole sequence of
codes you see there. I see the following:
$07A0 00 00 68 B0 C4 12 68 76 C0 33 3B FE CF C1 15 E0
$07B0 15 F0 8F 67 FE 99 FD FF F9 06 35 3B E0 99 1D C1
$07C0 FF E7 0A F0 0A F8 C7 33 FF CC 3E 18 01 41 3B 60
$07D0 9A 1D A0 57 FF 5F 8D 92 83 9F A6 04 21 53 CD D0
$07E0 1C 78 D7 7A 04 21 53 CD 21 40 02 03 68 70 83 A9
$07F0 C8 34 A7 74 06 64 42 F3 0F ED 41 AF AE 48 07 C0
(Those are the codes that will be burned into eeprom when you hit
RUN. I used a BS2pe, but it should be exactly the same for a '2sx)
Then RUN the program and look at the codes that appear on the debug
screen. That is what is really stored in the eeprom. And do it on
both the laptop and the weird desktop. If they all match, the
programs are okay and you have to look elsewhere for the problem.
But if they don't match, well, weird is the word.
>I've encountered a similar problem with a previous BS2SX when using
>a ULN2803 Darlington and the PWM command. If I plumbed the 2803 with
>5 Volts everything was perfect, it ramped to 255. But when I plumbed
>the 2803 with 12 Volts the thing would puke and reset when the loop
>go to about 128.
Did that also involve a difference in results between the desktop
computer and the laptop computer?
-- Tracy
connected directly to DTR or through a capacitor?
You should use a circuit like
http://www.emesystems.com/BS2rs232.htm#resets
Furthermore, check your hardware for shorts - particularly on
locations where you least expected them (I once had a case where
a solder contact of a keyboard touched an LCD's metal frame and
caused a reset whenever the serial cable touched
the serial port of my desktop - but it was working however on my
notebook).
Regards
Adrian
few odd irregularities but I still couldn't find the problem...
Grrr.. But after reading the bit on rs232 issues it led me down the
serial line and into my desktop.... Where I found the ribbon cable
that goes from the motherboard to the DB9 on the outside had come
somewhat loose. After reseating it the problem disappeared...
Grrr.. Thanks for the help gentlemen.
Note to self: "Don't bang your head on the desktop when all is going
wrong"
I'll post the schematics to my before mentioned darlington problem
some day soon..
Resc.
--- In basicstamps@yahoogroups.com, "Adrian Schneider"
<adrian.schneider@t...> wrote:
> PWM can produce a lot of noise. Is the ATN line of your stamp
> connected directly to DTR or through a capacitor?
> You should use a circuit like
> http://www.emesystems.com/BS2rs232.htm#resets
>
> Furthermore, check your hardware for shorts - particularly on
> locations where you least expected them (I once had a case where
> a solder contact of a keyboard touched an LCD's metal frame and
> caused a reset whenever the serial cable touched
> the serial port of my desktop - but it was working however on my
> notebook).
>
> Regards
> Adrian