LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading/Writing character commands to serial connection

Hey! I'm currently working on a project where part of it is to write a labview program to read and write commands through a serial connection to our PIC24F16KA304 board.

 

I basically have no knowledge on labview, I've been messing around on it for a few weeks trying to get myself familiar with it but I'm not having much luck.

Essentially I'm programming a train simulation control box. The PIC board will have a sensor that is connected to a train track that sends the character 'A' (for arrived) when a train stops at the station to lab view. I then want to be able to tell Labview to turn a LED on relevant to the station and then respond with the character 'M' for move. I need to repeat this situation for 6 stations

I also need to be able to 'R' for reversing the simulation, 'J' for jump (miss a station) and 'E' for end

 

If anyone with a bit more experience and knowledge then me can help I would be eternally grateful!

0 Kudos
Message 1 of 8
(3,255 Views)

Hi Getox,

 

Have you seen the examples that ship with LabVIEW? They're under Help >> Find Examples.

 

I suggest the Basic Serial Read and Write VIs are a good place to start with this project.

 

-CC

 

 

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


0 Kudos
Message 2 of 8
(3,253 Views)

I've had a look at the avaiable examples, they've helped with the basic serial configuration and reading/writing. My question now is there a way to have the commands set so I don't have to keep entering string? So for my first sequence I want to send an S to start the simulation. For the next sequence I want labview to wait for the PIC to read the character 'A' (for arrived) and then once it has this value, wait a few seconds, and then send the character 'M' (move) back. What's the best option for this case?

 

Also during each case I want a LED to turn on to represent the station that the train has arrived at. How can I turn a LED on in a stacked sequence after the serial input has read the character 'A'

0 Kudos
Message 3 of 8
(3,242 Views)

I suggest that you read some of the LabVIEW basics: http://www.ni.com/gettingstarted/labviewbasics

 

A state machine would be a good starting point for this project (and your understanding of LabVIEW).

 

You can always wire constants to VI inputs on the block diagram instead of having controls on the front panel that you have to type into. Just right click on the VI >> create >> constant.

 

The LabVIEW basics will help you out with all of these simple problems. Smiley Wink

 

Good luck,

 

-CC 

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


Message 4 of 8
(3,239 Views)

@ChrissyC87 wrote:

I suggest that you read some of the LabVIEW basics: http://www.ni.com/gettingstarted/labviewbasics

 

A state machine would be a good starting point for this project (and your understanding of LabVIEW).

 

You can always wire constants to VI inputs on the block diagram instead of having controls on the front panel that you have to type into. Just right click on the VI >> create >> constant.

 

The LabVIEW basics will help you out with all of these simple problems. Smiley Wink

 

Good luck,

 

-CC 


Mega-Dittos!

 

My thoughts exactly. Adding to what Chrissy posted...

 

Your question reads like "How do I unlock the door to my car and win the Daytona 500?" The first part is simple (use the constants like Chrissy said) but the second part is much more invloved.

 

plese take the advise posted above and go thorugh the tutorials and learn to use state machines. AS yo udo this other questions will come up and you should feel free to start a new thread on ech question. Stick with it, play nice and we'll get you to the finish line.

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 8
(3,234 Views)

Thanks for the help, I have a simple state machine that I think is looking half decent at the moment. I've built my sequences and i've set it so the VISA R reads a 'M' constant before it moves to the VISA W. Is there an option so I can tell it to write 'M' unless stated otherwise? So 'M' unless I tell it to 'J' or 'R'?

 

Also, I have LEDS I need to turn on during each case, can I just set these to a true statement during each case? 

0 Kudos
Message 6 of 8
(3,225 Views)

[Edit: I replied before you'd made your final edit!]

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


0 Kudos
Message 7 of 8
(3,217 Views)

Ah sorry, I wasn't expecting your quickness! I'm getting myself confused.

 

 

Basically I have VISA W writing 'M' to the serial, which is great. Is there an option to be able keep the constant string 'M' unless I state it to 'J' (jump a case) or 'R' (reverse the journey)?

 

Also, I can't get the string constant 'A' (for arrived) to be read into VISA R.

 

and one last question for now, because I want to turn a LED on each case on the simulation only (the PIC handles the actual LEDs) can I just put a true statement next to the one I want on? and will this then turn off once it goes to the next case? 

0 Kudos
Message 8 of 8
(3,212 Views)