MIAC Counter Problem

For MIAC users to discuss projects, applications, and any other issues related to the MIAC unit.

Moderators: Benj, Mods

Post Reply
royknaggs
Posts: 5
Joined: Thu Jul 30, 2015 3:11 pm
Has thanked: 3 times

MIAC Counter Problem

Post by royknaggs »

Hi Matrix,

We have had a problem with our Matrix MIAC controller.

What has happened is a variable (a counter) in the Flowcode program is assigned as a ulong but when this variable is actually used by the matrix controller it is acting like an integer, i.e. it gets to 32767 and starts counting down. I have re-uploaded the program but it makes no difference. What could be the possible problem?

Best Regards,

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: MIAC Counter Problem

Post by Benj »

Hello,

Please could you attach your Flowcode project file so we can have a look at your code.

royknaggs
Posts: 5
Joined: Thu Jul 30, 2015 3:11 pm
Has thanked: 3 times

Re: MIAC Counter Problem

Post by royknaggs »

Hi Benj,

I have attached what I believe is the project file! I did not do this programming but have been asked to try fix it!

Best Regards

Roy

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: MIAC Counter Problem

Post by Benj »

Hello Roy,

The PrintNumber function in the MIAC component only supports a signed integer and cannot display longs.

To work around this you can use the StringToInt function in the Strings tab of the calculation icon to convert your long variable to a hexadecimal string you can print to the display.

Flowcode 6 has an additional new function which allows you to correctly convert a long to a decimal string.

royknaggs
Posts: 5
Joined: Thu Jul 30, 2015 3:11 pm
Has thanked: 3 times

Re: MIAC Counter Problem

Post by royknaggs »

Hi Ben,

Thanks for the reply and possible solution! Since I am new to this are you able to do a short flowcode v5 file to show how your workaround solution works?

The company is still assessing whether they want to upgrade to Flowcode v6 but it might be an idea after this, I will push again with them! If we get Flowcode v6 would our current file need any changes or would it work as is?

In the meantime are you able to take down my flowcode file as I don't think the company wants it widely available! How do you Private Message so that you can send files without them being accessed by the wider world?

Many thanks again!

Regards

Roy

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: MIAC Counter Problem

Post by Benj »

Hello Roy,

Here is a quick example.
LongPrintAsHex.fcf
(6.5 KiB) Downloaded 563 times
To PM a user simply click on their name e.g. "Benj" to get to their about page and then click the Private Message (PM) link. Or there is a button marked PM on the right hand side of the forums under the poster's username --> .

royknaggs
Posts: 5
Joined: Thu Jul 30, 2015 3:11 pm
Has thanked: 3 times

Re: MIAC Counter Problem

Post by royknaggs »

Hi Ben,

Having thought about it a bit and played with your small program [Thank you for that!!], would it not be easier to just change the PrintNumber (CountedCycles) function [which doesn't work due to CountedCycles being a long variable] to the PrintString (CountedCyclesString) function because we have already calculated CountedCyclesString = ToString$ (CountedCycles) in the calculation icon?

Would it mess with the formatting at all on the screen, though I suspect it won't?

Best Regards

Roy

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: MIAC Counter Problem

Post by Benj »

Hello Roy,

You're right, ToString$ assumes a signed 32-bit INT as the maximum bit depth so should work fine.

In Flowcode v6 we added the a function to the LCD component called PrintFormattedNumber which supports 32-bit INTs in signed or unsigned formats just in case you need the extra flexibility.

royknaggs
Posts: 5
Joined: Thu Jul 30, 2015 3:11 pm
Has thanked: 3 times

Re: MIAC Counter Problem

Post by royknaggs »

Thanks Ben, I think it's problem solved as we only count to 200k for now! I'm looking at v6 anyway so I can do arduino as well, but as always funding is tight!

Best regards

Roy

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: MIAC Counter Problem

Post by medelec35 »

Hi Roy,
2 Links they maybe of interest to you?
Link 1
Link 2

Martin
Martin

Post Reply