Problem LUT GetIntCount en GetFloatCount

Moderator: Benj

Post Reply
Ronnyvs
Posts: 10
Joined: Mon Mar 25, 2019 3:04 pm
Been thanked: 2 times
Contact:

Problem LUT GetIntCount en GetFloatCount

Post 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 191 times
Ik hoop dat iemand mij kan helpen...

groeten,

Ronny

Ronnyvs
Posts: 10
Joined: Mon Mar 25, 2019 3:04 pm
Been thanked: 2 times
Contact:

Re: Problem LUT GetIntCount en GetFloatCount

Post 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

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Problem LUT GetIntCount en GetFloatCount

Post 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

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: Problem LUT GetIntCount en GetFloatCount

Post 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.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Ronnyvs
Posts: 10
Joined: Mon Mar 25, 2019 3:04 pm
Been thanked: 2 times
Contact:

Re: Problem LUT GetIntCount en GetFloatCount

Post 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.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Problem LUT GetIntCount en GetFloatCount

Post 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.

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: Problem LUT GetIntCount en GetFloatCount

Post 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.

Ronnyvs
Posts: 10
Joined: Mon Mar 25, 2019 3:04 pm
Been thanked: 2 times
Contact:

Re: Problem LUT GetIntCount en GetFloatCount

Post by Ronnyvs »

Thank you Ben!

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

Friendly regards,

Ronny

Post Reply