Tazntex , Can I please see a listing of the modified code?
Dave Purola,
N8NTA
Tazntex , Can I please see a listing of the modified code?
Dave Purola,
N8NTA
Here is the revision Dave,
INCLUDE "MODEDEFS.BAS"
@ DEVICE PIC16F628a,XT_OSC
@ DEVICE pic16F628a, WDT_OFF
@ DEVICE pic16F628a, PWRT_ON
@ DEVICE pic16F628a, MCLR_OFF
@ DEVICE pic16F628a, BOD_ON
@ DEVICE pic16F628a, LVP_OFF
@ DEVICE pic16F628a, CPD_OFF
@ DEVICE pic16F628a, PROTECT_OFF
DEFINE OSC 4
mydata1 VAR byte
mydata2 var byte
address1 var byte
address2 var byte
checksum var byte
chk_sum var byte
master var portb.0
vacuum var portb.1
datagood VAR porta.2
serpin VAR porta.1 'serial input pin
PORTA = 0
PORTB = 0
trisa = %00000010
trisb = %10000000
CMCON=%00000111
PAUSE 50
loop:
mydata1=%00000000
gosub loop1
CheckSum = (address1 + address2)
CheckSum = CheckSum + (mydata1 + mydata2)
IF checksum != chk_sum THEN loop
IF mydata1 != mydata2 THEN loop
IF address1 != address2 THEN loop
IF (mydata1>0) && (checksum = chk_sum) THEN
datagood = 1 'mydata1 > 0 so I know whether or not mydata1 has returned to %00000000 if 1 then my led will come on
else
datagood = 0 'If mydata1 is %00000000 then var mydata1 is 0, my led is off
endif
if mydata1=%01010110 then loop2
if mydata1=%10101111 then loop2
if portb.0=1 then loop3
goto loop
loop2:
if mydata1=%10101111 then master=1 'master relay turn on
pause 50
if mydata1=%01010110 then master=0 'master relay turn off
pause 50
goto loop
loop3:
if mydata1=%01011001 then
vacuum=1 'portb.1 is on
else
vacuum=0 'portb.1 is off
endif
GOTO loop
loop1:
SERIN2 serpin,16780,[wait(254),address1,address2,mydata1,mydata2,chk_su m]
Return
Last edited by tazntex; - 27th August 2008 at 04:53.
Not much has changed since my last posting, I haven't taken the hammer out of the toolbox just yet. The rf modules are capable of 5000bps so I did move up from 2400. I've been over under and through this forum, and saw a post where bruce had use a 100k to pull down the data, if I read this correctly, line coming in to reduce noise on the input. I have monitored my data on the serial input of the 628a, looks pretty clean. I haven't had any luck getting rid of the little gremlin who pops up every now then and holds the output pin high. Anyhow I am open to criticism, constructive preferred![]()
Hi Taz.
I see you have 2 ports as inputs, what is connected to them? PortB.7, I see no reference to in code, possibly my bad eyesight, but if open as input might allow "gremlins" to leak in.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
address con %00000001
This equals 1
chk_sum = (address + address)
chk_sum = 2
if A = 0 && B = 0 then keydata = %10101111
keydata = 175
chk_sum = chk_sum + (keydata + keydata)
chk_sum = 2 + 175 + 175
chk_sum = 352
chk_sum var byte
byte = 0 to 255
Maybe try WORD sized variables.
Or maybe I am missing something
Dave
Always wear safety glasses while programming.
Hello again Dave, you have a good point however I am using Bruce's idea for validating the in coming data. It is my understanding that the checksum will overflow which should not be a problem. I've been using it and that part doesn't seem to be the problem however I will experiment with it to see. I hope your right. Thanks Dave and 73
OVERFLOW...Yep I was missing something.
I will keep looking at it.
Do not get the hammer yet.
Dave
Always wear safety glasses while programming.
Bookmarks