how about your config fuses?
Any Schematic?
how about your config fuses?
Any Schematic?
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
this is the new whole program on the receiving end. If the inpu is not good, then I guess why continue making a big program making leds flash on different Pot output when the Pic cannot identify one input in the first place.
define osc 20
Include "modedefs.bas"
Define LOADER_USED 1
DEFINE LCD_DREG PORTB ' Set LCD Data port
DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
CMCON=7 ' Disable comparators
'ANSEL=0 ' Set port as digital I/O
ADCON1=7
TrisB = %11111111 'sets all port a as input
TrisA = %00000000 ' sets all port b as output
X VAR BYTE 'VARIABLE TO incoming VALUE
pause 100
mainloop:
X =0
serin2 PORTB.3,n2400,[X]
Lcdout $fe, 1, "Value in: ", dec X
'porta.2 = 1 ' trying to see if the loop is looping
'pause 200
'porta.3 = 1
'pause 200
Goto mainloop
End
as far as the configuration goes, It is an F88, with portB.3 as the input and porta.2 and porta.3 as led output
mmm, are you using the bootlader AND the LCD? If so, for sure there's some hardware problem... as the USART share the same I/O for your LCD data bits.
Also, ANSEL should be = 0 to disable those internal ADCs, ADCON1=7 will work on some other PIC... unfortunately not this one![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I think my problem might be the sending code. I have added the output line to my lcd tosee what is sending, it says it is sending V and I's..
here is the sending code
define osc 20
Include "modedefs.bas"
Define LOADER_USED 1
DEFINE LCD_DREG PORTB ' Set LCD Data port
DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
CMCON=7 ' Disable comparators
ANSEL=0 ' Set port as digital I/O
ADCON1=7
TrisA = %11111111 'sets all port a as input
TrisB = %00000000 ' sets all port b as output
X VAR BYTE 'VARIABLE TO PUT POT VALUE
B1 VAR BYTE
PORTB = 0 'ALL OUTPUTS LOW
'23
Start:
Pot PortA.2,49,X ' would like PortA.2,175,B0 use number to suit you
Lcdout $fe, 1 'Clear screen
Lcdout $FE,$80,"Pot: ", #X 'Display the numerical value
LCDOUT $FE,$C0,"Output: ",B1
Pause 10
IF X <= 60 THEN LED1
IF (X > 60) AND (X <= 120) THEN LED2
IF (X > 120) AND (X <= 180) THEN LED1
IF X > 180 THEN LED2
goto Start
LED1
serout portb.2,n2400, [ $AA, $AA,$AA,$AA,$AA,$AA ]
B1=$AA
goto Start
LED2
serout portb.2, n2400, [ $56,$56,$56,$56,$56 ]
B1=$56
goto Start
LED3
serout portb.2,n2400, [ $55,$55,$55,$55,$55 ]
B1=$55
goto Start
LED4
serout portb.2,n2400, [ $65,$65,$65,$65,$65,$65 ]
B1=$65
goto Start
end
By the way , in the receiving code you gave me, there is a Training function called, but it does not exists.
I tried ansel =o all you told me, and remove the boatloader. Dont even know why it was there. There is no change in the system .
If I am sending $aa on the tramsitter pic, shouldn'y I get that also on the LCD on the transmitter?
I have four output on my transmitter. Here is your code to with only four values, the rest I didnot change it. None of the leds are lighting besides the initial feed:
'RECEIVER CODE
DEFINE OSC 20 '20Mhz Oscillator was used
Include "modedefs.bas" ' Include serial modes
ADCON0 = 0 'AD MODULE OFF & CONSUMES NO CURRENT
CMCON = 7 'COMPARATORS OFF
TRISA = $00 : TRISB = $FF 'all porta is outputs, all portb is inputs
B0 var byte
'testing led outputs
porta.0 = 1 : pause 200 : porta.0 = 0
porta.1 = 1 : pause 200 : porta.1 = 0
porta.2 = 1 : pause 200 : porta.2 = 0
porta.3 = 1 : pause 200 : porta.3 = 0
start:
B0 = 0 'empty B0 because the program doesn't
serin PORTB.3,n2400,[B0] 'if n2400 doesn't work, try t2400
if B0 = $AA then ledson 'manchester encoded $f
if B0 = $55 then ledswing 'manchester encoded $0
if B0 = $5a then led1toggle 'manchester encoded $1
if B0 = $65 then led2toggle 'manchester encoded $2
goto start
led1toggle:
if porta.0 = 1 then
porta.0 = 0
else
porta.0 = 1
endif
goto start
led2toggle:
if porta.1 = 1 then
porta.1 = 0
else
porta.1 = 1
endif
goto start
ledson:
porta.0 = 1 : porta.1 = 1 : porta.2 = 1 : porta.3 = 1
goto start
ledsoff:
porta.0 = 0 : porta.1 = 0 : porta.2 = 0 : porta.3 = 0
goto start
ledswing:
porta.0 = 1 : pause 10 : porta.0 = 0
porta.1 = 1 : pause 10 : porta.1 = 0
porta.2 = 1 : pause 10 : porta.2 = 0
porta.3 = 1 : pause 10 : porta.3 = 0
goto start
end
Last edited by lerameur; - 4th December 2006 at 00:56.
Would it be posible my pic at the receiver dont recognize the data in ?
could the USART be at cause here ?
The programs take a lot of space, I decided to post them on my web site:
http://www3.sympatico.ca/lerameur/
k
Last edited by lerameur; - 4th December 2006 at 04:43.
Originally Posted by lerameur
Does your X value change with the POT when you rotate it?
How about this...let's break it down...again. Apparently there is too much going on here that can break the system and you're having trouble figuring out what's going on.....again...............
1. Get rid of the transmitter................
2. Get rid of the receiver...................
3. Get rid of the POT.......................
4. Put a button where the pot was....
5. Make sure the button works...in other words, you push it and an LED connected to the same PIC on a different pin lights up on software command, not because you pushed it and made an electrical connection, then you release it and the LED goes out on software command, not because you removed an electrical connection. Then change the program around to extinguish the LED when the button is pushed, and light the LED when the button is released. That will tell you that you know how to make an LED light up on command. (or something comes up on the LCD that verifies that you are pushing and releasing the button).
6. Then connect the other receiver PIC to the transmitter PIC through the serial port.
7. Set up a program in the receiver to receive control data from the transmitter PIC and act on it in some fashion, and make it repeatable. For example, each press of the button on the transmitter PIC sends a command to light up a different light in the receiver PIC (4 LEDs light up, one after the other, and so on down the line, until the end is reached, then they extinguish and the process starts again.
8. Then, after that is all working, connect the POT back into the transmitter PIC and rewrite your code to display the POT value on the LCD. When that works fine, continue...and not until it works as you want it to.
9. When steps 1-8 all work fine, each and every time, then disconnect the PIC' serial ports and reinsert the transmitter and receiver modules (not the encoder and decoder modules).
10. Add the code back into the transmitter that send out the various control codes for each LED at the receiver PIC. And don't forget about the receiver training code. It's the transmitter that does the training of the receiver, not the receiver itself.
Tune in tomorrow for more...I'm tired of explaining this...
JDG
, connect the 2 PICs at the serial ports.
Bookmarks