LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Having problems changing sample rate from 1 HZ to 10 Hz myRIO - PmodGPS

Hey Guys,

 

I did a search and I couldn't find where this was answered. So, if someone has already asked this, I'm sorry.

 

I'm in my senior year of school and I just puchased a myRIO. I have had a few measurement classes but I'm not really fimiliar with LabVIEW at all. I'm trying to record my GPS position and acceleration for some testing.

 

I'm basically using the default GPS and Acceleration programs that you can download for myRIO. I have combined them and added a USB write to file program to record the data (I cannot seem to get the DAQMX to work).

 

From the research I have done, I appears that I need to add a VISA Write command right after my VISA configuration icon to increase the baud rate up to 38.4Kbd I'm using the following write buffer comand line $PMTK251,38400*27<CR><LF> 

 

Once the Baud rate has been increased, then I can up the sampe rate. So, I added another VISA Write inline. the write buffer command line I'm using for this is:

$PMTK226,3,30*4<CR><LF>

 

The program runs fine, but the sampe rate hasn't changed with the above mentioned VISA's added. I have tried multiple Baud rate codes as well as position fixed interval codes. I have changed the loop wait times from 100 to 10 but that doesn't seem to have any affect either.

 

I'm assuming I'm just missing something dumb, but I cannot figure it out.

 

Need_help.GIFNeed_Help_1.GIFneed_help_2.GIF

 

 

 

Need_help_3.GIFThat should be all of the code for the GPS. The rest of the code that you cannot see is the Accelerometer. It is working fine now that I added the filters.

 

Anyhelp you can provide is greatly appreciated. I really need to get this done and I'm stuck.

0 Kudos
Message 1 of 21
(4,504 Views)

Are you trying to run all of that on the RT processor on the myRIO or is that something you want to run on your computer to talk to the myRIO?

 

The code is a bit difficult to read in all of those pictures.  You'd probably help us help you by posting the code.

 

But, here's what I'm really curious about.  Why aren't you using a timed loop?  If you're on the RT system, which you should be, you would want to use the timed loop over the while loop.  Beyond being able to tell the loop what period you want, it also lets you set priorities so you can control what takes place if you don't have enough time to process everything.  It also gives you flags to let you know if the loop is completing on time so you can troubleshoot where problems exist.  If you do this, you can write your data to a buffer and pull the data from this buffer out on your host pc.

 

Really, you shouldn't be running into issues with 10 Hz regardless.  There's a serious problem with the code if you're having this issue.  10 Hz is NOT fast for the myRIO.

0 Kudos
Message 2 of 21
(4,492 Views)

Basically, I'm in over my head. I needed to have this project completed by the 1st. I attached my full code (GPS_Accel_Main).

 

What I have done was modify code that I found that works. The PmodsGPS code, the Accelerometer code, and the USB drive code works independently. From there, I combined them into a single project. It isn’t pretty and it will need to be completely overhauled once I finish this and have time to learn what I’m doing.

 

Stepping back for a min. let’s just focus on the PmodsGPS portion (also, attached GPS_with_VISAs_10Hz). I have spent quite a bit of time researching what command packet code I need to broadcast. Digilent has the two that are in the file currently. I went to GlobalTop and found two slightly different codes. Neither of these seem to work.

 

Am I instituting the VISA wrong or do you see anything wrong with what I’m doing? 

Download All
0 Kudos
Message 3 of 21
(4,462 Views)
You certainly aren't changing the baud rate. You would need another VISA Configure Serial Port if the baud rate actually changed. The command itself is not sent correctly because you are not appending the correct termination characters. As has been discussed countless times, appending something like <CR> is not how you send a carriage return in LabVIEW. One way is to right click on the string constant and select '\' Codes Display. Use a \r for carriage return and \n for a line feed.
0 Kudos
Message 4 of 21
(4,454 Views)

Thanks for the help Dennis.

 

So, I changed the <CR><LF> to \R\N but left the display as normal

Normal_Display.GIF

And there was no change. Switched the display to "/" code displayed 

Codes Displayed_After_normal.GIF

And there was no change. So, I took out the extra "\" infront of the R and N. As soon as I did, the second "\" dissapeared when I clicked ouside of th text box.

Codes Displayed.GIF

No change here either. You mentioned another VISA Config. Would I add that where the first VISA write is or can I change the VISA Config Serial Port to 38400 and be done with it?

 

Again, I appreciate the help!

0 Kudos
Message 5 of 21
(4,445 Views)
Don't use the capital r or n. Use what I said.

If you are actually successful in changing the baud rate, the new config must be immediately after the write command. You might not need to change the baud rate if you can change the sample rate.
0 Kudos
Message 6 of 21
(4,432 Views)

Ok, made it lower case, tried it all three ways like before. When I do the "/" code display with the lower case r and n, I'm getting the following error

Framing_Error.GIF

 

The code looks like this

code_displayed_lowercase.GIF

I figured that maybe it is something in the Baud Rate, so I removed it and I'm still getting the same error

Code_Displayed_no_baud.GIF

 

This is one of the pdf's that I found while researching http://www.adafruit.com/datasheets/PMTK_A11.pdf

 

It mentions a PMTK 220 (bottom of page 8 and top of page 9). What is the difference between the 220 and 226?

0 Kudos
Message 7 of 21
(4,426 Views)
Sorry, what I forgot to mention was the need to close the VISA session before using the config again. It seems the change of baud rate worked because you got the framing error. To go back to 9600 baud, you would to issue the specific command. Cycling power may also work.
Message 8 of 21
(4,413 Views)

Thank you so much for all of your help!!!

 

So, I added it back in, ran the program and got the same error (as expected). I unplugged the power to the myRIO for probably 10 seconds, and then plugged it back in.

 

I'm still getting the same error. Is that what you meant by cycling the power or is there a comand I need to be using? 

 

here is how the code looks now. 

Added_back_in.GIF

0 Kudos
Message 9 of 21
(4,408 Views)
That section of code does not show enough.
0 Kudos
Message 10 of 21
(4,400 Views)