I don't understand this code!


Closed Thread
Results 1 to 40 of 47

Hybrid View

  1. #1
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Pssst.... Look in post #22.....

    Dave Purola,
    N8NTA

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dave View Post
    Pssst.... Look in post #22.....
    Dave Purola,
    N8NTA
    Shows where A & B are and what they should be doing on the 'scope, but, doesn't show for sure where he's measuring from.

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


    Did you find this post helpful? Yes | No

    Smile smoke to a minimum

    Quote Originally Posted by skimask View Post
    Shows where A & B are and what they should be doing on the 'scope, but, doesn't show for sure where he's measuring from.
    skimask is right.
    If your LEDs are referenced to V+ and your scope is referenced to Vcommon
    the scope will show a logic high when the LEDs are off.
    If you “invert” a channel on your scope it should show you what the LED is doing...

    I have not tried it but this code should work:

    ‘ with both LEDs referenced to V+
    high GPIO.0 ' OFF INITIAL CONDITIONS
    high GPIO.1 ' OFF INITIAL CONDITIONS
    START:
    PAUSEUS 2074 ' before pulse
    LOW GPIO.1 ‘ON = pulse
    PAUSEUS 4168 ' ON TIME - GPIO.1 only
    HIGH GPIO.1 ‘both pins OFF
    PAUSEUS 2074 ' after pulse
    PAUSEUS 20 ' anti-overlap time
    ‘should add to 8.336 milliseconds

    PAUSEUS 2074 ' before pulse
    LOW GPIO.0 ‘ON = pulse
    PAUSEUS 4168 ' ON TIME - GPIO.0 only
    HIGH GPIO.0 ‘both pins OFF
    PAUSEUS 2074 ' after pulse
    PAUSEUS 20 ' anti-overlap time
    ‘should add to 8.336 milliseconds
    GOTO START '60 HZ FREQUENCY

    END

    I agree with Malcolm on all three points he made.
    The idea about slowing the duty cycle down to visible speeds to test LEDs is good....
    But, because, your board is made:
    You should be able to use a single (LED) supply resistor in this circuit because you NEVER want the LEDs to be on at the same time.
    You can leave the LEDs referenced to V+ as long as you remember any Vcommon referenced measurements are inverted to the LEDs.

    Also:
    Do you have your optocouplers on the board? If so:
    You can temporarily feed them with +/-12V (instead of the 150V) and a series resistor in each leg to protect them (in case both on)...
    Measure the output referenced to common.

    Aside:
    The programmable guard time (anti-overlap time) between polarity switching is handy, I know you have done that in your analog work with deliberate propagation delays. Keeps the smoke to a minimum.

    The programmable “before / after pulse” time would help “push” the wave shape to what you want.

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

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


    Did you find this post helpful? Yes | No

    Default

    I hate to tell you this, Adam, but your program makes the outputs high for 4 ms and low for 12 ms, just like mine. And, I am refrencing the scope to VSS.

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


    Did you find this post helpful? Yes | No

    Default

    Are you sure you don't have a inverted probe type??? or scope setting.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Smile Aarrrggghh

    Quote Originally Posted by Russ Kincaid View Post
    I hate to tell you this, Adam, but your program makes the outputs high for 4 ms and low for 12 ms, just like mine. And, I am refrencing the scope to VSS.
    Aarrrggghh, I hate hearing that, too!

    Mister-e’s suggestion on the other tread sounds plausible (“Where's the CMCON setting?”).

    The other idea is: you may not be really re-programming the PIC.
    Try changing the times to 100 times longer. Just to check.
    or
    Try erasing the PIC, reading it, look at the hex to make sure it is erased. Then, program it with the new code compiled from MCS and PBP. Then read the device again to see it has really been re-programmed.
    I seem to remember some forum postings about forgetting to re-compile before re-burning.
    So they just kept burning the original (Version 1 of their code) ASM into HEX, not the new PBP (Version 2 of their code).
    -Adam-

  7. #7
    Join Date
    May 2006
    Location
    Kedah, Malaysia
    Posts
    18


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pic_User View Post
    Aarrrggghh, I hate hearing that, too!

    Mister-e’s suggestion on the other tread sounds plausible (“Where's the CMCON setting?”).

    The other idea is: you may not be really re-programming the PIC.
    Try changing the times to 100 times longer. Just to check.
    or
    Try erasing the PIC, reading it, look at the hex to make sure it is erased. Then, program it with the new code compiled from MCS and PBP. Then read the device again to see it has really been re-programmed.
    I seem to remember some forum postings about forgetting to re-compile before re-burning.
    So they just kept burning the original (Version 1 of their code) ASM into HEX, not the new PBP (Version 2 of their code).
    -Adam-
    I am proposoing to put NPN transistor to invert the waveform?

    If cannot then fine.

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


    Did you find this post helpful? Yes | No

    Default

    Good suggestions, Adam. But, I have done all those things (except make the time longer). Look at post#15, why is that waveform the same as post#1?

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


    Did you find this post helpful? Yes | No

    Smile My guess

    Hi Russ,
    Quote Originally Posted by Russ Kincaid View Post
    Look at post#15, why is that waveform the same as post#1?
    Because you are not really re-programming the PIC, with the PBP new program.

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

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Russ Kincaid View Post
    I hate to tell you this, Adam, but your program makes the outputs high for 4 ms and low for 12 ms, just like mine. And, I am refrencing the scope to VSS.
    I'm thinking the problem overall is the fact that you've got one resistor for current limiting for 2 LEDs. If you pull either pin low and you're measuring your signal on the LED side of the resistor, it won't matter which pin gets pulled low, they will probably both read low at back side of the LED (the connection nearest to the resistor).

    What do you get if you 'scope the actual pins themselves, right at the PIC with nothing else connected?

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