MIAC PIC Source code Errors

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: 956
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 304 times
Been thanked: 480 times
Contact:

MIAC PIC Source code Errors

Postby QMESAR » Sat Apr 21, 2018 7:06 am

Hi Team.
There is a few problems with the supplied FC MIAC USB Slave Source code.I will try to point it out in away tat you can follow what I am trying to say.
(1) Down loading the files from the MIAC resource page the files contain Examples for FC5, FC6 and FC7.There is also a folder LVINT which contains 2 LabVIEW examples and the FC MIAC USB Slave Source code (firmware Folder)
This FC Source code does not compile at all there are a number of errors reported as you can see here.

1.jpg
1.jpg (129.11 KiB) Viewed 545 times


The mentioned Source File
MIAC USB Slave Flowcode Source_V7.rar
(1009.62 KiB) Downloaded 14 times

Also downloading the MIAC Slave Firmware hex file from the resource page does not work at all the USB never connects!

(2) From the FC 6 Wiki page MIAC section you can down load the same files with the same name this file
MIAC USB Slave Flowcode Source_V6.rar
(255.02 KiB) Downloaded 13 times

This files compile and the MIAC function however there is a section commented out /disabled in the Request_Handler Makro
one issue I have been picking up is that I can transmit a CAN message but the command to change the CAN buffer data (19) never writes the new CAN data to the Buffer .

Here is a screen print from my CAN logger as you will see the Message is sended evry 50mSec with the preloaded data in the TX buffer
2.jpg
2.jpg (22.06 KiB) Viewed 545 times

Now loading sending new buffer data from LabVIEW to the MIAC never updates the Data in the Tx Buffer

sending new data to the MIAC
3.jpg
3.jpg (31.31 KiB) Viewed 545 times


and transmit the message the Data never changes
2.jpg
2.jpg (22.06 KiB) Viewed 545 times


Team please help me to solve this confusion with the source files It seams that the MIAC firmware only excepts a 3 byte string and handle it correctly every thing more than 3 bytes long is handled incorrectly as the 9 byte CAN set buffer Command and string /Array.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 956
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 304 times
Been thanked: 480 times
Contact:

Re: MIAC PIC Source code Errors

Postby QMESAR » Mon Apr 23, 2018 8:52 am

Hi Team.
As described above with the problem of setting the CAN Data buffer it also seams to have an issue of reading the CAN receive buffer.

I send the Command to check of incoming messages which works fine ( see LabVIEW print screen) Th ID is returend correctly then I select with a case structure based on the ID what to do ,I then send the Command to et the RX Buffer Data it returns 9 bytes however the data bytes are always empty (0)
Please help with this CAN issues all other things are working PWM,ADC;Relay Switching and LCD

I can clearly and 100% say that there is CAN Communication with the real DATA as I am sending the correct ID and Data for the message from my PeakCAN interface with a CAN.DBC file from the Manufacturer of the machine

CAN Data Send from Peak-.dbc File with data

3.jpg
3.jpg (43.22 KiB) Viewed 527 times


Capturing the ID and masking out what message was received

1.jpg
1.jpg (70.4 KiB) Viewed 527 times


Correct number of bytes is returned but no Data :D
2.jpg
2.jpg (17.14 KiB) Viewed 527 times

User avatar
LeighM
Matrix Staff
Posts: 1454
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 373 times
Been thanked: 528 times
Contact:

Re: MIAC PIC Source code Errors

Postby LeighM » Mon Apr 23, 2018 10:47 am

Hi,
I've had a quick look at the MIAC Slave program and found that the CAN initialise is missing.
I've added this into the attached, but not had chance yet to test the CAN communications with another device.
Do you want to try the attached?
Regards,
Leigh
Attachments
MIAC (PIC) USB Slave Source V7.fcfx
(62.78 KiB) Downloaded 12 times
These users thanked the author LeighM for the post:
QMESAR (Mon Apr 23, 2018 2:03 pm)
Rating: 5.88%
 

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 956
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 304 times
Been thanked: 480 times
Contact:

Re: MIAC PIC Source code Errors

Postby QMESAR » Mon Apr 23, 2018 1:38 pm

LeighM wrote:I've had a quick look at the MIAC Slave program and found that the CAN initialise is missing.I've added this into the attached, but not had chance yet to test the CAN communications with another device.


Leigh Thank you however I forgot to mention this I added the initialization already as you will see in my post that I mention I am able to get the RX ID and also I showed a print with the TX ID but in both cases there is a problem with the Buffer data byte 0 -7 :D

Please also read my comment carefuly regarding the 2 set of Firmware files :D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 956
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 304 times
Been thanked: 480 times
Contact:

Re: MIAC PIC Source code Errors

Postby QMESAR » Mon Apr 23, 2018 1:58 pm

Hi Leigh .
I tried the modified V7 file ,CAN does not work at all there is no Transmission (Command 20)
just to let you know the only file that works quite well (almost all function work) but with CAN buffer problems and strings longer that 3 bytes
is the old V6 Firmware source in a nutshell ,I have written more about this in the above posts

Have good one

User avatar
LeighM
Matrix Staff
Posts: 1454
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 373 times
Been thanked: 528 times
Contact:

Re: MIAC PIC Source code Errors

Postby LeighM » Mon Apr 23, 2018 3:52 pm

Hi,
The Slave MIAC transmitted CAN messages OK for me.
I've done another modification and receive now also works.
But I am testing with a Flowcode program using the USB Slave component, not LabView.
Maybe there is something different about the way it sends and receives the USB packet info?
Leigh
Attachments
MIAC_USB_Slave_Test_Read_CAN.fcfx
(11.53 KiB) Downloaded 12 times
MIAC (PIC) USB Slave Source V7.fcfx
(63.26 KiB) Downloaded 14 times
These users thanked the author LeighM for the post:
QMESAR (Mon Apr 23, 2018 4:06 pm)
Rating: 5.88%
 

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 956
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 304 times
Been thanked: 480 times
Contact:

Re: MIAC PIC Source code Errors

Postby QMESAR » Mon Apr 23, 2018 4:06 pm

LeighM wrote:But I am testing with a Flowcode program using the USB Slave component, not LabView.
Maybe there is something different about the way it sends and receives the USB packet info?


leigh
Thank you very much for your efforts however this is exactly the point the MIAC is advertised with labVIEW support however there is issue
with it ,let me try your files and look a bit deeper however at the end of the day together we need to solve the labVIEW issue :D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 956
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 304 times
Been thanked: 480 times
Contact:

Re: MIAC PIC Source code Errors

Postby QMESAR » Mon Apr 23, 2018 5:35 pm

Leigh.
my friend We are on opposing sides at the moment :D
I disagree that it is LabVIEW with this comment
Maybe there is something different about the way it sends and receives the USB packet info?

I commented the CAN buffer read in the FC firmware and load the outgoing string with the length of 9 and numbers from 1-7 and 0x0A in the 8 th byte posision the data should look like this in the array byte 0 the length and then the numbers following in each element which is then send over the USB and received perfectly in LabVIEW see print screens.
In my humble opinion there is some error /logic error in the firmware when the command 21 is issued the firmware returns the ID correctly of the message recieved then the firmware expects the command to get the received message Data(bytes 0 -7) which it does but it looks like it reads the wrong Receive buffer as the data returned is always 0

I can not say what the error is however the error is in the Miac FC firmware
2.jpg
2.jpg (83.26 KiB) Viewed 504 times


Here the array is received correctly by LabVIEW as pre-loaded in the Firmware

1.jpg
1.jpg (7.58 KiB) Viewed 504 times

User avatar
LeighM
Matrix Staff
Posts: 1454
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 373 times
Been thanked: 528 times
Contact:

Re: MIAC PIC Source code Errors

Postby LeighM » Tue Apr 24, 2018 9:16 am

OK, I've run through more tests but do not get the zero data error that you get.
I've attached the latest CAN component, although I guess you have same,
but might be worth dropping this into your components directory and rebuild the MIAC firmware.
At what repetition rate are your CAN messages being sent to the MIAC?
Attachments
CAN.fcpx
(25.64 KiB) Downloaded 13 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 956
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 304 times
Been thanked: 480 times
Contact:

Re: MIAC PIC Source code Errors

Postby QMESAR » Tue Apr 24, 2018 11:42 am

Leigh

Thank you very much for your confirmation,
I am sending and requesting CAN data from the MIAC every 100mSec
I will dug deeper into this thanks a million for all your efforts much appreciated :D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 956
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 304 times
Been thanked: 480 times
Contact:

Re: MIAC PIC Source code Errors

Postby QMESAR » Tue Apr 24, 2018 1:06 pm

Hi Leigh.
The new CAN component seams to do the trick,
I can read the CAN Received Data bytes out now , :D
I am not sure if the loading of the CAN Data is working as I did not have time yet to test that but will do tomorrow but if I can read the bytes then it should work the other way around too

I appreciate all your efforts very much once again than you
1.jpg
1.jpg (36.62 KiB) Viewed 474 times

User avatar
LeighM
Matrix Staff
Posts: 1454
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 373 times
Been thanked: 528 times
Contact:

Re: MIAC PIC Source code Errors

Postby LeighM » Tue Apr 24, 2018 1:10 pm

That's good, thanks for the update :D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 956
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 304 times
Been thanked: 480 times
Contact:

Re: MIAC PIC Source code Errors

Postby QMESAR » Tue Apr 24, 2018 3:11 pm

leigh.
found time to test the populating of the TX buffer from LabVIEW to the Miac :D it is working also
so now everything is working from LabVIEW on my Miac :D :D :D :D

Have great time thanks again for all your help and efforts

Sending data to be transmitted from Miac CAN
2.jpg
2.jpg (40.24 KiB) Viewed 468 times


The outgoing CAN message from the MIac with the populated data
1.jpg
1.jpg (16.93 KiB) Viewed 468 times
These users thanked the author QMESAR for the post:
LeighM (Tue Apr 24, 2018 3:31 pm)
Rating: 5.88%