can someone help me with RCTIME


Closed Thread
Results 1 to 26 of 26
  1. #1
    Join Date
    May 2007
    Posts
    26

    Unhappy can someone help me with RCTIME

    I have been having problem getting RCTIME to work it always results in 1 even when nothing is connected to it. I have a feeling it has something to do with the way I have analog set up, but I haven't been able to figure it out.

    the code for serial output and delays is working fine. but I just get a constant stream of 1's no matter what I do. If anyone could help it would be awesome!

    Code:
    '---clock settings
            define OSC 8
            OSCCON = %1111110 ' sets internal osc to run at 8MHZ
    
    '----------turn analog on porta off, and use as digital input/output
            CMCON = 0 'Comparators ON (right?)
            ANSEL = 1 'A/D ON -- Port pins all analog (I hope)
    '----------
    
    '---** Constants
    
    rcpin var porta.3
    
    '---**variables
    
    rcreturn var byte
    
    '------**main program
    
    
    
    loop:  
    
    '----its rctime!
    pause 1000
    
    high rcpin
    pause 5 
    rctime rcpin,1,rcreturn
    low rcpin
    
    
    '----(end rctime) shows over folks ^^
    
    
    
    '----send serial feedback      
            serout2 porta.0, 16468, ["rc time was: ",dec rcreturn] 'call for data    
     '-----end serial feedback
    
    goto loop   'loop forever
    end
    Last edited by gandora; - 15th May 2007 at 10:28. Reason: missing code

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    RCTIME is a digital command. All it does is measure the time it takes to discharge a capacitor to a certain voltage.

    Turn analog and comparators off for the pin you are using.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Hi and Welcome on the forum,
    Any specific reason why you want to use RcTime? What do you want to do?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Smile

    Gotta be a Time Machine. Just has to be. This would be about the only use for RCTIME.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Could be, but why i'm asking is that many use RcTime to read a POT, while using the ADC is much efficient and don't need any extra capacitor.

    Let's see...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Yeah - RCTIME is a bit inadequate for that, there's not enough span at the lower end. I think min is a few KΩ. Besides, relatively inefficient too, tying up a complex protocol for something so simple.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    I could easily see throwing a few push buttons, each with their own resistor, on the same pin, with a parallel cap, and using RCTIME to figure out which switch was pressed.

  8. #8
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    I could easily see throwing a few push buttons, each with their own resistor, on the same pin, with a parallel cap, and using RCTIME to figure out which switch was pressed.
    That is a very good idea!

  9. #9
    Join Date
    May 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Wink my reasonings

    well, as a clarification I forgot to include. I am using the 16f88 as this projects chip. And I am trying to read a photoresistor or a pot. Mostly I am trying to carry over my knowledge of electronics from the basic stamp. And make sure I know how to do everything I had learned up till' now.

    If I can do that, I can still use the books I purchased for the basic stamp as a learning tool for the pic micro. As I have decided that the stamps are not cost effective, and want to learn at a little more depth.

    Also as a note, I have attempted to get it to work all digital, and on digital only ports with the same result.

    If there is a better way, do tell, however I still want to know how to get the command to work. ^^ thankyou.


    Quote Originally Posted by mister_e View Post
    Hi and Welcome on the forum,
    Any specific reason why you want to use RcTime? What do you want to do?
    Last edited by gandora; - 15th May 2007 at 18:04. Reason: extra info

  10. #10
    Join Date
    May 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Not yet

    Quote Originally Posted by T.Jackson View Post
    Gotta be a Time Machine. Just has to be. This would be about the only use for RCTIME.
    Im starting with the basics but you discovered my evil plan! ^^

  11. #11
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    As pointed out earlier, RCTIME is a digital function not analog. So you'll need to enable the port in digital mode. Your code gears the port up in analog mode. BS2 is an unpopular joke in my opinion.

  12. #12
    Join Date
    May 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Talking Its Alive!

    Quote Originally Posted by T.Jackson View Post
    As pointed out earlier, RCTIME is a digital function not analog. So you'll need to enable the port in digital mode. Your code gears the port up in analog mode. BS2 is an unpopular joke in my opinion.

    Alright Thankyou for your help i now got it to work. For other newbs who would prefer not make a fool of themselves. The working code is below.

    Thanks again. it now results in different things depending on the light. ^^

    Code:
    '---clock settings
            define OSC 8
            OSCCON = %1111110 ' sets internal osc to run at 8MHZ
    
    '----------turn analog on porta off, and use as digital input/output
            CMCON = 7 'Comparators off
            ANSEL = 0 'A/D off -- Port pins all digital
    '----------^^^^^^^^^^
    '----------the change is in this block of code
    
    '---** Constants
    
    rcpin var porta.3
    
    '---**variables
    
    rcreturn var byte
    
    '------**main program
    
    
    
    loop:  
    
    '----its rctime!
    pause 1000
    
    high rcpin
    pause 5 
    rctime rcpin,1,rcreturn
    low rcpin
    
    
    '----(end rctime) shows over folks ^^
    
    
    
    '----send serial feedback      
            serout2 porta.0, 16468, ["rc time was: ",dec rcreturn] 'call for data    
     '-----end serial feedback
    
    goto loop   'loop forever
    end

  13. #13
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    in case you're using a LDR (or high impedance analog source), i see some advantage of RCTime.. unless, i really don't. A simple transistor+few resistor + PIC adc, would be my solution if i need accuracy.

    Level detector? ---> PIC Comparator

    OR, PIC16F785 i've ordered a thousand of them yesterday, sOOOO much nice stuff on-board... built-in OP-AMP, 2 phase PWM + asynchronous feedback as a teaser...

    NEW TOY, NEW TOY
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  14. #14
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by T.Jackson View Post
    BS2 is an unpopular joke in my opinion.
    To me, ANY Basic Stamp are as good as PIC16F84

    But come-on... 40$ EACH
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  15. #15
    Join Date
    May 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Smile Furthur ponderences.

    So you said there was a way of reading a pot in analog? Is there any chance you could give me a little synopsis of how it is done? Thankyou.

  16. #16
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Assuming your POT impedance is equal or less than the maximum recommended, you just need to feed the wiper to a PIC analog input and use the internal ADC.

    PBP ADCIN is a nice start point.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  17. #17
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    This is for a 877 but it will help you get the picture.

    http://www.rentron.com/PICX2.htm

    Be sure to look at the speacial feature part of the data sheet for the PIC you are usinf as at this point the PIC are not "standard".

    There is a RCTIME and place for everything Upgrading from the BS2, you will enjoy the built in ADC on some PICs. If you have used an external ADC with the BS2, do not try and compare this with the ones built in. End result the same but how tou get there is another story.

    Have fun.
    Dave
    Always wear safety glasses while programming.

  18. #18
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post

    Quote Originally Posted by mister_e View Post
    To me, ANY Basic Stamp are as good as PIC16F84

    But come-on... 40$ EACH
    - you must be joking. BS2 hovers along at around 2,000 instructions p/sec. BS2 has two major short comings. 1) Overhead of the serial EEPROM which is the reason why it's so slow. 2) Cost - in Australia when BS2 was initially released it retailed for something like $100. I'd swap you a BS2 for a 16f84a any day. In fact, I'd even pay a bit of money on top. Honda Vs Ferrari basically.

  19. #19
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by T.Jackson View Post
    - you must be joking. BS2 hovers along at around 2,000 instructions p/sec. BS2 has two major short comings. 1) Overhead of the serial EEPROM which is the reason why it's so slow. 2) Cost - in Australia when BS2 was initially released it retailed for something like $100. I'd swap you a BS2 for a 16f84a any day. In fact, I'd even pay a bit of money on top. Honda Vs Ferrari basically.
    And who drives a Ferrari as there first car. The BS2 is a good way to get started. Compare to the cost of PBP or the time of learning assembly and cost of a good programmer...

    And about the swap. Your on. What is you mailing address. This would make the Scouting Troop I work with very happy. Do not worry about the "bit of money on top", paying for the shipping will be fine.
    Dave
    Always wear safety glasses while programming.

  20. #20
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post

    Yeah - I guess few people drive Ferraris as their first car, BS2 has its place. As far as the swap goes, I have never personally owned a BS2. I'd be more than happy to adopt some more 16f84's though. One of my old College teachers was mad into BS2. Come to think of it, he was a bit mad himself actually.
    Last edited by T.Jackson; - 16th May 2007 at 09:48.

  21. #21
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by T.Jackson View Post
    he was a bit mad himself actually.
    As one of our greatest comics ( Michel Colucci alias "Coluche" ) said :

    " you always judge with your own intelligence "

    Quite true.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  22. #22
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post

    Quote Originally Posted by Acetronics View Post
    As one of our greatest comics ( Michel Colucci alias "Coluche" ) said :

    " you always judge with your own intelligence "

    Quite true.

    Alain
    Well, actually, I considered Adrian Down to be a very eccentric border line genius. A bit mad in his own right - many of the other students were a tad scared of him, I wasn't.

  23. #23
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by T.Jackson View Post
    Yeah - I guess few people drive Ferraris as their first car, BS2 has its place. As far as the swap goes, I have never personally owned a BS2. I'd be more than happy to adopt some more 16f84's though. One of my old College teachers was mad into BS2. Come to think of it, he was a bit mad himself actually.
    So, are you are backing out of the swap!!! ?

    A man is only as good as his word.

    And now that we know you have never used a BS2, I guess your comments are based on ...
    Dave
    Always wear safety glasses while programming.

  24. #24
    Join Date
    May 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default the stamps place

    Quote Originally Posted by mackrackit View Post
    So, are you are backing out of the swap!!! ?

    A man is only as good as his word.

    And now that we know you have never used a BS2, I guess your comments are based on ...
    Well despite the fact that I have moved on to bigger and better things. The truth is without the BS2 I can pretty much say for sure I would have just given up before I got this far. I feel that for an initial look on microcontrollers it is a good initial investment. but I have moved on. ^^

  25. #25
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Default PIC16f785

    Quote Originally Posted by mister_e View Post
    in case you're using a LDR (or high impedance analog source), i see some advantage of RCTime.. unless, i really don't. A simple transistor+few resistor + PIC adc, would be my solution if i need accuracy.

    Level detector? ---> PIC Comparator

    OR, PIC16F785 i've ordered a thousand of them yesterday, sOOOO much nice stuff on-board... built-in OP-AMP, 2 phase PWM + asynchronous feedback as a teaser...

    NEW TOY, NEW TOY
    PIC16F785 What do you like best about them? The op-amps? What type of projects will you use them for? Should we all get a bunch just to keep up?
    -Adam-
    Ohm it's not just a good idea... it's the LAW !

  26. #26
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Opamp is a REALLLY nice feature, i wasn't aware it was existing in one PIC.. but only voltage comparator & ADCs. Sure you could hack the voltage comparator with some feedback resistor, but my tests never give any good results... well not even close of what you should have with a op-amp.

    The Asynchronous PWM feedback (and 2 phase PWM) could be nice for some DC-DC converter, Motor control and for sure, some others.

    2 full independant analog comparator.. is a nice feature as well. There's also the REFCON and VRCON register which seems to add some nice stufff...

    There's also something i want to test.. the built-in voltage regulator..

    Don't worry, i did'nt read the whole thing really carefully

    Down side.. no USART, no MSSP... Oups!

    For analog stuff and power management, i think it's a really nice PIC.

    Time will tell...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. PULSIN & RCTIME resolution calculation
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th January 2010, 14:34
  2. POT and RCTIME instructions
    By ruijc in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th November 2007, 15:47
  3. RCtime timeout
    By chriroz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd May 2007, 15:45
  4. RC - connection using RCTime produces strange results
    By selbstdual in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 8th February 2007, 16:16
  5. PULSIN and RCTIME
    By Dwayne in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th November 2004, 14:45

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts