RCTIME problem jittering disco
KidE
Posts: 29
Hi All,
Iḿ pretty new to embedded programming so please excuse me if i drop a stupid question here.
Iḿ working through the http://www.parallax.com/Portals/0/Downloads/docs/prod/edu/28123-WAM-v3.0.pdf manual and on page 151 im seeing some unexplained behaviour which is givving me trouble later on in the book.
The code is for measuring the rctime
The Pot that is provided with the kit is a 10K and has a range for about 640.
When is set the pot to max the measurement displayed in the debug window is pretty steady but when i turn it down tp 640 it starts jittering enormously.
Its jumping up&down in values around 20+/-
I tried a different Pot but without any luck.
The result of this is that exercises later in the book become a complete menace vy turning (supposed to be steady) LED's into a locale disco.
Iḿ using the discovery USB board
Is this behaviour exacted or am i just doing something totally wrong here ?
Regards,
Ernst
Iḿ pretty new to embedded programming so please excuse me if i drop a stupid question here.
Iḿ working through the http://www.parallax.com/Portals/0/Downloads/docs/prod/edu/28123-WAM-v3.0.pdf manual and on page 151 im seeing some unexplained behaviour which is givving me trouble later on in the book.
The code is for measuring the rctime
time VAR Word PAUSE 1000 DO HIGH 7 PAUSE 100 RCTIME 7, 1, time DEBUG HOME, "time = ", DEC5 time LOOP
The Pot that is provided with the kit is a 10K and has a range for about 640.
When is set the pot to max the measurement displayed in the debug window is pretty steady but when i turn it down tp 640 it starts jittering enormously.
Its jumping up&down in values around 20+/-
I tried a different Pot but without any luck.
The result of this is that exercises later in the book become a complete menace vy turning (supposed to be steady) LED's into a locale disco.
Iḿ using the discovery USB board
Is this behaviour exacted or am i just doing something totally wrong here ?
Regards,
Ernst
Comments
BTW, it's probably jittery when you turn it down to the "zero resistance" side of the pot? That may be an inherent problem, too low a resistance. If so, figure out what the minimum stable resistance value is (measured with a multimeter) in ohms, and add a fixed resistor of that value in series with the pot.
'
PAUSE 1
'
Take a look at this. The Pause times can effect the readings from the pot.It is time sensitive.
'
http://www.parallax.com/Portals/0/Downloads/docs/books/sw/Web-SW-v2.1.pdf
'
http://www.parallax.com/Portals/0/Downloads/docs/prod/stamps/web-BSM-v2.2.pdf
'
The 2nd link is the BASICStampManuel...It has some good info on RCTIME too.
00001
00001
00001
00001
00001
00001
00001
00001
00022
00069
00086
00117
00168
00188
00219
00243
00299
00327
00343
00385
00437
00544
00570
00616
00630
00632
00627
00626
00633
00631
00632
00627
00626
00632
00631
00633
00628
00626
00631
00631
00633
00628
00626
00631
00630
00634
00628
00626
00635
00631
00632
00628
00630
00634
00633
00629
00616
00607
you see at the end the value sometimes differs +/- 30. also tried different caps but with no luck. how could this be?
00603
00605
00610
00613
00615
00616
00619
00621
00622
00627
00629
00630
00633
00634
00635
I did a sort -nu over the output to show the increment.
i changed the 0,1uF for a 0.01uF and the output varied from 0 to 60 where at 54 the jittering starts
swapping the 10K pot for a 25K gave the following
01356
01361
01373
01378
01393
01399
01400
01404
01408
01413
01417
01419
01420
01421
01422
01424
01425
01426
01427
01428
01429
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01444
'
Remember its the I/O pin that charges up the Cap The resister is reducing the charge to the Cap in your circuit. They should be slowly discharging the Cap only.
'
Another thing to remember is the Cap does not drain down to zero volts for the RCTIME command. It drains down to the threshold voltage. This voltage is around 2.5volts. So the window of time to measure is pretty tight for the RCTIME command.
It seemed i had a faulty jumper wire which was causing all the problems
In the reference manual i found the part regarding RCTIME and i build the following:
with code:
I found that the first "PAUSE 1" makes a major difference in the output and stability of the RCTIME value but i don't yet understand why.
Is there a good explanation for this? I myself thought that it had to do with the HIGH 2 command which is executed just before.
Is this assumption correct?
Shouldn't this be 1.4V ? at least thats what i'm reading in the manual or are you talking about another threshold?
Another caveat is that the 220 ohm resistor forms a voltage divider with the variable resistor, so for best results the value of the variable resistor should stay >> 220Ω.
You can rearrange that a little to allow more time for C to charge up to the high level:
643
645
654
655
660
663
664
665
666
667
668
669
671
This is when the POT is turned to the max left. The difference is about 28. If i do this with my code the difference is max 2
So i see your point about the flow but how do i get a stable value that i can use as input for steering while upholding your suggestion and giving the capacitor enough time to fully load?
At the end those readings are quite steady, varying only by 3. The variation of 28 there is only at the beginning of the sequence. I don't know what that means, because I'd have to make too many guesses about the setup and the procedure. I noticed that same trend in some of your other posted results too. They settle down to rather steady values at the end and the big variation is at the beginning. Maybe that is because you were turning the pot, or it was still settling into place, and there are other effects that can happen in the capacitor or the Stamp. I think you are better off with a larger resistance pot, the 25k, or 100k.
Another thing you have to watch out for with RC time is the length of wires. For example, the wire from the pot and capacitor over to Vss should be pretty short, not a big fat loop. Big loops of wire can pick up lots of external noise and noise produced by digital switching in the BASIC Stamp chip itself. The same is true for the other wires. Also the contacts should be nice and tight. Sometimes the contacts in a BOE become so loose that they do not make good contact. The best results with RCtime always come from really tight wiring practice. If you want more to read, I have an artice about RCTIME at this URL.
There will always be some jitter, but once you have it down to a reasonable level, more can be removed with a simple software lowpass filter.
'
Glad to here you got it working!
'
I said 2.5 volts...I meant around 1.5 volts sorry.
'
My point was it was not zero volts.
I indeed noticed that unequal length of wire can cause strange things here.
But please enlighten me about this low pass filter. How would you do this in this case?
But why call this a low-pass filter and not high-pass?