Serout problem


Closed Thread
Results 1 to 40 of 95

Thread: Serout problem

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    just posted the unworking program ,
    nothing is coming out of the sending chip
    Last edited by lerameur; - 5th December 2006 at 04:48.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur
    just posted the unworking program ,
    nothing is coming out of the sending chip

    I know nothing is working on your sending chip...you've got it set up wrong. Read my words a couple of posts ago. Going out of the chip back into the chip isn't going to work.

    Plug this into your sending chip, with only the LEDs and a button attached to portb.0 with a pulldown resistor:

    -------------------------------------------------------------------------
    INCLUDE "modedefs.bas"
    DEFINE OSC 20 'use external 20mhz crystal
    CMCON = 7 : ANSEL = 0 : ADCON1 = 7

    ledcount var byte

    led1 var porta.0 : output led1 'led on porta.0
    led2 var porta.1 : output led2 'and so on...
    led3 var porta.2 : output led3
    led4 var porta.3 : output led4

    key var portb.0 : input btn 'push button on portb.0
    '1K-10K resistor from portb.0 to ground (pulldown)
    'push button is wired between portb.0 and +5v

    led1 = 1 : pause 500 : led1 = 0 'initial light up to see if program is running
    led2 = 1 : pause 500 : led2 = 0
    led3 = 1 : pause 500 : led3 = 0
    led4 = 1 : pause 500 : led4 = 0

    mainloop:

    if key = 0 then 'button not pressed
    goto mainloop
    endif
    if key = 1 then
    pause 50 'wait 50ms for switch to debounce then check again
    if key = 1 then 'if it's still pressed, then increment the count
    ledcount = ledcount + 1
    endif
    endif

    if ledcount = 0 then 'all leds off
    led1 = 0 : led2 = 0 : led3 = 0 : led4 = 0
    endif
    if ledcount = 1 then '1st led on
    led1 = 1 : led2 = 0 : led3 = 0 : led4 = 0
    endif
    if ledcount = 2 then '2nd led on and so on and so on down the line....
    led1 = 0 : led2 = 1 : led3 = 0 : led4 = 0
    endif
    if ledcount = 3 then
    led1 = 0 : led2 = 0 : led3 = 1 : led4 = 0
    endif
    if ledcount = 4 then
    led1 = 0 : led2 = 0 : led3 = 0 : led4 = 1
    endif
    if ledcount = 5 then 'reset led count, roll it back to 0
    ledcount = 0 'and turn leds off since count is back to 0
    led1 = 0 : led2 = 0 : led3 = 0 : led4 = 0
    endif

    goto mainloop

    END




    Forget about serial code, the LCD and anything else that isn't listed above. Just do what's listed, and nothing else. If you go off on a tangent somewhere else, I don't know where you're going. Just do this. Get this to work. Then do the same basic thing on the receiver PIC. Get them both to work. We'll worry about connecting the 2 after both of these work.
    All this program is going to do is make the LED lights walk about 5 times a second as long as you hold the button down.
    JDG

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Ok I am going to do this, I will read and analyze your code before asking anything
    I'm off to bed now,
    thanks and see ya

    k

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur
    Ok I am going to do this, I will read and analyze your code before asking anything
    I'm off to bed now,
    thanks and see ya

    k

    There's no analyzing. You put the LEDs on PortA.0, A.1, A.2, A.3, set the pins to output. Put the switch on PortB.0, set the pin to input. Light them up in sequence for 1/2 second each.
    Then we sit in a loop waiting for the key input to go high (because it's pulled low without the button pressed).
    When it goes high, we wait 50ms. If it's still high after 50ms, then we increment the LED count.
    After that, it goes into a bunch of IF...THEN statements and sets the LEDs accordingly. If the count is 5, we reset the count back to zero and turn off all the LEDs...
    And start over again with checking the button...

    What's there to analyze? There is no analyzing. It is straight forward code, nothing hidden, no tricks of programming, no code magic, nothing. Short of
    10 PRINT"HELLO"
    20 GOTO 10
    it doesn't get much easier than this.

    JDG

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    well that works for both of them
    the four leds are funvtionning good on both circuits.

    k
    Last edited by lerameur; - 5th December 2006 at 12:55.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur
    well that works for both of them
    the four leds are funvtionning good on both circuits.

    k

    You have a PIC16F88 on the transmitter and a PIC16F628A on the receiver, yes?

    When you push the button on each PIC, the LEDs cycle thru on their respective PICs with each button press, yes? (remember, 2 seperate circuits running independant programs, not tied together except for the fact they happen to be mounted to the same workbench).

    If they do, change the pause 50 to pause 1000. When you hold the button down, the LEDs should increment once a second. That will verify that the oscillator is running at the correct speed (or at least close to it).

    I just want to make sure this is all work before we got any farther (small steps).

    JDG

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I have two Pic16F88 ( did try a PIC16F628A once to see what would happen, how did you know, I dont think I mentioned that)

    both circuits are running independently, Just the power supply is hooked up in parallel. Two circuits, two breadboards. two are doing the same thing


    k
    Last edited by lerameur; - 6th December 2006 at 02:35.

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 21:58
  2. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 17:46
  3. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 18:11
  4. Strange SerOut Problem
    By masosi in forum mel PIC BASIC Pro
    Replies: 39
    Last Post: - 23rd April 2007, 07:06
  5. Replies: 11
    Last Post: - 13th July 2005, 20:26

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