Wow bruce Thanks. I did receive it today and I am planning on working on it later tonight (the cd was in there and those files look very helpful). I am going to attach what I have as of now for both my receiving and transmitting chip (both 16F684). I would like you guys to correct me on some stuff because I had it working the day prior to yesterday (but it was just the serin and serout without the "get_direction" label and the forward, backwards, left, right labels as well), but now it has stopped working.
Here is the code for the 16F684 that will be connected to the transmitter:
*also, how can I make a circuit with about 4 buttons using my 7mm tact switches so that I can get the values and send them out over serout?
**what is needed...I am still unclear on this, is it a 10k resistor or something. A simple diagram would be helpful (maybe with an accompanying piece of code
)
***keep in mind that this is my first project ever in PBP, I have pieced stuff together from other's posts and stuff I have read. I have managed to get the somewhat good amount of knowledge that I possess of assembly programming (and all the stuff that you may learn from it) to better understand my code.
Transmitter chip code (beta - malfunctioning?):
*I was playing with the data being sent out and making it my own numbers so it is just a loop between start and the serout command...so I can test the receiver pic...which isn't working for some reason 
Code:
'****************************************************************
'* Name : Electric car (4 motors and remote controlled) for Science Olympiad*
'* Author : GiroTechs *
'* Notice : Copyright (c) 2009 GiroTechs *
'* : All Rights Reserved *
'* Date : 1/14/2009 *
'* Version : 1.0 *
'* Notes : this is a single attempt to make a remote controller electric *
'* : vehicle with both reverse and forward plus steering *
'* : capabilities as well as a stop button. *
'* major code piece that baffled me came from:
'*http://www.picbasic.co.uk/forum/showthread.php?p=50584#post50584
'* THANK YOU n qwerty!
'****************************************************************
'
' power ^ ground
' RA5 RA0
' RA4 RA1
' RA3 RA2
' RC5 RC0
' RC4 RC1
' RC3 RC2
'
Include "modedefs.bas"
'
' ——-[ Equates ]———————————————————————————-
'
FLbutton var porta.0 ;left side forward
FRbutton var porta.5 'right side forwad
BLbutton var porta.1 ;left side backwards
BRbutton var porta.4 ;right side backwards
rightbutton var portc.5 ;just turn right
leftbutton var porta.2 ;just turn left
act1 var word
act2 var word
;Create a changing pulsewidth signal from 10 usec wide to 655
;msec wide.
pulsewidth var word
;end equates
;Main start
start:
TRISA=%00000000
TRISC=%00000010
OPTION_REG.7=0 'Enable Pull-Up's on PORTB
ANSEL = 0 'turns off analogue inputs
OSCCON =$60 'sets internal osc to 4MHz
TRAIN VAR BYTE
movement1 VAR WORD
movement2 var word
direction var word
turns var word
PORTc.1 = 1 'turn enable pin high
TRAIN=$55
movement1 = 4
movement2 = 1
direction = movement1
turns = movement2
SEROUT PORTc.1,T2400,[TRAIN,TRAIN,TRAIN,TRAIN,TRAIN,9,movement1,movement2]
goto start
END
;
;subroutines
;
get_actions:
if leftbutton = 0 then
turns = 1 ;turns = 1 means a left turn
else
turns = 0 ;no turn at all
endif
if rightbutton = 0 then
turns = 2 ;turn = 2 means a right turn
else
turns = 0 ;no turn at all
endif
if FLbutton = 0 then
direction = 1
else
direction = 0
endif
if Frbutton = 0 then
direction = 2
else
direction = 0
endif
goto start ;now we have all the buttons pressed at this small
;interval of time...we need to send it.
;***RAN out of space on this post, you will need to get this part of code ;from the next one below.
;
My Receiving pic's code:
*in the previous code, I set it up to send fixed data so I can see if the pins are being enabled or not. As it turns out, my code isnt working for some reason. 2 days ago I had it working but idk what could be wrong because I know that "movement1" and "movement2" are being received (wired connection). Any help by looking over my if then statements and all that would be apreciated 
Code:
'****************************************************************
'* Name : Electric car (4 motors and remote controlled) for Science Olympiad*
'* Author : GiroTechs *
'* Notice : Copyright (c) 2009 GiroTechs *
'* : All Rights Reserved *
'* Date : 1/14/2009 *
'* Version : 1.0 *
'* Notes : this is a single attempt to make a remote controller electric *
'* : vehicle with both reverse and forward plus steering *
'* : capabilities as well as a stop button. *
'* major code piece that baffled me came from:
'*http://www.picbasic.co.uk/forum/showthread.php?p=50584#post50584
'* THANK YOU n qwerty!
'****************************************************************
'
' power ^ ground
' RA5 RA0
' RA4 RA1
' RA3 RA2
' RC5 RC0
' RC4 RC1
' RC3 RC2
'
Include "modedefs.bas"
'
' ——-[ Equates ]———————————————————————————-
'
forwardL var porta.0 ;left side forward
forwardR var porta.5 'right side forwad
backwardL var porta.1 ;left side backwards
backwardR var porta.4 ;right side backwards
right var portc.5 ;just turn right
left var porta.2 ;just turn left
rec var portc.1 ;receiver pin
action var byte
B1 var byte
movement1 VAR WORD
movement2 var word
direction var word
turns var word
;Create a changing pulsewidth signal from 10 usec wide to 655
;msec wide.
pulsewidth var word
;end equates
;Main start
TRISA=%00000000
TRISC=%00000010
OPTION_REG.7=0 'Enable Pull-Up's on PORTB
ANSEL = 0 'turns off analogue inputs
OSCCON =$60 'sets internal osc to 4MHz
TRAIN VAR BYTE
Start:
PORTc.1 = 1 'turn communication pin high
TRAIN=$55
SERIN PORTC.1,T2400,[9],movement1,movement2
movement1 = direction
movement2 = turns
goto checkdirection
goto start
forward:
if turns = 0 then
goto forwardgo
if turns = 1 THEN
goto forwardleft
if turns = 2 then
goto forwardright
endif
endif
endif
forwardgo:
high forwardl
high forwardr
pause 500
low forwardl
low forwardr
goto start
forwardleft:
forwardright:
backward:
if turns = 1 then
goto backwardleft
if turns = 2 then
goto backwardright
endif
endif
high backwardl
high backwardr
pause 500
low backwardl
low backwardr
goto start
backwardleft:
backwardright:
turnleft:
high left
low right
pause 500
low right
low left
goto start
if turns = 0 then
goto start
if turns = 1 THEN
goto checkturns
if turns = 2 then
goto turnright
endif
endif
endif
goto turnright
turnright:
low left
high right
pause 500
low left
low right
if turns = 0 then
goto start
if turns = 1 THEN
goto turnleft
if turns = 2 then
goto checkturns
endif
endif
endif
goto turnright
nomov:
goto start
;
;subroutines
;
checkdirection:
;forward and backwards
if direction = 0 then
goto start
if direction = 1 THEN
goto forward
if direction = 2 then
goto backward
endif
endif
endif
checkturns:
;forward and backwards
if turns = 0 then
goto start
start_turn:
if turns = 1 THEN
goto turnleft
if turns = 2 then
goto turnright
endif
endif
endif
goto start
;left and right turns
return
end
;Subroutines
nap18ms:
clearwdt ;let us make these nap intervals accurate by resetting the
nap 0 ;the watch dog timer on the PIC itself.
return
nap54ms:
gosub nap18ms
gosub nap18ms
gosub nap18ms
return
nap108ms:
gosub nap54ms
gosub nap54ms
return
nap216ms:
gosub nap108ms
gosub nap108ms
return
nap540ms:
gosub nap108ms
gosub nap108ms
gosub nap108ms
gosub nap108ms
gosub nap108ms
return
nap1080ms:
gosub nap540ms
gosub nap540ms
return
nap1512ms:
gosub nap1080ms
gosub nap108ms
gosub nap108ms
return
Thanks guys for helping me out, and bruce...for some reason you taking the care to responding to this thread and knowing that it was me that ordered the other day really shows that ye top you guys are at the top of your game around here. I am wanting to talk to you about something I want to do...it involves selling chips and stuff.
Just get back to me at my email "GiroTechs [at] gmail".
Thanks for your help all!
Regards,
n0rig
P.S. If you can help me out with my code please, please do it quickly as I will need to have a working piece with a remote control (transmitter chip connected to tact switches to designate what the motors connected to the receiving chip will do).
Bookmarks