NMEA Data simulator Project

MarkDuncan34

New Member
Hi guys and girls,
Im a second year electronics BTEC national student.I should make it clear i have very litle knowldge of Picaxe (I have completed the basic dice and buggy project but thats it)
i am tryin to store NMEA 0183 marine comunication data into a picaxe chip then transmit it out at the correct baud rate to marine instruments.
i have writen a program

I am trying to use a 18X on a logger board currently, I have pasted my current program bellow (it does not work that well)

any help would be great

start:
if pin7 = 1 then gosub poweron
if pin7 = 1 then high output1
endif
goto start
poweron:
init: pause 500
serout 6,N2400,(254,128)
serout 6,n2400,("NMEA O183")
serout 6,n2400,(254,192) '
serout 6,n2400, ("DATA SIMULATOR")
pause 5000

selection:

serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400, ("PRESS BUTTON 1")
serout 6,n2400,(254,192)
serout 6,n2400,("TX POSITION DATA")
pause 5000

serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400, ("PRESS BUTTON 2")
serout 6,n2400,(254,192)
serout 6,n2400,("TX SPEED DATA")
pause 5000

serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400, ("PRESS BUTTON 3")
serout 6,n2400,(254,192)
serout 6,n2400,("TX DEPTH DATA")
pause 5000

serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400,("PRESS BUTTON")
serout 6,n2400,(254,192)
serout 6,n2400,("1 - 2 - 3 TO TX")


I2cslave %10100010, i2cfast,i2cbyte
writei2c 0, ("NMEA,0183,test,data,sample,one,of,three")
pause 500

I2cslave %10100100, i2cfast,i2cbyte
writei2c 1, ("NMEA,0183,test,data,sample,two,of,three")
pause 500


I2cslave %10101000, i2cfast,i2cbyte
writei2c 2, ("NMEA,0183,test,data,sample,three,of,three")
pause 500



again:
pause 1000
if pin0 = 1 then gosub subone
if pin1 = 1 then gosub subtwo
if pin2 = 1 then gosub subthree
goto again

subone:
i2cslave %10100010, i2cfast, i2cbyte
for b1 = 0 to 59
readi2c b1, (b0)
serout 6,n2400,(254,1)
pause 30
serout 7,n4800,(b0)
serout 6,N2400,(b0)
serout 6,n2400,(254,20,128)
next b1
pause 1000
serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400,("PRESS BUTTON")
serout 6,n2400,(254,192)
serout 6,n2400,("1 - 2 - 3 TO TX")
return



subtwo:
i2cslave %10100100, i2cfast, i2cbyte
for b2 = 0 to 59
readi2c b2, (b0)
serout 6,n2400,(254,1)
pause 30
serout 7,n4800,(b0)
serout 6,N2400,(b0)
serout 6,n2400,(254,20,128)
next b2
pause 1000
serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400,("PRESS BUTTON")
serout 6,n2400,(254,192)
serout 6,n2400,("1 - 2 - 3 TO TX")
return

subthree:
i2cslave %10101000, i2cfast, i2cbyte
for b3 = 0 to 59
readi2c b3, (b0)
serout 6,n2400,(254,1)
pause 30
serout 7,n4800,(b0)
serout 6,n2400,(b0)
serout 6,n2400,(254,20,128)
next b3
pause 1000
serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400,("PRESS BUTTON")
serout 6,n2400,(254,192)
serout 6,n2400,("1 - 2 - 3 TO TX")
return



thank you for your time and help
 

Mycroft2152

Senior Member
Hi Mark,

Welcome to the forum!

Interesting project. Exactly what is not working well?

You have given us alomst all the info needed to help you. Bu t,an example or definition of the NMEA string would be helpful.

Myc
 

Jeremy Leach

Senior Member
Hello Mark. I've built your circuit and run your code all in my own time, to pinpoint your problem .....er, no, joking. Come on, I think we need a few more clues to be able to help you !! Exactly what are you trying to do and exactly what doesn't work in your code? The more info you can give the better the response is going to be. Very helpful bunch here IF given good information ;)

For instance ("NMEA,0183,test,data,sample,one,of,three") isn't anywhere close to an NMEA sentence.

Also, when you say 'store' does that mean you are receiving the NMEA sentences then forwarding them on? Or are you just having them pre-loaded in the picaxe and sending them out on demand, as a 'simulation'??

Sorry to sound a bit blunt, but you haven't given us much to go on ;)
 
Last edited:

eclectic

Moderator
Mark.
I know nothing about NMEA, but, can I offer a couple of suggestions:

Look at the Readme First message in the Main Forum.
Enclose your program using [ / code
Much easier to read and copy
Code:
start:
if pin7 = 1 then gosub poweron
if pin7 = 1 then high output1 
endif
goto start
poweron:
init: pause 500
serout 6,N2400,(254,128)
serout 6,n2400,("NMEA O183")
serout 6,n2400,(254,192) '
serout 6,n2400, ("DATA SIMULATOR")
pause 5000

selection:

serout 6,n2400,(254,1)
pause 10 
serout 6,n2400,(254,128) 
serout 6,n2400, ("PRESS BUTTON 1")
serout 6,n2400,(254,192)
serout 6,n2400,("TX POSITION DATA")
pause 5000

serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400, ("PRESS BUTTON 2")
serout 6,n2400,(254,192)
serout 6,n2400,("TX SPEED DATA")
pause 5000

serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400, ("PRESS BUTTON 3")
serout 6,n2400,(254,192)
serout 6,n2400,("TX DEPTH DATA") 
pause 5000

serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400,("PRESS BUTTON")
serout 6,n2400,(254,192)
serout 6,n2400,("1 - 2 - 3 TO TX")


I2cslave %10100010, i2cfast,i2cbyte 
writei2c 0, ("NMEA,0183,test,data,sample,one,of,three")
pause 500

I2cslave %10100100, i2cfast,i2cbyte
writei2c 1, ("NMEA,0183,test,data,sample,two,of,three")
pause 500


I2cslave %10101000, i2cfast,i2cbyte
writei2c 2, ("NMEA,0183,test,data,sample,three,of,three")
pause 500



again: 
pause 1000
if pin0 = 1 then gosub subone
if pin1 = 1 then gosub subtwo
if pin2 = 1 then gosub subthree
goto again

subone: 
i2cslave %10100010, i2cfast, i2cbyte 
for b1 = 0 to 59
readi2c b1, (b0)
serout 6,n2400,(254,1)
pause 30
serout 7,n4800,(b0)
serout 6,N2400,(b0)
serout 6,n2400,(254,20,128) 
next b1
pause 1000
serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400,("PRESS BUTTON")
serout 6,n2400,(254,192)
serout 6,n2400,("1 - 2 - 3 TO TX")
return 



subtwo:
i2cslave %10100100, i2cfast, i2cbyte
for b2 = 0 to 59
readi2c b2, (b0)
serout 6,n2400,(254,1)
pause 30
serout 7,n4800,(b0)
serout 6,N2400,(b0)
serout 6,n2400,(254,20,128)
next b2
pause 1000
serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400,("PRESS BUTTON")
serout 6,n2400,(254,192)
serout 6,n2400,("1 - 2 - 3 TO TX")
return

subthree:
i2cslave %10101000, i2cfast, i2cbyte
for b3 = 0 to 59
readi2c b3, (b0)
serout 6,n2400,(254,1)
pause 30
serout 7,n4800,(b0)
serout 6,n2400,(b0)
serout 6,n2400,(254,20,128)
next b3
pause 1000
serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400,("PRESS BUTTON")
serout 6,n2400,(254,192)
serout 6,n2400,("1 - 2 - 3 TO TX")
return
Second., run your program in the simulator.
(Yellow arrow, in the Programming Editor).
Is it “getting lost” ?

You may need some more “returns”

e
 

MarkDuncan34

New Member
my fault

Thankyou for your help so far,

I am looking to write an nmea string to a pic then send it out to a bit of marine equipment (i work for Furuno UK ltd) , the equipment will recive data at 4800 bps in 8bit no parity i belive.

i have writen a sample nmea code the one that goes something like "NMEA,0183,test,data,sample,one,of,three" i did this because it was easyer to read on the simulated display

$GPDPT,15.6,0.0*655046.918,N,00111.1 this is a realy dpt depth sentance

i have tried to store the data using the i2c system then read it out onto a LCD (serout 6) and serout 7 to be conected to the marine equipment or mayb a max232.

i have searched for other NMEA projects on here and people look to store there data in diffrent ways.

i dont think my conversion between i2c and serout is working well. i have reed a lot but im not sure about buffer or weather im storing the data corretly in the first place

in short i am trying to make a simulator so when you take a bit of marine equipment to a boat show it has some data on the display

thank you again
 

Mycroft2152

Senior Member
Sorry Mark,

I am going to have to pass on this one. I have a problem in providing free engineering for a commercial product.

Good Luck

Myc
 

Jeremy Leach

Senior Member
I'm not keen either, but I'll say this: your code has n2400 all over it yet you are saying the kit receives at 4800. Also, I expect the receiving equipment doesn't like the data being sent byte by byte - i.e not a continous stream of data for a sentence. There's no way I know of with picaxes to be able to serout a block of data from storage in one continous stream. You can put long strings directly into code, and you can use variables as the data, but the number of variables are limited.
 

MarkDuncan34

New Member
comercial

this is not actualy going to be used by Furuno, i had to come up with a product to make for my year 2 exams at colege. so i chose to do something that i thought i had a litle knowldge on. thid will never be sold or used by furuno they have much more advanced products that are all made in japan. i am just trying to pass my colege course by making something that my coleges in the repair's workshop would be able to help me with.

i had to change it to n2400 because the lcd would not display n4800.
i also cant get the data to scroll across the 2 lin 16 bit lcd , i have tried things like 254,128,7 but im not sure if scrolling is only avalible when the lcd is set to i2c mode

if anyone could give further help i would be most great full:)
 

MarkDuncan34

New Member
post 4

I have run this in simulator, it seems to work. but when i dwon load it it looks to have switching problems where im using the data loger board. i think the input are high as standard so i need toi switch them low. im not to worried about this as this is an area inwhich my teacher seem to be able to help.
I have been trying difffrent serout comands to see if i can get the information to scroll across the 2 line 16 bit lcd display but cant crack it. i hope that it will out put the same sentance on serial out 7 at the higher baud rate of 4800bps, this is still only going to be one bit at a time and willl never work with marine equipment but may display something on hyperterminal on the computer. this should be enuff for me to pass the project as its only BTEC national and if i get onto the HNC i may be able to resolve more of the problems. once again any help or advise much appreciated

(thank you eclectic for your continued help)
 

BeanieBots

Moderator
To be honest, you're not being too forthcomming with information yourself.
If that is a Btech project, you would get a big fat ZERO for it.

Here's why:-

take this little clip to your nextdoor neigbour and ask what they think this means.

i2cslave %10101000, i2cfast, i2cbyte
for b3 = 0 to 59
readi2c b3, (b0)
serout 6,n2400,(254,1)
pause 30
serout 7,n4800,(b0)
serout 6,n2400,(b0)
Even the people on this forum won't know, let alone the person who gives you marks for it. The marks are given for demonstrating that YOU understand. Even if it works perfectly, there will be no marks if you don't make it clear.

Here's my GUESS. (of that little clip)
You get some data (format unknown) from an I2C device. (59 bytes)
Reset an AXE033 display
send one byte to a device on OP7 at 4800 baud. (does it need true or inverted?)
Then you send the RAW data to OP6 at 2400 baud. Is this the AXE033?
Is the data text or numbers? If it's numbers you will probably need the # output directive to display them.

At some point that clip will reach the "next" statement when it will jump back and do the next byte. Note, your loop includes a clear display for each of the 59 bytes. If you commented the code, it would be quite obvious when you "walked" through it.
 

Mycroft2152

Senior Member
Mark,

One hint, you'll get a much better response if you post the ENTIRE code. Which sloudd not be a problem, if it is is really a personal / hobby project.

Myc
 

MarkDuncan34

New Member
my code

right guys

When i get back to college on thursday i will try and write notes to go with my code and an explane it. sorry if i have not made my self clear (and it would seem from some helpfull points that i have not). seems I was frustrated from going round in circles and gave you lot very litle to work on (not because there are any secrets here at all). sorry again and i will repost the programe here on thursday, hopefully it will be a lot more clear.

thank you Mark
 

MarkDuncan34

New Member
Start again

Hi guys, right i have included my picaxe program with some notes this time. sorry about my spelling, im just no good.



start:

if pin1 = 1 then gosub poweron
pause 20 'when battery box switch is turned on the program should start
if pin1 = 1 then high output2
pause 20 'the Start section will wait for pin 1 to go high which will then
endif 'activate output 2 which is a status LED and allow the program to move onto
goto start 'the "poweron" section.
poweron:
pause 500 'a pause to set up the LCD
serout 6,N2400,(254,128)
serout 6,n2400,("NMEA O183") 'serial out 6, no parity, 2400 baud rate,254 1st line, 128 position 1
serout 6,n2400,(254,192) 'The display should the show "NMEA 0183" on the first line and "DATA SIMULATOR" on the second '
serout 6,n2400, ("DATA SIMULATOR")
pause 3000

selection:

serout 6,n2400,(254,1) 'this section would be used as a menu where the option are displayed on the LCD
pause 10 ' the information in the brackets will be displayed (it is not code or instruction)
serout 6,n2400,(254,128)
serout 6,n2400, ("PRESS BUTTON 1")
serout 6,n2400,(254,192)
serout 6,n2400,("TX POSITION DATA")
pause 3000

serout 6,n2400,(254,1)
pause 1000
serout 6,n2400,(254,128)
serout 6,n2400, ("PRESS BUTTON 2")
serout 6,n2400,(254,192)
serout 6,n2400,("TX SPEED DATA")
pause 3000

serout 6,n2400,(254,1)
pause 100
serout 6,n2400,(254,128)
serout 6,n2400, ("PRESS BUTTON 3")
serout 6,n2400,(254,192)
serout 6,n2400,("TX DEPTH DATA")
pause 3000

serout 6,n2400,(254,1) 'this is the last information sent to the LCD so it shoulod sit there untill cleared
pause 100
serout 6,n2400,(254,128)
serout 6,n2400,("PRESS BUTTON")
serout 6,n2400,(254,192)
serout 6,n2400,("1 - 2 - 3 TO TX")


I2cslave %10100010, i2cfast,i2cbyte 'in this section the NMEA data is writen to the I2C chip
writei2c 0, ("$GPDPT,15.6,0.0*655046.918,N,00111.1") 'it is all individualy adressed
pause 500
' rom my understanding this data should be acsessed by the "0" "1" and "2"
I2cslave %10100100, i2cfast,i2cbyte
writei2c 1, ("NMEA,0183,test,data,sample,two,of,three") 'i have left these as words because i dont want to complicate
pause 500 'the project any more at this point in time and this shou


I2cslave %10101000, i2cfast,i2cbyte
writei2c 2, ("NMEA,0183,test,data,sample,three,of,three")
pause 500



again:
pause 20
if pin0 = 0 then gosub subone
pause 20 'this the part of the program where you will chosse what data to transmit.
if pin7 = 0 then gosub subtwo
pause 20 'when a switch is pressed the relivant pin goes high and the program moves on to the sub program
if pin2 = 0 then gosub subthree 'these switches will be push button momenterialy on.
goto again

subone:
pause 30
serout 6,n2400,(254,1) 'the display is set up and cleared
pause 30
i2cslave %10100010, i2cfast, i2cbyte 'the data is sent from the memorey at 4800 byte by byte
for b1 = 0 to 36 ' each byte from 0-59 is sent out
readi2c b1, (b0) 'read location B1 starting at byte 0
pause 30 'send the data out on serial port 7 at 4800bps for conecting to nav equipment
serout 7,n4800,(b1) 'send the data out to the LCD at 2400
serout 6,N2400,(b0)
serout 6,n2400,(254,24) 'this is one of my porblems and where my main fault lies, i would like the data
pause 500
next b1 'to scroll across the display but i am unure what comand to use i have tried lots!
pause 1000
serout 6,n2400,(254,1)
pause 10

serout 6,n2400,(254,1)
pause 30
serout 6,n2400,(254,128)
serout 6,n2400,("PRESS BUTTON")
serout 6,n2400,(254,192)
serout 6,n2400,("1 - 2 - 3 TO TX")
goto again



subtwo:
i2cslave %10100100, i2cfast, i2cbyte
for b2 = 0 to 59
readi2c b2, (b0)
serout 6,n2400,(254,1)
pause 30
serout 7,n4800,(b0)
serout 6,N2400,(b0)
serout 6,n2400,(254,20,128)
next b2
pause 1000
serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400,("PRESS BUTTON")
serout 6,n2400,(254,192)
serout 6,n2400,("1 - 2 - 3 TO TX")
return

subthree:
i2cslave %10101000, i2cfast, i2cbyte
for b3 = 0 to 59
readi2c b3, (b0)
serout 6,n2400,(254,1)
pause 30
serout 7,n4800,(b0)
serout 6,n2400,(b0)
serout 6,n2400,(254,20,128)
next b3
pause 1000
serout 6,n2400,(254,1)
pause 10
serout 6,n2400,(254,128)
serout 6,n2400,("PRESS BUTTON")
serout 6,n2400,(254,192)
serout 6,n2400,("1 - 2 - 3 TO TX")
return


Ok so this time im going to list the faults

1. the inputs on the picaxe 18x data logger seem to be high then pulled low with the switch. this is causing the program to run straight through and not stop when i want a switch to decide the next step. i think i need to use a pull up or down resistor. i will look into this with my teacher but any help on this is welcom.

2. i am having trouble with the axe033. it work fine in the first part of the program but when i try and display a mesage longer than 16 bytes (then length of the display) my problems start. i have tryed to use comands such as 254,7 to make the lcd scroll and now using 254,24 scroll display window left one position. i have used other but cant find one to work right for me. if any one has any experiance with these it would be great help

3. im no to concernd about the serout 7 side of things yet, i dont think i will be able to get the NMEA data out at the correct baud rate in a 8bit sentances etc. but it may display something when conected to hyperterminal of a PC. this would be ok for my btec and i may take this further in the HNC

4.any views on the way im storing the data would be good are there beter was other than using I2C. same for the LCD should i be conecting it in another way to gain more comands.

Thank yoou for any help, sorry for the length of this post. hope i can help some one back one day

cheers Mark
 

eclectic

Moderator
Mark.

Please print out your program and then go through it, using a pencil.

I have not, and cannot go through it all, but, for example,
Code:
subone:
pause 30
serout 6,n2400,(254,1) 'the display is set up and cleared
pause 30 
i2cslave %10100010, i2cfast, i2cbyte 'the data is sent from the memorey at 4800 byte by byte
for b1 = 0 to 36 ' each byte from 0-59 is sent out 
readi2c b1, (b0) 'read location B1 starting at byte 0
pause 30 'send the data out on serial port 7 at 4800bps for conecting to nav equipment
serout 7,n4800,(b1) 'send the data out to the LCD at 2400
serout 6,N2400,(b0)
serout 6,n2400,(254,24) 'this is one of my porblems and where my main fault lies, i would like the data
pause 500
next b1 'to scroll across the display but i am unure what comand to use i have tried lots!
pause 1000
serout 6,n2400,(254,1)
Is the LCD on output 6 or 7 ?

Second.
Code:
again: 
pause 20
if pin0 = 0 then gosub subone
pause 20 'this the part of the program where you will chosse what data to transmit.
if pin7 = 0 then gosub subtwo
pause 20 'when a switch is pressed the relivant pin goes high and the program moves on to the sub program 
if pin2 = 0 then gosub subthree 'these switches will be push button momenterialy on.
goto again
I'm definitely puzzled about this bit. It's going ever so fast.

Third. I've very quickly tried the program in the Simulator.
Sometimes, it looks very good. (see pic)
Then, I'm thinking
“Help! What do I do now?”

Just my opinion, but, simplify your program.
Remove as much as possible, until you get something that is
Easy to use.
Works every time.
And most importantly, that YOU understand, and can explain to the assessor.

Please check with your teacher, but, I think that you'll get more credit for
a simple program that works, rather than
a complex program which doesn't work.

e
 

Attachments

kevrus

New Member
Slightly off topic I guess, but following on from what Eclectic said
Please check with your teacher, but, I think that you'll get more credit for
a simple program that works, rather than
a complex program which doesn't work.
I recall many years ago, during exams, teachers at school and lecturers at college emphasised that correct answers amounted to very little in the way of marks, but to show the correct working and that there was an understanding did achieve good marks.
 

Jeremy Leach

Senior Member
A very quick scan of your code shows some repeating blocks of identical statements. Put this code in a subroutine and then call the subroutine as required - will make it much clearer.
 

BeanieBots

Moderator
The main reason I was particularly helpful early one and made you comment your code was in the hope that while doing it you would spot some of the "sillies" like this:-

"serout 7,n4800,(b1) 'send the data out to the LCD at 2400"

As has already been asked, is the LCD on OP7 or OP6?
If the LCD is 2400 baud, then why use N4800?
If you want to display the numeric value of b1, then you need use the "#" operator.

Try to use 'symbol' definitions for the hardware. It makes life a lot easier.

Code:
Symbol LCD=7
Symbol BaudRate=N2400
symbol Mydata=b0

Mydata=$41
Serout LCD,BaudRate,(254,128,#MyData)  'Print numeric value of Mydata on line 1 of the LCD.
Serout LCD,BaudRate,(254,192,MyData)  'Print character "Mydata" on line 2 of the LCD
Suggest you put your program to one side for a while and concentrate on one thing at a time. Maybe get more familiar with the LCD display and all its functions first. Then, once you are fully confident with using it, expand your program to include whatever functionality it requires. Until you have the basics mastered, anything else will just cause you to flounder.

Try the simple program I've shown above to see the difference of using the "#" operator.
 
Top