Shop OBEX P1 Docs P2 Docs Learn Events
Propeller doesn't run code properly on StingRay if not attached via USB — Parallax Forums

Propeller doesn't run code properly on StingRay if not attached via USB

HemPeterHemPeter Posts: 28
edited 2010-04-25 23:51 in Propeller 1
Hi guys,

I am currently working on a project to get the StingRay to autonomously make its way to a GPS location. I have the code up together, it everything seems to work while it's attached to the PC, but when I turn it on and its not connected, it won't get past the first line of code. I have multiple objects and cogs running, so the way to test to see if the code is getting past the first hurdle is to launch the pings straight after:

OBJ
  'PINGS
  ping           : "Ping_Handler"
  'SERIAL
  dbg           : "FullDuplexSerial"
  FS            : "FloatString"


PUB Main | ok1, ok2, ok3, ok4, ok5, ok6
  ok1 := dbg.Start(31, 30, 0, 31_250)                   'Start serial comms
  waitcnt(clkfreq + cnt)                                'Pause 1 Second
  ok6 := ping.start                                     'Start pings
  if ok1
    dbg.Str(STRING("Ping Cog = "))
    dbg.dec(ok6)      
    dbg.tx(13)




I've tried enclosing all the instances of serial output in the 'if ok1' statements, but since the cog is actually launching they are true and run anyway.
I think the program is falling over any time there is serial communication without a receiving terminal. Has anyone else had this problem? The parallax search feature doesn't yield any meaningful results.

Also, another interesting feature.. my ping handler doesn't work at all if I remove the serial com object, even though it doesn't use it. any thought?

<code>
CON

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

PING_Pin0 = 0 ' I/O Pin For PING)))
PING_Pin1 = 3 ' I/O Pin For PING)))
PING_Pin2 = 2 ' I/O Pin For PING)))
PING_Pin3 = 1 ' I/O Pin For PING)))
PING_Pin4 = 4 ' I/O Pin For PING)))

FRONTLIMIT = 15
DOWNLIMITMIN = 4
DOWNLIMITMAX = 10


VAR
long stack[noparse][[/noparse]10]
long cog


OBJ
dbg : "FullDuplexSerial"
ping : "ping"

DAT
ping_out long $0, $0

PUB stop
{{ Stop driver - frees a cog }}
if cog
cogstop(cog~ - 1)

PUB start : Success
stop
Success := (cog := cognew(checkpings, @stack) +1)

PUB set(pf, pd)
ping_out[noparse][[/noparse]0] := pf
ping_out := pd

PUB get(pf, pd)
long[noparse][[/noparse]pf] := ping_out[noparse][[/noparse]0]
long[noparse][[/noparse]pd] := ping_out

PUB checkpings | range0, range1, range2, range3, range4, pingfront, pingdown

repeat
pingfront := pingdown := 0
range0 := ping.Inches(PING_Pin0) ' Get Range In Inches
if range0 =< FRONTLIMIT
pingfront += %0001

range1 := ping.Inches(PING_Pin1) ' Get Range In Inches
if range1 =< FRONTLIMIT
pingfront += %0010

range2 := ping.Inches(PING_Pin2) ' Get Range In Inches
if range2 =< FRONTLIMIT
pingfront += %0100

range3 := ping.Inches(PING_Pin3) ' Get Range In Inches
if DOWNLIMITMIN =< range3 AND range3 =< DOWNLIMITMAX
pingdown += %0001

range4 := ping.Inches(PING_Pin4) ' Get Range In Inches
if DOWNLIMITMIN =< range4 AND range4 =< DOWNLIMITMAX
pingdown += %0010

set(pingfront, pingdown)

waitcnt(clkfreq / 50 + cnt) ' Pause 1/30 Second
</code>

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm either going mad or both...

Comments

Sign In or Register to comment.