just posted the unworking program ,
nothing is coming out of the sending chip
just posted the unworking program ,
nothing is coming out of the sending chip
Last edited by lerameur; - 5th December 2006 at 04:48.
Originally Posted by lerameur
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
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
Originally Posted by lerameur
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
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.
Originally Posted by lerameur
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
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.
Bookmarks