Shop OBEX P1 Docs P2 Docs Learn Events
rctime larger than 65536 — Parallax Forums

rctime larger than 65536

CharlieCCharlieC Posts: 14
edited 2005-03-22 06:32 in BASIC Stamp
I have an app that checks the timing on an RC circuit and takes action if the timing is below a certain threshhold· (something like this)

RET VAR WORD

DO
·· PAUSE 1
·· RCTIME P1, RET
...
·· IF·RET < 700 THEN GOSUB DO_SOMTHG
LOOP

My problem is that the results returned by the rc circut can range from 0 to well over 65xxx, and once the word boundry has been reached, the ret is set to 0.

Sinse I might lagitamely have a 0 output, this is confusing things.· Is there any way to capture a value gater than·the 16 bit word?· I think from some other conversation, this might not be resolvable.

Charlie

·

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Charlie Chisholm

That part, at least,·I'm sure of.

Comments

  • NewzedNewzed Posts: 2,503
    edited 2005-03-17 16:38
    You haven't indicated your RC values, which makes it difficult to help.

    If you use circuit (a) in the Stamp RCTime help files, with R = 220 and C = .1uf and a 5K pot you can get values on a BS2 from 0 to about 680.· A resistor of 1.2K in place of the pot will give you a reading of about 53.

    Your program needs to say:

    high pin
    pause 5
    RCTIME pin, 1, ret
    debug "Time = ", dec3 ret, cr

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    NEW! 4 MB EEPROM

    http://hometown.aol.com/newzed/page4.html
    ·
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-17 16:52
    You haven't disclosed what exactly you are trying to do (do your really need a time value precision greater than 16 bit, or are you just using a resistor and capacitor that are too large?), but in the vast majority of times you are going to be able to specify the R or the C or both, this will allow you to change the charge and discharge time, heres a link that describes the equation. http://hyperphysics.phy-astr.gsu.edu/hbase/electric/capdis.html

    Not knowing what your actually trying to do, I cannot provide any further help.

    Post Edited (Paul Baker) : 3/17/2005 4:56:31 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-17 17:03
    If your RCTIME result is too big, and the R part is variable, change the C part to a smaller value. We typically recomment a 0.1 uF cap -- but it you're using a very large R component then you may want to change the C to 0.047 uF or even 0.01 uF.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • CharlieCCharlieC Posts: 14
    edited 2005-03-17 17:10
    The resistance varies from less than an ohm to around 5M. (photo resister), and I can use any cap that will give me a pretty wide range of values (I think I am using a .001mf at presnt - a am at the office, not able to check). The project is to see how finely I can read changes in surface reflectivity in varying (and sometime very low) lighting conditions. Just a learning project.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Charlie Chisholm

    That part, at least,·I'm sure of.
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2005-03-17 17:16
    Can you put a resistor in parallel with your 5M photo resistor? ...say another 5M or 10M resistor. It really depends on what value the photoresistor is before
    you have an overflow. If you can determine this value with your circuit, then place a parallel resistor so that it in combination with your photoresistor will come
    very close but never reach the overflow value.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071
  • CharlieCCharlieC Posts: 14
    edited 2005-03-17 17:25
    That is certainly worth trying. I will give it a shot.

    I had originally wanted to keep the wide swing in values so that I could more easily perseive a small change, but I am starting to think that would over-complicate it.

    Thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Charlie Chisholm

    That part, at least,·I'm sure of.
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2005-03-17 18:10
    Charlie,

    Keep in mind that by placing a resistor in parallel with a pot, you "de-linearize" the pot.
    However, that said, the "POT" or photo resistor being used in your case is not linear to
    begin with.

    The image I have provided compares the effective resistance with a 5M (series 2) and 10M
    (series 3) resistor in parallel with a 5M POT (series 1).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071
    800 x 600 - 38K
    RES.JPG 38.5K
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-17 18:34
    This may be too complex for your liking, but how about using the photo resistor in a voltage divider and fed to the negative input of a transconductance amplifier whose output is connected to your cap? The output voltage of the divider would (through the transamp)·produce a variable negative current which should act like a resistor discharging the capacitor. I think this wouldn't introduce any more nonlinearity to the system. Beau, perhaps you could provide some insight if this approach would be feasible.
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2005-03-17 18:49
    Paul,

    For that matter you could effectively do a similar thing by just changing the reference voltage that the Cap
    and/or photo resistor is tied to and maintain what ever linearity the POT has to offer. I will see if I can work
    something out....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071
  • The Dead BugThe Dead Bug Posts: 73
    edited 2005-03-17 19:23
    CharlieC wrote:

    The resistance varies from less than an ohm to around 5M. (photo resister),

    Wow...I've never seen a photoresistor with such a range. Is this something unusual? Where can I get one? [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Name: Bruce Clemens

    Work:· Clemensb@otc.edu
    Good Stuff on my Blog: http://theDeadBug.journalspace.com
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2005-03-17 19:34
    Bug,

    I haven't seen one go that low.... usually in the 100's of Ohms in full sunlight,
    but the upper end is typical of a CdS cell.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    Latest Company News
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071
  • CharlieCCharlieC Posts: 14
    edited 2005-03-18 00:45
    Opps! I was at work describing this from memory. I should have reported the range of the photoresister from less than a k (~450 ohm) to about 12M (with something slightly more than total darkness)

    I am going to try the parallel resister tonight and see what that does for me.

    Paul, I am also intreged by the your suggestion, but I must admit that it is way over my head. I guess that is how I learn, though so I may see if I can do it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Charlie Chisholm

    That part, at least,·I'm sure of.
  • BeanBean Posts: 8,129
    edited 2005-03-18 00:54
    As beau pointed out, I would just put a resistor acrossed the cds cell. Maybe something as low as a couple hundred K ohms.
    A value this high will have very little effect in a light environment, and will get a handle on the dark resistance, limiting it to the value of the resistor.
    And also making the cds more linear though it's light range.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out· the "SX-Video Display Module"

    www.sxvm.com
    ·
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2005-03-18 04:38
    Bean is right, I did not think about this.... the response curve of the photocell is opposite
    of the curve of a paralleled resistor with the photocell.... The combined effect actually helps
    to linearize the total resistance.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    Latest Company News
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-18 04:38
    I was in the process of writing a nice article on transconductance amps, when I was searching for a good site explaining "voltage controlled resistor" I visited a site that automatically installed malware which in turn installed 4 viruses, 6 trojan horses, 2 worms, a web tracker program, a web hijacker program, (Explative) it just started again where the heck is that darn thing hiding, gotta go.

    Ok back (using Opera, I vetted all the programs running, It must have embedded itself into IE) anyways, back to the point, sorry but ill likely not post it at least tonight, Im too frustrated at the moment to type it all out again (anyone know a program that will strip all "extras" from IE? its passing through my virus scan and spyware programs)

    Post Edited (Paul Baker) : 3/18/2005 4:47:16 AM GMT
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-03-18 04:38
    Here are some PBASIC notes:

    RCTIME returns zero only when the time exceeds the maximum. 65535 units, 0.13107 second on a BS2. The shortest interrval it can measure returns 1, not zero. Here is a way to make it more like you might expect, with zero the minimum and 65535 the maximum:

    HIGH 1
    RCTIME 1,1,ret ' result is zero if maximum time exceeded.
    RET=RET-1 ' zero becomes 65536, and 1 becomes 0.

    To measure longer times, you could put RCTIME in a loop.

    HIGH 1
    FOR ret2=0 TO 65534
    RCTIME 1,1,ret
    IF ret>0 THEN EXIT ' got it!
    NEXT

    DEBUG HEX ret2, HEX4 ret

    The loop index, ret2, counts how many multiples of 0.131072 seconds pass before p1 goes low. Times out after about 2.5 hours.

    While it might be okay in theory, from a hardware standpoint, this is hard not really a good idea. Leakage paths may be as significant as the resistance of the CDS cell. And, RCTIME is hugely sensitive to noise as the voltage approaches the threshold.

    Another alternative, try a range switching scheme: Connect a couple of different capacitors (say 0.001uF and 0.1 uF) to the measuring pin, p1, and instead of grounding the bottom side of the 0.1uF capacitor, hook it to a Stamp pin. When that Stamp pin is an input, the capacitor is effectively out of the circuit and you can measure high resistance values against the 0.001 uf. But when the pin is a low output, it grounds the bottom plate of te 0.1 uf capacitor so that you can measure lower values of resistance.

    Very low levels of light (even those that are still perceived by our scotoptic vision) can only be measured with a photomultiplier tube.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • kelvin jameskelvin james Posts: 531
    edited 2005-03-18 06:47
    Paul, have you tried microsoft antispyware beta? Don't know if it will clean everything, but it works pretty good,and i find the real time protection from stopping anything being insatalled to the pc works also. You can get it at download.com

    kelvin
  • CharlieCCharlieC Posts: 14
    edited 2005-03-18 11:33
    Bean and Beau: I tried the the resister in parallel and it seemed work but I an not sure yet if it is the best approach. I tried using a pot instead and it gave me some adjustability, but I will have to play some more to get the right combination of cap/pot/inline resistenace. I seem to be moving head though and learning quite a bit.

    Tracy: You are taking more of a code direction, which is what I had orignally wanted to do. I had thought that maybe there was a way I could setup a staged reading using something remotely like what you suggest. I think this is something else I want to explore further. I have a BOE board and a homework board and I will probably setup the other board to play with your approach.

    Pual: I feel your pain. My department has about 350 users spread over about thirty locations and it is an ongoing nightmare to keep educating people on the dangers of the mine field that is the internet. Most everything we have run into so far could be controlled through Nortens enterprise, ad-aware, spybot s&d and some policy and internet settings. I would like to know more about this site you hit. we have not run into one that could do as much damage as the one you discribe.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Charlie Chisholm

    That part, at least,·I'm sure of.
  • SunflowerSunflower Posts: 48
    edited 2005-03-18 16:57
    Might try two photo resistors in parallel. Check that they are similar first (balanced).
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-03-18 17:42
    Paul Baker said...
    (anyone know a program that will strip all "extras" from IE? its passing through my virus scan and spyware programs)
    Paul,

    ·· In the advanced internet options, you could try unchecking, "Enable Third Party Plug-Ins."· Also, without SP2, many things can self-install on your computer.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Tech Support
    csavage@parallax.com
  • edited 2005-03-22 06:32
    Ad-Aware and Spybot Search and Destroy are two decent programs for debugging and that sort of thing...although Ad-Aware wouldn't be much help against viruses.
Sign In or Register to comment.