mathematical calculations in the simulation and the real pro

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
siwo278
Posts: 39
Joined: Tue Feb 12, 2013 9:07 am
Has thanked: 4 times
Been thanked: 5 times
Contact:

mathematical calculations in the simulation and the real pro

Post by siwo278 »

mathematical calculations in the simulation and the real program - different results

Hello

What is the difference between the simulation and the actual operation of the program in the CPU in mathematical calculations? In my program I set day of the week based on such date: 01.01. (20) 00 this Saturday. In the simulation FLOWCODE program it works correctly. After programming the operation of the processor PIC18F46K22 calculation differs from the real. What mistakes committed in the program?

obliczenia matematyczne w symulacji a realny program - różne wyniki

Witam

Jaka jest różnica pomiędzy symulacją a właściwym działaniem programu w procesorze w obliczeniach matematycznych? W moim programie wyznaczam dzień tygodnia na podstawie daty np: 01.01.(20)00 to sobota. W symulacji flowcode program działa poprawnie. Po zaprogramowaniu procesora PIC18F46K22 działanie obliczeń odbiega od realnych. Jakie błędy popełniłam w programie?

Natalia
Attachments
27.09.15.rar
all
(427.85 KiB) Downloaded 431 times
18f46k22v9.hex
hex
(36.39 KiB) Downloaded 440 times
18f46k22v9.fcf
fcf - v5.5
(296.44 KiB) Downloaded 436 times

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: mathematical calculations in the simulation and the real

Post by kersing »

What is the result on hardware and what are you expecting? Currently you seem to expect us to look at 25 macros and guess what the problem might be. Please provide more details as to what the error is and where we can find the calculations you are referring to.
Please do not forget you know what your program is supposed to do, we have to reverse engineer the code and guess what you expect to happen.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

siwo278
Posts: 39
Joined: Tue Feb 12, 2013 9:07 am
Has thanked: 4 times
Been thanked: 5 times
Contact:

Re: mathematical calculations in the simulation and the real

Post by siwo278 »

Hello

I'm sorry not clarified questions. As for the calculation of the date of the macro "DZIEN_TYGODNIA" - a processing algorithm of calculating the day of the week based on the date. In the simulation, the algorithm correctly computes flowkode day of the week and the real program on the processor completely lost calculations - does not set correct day of the week. This algorithm which determines the day of the week by date http://www.algorytm.org/przetwarzanie-d ... odnia.html

Witam

Przepraszam nie doprecyzowałam pytania. Chodzi o obliczenia daty w makro "DZIEN_TYGODNIA" - jest to przeróbka algorytmu wyznaczania dnia tygodnia na podstawie daty. W symulacji flowkode algorytm poprawnie oblicza dzień tygodnia a w realnym programie na procesorze zupełnie gubi obliczenia - nie wyznacza poprawnie dnia tygodnia. To algorytm który wyznacza dzień tygodnia na podstawie daty http://www.algorytm.org/przetwarzanie-d ... odnia.html

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

Re: mathematical calculations in the simulation and the real

Post by medelec35 »

I have used:
Flowcode DOTW calculation.png
(1.54 KiB) Downloaded 9355 times
Month Code:
Monthcode.png
(3.7 KiB) Downloaded 9355 times
Year is just the last two digits of the year.
The Date-1 and Date+1 is for RTC I was using.
So thay can be removed of you want the results to be from 0 to 6 instead of 1 to 7
Works with Flowcode simulator and on hardware

Martin
Martin

siwo278
Posts: 39
Joined: Tue Feb 12, 2013 9:07 am
Has thanked: 4 times
Been thanked: 5 times
Contact:

Re: mathematical calculations in the simulation and the real

Post by siwo278 »

Hey

Cool algorithm. And could I bring it more mathematically?
Since my English is at the level of buying flowers. It is rather simple - Sunday? - Number Monday? - number

if so, I mean?

2015 years - (15 + 1) - year
27 days of the month - date
09 months - MonthCode

the extent to which year is this algorithm correct, could you bring me how to interpret tables Monthcode

my rtc is encoded as in the picture

Cześć

Fajny algorytm. A mógłbyś mi go bardziej przybliżyć matematycznie?
Ponieważ mój angielski jest na poziomie kupowania kwiatków. To raczej prosto - niedziela?- numer, poniedziałek? - numer

czy tak to mam rozumieć?

2015 rok - (00+1) - year
27 dzień miesiąca - date
09 miesiąc - MonthCode

w jakim zakresie lat jest ten algorytm prawidłowy, mogłbyś mi przybliżyć jak interpretować tabele Monthcode

mój rtc ma kodowanie jak na zdjęciu
Attachments
dayofweek.jpg
dayofweek.jpg (46.75 KiB) Viewed 14706 times

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

Re: mathematical calculations in the simulation and the real

Post by medelec35 »

Hi siwo278,
siwo278 wrote:Cool algorithm.
Thanks.
If you remove all the 1's as stated in the previous email i.e.

Code: Select all

DayNum = (Date  + MonthCode + Year + (Year / 4)) MOD 7
Then Daynum will match what you have posted.
E.g Sun = 0, Mon = 1 ..........Sat = 6
You can use the switch component to convert month to MonthCode:
Monthcode.png
(12.1 KiB) Downloaded 4364 times
So if you have
27
09
15
then the 9 will be converted to 5 (just like in the JFMAMJJOSOND table I posted.

Note: The

Code: Select all

Year % 4 = 0
is just checking if the year is disable by 4.
Where % = Mod
If it is then it's a different branch for Jan & Feb.

Hope this helps
Martin

siwo278
Posts: 39
Joined: Tue Feb 12, 2013 9:07 am
Has thanked: 4 times
Been thanked: 5 times
Contact:

Re: mathematical calculations in the simulation and the real

Post by siwo278 »

Hello

Replacing an algorithm that calculates the day of the week helped , now and simulation and realistic program calculate correctly . The above error dimmed further problems in the operation of the program. The problem is now interrupt TMR0 and faulty billing days during data input by the user. TMR0 is set to internal clock CLKO and has a value of 100Hz , and everything is driven quartz 3,2768MHz , if it's all good simulation runs in real time system interrupt it once does not start.
2.Wadliwe charging units days - in a user enters days by + and - keys . In the simulation work all the conditions of the top and bottom limit to the number of days for the month , in the real system as if they were not there . (Macro USTAWIANIE_ZEGARA )

Witam

Wymiana algorytmu obliczającego dzień tygodnia pomogła, teraz i symulacja i realny program obliczają poprawnie. Powyższy błąd zaćmił dalsze problemy w działaniu programu. Problemem są teraz przerwania od TMR0 i wadliwe naliczanie dni podczas wprowadzania danych przez użytkownika. TMR0 jest ustawione na wewnetrznym zegarze CLKO i ma wartość 100Hz, a wszystko jest napędzane kwarcem 3,2768MHz, o ile w symulacji to wszystko fajnie działa to w realnym układzie przerwanie to raz jest raz nie startuje.
2.Wadliwe naliczanie jednostek dni - w układzie użytkownik wprowadza dni poprzez klawisze + i -. W symulacji działaja wszystkie warunki od góry i dołu ograniczenia ilości dni dla danego miesiąca, w realnym układzie tak jak by ich nie było.(maCro USTAWIANIE_ZEGARA)
Attachments
PIC_RTCDCF72421.rar
protel99SE_sch_pcb
(15.33 KiB) Downloaded 433 times
18f46k22v10.fcf
fcf5.5
(286.89 KiB) Downloaded 462 times
Protel Schematic.pdf
(34.93 KiB) Downloaded 461 times

siwo278
Posts: 39
Joined: Tue Feb 12, 2013 9:07 am
Has thanked: 4 times
Been thanked: 5 times
Contact:

Re: mathematical calculations in the simulation and the real

Post by siwo278 »

Hello

It works ! Cause trouble was bad code word processor , and two variables that introduce errors in the calculation day of the week , which varied ranges of numbers used in the program . Thank you all for your help, especially colleague " medelec35 " - (Algorithm - day of the week ) - for the attention that each algorithm can be simplified .

Witam

Działa! Przyczyna kłopotów było złe słowo kodowe procesora, i dwie zmienne, które wprowadzały błędy w obliczeniach dnia tygodnia, co zmieniało zakresy liczb używanych w programie. Dziękuję wszystkim za pomoc, szczególnie koledze "medelec35" - (algorytm - dzien tygodnia) - za zwrócenie uwagi że każdy algorytm można uprościć.

Natalia

Post Reply