Sign in

username:

password:



Not a member?

Search basicx



Search tips

Subscribe to basicx



basicx by Keywords

Accelerometer | ADC | ADXL | Adxl20 | AVR | BasicStamp | BX-35 | BX28 | BX35 | COM3 | Compiler | Downloader | EEPROM | Electromagnet | GetADC | GP2D1 | GPS | I2C | IDE | Keypad | LCD | LCD+ | MIDI | Motors | Multitasking | Netmedia | Networking | PCB | PID | PlaySound | PWM | Relays | RTC | Servo | ShiftOut | SitePlayer | SPI | Stack | Timer | USB

Sponsor

controlSUITE™ software
Comprehensive.
Intuitive.
Optimized.

Real-world software for real-time control. Details Here!

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | BasicX | Multitasking InputCapture problem

Discussion forum for the BasicX family of microcontroller chips.

Multitasking InputCapture problem - medude56au - Aug 14 10:59:00 2002

Hi,
I am posting this for my 14year old son who is wanting to multitask a
servo movement while reading a TSL230 current to frequency
photodiode. He had progressed from having the read and print.debug
working well on Com1 as a non-multitasking process but once he added
in the first part of the multitasking he cannot get the conversion to
string function working. In the code below the program appears to
work until it gets to the Cstr function. The "checkpoint 1" prints
out but then continues to print out "Checkpoint 1". If Cstr(res) is
commented out it does continue through to "checkpoint 2" etc. Maybe
there is a problem with the variable res. If he replaces res with a
number (e.g 5.2) it does print out. But the Call InputCapture and
calculation of res did work before he added in multitasking. I
haven't been able to help him. Can any body help us.

Thanks in anticipation.

Peter & Michael

Option Explicit
dim tasktag as byte
dim read_tslstack(1 to 60) as byte
dim move_servostack(1 to 60) as byte

Public Sub Main()
const SenS0 as byte = 5
const SenS1 as byte = 6
const ScaleS2 as byte = 7
const ScaleS3 as byte = 8
const OutEnable as byte = 9

Call PutPin(SenS0, bxOutputHigh)
Call PutPin(SenS1, bxOutputLow)
Call PutPin(ScaleS2, bxoutputHigh)
Call PutPin(ScaleS3, bxoutputHigh)
Call PutPin(OutEnable, bxoutputlow)
Call PutPin(12, bxInputTristate)
calltask "read_tsl", read_tslstack

End Sub

public sub read_tsl()
dim tasktag as byte
dim localtag as byte
localtag = tasktag
dim reps as integer
dim x as integer
dim convstr as string
dim res as single
dim PulseTrain(1 To 10) As Integer

res = 0!
reps = 10

do
call InputCapture(PulseTrain, reps, 1)
x=2
do until x = reps
res = res + Csng(PulseTrain(x))
x = x+2
loop
res = 1!/((res/5!)/7372800!)
debug.print "Checkpoint 1"
convstr = CStr(res)
debug.print "Checkpoint 2"
debug.print convstr
debug.print "Checkpoint 3"
loop
call sleep(0.1)
End sub





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )


Re: Multitasking InputCapture problem - Frank Manning - Aug 14 12:42:00 2002

From: "medude56au" <>

> [...]
> In the code below the program appears to work until it
> gets to the Cstr function. The "checkpoint 1" prints
> out but then continues to print out "Checkpoint 1".
> [...]
> Option Explicit
> [...]
> dim read_tslstack(1 to 60) as byte
> [...]
> calltask "read_tsl", read_tslstack
> [...]
> public sub read_tsl()
> [...]
> dim convstr as string

What setting are you using for lengths of variable length strings?
If you're using 64, this will blow the stack right away, since the
task stack is only 60 bytes long.

Unless there is a compelling reason to keep the string around, I'd
just use this:

Debug.Print CStr(res)

which minimizes the memory use, since you don't need to declare a
separate variable. Also, CStr is expensive in RAM when you're
converting floating point. This might be another reason the stack
may be overflowing.

If you could output an integer instead of floating point, that
would save RAM. Or you could use code posted to the Yahoo files
section, which converts float to string types, and uses less RAM
than CStr, although it's also more restrictive than CStr.

-- Frank Manning
-- NetMedia, Inc.




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )