Page 1 of 1

Problem LUT GetIntCount en GetFloatCount

Posted: Mon Mar 25, 2019 5:56 pm
by Ronnyvs
Beste Allen,

Ik heb een probleem bij de omzetting van de parameter (return Value is UInt) die word gegenereerd wanneer de parameters GetIntCount en GetFloatCount worden gebruikt met de "LUT".

Het probleem werkt door in het hele programma, andere LUT's en andere variabelen... (hier zit dan ook het grootste probleem)

Ik heb een klein test programmaatje gemaakt waarin het duidelijk wordt...
Ik genereer een "fout" bij het uitlezen van het aantal integers in de LUT1 (dat werkt goed) echter wanneer ik die waarde (UInt) wil omzetten in een String gaat het fout.... (ik kan het aantal karakters in de string tussen de [] wek veranderen, maar het aantal blijft altijd 8...

zelfs bij uitlezen van andere LUT en andere variabelen(strings) worden deze met 8 karakters weergegeven...
wanneer ik handmatig de waarde als integer ingeef, dat gaat alles goed.

Het lijkt er dus op, dat omzetten van Uint naar String niet werkt...

Testprogrammaatje:
LUT_GetIntCount_Problem.fcfx
Test_programma
(11.57 KiB) Downloaded 193 times
Ik hoop dat iemand mij kan helpen...

groeten,

Ronny

Re: Problem LUT GetIntCount en GetFloatCount

Posted: Tue Mar 26, 2019 4:02 pm
by Ronnyvs
Het lijkt er op dat ik zelf het probleem heb gevonden....

De uitgelezen waarde (wordt volgens mij) gezien als een Float...

ik gebruik dan na het uitlezen de functie FloatToString$, echter geef ik bij de float een komma met getal weer. Dit geeft aan hoeveel decimalen de Float heeft...

voorbeeld zoals ik het gebruik nu....
Stapgrootte_LUT3_Str = FloatToString$ (Stapgrootte_LUT3_Float,2)

Ik hoop dat ik hiermee de juiste stap zet om van een LUT-waarde (via Float) naar een string ga...
zo niet, dan verneem ik het graag!

Ronnyvs

Re: Problem LUT GetIntCount en GetFloatCount

Posted: Tue Mar 26, 2019 4:48 pm
by LeighM
Yes, looks like you have solved the problem.
But also the length 4 of the Float2_Str[4] character buffer might be too small

Re: Problem LUT GetIntCount en GetFloatCount

Posted: Tue Mar 26, 2019 5:14 pm
by kersing
First of all, please use English on the forum.

First question I have is what you are trying to achieve. The functions to get the number integers (or floats) is simulation only so will not work on the real hardware. Is that what you want?

Why do you use FloatToString to go from an integer to a string? ToString works for integer and avoids converting an integer to a float.

---
Allereerst, s.v.p Engels gebruiken op het forum

Eerste vraag die ik heb is wat je probeert te bereiken. De functies om het aantal integers (of floats) te krijgen werken alleen in simulatie en niet op de hardware. Is dat wat je wilt?

Waarom gebruik je FloatToString om een integer in een string om te zetten? ToString gebruikt een integer als invoer en vermijdt het omzetten van een integer naar een float.

Re: Problem LUT GetIntCount en GetFloatCount

Posted: Fri Mar 29, 2019 12:21 am
by Ronnyvs
First of all, thank you for the reply's

I thought that these functions also worked on the hardware... I'm a new user of flowcode, so I’m just a little bit struggling with the programming.
Sometimes it's hard to know if it is only working in simulation or really in the hardware.
(My real program is totally different, I only wrote this small program to show the problem)
Specially for this function… I want to count the number of stored variables in a LUT
The reason why I’m using FloatToString is that I want to show some values on a display.
These values are decimal values.
But,directly the question:
What is the right way to count the number of integers or floats in the LUT?
Already thanks for the reply


Allereerst bedankt voor de antwoorden

Ik dacht dat deze functies ook op de hardware werkten ... Ik ben een nieuwe gebruiker van flowcode, dus ik heb nog een beetje moeite met de programmering.
Soms is het moeilijk om te weten of het alleen in de simulatie of echt in de hardware werkt.
(Mijn echte programma is heel anders, ik heb alleen dit kleine programma geschreven om het probleem te laten zien)
Speciaal voor deze functie ... wil ik het aantal opgeslagen variabelen in een LUT tellen
De reden waarom ik FloatToString gebruik, is dat ik een aantal waarden op een display wil weergeven.
Deze waarden zijn decimale waarden.
Maar direct de vraag:
Wat is de juiste manier om het aantal gehele getallen of drijvers in de LUT te tellen?
Alvast bedankt voor het antwoord.

Re: Problem LUT GetIntCount en GetFloatCount

Posted: Fri Mar 29, 2019 2:52 pm
by LeighM
What is the right way to count the number of integers or floats in the LUT?
The LUT component does not support the count feature on the target device, only in simulation.
We agree this would be a useful feature, hopefully we can add this some time, but cannot say when.

Re: Problem LUT GetIntCount en GetFloatCount

Posted: Fri Apr 05, 2019 12:04 pm
by Benj
I've done a mod to the LUT component and added a new embedded macro to get the number of elements in the LUT which can be ran on microcontroller hardware.

The latest version of the component can be downloaded from the Help -> Check for updates if you are running version 8.1.

Re: Problem LUT GetIntCount en GetFloatCount

Posted: Mon Apr 08, 2019 3:48 pm
by Ronnyvs
Thank you Ben!

i will try it this week, and of course... i will let you know.

Friendly regards,

Ronny