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

Ads

Discussion Groups

Discussion Groups | BasicX | Multitasking...

Discussion forum for the BasicX family of microcontroller chips.

Multitasking... - ffolkes - Jan 14 1:07:00 2000

Hello-

I seem to be able to multitask with the BX-24....except for this. I want to
have a main subroutine, and say "Call Servo()" and then have a subroutine run
that uses the standard servo controlling code.....a pulse every x amount of
seconds, looped to hold the servo in that position. How can I do this? Can I do
this at all? Thanks.

fs






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


Re: Multitasking... - Chris H. - Jan 16 22:21:00 2000

> From: ffolkes <>
>
> Hello-
>
> I seem to be able to multitask with the BX-24....except for this. I want
to
> have a main subroutine, and say "Call Servo()" and then have a subroutine
run
> that uses the standard servo controlling code.....a pulse every x amount
of
> seconds, looped to hold the servo in that position. How can I do this? Can
I do
> this at all? Thanks. Yes, you can do this. In fact, I have done this before with a BX1 several
months ago. Unfortunately I have lost the code after a HD crash. It was
pretty simple though. Basically I made two other tasks, one for each servo,
and had each task read a global variable. My main program would then simply
update the global variables with position values and the two servo tasks
would use the value in the global variables for their servo position
information. It worked very good. I also had my bumper switches values in
global variables and had a check in the servos loops to not allow forward
servo positions if the bump switch was triggered. This was a fail safe
incase my main program messed up and continued trying to give a wheel a
forward value if the bump switch was pressed. Another benifit was that my
main program could always look at the value in the global variable to see
what the servos were currently set to.

I plan on using this method in my latest project, using a BX24 to send
sensor readings to my robots onboard PC. I will create a global variable for
each sensor, then run a loop in its own task that simply updates the global
variables as fast as it can. My main routine will then output the values out
the serial port as fast as it can, using the values in the global variables.
This will insure that the BX24 is sending the very latest values.

Just remember, if you want a sub routine to run as a separate task, you must
call it as such. Call Servo() does not make a new task. You must use
CallTask. You can find more info about it in the docs.

Good luck!

-C
http://www.theonespot.com





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