LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to communicate or send signals from labview going to 8051 microcontroller?

Hi to all,

 

 Just want to ask, how are you going to send signals or data from your labview program going to my 8051 microcontroller board? I'm having problems communicating both. Your help will be much appreciated. thanks. 

0 Kudos
Message 1 of 24
(6,343 Views)

Hi jmvrd,

 

what exactly are you trying to do? 

But you would need some sort of Digital Input/Output device to read/write the ports.

 

PS.: Don't forget the pull ups 😉

 

Regards,

Pattos

LabVIEW Gretchin
0 Kudos
Message 2 of 24
(6,334 Views)

Or, are you trying to communicate with the microcontroller over its serial port? If so, do you have a program running on the microcontroller to listen to and respond to serial communication?

 

Please provide more details on exactly what you're trying to do, as your question is too vague.

0 Kudos
Message 3 of 24
(6,317 Views)

yah, thats what im trying to do. what il be doing, is that i have a labview program that simulates a typical an actual guitar. Its like a tutorial or a software responsible for teaching how to play a guitar with the basic chords and basic strumming patterns. Now, i cant figure out how i will transmit the data from the program going to the microcontroller since our microcontroller will be responsible for receiving signals from labview and it will transmit it to its specific motor assignment. The idea is, if i input A,B,C chords from the program, the microcon will respond to it, by lighting up a specific led in it. Here's the sample of my program so that you will have a more concise idea, on what im trying to accomplish, though its not final yet. Thanks for all the help!

 

 

Download All
0 Kudos
Message 4 of 24
(6,302 Views)

I still don't understand what kind of help you are seeking as far as the microcontroller communication. It appears that you will be communicating to it over the serial port. Do you actually have code on the microcontroller? Do you have a protocol defined? Do you have a list of commands and responses?

 

As for the code itself, I would strongly suggest rethinking the approach. You have waaaaay too many local variables, and the use of so many individual controls makes the code difficult to write and to manage. Here's a list of recommendations:

  • Do not force a user to use the Run button to run the code. You may end up creating an application out of this, and you won't have that. Your code should have an outer while loop that runs and waits for user interaction. Right now you have a "Play" button, but it's not doing anything. This button should trigger the action.
  • Use the Spreadsheet String to Array function to convert the comma-delimited list of chords to an array of strings. This will allow you to replace that inner while loop with an auto-indexed for loop.
  • Instead of having individual LEDs to try to show the strumming pattern, create a custom control and use an array. You can do this many ways, and a picture ring is a very good candidate. You would need 3 pictures: off, up lit, down lit. This will allow you to more easily create the pattern. Then you can replace that entire sequence frame over on the right with a for-loop. In the for-loop you'd basically just be writing a new array value. See attached example for an idea.
  • Similarly, instead of using individual LEDs for the chords, you could use a cluster. Since you have different horizontal gaps a 2D array wouldn't work well on the front panel, but internally you could store the data as a 2D array and you can use the Cluster to Array and Array to Cluster functions to update the front panel.
0 Kudos
Message 5 of 24
(6,283 Views)

What i want to do is that, if i type a chord, lets say A chord at the string command, the program will be able to send it to the microcontroller, then the board will be able to receive it, then eventually transmit it to necessary motors. However, for the mean time, i want to know how commands from the program will be transmitted going to our board. The attached serial2.vi in the previous post is my basic sample code on how to communicate through our microcontroller. The microcontroller has a C program embedded in it. Attached is the sample/test program, currently programmed in our 8051 board.

 

Wow! i was astouned by your program! its very nice! and i find it a bit sophisticated and confusing, since im only a beginner in this and still studying the functions of this program. Will try to digest everything you suggested and will try to embed those things to our program. Thanks for all the comments and suggestions! greatly appreciate it. Please feel free to comment more on this and on the program itself. Thanks a lot guys!

 

 

0 Kudos
Message 6 of 24
(6,267 Views)

Since it appears that you have a serial port interface running on the microcontroller, then all you need to do is to send the specified characters over the serial port. Based on the c code that you uploaded it appears the commands are simply single characters. It does not appear that the device sends anything back, so you wold have nothing to read from the serial port. Thus, you don't even need to use a subVI. You can have the serial port initialization at the start of the program and just use a VISA Write whenever you "play" the new chord. I don't think you really need to get too hung up on this aspect of it since it's relatively easy to include a VISA Write whenever you "play" the new chord. Thus, I would suggest concentrating on simplifying your program so it's easier to manage.

 


Wow! i was astouned by your program! its very nice! and i find it a bit sophisticated and confusing, since im only a beginner in this and still studying the functions of this program.

Sometimes you need to think outside the box. I'd guess that you have a background in text-based programming. The example VI I wrote is fairly simple. The 2D array on the block diagram simply pre-defines the strumming patterns. The rows are the individual patterns, and the columns are the picture states you want to show (0 = nothing lit, 1 = up is lit, 2 = down is lit). The row (strumming pattern) is indexed out based on the front panel control. Then we just need to go into a loop that walks through the pattern. An array of all "off" pictures is initially created and then in the loop we just replace the next element in the sequence based on the pattern that was selected. 

 

0 Kudos
Message 7 of 24
(6,257 Views)

Actually, we need to device a feedback system for us to be sure that the board receives the necessary data we're sending, so i think we would still need the VISA read command, however, we'll just do it after we figured out the VISA write properly. As much as i dont want to get too hung up here, i need to figure this out first, then the revision of the program will follow, after i successful send a data to our board, then i can concentrate on revising our program.

 

Yah, i have a little background in C, and still studying labview. Thanks for all the help and the explanation. will upload another VI of our program with your suggested structure. Btw, let me ask, in my program is it more advisable to use a stacked sequence rather than using a flat sequence? im planning to change all my flat sequence to a stacked sequence so that it will be easier for us to manage the said program. thanks again! 

0 Kudos
Message 8 of 24
(6,243 Views)

NO!  DON'T DO IT!   A flat sequence is almost always better than a stacked sequence.  What makes you think a stacked sequence would be easier for managing the program?

 

Pros for flat sequence:

  1. You can see all the code, nothing is hidden.
  2. Don't have to deal with sequence locals to pass data from one frame to the next.  (Hmm, that data used in frame 7, did it come from frame 1 or frame 6???)
  3. Won't need to have any wires running backwards to get to or from sequence locals.  This allows the wires to maintain a left to right dataflow for easier readability.
  4. Data can arrive later in the sequence structure if it isn't required until a later frame.  This allows some code to operate in parallel if desired.
  5. Data can leave earlier from the sequence structure if it isn't required in a later frame.  Again, this allows some code to operate in parallel if desired.

 

Only advantage to stacked sequence:

  1. It takes up less screen real estate.
Message Edited by Ravens Fan on 12-06-2009 12:20 AM
0 Kudos
Message 9 of 24
(6,239 Views)
a ok ok. i thought, it has almost the same function and convenience as the flat sequence. coz a flat sequence takes up a lot of space from my screen and its harder for me to see my program and for others to understand the program flow because it takes up lots of space. ok then, thanks for the comment! 
0 Kudos
Message 10 of 24
(6,236 Views)