Random

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times

Random

Post by jgu1 »

Hi everyone!

Can anyone help me with an example how to make a random generator with readout on a display or Led output
I've tried with an example from Ver. 3 but it does not work in flowcode v4.

Thanks in advance


Jgu1

User avatar
DavidA
Matrix Staff
Posts: 1076
Joined: Fri Apr 23, 2010 2:18 pm
Location: Matrix Multimedia Ltd
Has thanked: 58 times
Been thanked: 258 times
Contact:

Re: Random

Post by DavidA »

Hello,

If you could include the v3 example you are trying to make work it may be easier to see why that one is not working.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Random

Post by medelec35 »

Martin

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times

Re: Random

Post by jgu1 »

Hello again! :)

Thank you for your prompt response and examples and they work fine too. :)
But the example I use is from Bert V. Damm 's book chapter 4.1 in the flow code 3 (Very simple) I have imported and chance the Pic to an Eico 40 in Flow Code v4 and get the following message when I compilers it Eico:


C:\Flow4examples\Random\Random C.c(592:9): error: unknown identifier 'tmr0'
C:\Flow4examples\Random\Random C.c(592:8): error: arguments of 'srand' don't match the parameters of call
C:\Flow4examples\Random\Random C.c(592:2): error: failed to generate expression
Random C.c success

failure

Return code = 1

Flowcode var ude i stand til at kompilere flowchart's C kode pågrund af følgende fejl:


If dit flowchart indeholder C kode, review det nøje. Hvis dit flowchart ikke indeholder C-kode og du virkelig har reviewed koden, kontakt Teknisk.


Can anyone tell what I'm doing wrong. :?:

Thank´s in advance!

Best regard

Jgu1
Attachments
Random C.fcf
(7.5 KiB) Downloaded 301 times

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Random

Post by medelec35 »

Hi jgu1
Just add letter l to C code Block.
Instead of srand (tmr0);
Change to srand (tmr0l);

Some Microcontrollers use tmr0 whist others in particular the newer ones use tmr0l

Note: Since using A cblock containing FCV_RANDOM = rand ();
Simulation result will always be 0 as simulator does not simulate C.


Martin
Martin

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times

Re: Random

Post by jgu1 »

Hi medelec!

Unfortunately, it did not work. I get the same error when I try to compile to the Eico. :(

Regard


jgu1

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Random

Post by medelec35 »

Hmm. Odd Compiles for me OK
If this fails then maybe you require an update?

Can you post your Random C.c file and Random C.msg, after compiling with this updated Flowchart.
Attachments
Random C.fcf
(7.5 KiB) Downloaded 314 times
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Random

Post by Benj »

Hello,

You could try changing the C code icon from "srand (tmr0);" to "srand (tmr0l);"

I think the problem may be due to the fact that the timer0 on the ECIO is a 16-bit timer so there is a high and a low count register instead of a single count register.

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times

Re: Random

Post by Spanish_dude »

If you're not using the EEPROM of the ECIO you could try my way of having random numbers ?

http://www.matrixmultimedia.com/mmforum ... 004#p22825

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times

Re: Random

Post by jgu1 »

Hi everybody! :lol:

Medelec´s example works fine. What I have done wrong, I do not know. I am very grateful for everyone's interest and help. :D :D

Thank´s guy´s

jgu1

Post Reply