I don't understand this code!


Closed Thread
Results 1 to 40 of 47

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    New Hampshire, USA
    Posts
    107


    Did you find this post helpful? Yes | No

    Default

    Thanks, I should have said that: I want the output to be low for the short time (4+ms) and high for the long time (12+ms). I think the program should do that, but it doesn't. The output is high for the short time and low for the long time.

  2. #2
    Join Date
    Jul 2003
    Location
    USA - Arizona
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    Your main code looks fine:
    Code:
    START:
    LOW GPIO.1 
    PAUSEUS 4168 ' ON TIME
    HIGH GPIO.1
    PAUSEUS 4167 'DEAD TIME 
    LOW GPIO.0 'SETS PIN 7 LOW
    PAUSEus 4168 'FOR 4.168 MILLISECONDS 
    HIGH GPIO.0
    PAUSEUS 4167 'DEAD TIME
    Your startup code does not:
    Code:
    TRISIO = %111111
    This sets all pins to <U>inputs</U>. You want to use:
    Code:
    TRISIO = %001000 '(since GPIO3 is input only anyway)

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by languer View Post
    Code:
    TRISIO = %001000 '(since GPIO3 is input only anyway)
    Except for the fact that HIGH and LOW automatically set the pins as outputs...

    Now then...what is this output thing? Is this a 2 bit R/2R D/A ladder type setup or what is it?

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


    Did you find this post helpful? Yes | No

    Default

    If it was me, i would use a timer interrupt, but add somes extra filter outside.

    I don't understand what you mean by
    Quote Originally Posted by Russ Kincaid
    The program runs but the waveform is upside down. I could change the circuit to accept the upside down wave,
    Last edited by mister_e; - 6th May 2007 at 09:52.
    Steve

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

  5. #5
    Join Date
    Jan 2006
    Location
    New Hampshire, USA
    Posts
    107


    Did you find this post helpful? Yes | No

    Default

    What I mean by "upside down" is: When the programmed output is high, the output actually goes low and when the programmed output is low, it actually goes high. I don't understand that.

    Russ

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


    Did you find this post helpful? Yes | No

    Question upside down

    Hi Russ,
    Quote Originally Posted by Russ Kincaid View Post
    What I mean by "upside down" is: When the programmed output is high, the output actually goes low and when the programmed output is low, it actually goes high.
    We are not trying to give you a difficult time about this inverted waveform thing. It is just difficult to tell what you are seeing on a recurring waveform. Do you have another circuit synchronized with this output? Are you referencing the measurement to the PIC common?
    The timing may be difficult to see with a rapidly cycling code. You could change the code to seconds, just to watch the sequence.

    It looks like you WANT the output to be HIGH for three time increments and LOW for one. (See attachment.) http://www.picbasic.co.uk/forum/atta...1&d=1178466510
    Is the waveform LOW for three time increments and HIGH for one?

    -Adam-
    Attached Images Attached Images  
    Ohm it's not just a good idea... it's the LAW !

  7. #7
    Join Date
    Jan 2006
    Location
    New Hampshire, USA
    Posts
    107


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pic_User View Post
    Hi Russ,



    It looks like you WANT the output to be HIGH for three time increments and LOW for one. (See attachment.) http://www.picbasic.co.uk/forum/atta...1&d=1178466510
    Is the waveform LOW for three time increments and HIGH for one?

    -Adam-
    Exactly right. Why does it do that?
    BTW, GPIO.0 produces the positive half of an AC signal while GPIO.1 produces the negative half. The result is an AC that reads the same on a true RMS meter or one that reads 0.7 of the peak.
    Last edited by Russ Kincaid; - 6th May 2007 at 18:24.

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23

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