Hi there, i'm making a RS232 interface between a Siemens controller and Diesel generator to allow control and monitoring of the generator.
I had some weird things happening when using "@ptrinc" in my serin command, what was happening was the ascii code being passed onto the siemens controller was missing characters now and then, but i found if i had a debug in the program all problems went away no missing characters at all and it was reliable. I'd really like to get ride of the debug as it's not needed or used.
GENCOM: ' generator comm's loop
serout 7,t4800,("#","p","c","v") ' set siemens controller rady to recieve commands
ptr=0 ' set pointer to zero
serout 6,t4800,(13) ' get gen ready for comm's
serout 6,t4800,("load",13) ' ask gen for load value
serin [500,GENTO],6,t4800,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptr ' recieve data
gosub SITE ' start command to siemens controller point
serout 7,t4800,("load",13) ' finalise point name
pause 80 ' wait for siemens controller to finish response
debug ' this is the line required to fix missing characters???
gosub VALUE ' set value to siemens controller point
goto GENCOM ' start again and repeat the above steps
SITE: ' siemens controller point site name
serout 7,t4800,("site name") ' site name
return ' return to gen comm's loop
VALUE: ' set value to siemens controller point
ptr=1 ' set pointer to 1 as 0 is disregarded
for b6=1-5 ' loop five time if allowed by exit command
let b7=@ptrinc ' set @ptrinc value into b7 variable for reading
if b7=32 then exit ' read variable b7 and exit if value is "space" (32)
serout 7,t4800,(b7) ' send character to siemens controller
next b6 ' loop back for next character
serout 7,t4800,(13) ' send enter command to siemens controller
return return to gencom loop
here are the updates on the siemens controller when the debug is not used (heaps more)
3/2/2008 00:04:20 -29.299999 -N- OPER
3/2/2008 00:04:21 9.299999 -N- OPER
3/2/2008 00:04:21 -29.299999 -N- OPER
3/2/2008 00:04:28 3.0 -N- OPER
3/2/2008 00:04:29 -29.299999 -N- OPER
3/2/2008 00:04:29 9.299999 -N- OPER
3/2/2008 00:04:30 -29.299999 -N- OPER
3/2/2008 00:04:37 9.299999 -N- OPER
3/2/2008 00:04:37 -29.299999 -N- OPER
3/2/2008 00:04:43 9.299999 -N- OPER
3/2/2008 00:04:46 -29.299999 -N- OPER
if debug used the value sits stable on one value unless gen detects change.
I had some weird things happening when using "@ptrinc" in my serin command, what was happening was the ascii code being passed onto the siemens controller was missing characters now and then, but i found if i had a debug in the program all problems went away no missing characters at all and it was reliable. I'd really like to get ride of the debug as it's not needed or used.
GENCOM: ' generator comm's loop
serout 7,t4800,("#","p","c","v") ' set siemens controller rady to recieve commands
ptr=0 ' set pointer to zero
serout 6,t4800,(13) ' get gen ready for comm's
serout 6,t4800,("load",13) ' ask gen for load value
serin [500,GENTO],6,t4800,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptr ' recieve data
gosub SITE ' start command to siemens controller point
serout 7,t4800,("load",13) ' finalise point name
pause 80 ' wait for siemens controller to finish response
debug ' this is the line required to fix missing characters???
gosub VALUE ' set value to siemens controller point
goto GENCOM ' start again and repeat the above steps
SITE: ' siemens controller point site name
serout 7,t4800,("site name") ' site name
return ' return to gen comm's loop
VALUE: ' set value to siemens controller point
ptr=1 ' set pointer to 1 as 0 is disregarded
for b6=1-5 ' loop five time if allowed by exit command
let b7=@ptrinc ' set @ptrinc value into b7 variable for reading
if b7=32 then exit ' read variable b7 and exit if value is "space" (32)
serout 7,t4800,(b7) ' send character to siemens controller
next b6 ' loop back for next character
serout 7,t4800,(13) ' send enter command to siemens controller
return return to gencom loop
here are the updates on the siemens controller when the debug is not used (heaps more)
3/2/2008 00:04:20 -29.299999 -N- OPER
3/2/2008 00:04:21 9.299999 -N- OPER
3/2/2008 00:04:21 -29.299999 -N- OPER
3/2/2008 00:04:28 3.0 -N- OPER
3/2/2008 00:04:29 -29.299999 -N- OPER
3/2/2008 00:04:29 9.299999 -N- OPER
3/2/2008 00:04:30 -29.299999 -N- OPER
3/2/2008 00:04:37 9.299999 -N- OPER
3/2/2008 00:04:37 -29.299999 -N- OPER
3/2/2008 00:04:43 9.299999 -N- OPER
3/2/2008 00:04:46 -29.299999 -N- OPER
if debug used the value sits stable on one value unless gen detects change.