MIAC PIC LABVIEW[Solved]

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

Moderators: Benj, Mods

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

MIAC PIC LABVIEW[Solved]

Post by QMESAR »

Hi Team.

I am looking into using a MIAC PIC for an Project.
The requirement is that the Controller has an LABVIEW User operating SW which I saw is possible with the MIAC through the USB interface
(I gues I could also use the (Serial UART/USB) connection to LABVIEW however if I could use the USB I would like that.
The problem/confusion at the moment is that I see in the supplied LABVIEW files from MIAC only a USB transfer VI and in the example
only data is transferred from LABVIEW to the MIAC this brings me to the question does this Transfer VI also read data into the LABVIEW project or is there another VI available to do that.
1.JPG
1.JPG (14.86 KiB) Viewed 13525 times


Please shed some light on my confusion :oops:

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 PIC LABVIEW

Post by Benj »

Hi Peter,

The Transfer function should allow you to send and receive data. I think you provide a buffer for outgoing data and another buffer for incoming data. I don't currently have Labview available to investigate further for you.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Ben.

Thank you for the answer,
Unfortuenalty the examples on the MIAC web page only shows Transmit buffer :)
Any case I will try and see what I can achieve once I have a MIAC :D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Ben.
I understand your problem with labView,
However I have tried to run the example 1 from Matrix and there is an issue with the Transfer VI it causes the Run Arrow to be broken(Error in the VI)
I then used the user example which as have no transfer VI in the block diagram then the Run Arrow is complete and I can run the VI,Once I place a Transfer VI on the Block Diagram the Run Arrow goes broken .You will notice in my pic4 I have actually wired all the terminals on the VI to avoid Errors because of unwired VI terminals (yellow markings).
As it is at the moment I suspect something is missing in the examples related to the Transfer VI (it is something in the background which I can not see from looking at the Transfer VI itself.

Can we somehow find a solution to this ? as MIAC with labView user Control make a lot of sense as it is an industrial Automation controller.
I understand that we can control MIAC over the UART(Serial) from labVIEW however if the MIAC has USB it is not so easy to explain the customer why we need a second USB to serial Converter :)
:D
1.JPG
1.JPG (29.08 KiB) Viewed 13418 times
3.JPG
3.JPG (53.58 KiB) Viewed 13418 times
2.JPG
2.JPG (39.9 KiB) Viewed 13418 times
4.JPG
4.JPG (85.14 KiB) Viewed 13418 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Team,
I think I have found the solution to my error.
I am waiting for my Miac to arrive and then I will check and test.

:D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Leigh/Ben.
After fixing the Firmware and sending me a new CAN component I must say that 99% of the LabVIEW stuff is working in MIAC however as you know and I reported above the supplied USB Transfer Sub VI is broken and not running in LabVIEW 2013 and higher.

The problem is when you transfer an ARRAY of data over the USB/dll then if all the elements are nonzero(this containing a value 1 and up the array elements transfer correctly,if any element contains a 0 value all elements after the one containing the zero is not updated or send

The supplied sub VI looks like this
4.jpg
4.jpg (61.88 KiB) Viewed 13087 times
Then I added control to the missing wire as LabVIEW complains about them and that fix the Error report However something is still wrong as it give the problem as described above .

I do not have the knowledge to check this what your dll needs please help to fix this dll and labVIEW sub VI issue .
5.jpg
5.jpg (72.8 KiB) Viewed 13087 times
This seams to be the only error left for having a 100% working LabVIEW MIAC interface
I am so sorry that I am bugging you guys with all of this I am really sorry however this is an important part of the MIAC for me and my customers
I ran my VI pass NI support and my handling of the Arrays are 100% correct no issue generated from my LabVIEW Vi
The question I have no answer to here may be you guys can shed some light
Could it be a case of the USB transfer assuming 0-terminated array, like a C-style string? Does 0 require some special handling? In some systems e.g. 0 could be a special character sign require some transformation (though you'd think the USB Transfer should handle that).

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Team.

It seams there not going to be support on this LabVIEW issue :shock:
In any case here is a FC Firmware question

In the USB Request_Handler macro there is defined a String variable of b[20]in which the USB string is placed
question 1 where is this done in the code ( :oops: I seam to miss it I do not see this)
1.jpg
1.jpg (43.84 KiB) Viewed 13047 times
Question 2
Why is this string terminated the moment there is 0 in an elemment
example if string (byte array) 1,2,3,4,0,6,7,8 CAN buffer is populated with 1,2,3,4 the rest of the string is then missing
similar if the USB string (array contains ) 1,2,0,4,5,6,7,8 CAN buffer is populated withg 1,2 and the rest is missing
2.jpg
2.jpg (41.43 KiB) Viewed 13046 times
The same is true fro for the outgoing string(Miac to PC) if all elemenst are non zero it works fine ,when one element contain a 0 everything after the 0 is missing,

Please help me understand this as in many CAN messages 16 bit variables are send as a High and a low byte for example if the value is 200 the
the CAN Message will send High byte = 0 and the low byte = C8 if the Value is 500 the High byte = 01 and the Low byte = F4 as you can see
if the USB string is terminated(for example)when it contains a 0 in a byte element then the MIAC and USB slave control is no option for me and I should stop waisting my time on this as at the moment I am strugling with MATRIX Firmware and labVIEW supplied support files and very little support from the Team so I am asking myself is this worth it to carry on trying to sell MIAC's

Team let us make a dicision we fix this issue or we stop it but I have now waste 1 week all on my own with this labVIEW files and Leigh fixed the issue in the Firmware ( 2 fixes applied) I am prepared to to help and support but I can not fix these issue on my own struggling for weeks ,
I applogize if I sound rude it is not my Intension but I am frustrated I have a DEMO coming up with a Serious Institution regarding eBlocks and Miac and I will have to say red faced I did not mange to get the labVIEW support working this is not good for me or my company understand this too secondly if MATRIX do not want to support the labVIEW stuff for MIAC that fine too but then remove it from Datasheet as customers see this and ask for it

Once again I am sorry about this I realize I have been bugging you guys a lot with the labVIEW issue

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: MIAC PIC LABVIEW

Post by LeighM »

I'll investigate

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: MIAC PIC LABVIEW

Post by Steve »

Hi QMESAR,

I'm sorry that you're not getting a quick reply to your problem. As you might be aware, the team here are working hard to get Flowcode V8 finished, so it's difficult for them to find a lot of time for things like this at the moment.

I'm not too familiar with this, but within LabView you are passing a string, and I assume that LabView is seeing the NULL character (i.e. 0) in this string and interpreting it as the termination of the string.

Instead of using a string in LabView, could you try a byte array instead?

Regards,
Steve.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Steve / Team

I am aware of all your pressures you are having and it no problem ,I am sorry for bugging the Team :oops:
I will give it ago to use string to byte array however the array shows correctly in labVIEW .
The string you see is in the Matrix sub VI that calls the dll from the application (my code) I am using an array of bytes
I will work on this a bit more :D

@Leigh hang on at first let me see if Steve solution helps before you loose time on this

Have good time

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Team.
I did now explicit creation of a string and then convert the string to an Byte Array( as Steve thought) this removes the possibility of the NULL terminator from LabVIEW as you see here.
what this code is doing is it takes the variable values convert it to an byte values then I build an string which is then converted from a string to a byte array(1D) which is then send out by the dll /USB to Miac I place an Array just before the USB Transfer VI which show/ display the values of the byte Array, this is all the time showing the correct values from the first to the last element
1.jpg
1.jpg (83.68 KiB) Viewed 13012 times
Sending this array out you will notice on the Front panel the Array with the byte array values going out to Miac ,when byte 1 has the value of higher than 0 the array is correct when the value in byte 1 is zero the array in LabVIEW updates correctly( I chande byte 2 from 7 to 9, however the CAN Tx Data buffer then does not update with any changes made in byte 2
2.jpg
2.jpg (42.49 KiB) Viewed 13012 times
The CAN tx buffer send out by the Miac
3.jpg
3.jpg (29.95 KiB) Viewed 13012 times
I realize you are very busy at the moment , I can not solve the problem and in my humble opinion it is in the Transfer sub Vi or in the MIAC as from this test shown above the NULL terminator is explicitly removed and a 1D array of U8 bytes are created

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Team.
This is my contribution to the MIAC Slave support files.

The attched LabVIEW files contains all the subVI to read
(1) Analog Channels 1-4
(2) Read Digital Input Channels (I5-I8)
(3) Set Up and Run PWM outputs on Transistor A and C
(4) Output Voltage at Transistors B and D
(5) Switch Relay Channels 1 - 4
All the files including the Dependancies are placed in a LabVIEW Project folder so it is easy to use by other just save the files on your HD and rename the project
3.jpg
3.jpg (85.77 KiB) Viewed 13000 times
Miac_FrontPanel.jpg
Miac_FrontPanel.jpg (89.62 KiB) Viewed 13000 times
2.jpg
2.jpg (86.31 KiB) Viewed 13000 times
Miac_Slave_labVIEW_2014.rar
(137.55 KiB) Downloaded 259 times
The attached Flowcode USBslave Firmware projects is working fine(Leigh fixed some issues in it).
The only section of the MIAC USB slave with LabVIEW is the CAN module once we have a solution I will update the files however for most users
these files will be sufficient to work with MIAC PIC as a slave controlled from LabVIEW.
Miac USB Slave Flowcode Source_V7.rar
(254.9 KiB) Downloaded 249 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Team.
I have been working a bit more on the USB string/packet issue which I am having when sending the CAN 8 data bytes,(in Both Directions)

I have installed and run USB sniffer ,
Looking that the USB packet I can see that the Byte Array I am sending is correct all the time here I am sending the following array from the LV application.

13h,8h,1h,2h,3h,4h,5h,6h,7h,8h which is the Command and the byte length with 8 data bytes
The data is correctly received by Miac packed in the CAN Tx buffer and send out exactly as I send it out from LV
1.jpg
1.jpg (168.97 KiB) Viewed 12978 times
Now I set byte 1 to zero and byte 2 to 6 and byte 3 to 3 and the remaining bytes to 8h as you will see the packet from LV is updated correctly however
in the MIAC only byte 1 is set to zero and the rest remains as they were 2h,3h,4h,5h,6h,7h,8h

The same is valid for sending the CAN received data from Miac to PC,however I did not yet had time to check the byte received from the MIAC in the USB sniffer
2.jpg
2.jpg (152.05 KiB) Viewed 12978 times
To me this all point more and more to the Miac Firmware and I expect that it is the USB salve component that handle the string parameter wrongly,unless I am understanding the USB sniffer data incorrectly which is possible, I am no USB expert this is my first time I work with USB :oops:
I would appreciate if the team can give me an indication if we will beable to fix this issue as I am having a meeting with the customer on Thuesday and I need to say yes MIAC can do what they need or wave the deal unfortunate it is the case now :(

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: MIAC PIC LABVIEW

Post by LeighM »

Hi QMESAR,

I think I now have a fix, for the CAN sending at least.
Please use updated USBSlave component attached.
Also the MIAC Firmware has a couple of changes, attached.
If you have edited your own version, then the changes are:

1) Edit the Request_Handler macro and un-tick the string copy
no_string_copy.jpg
no_string_copy.jpg (63 KiB) Viewed 12946 times
2) Change the USB Slave property, to the new setting ..
parameters.jpg
parameters.jpg (67.76 KiB) Viewed 12946 times
Please try those.
Regards,
Leigh
Attachments
MIAC (PIC) USB Slave Source V7.fcfx
(63.17 KiB) Downloaded 217 times
USB_Slave.fcpx
(17.78 KiB) Downloaded 196 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Leigh.
HURA :D :D :D :D :D :D :D :D :D
The CAN TX is doing what we want now ,Great stuff I can only say thank you a million times,I am in a meeting this afternoon however I will check the receiving of the CAN data in LabVIEW tonight or tomorrow and report back.
I really feel awful as I know I bugged you guys a lot and you must had it with me, I am really sorry however this MIAC and LabVIEW is quite an important thing for me !

Here you can see 2 bytes with 0 and the number 3 byte I can change as I need and the string /Array update correctly
1.jpg
1.jpg (42.8 KiB) Viewed 12939 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Leigh,
I have tested the CAN Rx side now the ID is received correctly in LabVIEW and when the Array is all populated with non zero values the Array is received correctly .

Here you can see I send a CAN message to Miac with the 8 bytes populated as lenght 8 then 01,02,03,04,05,06 07,08 the USBTransfer function receive from the MIAC
when requested to send the CAN data bytes (CMD22) the Miac send the the lenght 8 and then 01,02,03,04,05,06 07,08 received by CAN
1.jpg
1.jpg (39.73 KiB) Viewed 12924 times
if I then send CAN array to Miac byte 2 = 0and byte 3 = 6 ,you will notice that the array/string is terminated (LV greys out the elements after byte 1)
We have the same/similar issue with the outgoing Array in Miac. I am so sorry about this however the CAN Tx is working fine
2.jpg
2.jpg (34.66 KiB) Viewed 12924 times

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 PIC LABVIEW

Post by Benj »

Hi Peter,

The problem seems to be in the USB_Transfer VI.

Currently there is a string data type being used which must be doing the end of data when it hits a 0.

I've had a go at converting this to a Byte array.

Have a play with the attached USB_Transfer sub VI and let us know how you get on.
USB_Transfer (SubVI).zip
(8.15 KiB) Downloaded 205 times
Maybe make a backup of the old version so you can go back if I've made problems worse :wink:

Just doing some testing here.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

:D :D
Ben great stuff I will give it ago and let you know what is happening
Thanks a million I appreciate your and Leigh's efforts

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Guys.
:( :(
I am so sorry ,Ben this sub Vi makes things worse ,
(1) The PC LV execute like it has an delay of 1 sec and more very slow execution of the LV code
(2) it breaks all other sub VIs like the Analog Read, Transistor and Relay switches
(3) it returns no data bytes at the Output of the Transfer function.

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 PIC LABVIEW

Post by Benj »

Hi Peter,

Many thanks for letting us know. I have done some more testing and think I've fixed the problem now.
USB_Transfer (SubVI).zip
(8.21 KiB) Downloaded 217 times
The data coming in (from MIAC to PC) now has to be handled slightly differently so here is a project that shows how to do this.
Example4.zip
(62.69 KiB) Downloaded 211 times
Fingers crossed this should solve all the problems with data bytes with 0 as the value but let us know how you get on.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Ben

Thank you very much ,I will give it ago tomorrow it was long and a hard day today, normally at 20H00 in the evenings I still have forces to test these things however today no go :oops:

have good one I will be back with the results

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Ben.
:( No good news,
As mentioned in my post #6 in this tread the Transfer Vi has a broken Run Arrow and the reason is LV 2013 and higer requires the string connection on the dll Library call to be wired .(I assume you are using LV 2011 or 2012)
Your newly supplied sub Vi I see no difference in it compared to the one we are using, are you using a updated dll ?, I need to know this as well as in my existing projects I should replace the dll if you have modified it!

The new subVi note the Broken run Arrow
2.jpg
2.jpg (85.09 KiB) Viewed 12835 times
Then I have to wire the connection to something ,I do this by placing a string control (it is the only option I have as the dll call requires a string Data type!) This fix the broken Run Arrow however then we loose the Data once there is an 0 in a element even in the method we are trying now by masking out each element on its own
3.jpg
3.jpg (66.24 KiB) Viewed 12835 times
Note the CAN Data I am sending to the Miac with the new method of masking out single bytes it is fine
4.jpg
4.jpg (115.36 KiB) Viewed 12835 times
Now I send a zero and a few changes to the data bytes once the o is seen the string goes terminated and all I did is add the missing wire to the dll call and as mentioned I have no choice otherwise nothing works the VI is broken
5.jpg
5.jpg (93.89 KiB) Viewed 12835 times
Thanks again for all your efforts I appreciate it,in my stupidity I still have the feeling it is in the dll or LV Call to the dll as also mentioned a few time before as taking substring from the Data_in String does the same as reading the whole string, but I am no SW developer that is the reason we/I use tools such as LV and FC :D

Have good time

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Ben
I am fairly confident after the fixes leigh applied to the Firmware that it is not an firmware issue
here you can see in the USB sniffer the bytes received from Miac in the PC
I am sending Request 21 to check for CAN message received Miac relies with 2 bytes and the Correct ID,the I request tha Data(22) Miac answers with the Correct CAN data received ( lenght 8,01,02,03,04,05,06,07,08)
1.jpg
1.jpg (202.28 KiB) Viewed 12830 times
and the bytes returned
2.jpg
2.jpg (193.58 KiB) Viewed 12830 times
Then Sending CAN data in byte 3 = 0,byte 4 = 9 the Miac Return the correct string/Array
3.jpg
3.jpg (362.24 KiB) Viewed 12830 times
I am not sure what you are thinking about this but as said before I think it is in the dll call or dll :oops: We are using both the standard ways in LabVIEW to handle array data and both returns the same result to me its not LV or the way the handle it .it has to do with the way LV calls the dll in newer versions compared to the Vi that previously worked well it is the only logic I make out of all of this

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 PIC LABVIEW

Post by Benj »

Hi Peter,

The SubVI shouldn't have any strings any more? Hmm. Let me check I uploaded the right files.

These should now be right.
Transfer.jpg
Transfer.jpg (29.44 KiB) Viewed 12817 times
USB_Transfer (SubVI).zip
(8.29 KiB) Downloaded 209 times
The bytes are pulled out the array using the Array -> Index Array SubVI.
IndexArray.jpg
IndexArray.jpg (106.59 KiB) Viewed 12816 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MIAC PIC LABVIEW

Post by QMESAR »

Hi Ben.
That looks good I will have go at it tonight
Thanks a million :D :D :D :D

Post Reply