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 | Re: Random Doesnt Stop well multi Tasking

Discussion forum for the BasicX family of microcontroller chips.

Random Doesnt Stop well multi Tasking - ryan_autet - Apr 17 6:44:26 2007

Hi

Ok odd Problem or maybe not you guys seem to answers for every
thing ;)

any way im playing this little bot and as soon i call the random
function well multi tasking it keeps calling it no matter what till
the multi tasking stalls

heres my code any ideas ?

Option Explicit
Dim Lower_Thought_Stack(1 to 80) As Byte
Dim SensorStack(1 to 60) As Byte
Dim MovmentStack(1 to 40) As Byte

Public Status As String
Public Movement_Status As String

'|----------[Main Routine]----------|

Public Sub Main()
Call BlinkLeds

''Insurt First Run Coder here
Status = "Moving_Around"

CallTask "Sensors", SensorStack
CallTask "Movment", MovmentStack
CallTask "Lower_Thought",Lower_Thought_Stack

Call BlinkLeds
End Sub

'|----------[Thought Routines]----------|

Public Sub Lower_Thought()
Do

If Status = "Looking_Around" then
'Insert Code
End If

If Status = "Moving_Around" Then
If Range >= 15 Then
Movement_Status = "Move_Forward"
ElseIf Range <= 15 Then
Call Random '<-------------AARRRGGG it fcks
every thing up XD
Movement_Status = "Move_Left"
End if
End If

If Status = "Random_Pause" Then
Call Sleep (1.0)
Else
Call Sleep(0.1)
End If

Loop

End Sub

'|----------[Sub Routines]----------|

Public Sub Sensors()
Do

Call Get_Tilt
Call SRF04
Call Sleep(0.05)

Loop
End Sub

Public Sub Movment()
Do

If Movement_Status = "Move_Forward" then
Call Forward
End If

If Movement_Status = "Move_Back" then
Call Move_Back
End If

If Movement_Status = "Move_Left" then
Call Left
End if

If Movement_Status = "Stopped" Then

End If

Call Sleep(0.05)

Loop



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


Re: Random Doesnt Stop well multi Tasking - ryan_autet - Apr 18 9:33:57 2007


Public Sub Random()
Call Randomize
Result = (Rnd / 1000.1)
Debug.Print "Random Gen: "; CStr(Result)
End Sub

that is the random code, i cant make it as simpole as 1 or twp
on a side note beside the the fat i cant make it work well multi
tasking all of a suden periode.
im wondernging if there was a way to mathictivly work it out so do
random work outs to a choise 1-10
so ingeger works out to 1 or 10 leaving choise of 1to 10
if it is posdible like said, have to get past the fact it all fo a
suden stalls my mulati tasking.

witch is very odd

--- In b...@yahoogroups.com, "ryan_autet" wrote:
>
> Hi
>
> Ok odd Problem or maybe not you guys seem to answers for every
> thing ;)
>
> any way im playing this little bot and as soon i call the random
> function well multi tasking it keeps calling it no matter what till
> the multi tasking stalls
>
> heres my code any ideas ?
>
> Option Explicit
> Dim Lower_Thought_Stack(1 to 80) As Byte
> Dim SensorStack(1 to 60) As Byte
> Dim MovmentStack(1 to 40) As Byte
>
> Public Status As String
> Public Movement_Status As String
>
> '|----------[Main Routine]----------|
>
> Public Sub Main()
> Call BlinkLeds
>
> ''Insurt First Run Coder here
> Status = "Moving_Around"
>
> CallTask "Sensors", SensorStack
> CallTask "Movment", MovmentStack
> CallTask "Lower_Thought",Lower_Thought_Stack
>
> Call BlinkLeds
> End Sub
>
> '|----------[Thought Routines]----------|
>
> Public Sub Lower_Thought()
> Do
>
> If Status = "Looking_Around" then
> 'Insert Code
> End If
>
> If Status = "Moving_Around" Then
> If Range >= 15 Then
> Movement_Status = "Move_Forward"
> ElseIf Range <= 15 Then
> Call Random '<-------------AARRRGGG it fcks
> every thing up XD
> Movement_Status = "Move_Left"
> End if
> End If
>
> If Status = "Random_Pause" Then
> Call Sleep (1.0)
> Else
> Call Sleep(0.1)
> End If
>
> Loop
>
> End Sub
>
> '|----------[Sub Routines]----------|
>
> Public Sub Sensors()
> Do
>
> Call Get_Tilt
> Call SRF04
> Call Sleep(0.05)
>
> Loop
> End Sub
>
> Public Sub Movment()
> Do
>
> If Movement_Status = "Move_Forward" then
> Call Forward
> End If
>
> If Movement_Status = "Move_Back" then
> Call Move_Back
> End If
>
> If Movement_Status = "Move_Left" then
> Call Left
> End if
>
> If Movement_Status = "Stopped" Then
>
> End If
>
> Call Sleep(0.05)
>
> Loop
>



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

Re: Random Doesnt Stop well multi Tasking - ryan_autet - Apr 18 9:41:42 2007

to be perficly honist those holle project os so i have a bot to
interact with my AIBO ERS 7 mind 3

I luv sony God bless them they have created a robot that realy
desurves luv, so i have a bot to walk it and keep it company.
i have these basic X micrcocontrollers kickining around,

so im trying to make dog a friend unfortantly untill its friend can
navigate it cant walk my dog ;)
--- In b...@yahoogroups.com, "ryan_autet" wrote:
>
> Hi
>
> Ok odd Problem or maybe not you guys seem to answers for every
> thing ;)
>
> any way im playing this little bot and as soon i call the random
> function well multi tasking it keeps calling it no matter what till
> the multi tasking stalls
>
> heres my code any ideas ?
>
> Option Explicit
> Dim Lower_Thought_Stack(1 to 80) As Byte
> Dim SensorStack(1 to 60) As Byte
> Dim MovmentStack(1 to 40) As Byte
>
> Public Status As String
> Public Movement_Status As String
>
> '|----------[Main Routine]----------|
>
> Public Sub Main()
> Call BlinkLeds
>
> ''Insurt First Run Coder here
> Status = "Moving_Around"
>
> CallTask "Sensors", SensorStack
> CallTask "Movment", MovmentStack
> CallTask "Lower_Thought",Lower_Thought_Stack
>
> Call BlinkLeds
> End Sub
>
> '|----------[Thought Routines]----------|
>
> Public Sub Lower_Thought()
> Do
>
> If Status = "Looking_Around" then
> 'Insert Code
> End If
>
> If Status = "Moving_Around" Then
> If Range >= 15 Then
> Movement_Status = "Move_Forward"
> ElseIf Range <= 15 Then
> Call Random '<-------------AARRRGGG it fcks
> every thing up XD
> Movement_Status = "Move_Left"
> End if
> End If
>
> If Status = "Random_Pause" Then
> Call Sleep (1.0)
> Else
> Call Sleep(0.1)
> End If
>
> Loop
>
> End Sub
>
> '|----------[Sub Routines]----------|
>
> Public Sub Sensors()
> Do
>
> Call Get_Tilt
> Call SRF04
> Call Sleep(0.05)
>
> Loop
> End Sub
>
> Public Sub Movment()
> Do
>
> If Movement_Status = "Move_Forward" then
> Call Forward
> End If
>
> If Movement_Status = "Move_Back" then
> Call Move_Back
> End If
>
> If Movement_Status = "Move_Left" then
> Call Left
> End if
>
> If Movement_Status = "Stopped" Then
>
> End If
>
> Call Sleep(0.05)
>
> Loop
>



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

Re: Random Doesnt Stop well multi Tasking - Chris Odom - Apr 19 11:52:27 2007

--- In b...@yahoogroups.com, "ryan_autet" wrote:
> Public Sub Random()
> Call Randomize
> Result = (Rnd / 1000.1)
> Debug.Print "Random Gen: "; CStr(Result)
> End Sub

My guess is Result is not really random. The folks at NetMedia made a
mistake with the Randomize procedure, as I state in my textbook. It
seems like we _should_ use Randomize to seed the random number
generator (like we would using Visual Basic), however just the opposite
is true with BasicX. If you call Randomize in BasicX, the numbers will
not be random, but will be the same each time the program is run.
Since you call Randomize each time, RND will be the same number each
time, yielding the same result each time.

To get random numbers, do NOT call Randomize. Try that and see if it
works.

chris


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

Re: Random Doesnt Stop well multi Tasking - ryan_autet - Apr 20 5:05:00 2007

:?

Thanks for your thoughts Chris, i tryed not calling the Randomize
but i it didnt return me a number at all XD and now the prossor
restarts. XD witch is step up from stalling lol

could you show me some source code so i can compair please?

--- In b...@yahoogroups.com, "Chris Odom" wrote:
>
> --- In b...@yahoogroups.com, "ryan_autet" wrote:
> > Public Sub Random()
> > Call Randomize
> > Result = (Rnd / 1000.1)
> > Debug.Print "Random Gen: "; CStr(Result)
> > End Sub
>
> My guess is Result is not really random. The folks at NetMedia
made a
> mistake with the Randomize procedure, as I state in my textbook.
It
> seems like we _should_ use Randomize to seed the random number
> generator (like we would using Visual Basic), however just the
opposite
> is true with BasicX. If you call Randomize in BasicX, the numbers
will
> not be random, but will be the same each time the program is run.
> Since you call Randomize each time, RND will be the same number
each
> time, yielding the same result each time.
>
> To get random numbers, do NOT call Randomize. Try that and see if
it
> works.
>
> chris
>



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

Re: Re: Random Doesnt Stop well multi Tasking - rosa...@aol.com - Apr 20 14:20:04 2007

Hi,

I tried his routine for random and it works. Here is how I try it. It give me a different number every time.
Attached is the output file from Debug. I do not know if this is what you are looking. You can open it with notepad.

Option Explicit
Public Sub Main()
start:
call random
goto start
End Sub

Sub Random()
dim Result as single
Call Randomize
Result = (Rnd / 1000.1)
Debug.Print "Random Gen: "; CStr(Result)
end sub

rosarite

-----Original Message-----
From: r...@hotmail.com
To: b...@yahoogroups.com
Sent: Fri, 20 Apr 2007 2:20 AM
Subject: [BasicX] Re: Random Doesnt Stop well multi Tasking

:?

Thanks for your thoughts Chris, i tryed not calling the Randomize
but i it didnt return me a number at all XD and now the prossor
restarts. XD witch is step up from stalling lol

could you show me some source code so i can compair please?

--- In b...@yahoogroups.com, "Chris Odom" wrote:
>
> --- In b...@yahoogroups.com, "ryan_autet" wrote:
> > Public Sub Random()
> > Call Randomize
> > Result = (Rnd / 1000.1)
> > Debug.Print "Random Gen: "; CStr(Result)
> > End Sub
>
> My guess is Result is not really random. The folks at NetMedia
made a
> mistake with the Randomize procedure, as I state in my textbook.
It
> seems like we _should_ use Randomize to seed the random number
> generator (like we would using Visual Basic), however just the
opposite
> is true with BasicX. If you call Randomize in BasicX, the numbers
will
> not be random, but will be the same each time the program is run.
> Since you call Randomize each time, RND will be the same number
each
> time, yielding the same result each time.
>
> To get random numbers, do NOT call Randomize. Try that and see if
it
> works.
>
> chris
>

________________________________________________________________________
AOL now offers free email to everyone. Find out more about what's free from AOL at AOL.com.
[Non-text portions of this message have been removed]


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

Re: Random Doesnt Stop well multi Tasking - ryan_autet - Apr 20 22:36:55 2007

:?
Yeah your code is pretty much same as mine,
but doesnt returns random numbers, Even if it is the only task
running the numbers are the same.

My Problem is i need an actual radom number generator that doesnt
stall multi tasking or cause a reboot.

I dont know maybe its a timming issue.
im not sure.
--- In b...@yahoogroups.com, rosarite@... wrote:
>
> Hi,
>
> I tried his routine for random and it works. Here is how I try it.
It give me a different number every time.
> Attached is the output file from Debug. I do not know if this is
what you are looking. You can open it with notepad.
>
> Option Explicit
> Public Sub Main()
> start:
> call random
> goto start
> End Sub
>
> Sub Random()
> dim Result as single
> Call Randomize
> Result = (Rnd / 1000.1)
> Debug.Print "Random Gen: "; CStr(Result)
> end sub
>
> rosarite
>
>
>
>
> -----Original Message-----
> From: ryan_autet@...
> To: b...@yahoogroups.com
> Sent: Fri, 20 Apr 2007 2:20 AM
> Subject: [BasicX] Re: Random Doesnt Stop well multi Tasking
>
> :?
>
> Thanks for your thoughts Chris, i tryed not calling the Randomize
> but i it didnt return me a number at all XD and now the prossor
> restarts. XD witch is step up from stalling lol
>
> could you show me some source code so i can compair please?
>
> --- In b...@yahoogroups.com, "Chris Odom" wrote:
> >
> > --- In b...@yahoogroups.com, "ryan_autet" wrote:
> > > Public Sub Random()
> > > Call Randomize
> > > Result = (Rnd / 1000.1)
> > > Debug.Print "Random Gen: "; CStr(Result)
> > > End Sub
> >
> > My guess is Result is not really random. The folks at NetMedia
> made a
> > mistake with the Randomize procedure, as I state in my textbook.
> It
> > seems like we _should_ use Randomize to seed the random number
> > generator (like we would using Visual Basic), however just the
> opposite
> > is true with BasicX. If you call Randomize in BasicX, the
numbers
> will
> > not be random, but will be the same each time the program is
run.
> > Since you call Randomize each time, RND will be the same number
> each
> > time, yielding the same result each time.
> >
> > To get random numbers, do NOT call Randomize. Try that and see
if
> it
> > works.
> >
> > chris
> >
>
>
>
______________________________________________________________________
__
> AOL now offers free email to everyone. Find out more about what's
free from AOL at AOL.com.
> [Non-text portions of this message have been removed]
>



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

Re: Re: Random Doesnt Stop well multi Tasking - rosa...@aol.com - Apr 20 23:44:57 2007

Hi,

Did you try to run the routine alone in your micro? Because when I ran mine you can see the numbers changing randomly from 1 thru 9.

Rosarite

-----Original Message-----
From: r...@hotmail.com
To: b...@yahoogroups.com
Sent: Fri, 20 Apr 2007 10:02 PM
Subject: [BasicX] Re: Random Doesnt Stop well multi Tasking

:?
Yeah your code is pretty much same as mine,
but doesnt returns random numbers, Even if it is the only task
running the numbers are the same.

My Problem is i need an actual radom number generator that doesnt
stall multi tasking or cause a reboot.

I dont know maybe its a timming issue.
im not sure.
--- In b...@yahoogroups.com, rosarite@... wrote:
>
> Hi,
>
> I tried his routine for random and it works. Here is how I try it.
It give me a different number every time.
> Attached is the output file from Debug. I do not know if this is
what you are looking. You can open it with notepad.
>
> Option Explicit
> Public Sub Main()
> start:
> call random
> goto start
> End Sub
>
> Sub Random()
> dim Result as single
> Call Randomize
> Result = (Rnd / 1000.1)
> Debug.Print "Random Gen: "; CStr(Result)
> end sub
>
> rosarite
>
>
>
>
> -----Original Message-----
> From: ryan_autet@...
> To: b...@yahoogroups.com
> Sent: Fri, 20 Apr 2007 2:20 AM
> Subject: [BasicX] Re: Random Doesnt Stop well multi Tasking
>
> :?
>
> Thanks for your thoughts Chris, i tryed not calling the Randomize
> but i it didnt return me a number at all XD and now the prossor
> restarts. XD witch is step up from stalling lol
>
> could you show me some source code so i can compair please?
>
> --- In b...@yahoogroups.com, "Chris Odom" wrote:
> >
> > --- In b...@yahoogroups.com, "ryan_autet" wrote:
> > > Public Sub Random()
> > > Call Randomize
> > > Result = (Rnd / 1000.1)
> > > Debug.Print "Random Gen: "; CStr(Result)
> > > End Sub
> >
> > My guess is Result is not really random. The folks at NetMedia
> made a
> > mistake with the Randomize procedure, as I state in my textbook.
> It
> > seems like we _should_ use Randomize to seed the random number
> > generator (like we would using Visual Basic), however just the
> opposite
> > is true with BasicX. If you call Randomize in BasicX, the
numbers
> will
> > not be random, but will be the same each time the program is
run.
> > Since you call Randomize each time, RND will be the same number
> each
> > time, yielding the same result each time.
> >
> > To get random numbers, do NOT call Randomize. Try that and see
if
> it
> > works.
> >
> > chris
> >
>
>
>
__________________________________________________________
__
> AOL now offers free email to everyone. Find out more about what's
free from AOL at AOL.com.
>
>
> [Non-text portions of this message have been removed]
>

________________________________________________________________________
AOL now offers free email to everyone. Find out more about what's free from AOL at AOL.com.
[Non-text portions of this message have been removed]


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

Re: Random Doesnt Stop well multi Tasking - ryan_autet - Apr 23 12:11:50 2007

Ok after stuggling with this random stuff i made i tryed a nother
aproch to making random numbers but later returned to this XD

So heres were iam at
Public Sub Random()
'Call Randomize
Result = (RND)
Debug.Print "Random Gen: "; CStr(Result)
End Sub

I can get random numbers
Calling Randomize messed it up yes
but my prossor either stalls or keeps callin random :?

realy im puzzled.

--- In b...@yahoogroups.com, rosarite@... wrote:
>
> Hi,
>
> Did you try to run the routine alone in your micro? Because when I
ran mine you can see the numbers changing randomly from 1 thru 9.
>
> Rosarite
>
>
> -----Original Message-----
> From: ryan_autet@...
> To: b...@yahoogroups.com
> Sent: Fri, 20 Apr 2007 10:02 PM
> Subject: [BasicX] Re: Random Doesnt Stop well multi Tasking
>
> :?
> Yeah your code is pretty much same as mine,
> but doesnt returns random numbers, Even if it is the only task
> running the numbers are the same.
>
> My Problem is i need an actual radom number generator that doesnt
> stall multi tasking or cause a reboot.
>
> I dont know maybe its a timming issue.
> im not sure.
> --- In b...@yahoogroups.com, rosarite@ wrote:
> >
> > Hi,
> >
> > I tried his routine for random and it works. Here is how I try
it.
> It give me a different number every time.
> > Attached is the output file from Debug. I do not know if this is
> what you are looking. You can open it with notepad.
> >
> > Option Explicit
> > Public Sub Main()
> > start:
> > call random
> > goto start
> > End Sub
> >
> > Sub Random()
> > dim Result as single
> > Call Randomize
> > Result = (Rnd / 1000.1)
> > Debug.Print "Random Gen: "; CStr(Result)
> > end sub
> >
> > rosarite
> >
> >
> >
> >
> > -----Original Message-----
> > From: ryan_autet@
> > To: b...@yahoogroups.com
> > Sent: Fri, 20 Apr 2007 2:20 AM
> > Subject: [BasicX] Re: Random Doesnt Stop well multi Tasking
> >
> > :?
> >
> > Thanks for your thoughts Chris, i tryed not calling the Randomize
> > but i it didnt return me a number at all XD and now the prossor
> > restarts. XD witch is step up from stalling lol
> >
> > could you show me some source code so i can compair please?
> >
> > --- In b...@yahoogroups.com, "Chris Odom" wrote:
> > >
> > > --- In b...@yahoogroups.com, "ryan_autet"
wrote:
> > > > Public Sub Random()
> > > > Call Randomize
> > > > Result = (Rnd / 1000.1)
> > > > Debug.Print "Random Gen: "; CStr(Result)
> > > > End Sub
> > >
> > > My guess is Result is not really random. The folks at NetMedia
> > made a
> > > mistake with the Randomize procedure, as I state in my
textbook.
> > It
> > > seems like we _should_ use Randomize to seed the random number
> > > generator (like we would using Visual Basic), however just the
> > opposite
> > > is true with BasicX. If you call Randomize in BasicX, the
> numbers
> > will
> > > not be random, but will be the same each time the program is
> run.
> > > Since you call Randomize each time, RND will be the same
number
> > each
> > > time, yielding the same result each time.
> > >
> > > To get random numbers, do NOT call Randomize. Try that and see
> if
> > it
> > > works.
> > >
> > > chris
> > >
> >
> >
> >
> __________________________________________________________
> __
> > AOL now offers free email to everyone. Find out more about
what's
> free from AOL at AOL.com.
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
______________________________________________________________________
__
> AOL now offers free email to everyone. Find out more about what's
free from AOL at AOL.com.
> [Non-text portions of this message have been removed]
>



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

Re: Re: Random Doesnt Stop well multi Tasking - Tom Becker - Apr 23 13:15:18 2007

> Calling Randomize messed it up...

Randomize appears to use the current RTC tick count to create a new
randomizer seed. Unfortunately, the RTC tick count always starts at
zero, so Randomize, at startup, will always produce the same seed.

A solution is to randomly seed the RTC value, then call Randomize, then
reset the RTC to zero - if you need that. Or, you can set the internal
seed variable directly; the randomizer seed is in a special variable
called SEEDPRNG.

For example:

dim YourSeed as new persistentlong
dim result as single

sub main()
SEEDPRNG = YourSeed
do
call random
loop
end sub

public sub random()
result = (RND)
debug.print "Random Gen: "; cstr(result)
YourSeed = register.rtctick 'BEWARE OF Persistent EEPROM BURN
end sub
Variable YourSeed contains the RTC value at the last call of Random;
since it is stored as a Persistent variable, it will survive resets and
continue to provide a new starting variable. Note that persistent vars
have limited lifespans; it is only the process time that Debug.Print
uses that prevents rapid looping that might quickly use the 1E5 to 1E6
writes that EEPROM tolerates. Be careful.

If your device has a pushbutton switch on it, another method at startup
can require the operator to push that button to proceed; how long the
operator took to press - or how long he pressed the button - can seed
the randomizer, too.
Tom



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

Re: Random Doesnt Stop well multi Tasking - p_dubinsky - Apr 23 14:02:39 2007

This problem reminds me of a similar problem that electronic
encryption equipment suffered from in the very early days of
semi-conductor revolution.

It became apparent in the early days of electronic encryption that it
would be impossible to create a software derived "random" number for
reasons that are similar to the RTC seed problem. The solution at that
time was to use software to count voltage spikes from a particularly
noisy diode circuit and use that count as the seed for the randomize
software.

I don't know if the diode circuit actually produced a truly random
number of spikes per unit time but when you consider that the noise
output of the diode circuit was influenced by the diode temperature,
the supply voltage, the component tolerances, the component
manufacturing process, etc. it's unlikely that you could reproduce the
output of that circuit. It certainly looked like a random signal when
you put the circuit output on an oscilloscope. Of course, the
equipment also used key cards in the encryption scheme so the system
wasn't totally reliant on the diode circuit.

An historical note: when the USS Pueblo was grabbed by the North
Koreans, equipment that used this type of randomizing circuit was on
board the ship and no one knew if the equipment had been destroyed or
captured. Within the next 24 hours, our facility was visited by an NSA
officer who brought us new key cards and supervised destruction of the
old key cards. When I left that episode of my life some years later,
the equipment was still being used AND the NSA knew that the equipment
on the Pueblo had not been destroyed before capture. (The equipment
was returned intact with the Pueblo some years later.) Apparently,
they weren't worried about the equipment being reverse-engineered. The
noise diode circuit might have been the elegant solution of this problem.

Paul

--- In b...@yahoogroups.com, Tom Becker wrote:
>
> > Calling Randomize messed it up...
>
> Randomize appears to use the current RTC tick count to create a new
> randomizer seed. Unfortunately, the RTC tick count always starts at
> zero, so Randomize, at startup, will always produce the same seed.
>...<



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

Re: Random Doesnt Stop well multi Tasking - ryan_autet - Apr 23 14:18:40 2007

:?

That doesnt help with the problem lol
but thats very insight full thank you.
notice you reply to a forum messages, are you a basic X
founder?
or just a realy realy helpfull guy? ;)

--- In b...@yahoogroups.com, Tom Becker wrote:
>
> > Calling Randomize messed it up...
>
> Randomize appears to use the current RTC tick count to create a new
> randomizer seed. Unfortunately, the RTC tick count always starts
at
> zero, so Randomize, at startup, will always produce the same seed.
>
> A solution is to randomly seed the RTC value, then call Randomize,
then
> reset the RTC to zero - if you need that. Or, you can set the
internal
> seed variable directly; the randomizer seed is in a special
variable
> called SEEDPRNG.
>
> For example:
>
> dim YourSeed as new persistentlong
> dim result as single
>
> sub main()
> SEEDPRNG = YourSeed
> do
> call random
> loop
> end sub
>
> public sub random()
> result = (RND)
> debug.print "Random Gen: "; cstr(result)
> YourSeed = register.rtctick 'BEWARE OF Persistent EEPROM BURN
> end sub
> Variable YourSeed contains the RTC value at the last call of
Random;
> since it is stored as a Persistent variable, it will survive resets
and
> continue to provide a new starting variable. Note that persistent
vars
> have limited lifespans; it is only the process time that
Debug.Print
> uses that prevents rapid looping that might quickly use the 1E5 to
1E6
> writes that EEPROM tolerates. Be careful.
>
> If your device has a pushbutton switch on it, another method at
startup
> can require the operator to push that button to proceed; how long
the
> operator took to press - or how long he pressed the button - can
seed
> the randomizer, too.
> Tom
>



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

Re: Re: Random Doesnt Stop well multi Tasking - rosa...@aol.com - Apr 23 15:16:33 2007

Hi,

Suggestion: What about using a free oscillator in one of the A/D input and use the value as random number. You can use a 555 timer as a sawtooth oscillator. Adjusted the output from zero to 5 volts and then read the input .
rosarite

-----Original Message-----
From: g...@rightime.com
To: b...@yahoogroups.com
Sent: Mon, 23 Apr 2007 1:10 PM
Subject: Re: [BasicX] Re: Random Doesnt Stop well multi Tasking

> Calling Randomize messed it up...

Randomize appears to use the current RTC tick count to create a new
randomizer seed. Unfortunately, the RTC tick count always starts at
zero, so Randomize, at startup, will always produce the same seed.

A solution is to randomly seed the RTC value, then call Randomize, then
reset the RTC to zero - if you need that. Or, you can set the internal
seed variable directly; the randomizer seed is in a special variable
called SEEDPRNG.

For example:

dim YourSeed as new persistentlong
dim result as single

sub main()
SEEDPRNG = YourSeed
do
call random
loop
end sub

public sub random()
result = (RND)
debug.print "Random Gen: "; cstr(result)
YourSeed = register.rtctick 'BEWARE OF Persistent EEPROM BURN
end sub

Variable YourSeed contains the RTC value at the last call of Random;
since it is stored as a Persistent variable, it will survive resets and
continue to provide a new starting variable. Note that persistent vars
have limited lifespans; it is only the process time that Debug.Print
uses that prevents rapid looping that might quickly use the 1E5 to 1E6
writes that EEPROM tolerates. Be careful.

If your device has a pushbutton switch on it, another method at startup
can require the operator to push that button to proceed; how long the
operator took to press - or how long he pressed the button - can seed
the randomizer, too.

Tom

________________________________________________________________________
AOL now offers free email to everyone. Find out more about what's free from AOL at AOL.com.
[Non-text portions of this message have been removed]


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

Re: Re: Random Doesnt Stop well multi Tasking - Tom Becker - Apr 23 18:02:44 2007

> That doesn't help with the problem...

Then I conclude that Randomize is not your problem. Try to describe the
problem another way.

No, I am not related to Netmedia other than as a user, and as a
moderator here - who often gets to see messages first, that's all.
Tom



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

Re: Re: Random Doesnt Stop well multi Tasking - Mechatronics At Camden CC - Apr 23 23:06:59 2007

I think that will work too. Even if you use some sensors already on the A/D inputs and some how add and subtract and so on different sensor values to get your random number then your not using the randomize at all. You could also include the timer.
I
Dose anyone know is the randomize one of those things that cant be used while Multitasking?

Keep us updated

r...@aol.com wrote:
Hi,

Suggestion: What about using a free oscillator in one of the A/D input and use the value as random number. You can use a 555 timer as a sawtooth oscillator. Adjusted the output from zero to 5 volts and then read the input .
rosarite

-----Original Message-----
From: g...@rightime.com
To: b...@yahoogroups.com
Sent: Mon, 23 Apr 2007 1:10 PM
Subject: Re: [BasicX] Re: Random Doesnt Stop well multi Tasking

> Calling Randomize messed it up...

Randomize appears to use the current RTC tick count to create a new
randomizer seed. Unfortunately, the RTC tick count always starts at
zero, so Randomize, at startup, will always produce the same seed.

A solution is to randomly seed the RTC value, then call Randomize, then
reset the RTC to zero - if you need that. Or, you can set the internal
seed variable directly; the randomizer seed is in a special variable
called SEEDPRNG.

For example:

dim YourSeed as new persistentlong
dim result as single

sub main()
SEEDPRNG = YourSeed
do
call random
loop
end sub

public sub random()
result = (RND)
debug.print "Random Gen: "; cstr(result)
YourSeed = register.rtctick 'BEWARE OF Persistent EEPROM BURN
end sub

Variable YourSeed contains the RTC value at the last call of Random;
since it is stored as a Persistent variable, it will survive resets and
continue to provide a new starting variable. Note that persistent vars
have limited lifespans; it is only the process time that Debug.Print
uses that prevents rapid looping that might quickly use the 1E5 to 1E6
writes that EEPROM tolerates. Be careful.

If your device has a pushbutton switch on it, another method at startup
can require the operator to push that button to proceed; how long the
operator took to press - or how long he pressed the button - can seed
the randomizer, too.

Tom

__________________________________________________________
AOL now offers free email to everyone. Find out more about what's free from AOL at AOL.com.

[Non-text portions of this message have been removed]

---------------------------------
Ahhh...imagining that irresistible "new car" smell?
Check outnew cars at Yahoo! Autos.

[Non-text portions of this message have been removed]


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

Re: Random Doesnt Stop well multi Tasking - ryan_autet - Apr 24 11:00:27 2007

Lol
so i guess that just makes make you an uber smart man ;)

ok well Tom i had a brain fart last night my self.

Ok bear with me here im gonna try to copy some code over

Option Explicit
Dim Lower_Thought_Stack(1 to 100) As Byte
Dim SensorStack(1 to 60) As Byte
Dim MovmentStack(1 to 50) As Byte

Public Status As String
Public Movement_Status As String
Public Range_Stat As String
'|----------[Main Routine]----------|

Public Sub Main()
Call BlinkLeds

''Insurt First Run Coder here
Status = "Moving_Around"
Movement_Status = "Stopped"

Call Randomize

CallTask "Sensors", SensorStack
CallTask "Movment", MovmentStack
CallTask "Lower_Thought",Lower_Thought_Stack

Call BlinkLeds
End Sub

'|----------[Thought Routines]----------|

Public Sub Lower_Thought()
Do

'If Status = "Looking_Around" then
'Insert Code
'End If

If Status = "Moving_Around" Then
Call Run_Around
End If

Call Sleep(0.05)

Loop

End Sub

'|----------[Sub Routines]----------|

Public Sub Sensors()
Do
Call SRF04
Call Get_Tilt
Call Sleep(0.02)
Loop
End Sub

Public Sub Movment()
Do

If Movement_Status = "Move_Forward" then
Call Forward
End If

If Movement_Status = "Move_Back" then
Call Move_Back
End If

If Movement_Status = "Move_Left" then
Call Left
End if

If Movement_Status = "Move_Right" then
Call Right
End if

If Movement_Status = "Stopped" Then

End If

Call Sleep(0.02)

Loop

End Sub

Ok i have three task running, now Lower_Thought
handles navigation, comunication and charitor.

Public Sub Run_Around()
If Range >= 15 Then
Range_Stat = "OK"
ElseIf Range <= 15 Then
Call Random <----
Movement_Status = "Move_Right"
End if

If TiltX >= 50 Then
Movement_Status = "Move_Back"
'Till TiltX <= 45 Then
Movement_Status = "Move_Left"
End If

End Sub

When i turn i call random more then once XD
silly problem lol
Allthough thanks to you i know have actual random numbers and not
just a supped up version of 1 and 0
But now im faced with the problem of how to call this just once befor
a turn. Because its being looped when the robot turns...

Thanks for the reply on the linux :) gonna try that later when i have
more free time.
--- In b...@yahoogroups.com, Tom Becker wrote:
>
> > That doesn't help with the problem...
>
> Then I conclude that Randomize is not your problem. Try to
describe the
> problem another way.
>
> No, I am not related to Netmedia other than as a user, and as a
> moderator here - who often gets to see messages first, that's all.
> Tom
>



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

Re: Re: Random Doesnt Stop well multi Tasking - Tom Becker - Apr 24 11:53:39 2007

> ... When I turn, I call Random more than once...

Ah, well, I guess you have a coding logic difficulty that you'll need to
resolve. Sorry; I can't help much with that.
Tom


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

Re: Random Doesnt Stop well multi Tasking - ryan_autet - Apr 24 12:32:28 2007

--- In b...@yahoogroups.com, Tom Becker wrote:
>
> > ... When I turn, I call Random more than once...
>
> Ah, well, I guess you have a coding logic difficulty that you'll need
to
> resolve. Sorry; I can't help much with that.
> Tom
>
Yeah lol
i just didnt see the logic last night XD
now i feel silly
But thanks for info Tom
it was very educatal.


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

Re: Random Doesnt Stop well multi Tasking - ryan_autet - Apr 24 14:35:55 2007

Tom this is a little off topic but has been pointed out befor the
Basic X is limited in its Ram were as Basic Z provides ample ram.
But you wouldnt happen to know of a way to expland the Ram on a Basic
X 24 microcontroller?

--- In b...@yahoogroups.com, "ryan_autet" wrote:
>
> --- In b...@yahoogroups.com, Tom Becker wrote:
> >
> > > ... When I turn, I call Random more than once...
> >
> > Ah, well, I guess you have a coding logic difficulty that you'll
need
> to
> > resolve. Sorry; I can't help much with that.
> >
> >
> > Tom
> >
> Yeah lol
> i just didnt see the logic last night XD
> now i feel silly
> But thanks for info Tom
> it was very educatal.
>



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

Re: Re: Random Doesnt Stop well multi Tasking - Tom Becker - Apr 24 19:15:36 2007

> ... know of a way to expand the Ram on a BX-24?

No, 401 bytes is it for the BX-24.
Tom


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