GPS expansion module code example

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

Moderators: Benj, Mods

Post Reply
Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

GPS expansion module code example

Post by Monie Jacobsen »

I purchased MAC - GPS expansion module type: MI8582
But want connection examples.
Want to use the GPS device connected MIAC (Arduino) type: MI5466
Or connect to the ECIO40P.
Can not fine document or connect or code examples for output.

Is there anyone - who will want to help with coding as described below.

For output as:
Sec, minute and hour.
day, month and year.
Latitude and Longitude

Will be very pleased code eksemple
Best Regard
Monie

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: GPS expansion module code example

Post by LeighM »

Hi Monie,

Attached is a MIAC System GPS example to get you started.
It also revealed a little bug, so please also update the MIAC_CAL_SYSTEM.c in your Flowcode \CAL\MIAC directory.

Regards,
Leigh
Attachments
MIAC Arduino GPS example.fcfx
(13.6 KiB) Downloaded 467 times
MIAC_CAL_SYSTEM.c
(37.23 KiB) Downloaded 431 times

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: GPS expansion module code example

Post by Monie Jacobsen »

Hi LeighM
Many, many thanks.
Will immediately test codes;-)

Good weekend
Best Regard
Monie

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: GPS expansion module code example

Post by Monie Jacobsen »

Hi LeighM
The wires from CAN L and H -where they must be connected to the MIAC (Arduino-Compatible) ??
Best Regard
Monie

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: GPS expansion module code example

Post by LeighM »

On the MIAC, top left, T, CH and CL.
Module CAN L goes to MIAC CL
Module CAN H goes to MIAC CH
To activate the internal MIAC CAN terminating resistor, also make a wire link between T and CH on the MIAC Ardunio

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: GPS expansion module code example

Post by Monie Jacobsen »

Hi LeighM
Thank you.

Good weekend
Best Regard
Monie

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: GPS expansion module code example

Post by Monie Jacobsen »

Hi LeighM
MIAC GPS expansion not working in practice?????

Without GPS Ice Data Valid function:
MIAC display shown below:
----------------------
10:13:30 27: 02: 2017
Latitude: 0.000000
Longitude: 0.000000
Satellites 247
-----------------------

But why is Latitude and Longitude does not work?

Do not come out of "Data not yet valid" and does not start up GPS.

Have 120ohm resistor is connect to the CAN L and CAN H terminals on the MIAC GPS expansion module.

GPS Ice Data Valid function Decision:
Error state.JPG
Error state.JPG (16.09 KiB) Viewed 16653 times
Decision.JPG
Decision.JPG (39.32 KiB) Viewed 16653 times
See attached file.
MIAC Arduino GPS not ouput.fcfx
(21.07 KiB) Downloaded 440 times
Best Regard
Monie

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: GPS expansion module code example

Post by LeighM »

Hi Monie,

On hardware, is the LED on the GPS expansion module flashing?
If so, then that means that the CAN connection is OK.

You listed the time as being shown, so that would also indicate that the CAN connection is OK.
Your flowchart is very good, but I noticed you had a missing return of the state variable ...
state.jpg
state.jpg (12.94 KiB) Viewed 16652 times
I've fixed that in the attached and also moved the time display.

As for the location information it could be that the GPS module has not yet locked onto enough satellites to provide a reliable result.
Is the module in a location where it has clear "sight" of the sky?

Regards,
Leigh
Attachments
MIAC Arduino GPS 2.fcfx
(21.75 KiB) Downloaded 443 times

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: GPS expansion module code example

Post by Monie Jacobsen »

Hi Leigh
Now it seems the device correctly.
Thank you for your patience;-)

GO'Working
Best Regard
Monie

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: GPS expansion module code example

Post by Monie Jacobsen »

Hi Leigh

Can I convert file-format from the flowCode v7 MIAC (Arduino-Compatible) Systemfor Arduino
If yes, how is this done below.
Do you want to be helpful with a small eksemple?
Do like to be with component "C code"
Or another suggestion from you;-)
Please see below!

Convert at Flowcode to float latitude Arduino.
Convert at Flowcode to float longitude Arduino.

Convert at Flowcode to float month Arduino.
Convert at Flowcode to float day Arduino.
Convert at Flowcode to float hour Arduino.
Convert at Flowcode to float minute Arduino.
Best Regard
Monie

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: GPS expansion module code example

Post by LeighM »

Hi Monie,

We do not yet have any support for the MIAC Expansion modules (MIAC System) with Arduino code.
I would be possible to re-use the MIAC_CAL_SYSTEM.c code and the C code generated by the Flowcode components to create an Arduino library, but not easy.

Using Flowcode gives the simplest way of creating MIAC System (CAN Expansion modules) applications.

Leigh

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: GPS expansion module code example

Post by Monie Jacobsen »

Hi Leigh
OK, thank you..

Go'Working
Best Regard
Monie

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: GPS expansion module code example

Post by Monie Jacobsen »

Hi Leigh
I have been able to use the following C Code in Flowcode v 5 to v6
Why can not I upload the file (Flow Code v7) including?
C Code FCVxxx.JPG
C Code FCVxxx.JPG (48.6 KiB) Viewed 16622 times
See attached "compiler messages"

Code: Select all

Target folder: C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2
Source name:   C:\Users\Bruger\Documents\FlowCode V7 Projekter\MIAC Arduino GPS example\MIAC Arduino GPS Latitude Longitude-002.fcfx
Title:         
Description:   
Device:        AVR.ATMEGA.ATMEGA1281
Generated by:  Flowcode v7.1.1.0
Date:          Tuesday, February 28, 2017 10:39:18
Users:         1
Registered to: monie jacobsen
Licence key:   ******
http://www.matrixtsl.com
Launching the compiler...
C:\Program Files (x86)\Flowcode 7\compilers\avr\batchfiles\avra.bat  atmega1281 "C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.elf" "C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.c" "C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.lst"
Launching compiler...

C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2>"C:\PROGRA~2\FLOWCO~1\COMPIL~1\avr\BATCHF~1\..\bin\avr-gcc.exe" -mmcu=atmega1281 -Os -funsigned-char -o "C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.elf" "C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.c" -lm 
C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.c: In function 'FCM_Solar_position':
C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.c:2627: error: 'FCV_day' undeclared (first use in this function)
C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.c:2627: error: (Each undeclared identifier is reported only once
C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.c:2627: error: for each function it appears in.)
C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.c:2627: error: 'month_day' undeclared (first use in this function)
C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.c:2627: error: 'FCV_month' undeclared (first use in this function)
C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.c:3147: warning: passing argument 3 of 'FCI_FLOAT_TO_STRING' discards qualifiers from pointer target type
C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.c:3159: warning: passing argument 1 of 'MIAC_PrintString' discards qualifiers from pointer target type
C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.c:3173: warning: passing argument 3 of 'FCI_FLOAT_TO_STRING' discards qualifiers from pointer target type
C:\Users\Bruger\DOCUME~1\FLOWCO~1\MIACAR~2\MIAC Arduino GPS Latitude Longitude-002.c:3186: warning: passing argument 1 of 'MIAC_PrintString' discards qualifiers from pointer target type

Error returned from [avr-gcc.exe]
Completed compilation, return = 1

C:\Program Files (x86)\Flowcode 7\compilers\avr\batchfiles\avra.bat reported error code 1


FINISHED
Have a suggestion for another C Code?
Or another way to solve the problem?
Best Regard
Monie

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: GPS expansion module code example

Post by LeighM »

Hi Monie,

The variable names in C are case sensitive and Flowcode uses upper case.
The Flowcode variable can be dragged into the C code ...
variables.jpg
variables.jpg (39.89 KiB) Viewed 16618 times
Your month_day[] array probably needs re-defining in the Build->Project Options->Supplementary Code

Leigh

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: GPS expansion module code example

Post by Monie Jacobsen »

Hi Leigh
Thanks for your reply for C code;-)

Have work all day in below
Want degree as below
180.5 °
degree.JPG
degree.JPG (28.69 KiB) Viewed 16614 times
Can easily make it in Flowcode but not in MIAC
Do you have a suggestion?
Best Regard
Monie

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: GPS expansion module code example

Post by LeighM »

Hi Monie,
I will try and add that in the next day or two.
Regards,
Leigh

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: GPS expansion module code example

Post by Monie Jacobsen »

Hi Leigh,
That is great.
I welcome very much ..
Best Regard
Monie

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: GPS expansion module code example

Post by LeighM »

Hi Monie,

I've added the degree symbol to the dsPIC and Arduino compatible MIAC Flowcode components.
Please update with the attached files...

MIAC (Arduino-Compatible).fcdx and MIAC (Arduino-Compatible) System.fcdx to go into your Flowcode7 installation \FCD\AVR directory
MIAC (dsPIC).fcdx and MIAC (dsPIC) System.fcdx to go into your Flowcode7 installation \FCD\PIC16 directory
MIAC_CAL_API.c to go into your Flowcode7 installation \CAL\MIAC directory
miac_dspic.fcpx and miac_arduino.fcpx to go into your Flowcode7 installation \components directory

Regards,
Leigh
Attachments
MIAC (dsPIC).fcdx
(57.08 KiB) Downloaded 342 times
MIAC (dsPIC) System.fcdx
(57.19 KiB) Downloaded 352 times
MIAC (Arduino-Compatible).fcdx
(35.8 KiB) Downloaded 332 times
MIAC (Arduino-Compatible) System.fcdx
(35.91 KiB) Downloaded 333 times
miac_arduino.fcpx
(80.55 KiB) Downloaded 349 times
miac_dspic.fcpx
(80.6 KiB) Downloaded 335 times
MIAC_CAL_API.c
(15.09 KiB) Downloaded 329 times

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: GPS expansion module code example

Post by Monie Jacobsen »

Hi Leigh,
Many, many thanks for your many devices ..
I immediately try out the units and the degree symbol showing now in Miac display, with code: PrintASCII (223)

Enduring many thanks for your work;-)
Continued go working ..
Best Regard
Monie

Post Reply