Page 1 of 1
Random
Posted: Mon Apr 04, 2011 1:02 pm
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
Re: Random
Posted: Mon Apr 04, 2011 1:31 pm
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.
Re: Random
Posted: Mon Apr 04, 2011 1:32 pm
by medelec35
Re: Random
Posted: Tue Apr 05, 2011 12:58 pm
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
Re: Random
Posted: Tue Apr 05, 2011 1:21 pm
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
Re: Random
Posted: Tue Apr 05, 2011 1:47 pm
by jgu1
Hi medelec!
Unfortunately, it did not work. I get the same error when I try to compile to the Eico.
Regard
jgu1
Re: Random
Posted: Tue Apr 05, 2011 2:11 pm
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.
Re: Random
Posted: Tue Apr 05, 2011 2:39 pm
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.
Re: Random
Posted: Tue Apr 05, 2011 7:31 pm
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
Re: Random
Posted: Wed Apr 06, 2011 6:36 am
by jgu1
Hi everybody!
Medelec´s example works fine. What I have done wrong, I do not know. I am very grateful for everyone's interest and help.
Thank´s guy´s
jgu1