LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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


jmvrd wrote:

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


OK, if you need to do that first that's fine. However, that means updating the microC code since that code sends no responses. To make life easy you should configure the responses from the microC so they end with a carriage return character or a linefeed. This will allow you to configure the serial port in LabVIEW to terminate reads once it sees that character. This will simplify the LabVIEW code. You may want to do the same thing for the commands to the microC if they end up being more than single characters as they are now.

 

If you take a look at the "Advanced Serial Write and Read" example that ships with LabVIEW you will see a general idea of how you can configure the writes and reads to end with terminations. In your case you are probably not going to need to set the buffer size or the XON/XOFF. The loop that's in there would be your program's main loop. Notice how the serial port initialization occurs outside the loop so you're not always initializing the port. There are inner case structures driven by the existence of an error which are really unnecessary and can be eliminated. 

0 Kudos
Message 11 of 24
(1,904 Views)
let me ask you again regarding the sequence, when it is more advantageous to use the stacked sequence compare to a flat sequence? in my case, with the program that i have, is it still more advisable to stick to flat sequence rather than shifting to flat sequence? thanks
0 Kudos
Message 12 of 24
(1,894 Views)
ok ok..will try to look at it and study it further. so far ive just focused on the basic read and write sample on labview and didnt think i will be able to use the advance serial sample their since i find it complicated and cannot understand the block diagram at all. anyway, thanks again for the help!
0 Kudos
Message 13 of 24
(1,890 Views)

jmvrd wrote:
let me ask you again regarding the sequence, when it is more advantageous to use the stacked sequence compare to a flat sequence? in my case, with the program that i have, is it still more advisable to stick to flat sequence rather than shifting to flat sequence? thanks

You're actually asking the wrong question. Sequence frames in LabVIEW are used to enforce execution order, so they should be looked at from the perspective of which is the best method for enforcing execution order, rather than which one is better for your program. You need to use sequence frames when you cannot use a wire to enforce execution order. Remember that LabVIEW is a dataflow language, which means a function or VI will not execute until all data on all its wired inputs is present, and that data must be generated from somewhere, whether it's a control, a constant, or a VI (including global variables). Thus, wires can be used to enforce execution order instead of sequence frames, and are the preferred method for doing so.

 


ok ok..will try to look at it and study it further. so far ive just focused on the basic read and write sample on labview and didnt think i will be able to use the advance serial sample their since i find it complicated and cannot understand the block diagram at all. anyway, thanks again for the help!

Well if the Basic Serial Write and Read was clear, then the Advanced one isn't that much different. The only additional things it does is:

  • Configure VISA to automatically append a specific character on the strings you send out with VISA Write. With some devices you need to end a command with a specific character so it knows that it has received the end of the command string. If you stick with single-character commands then you do not need this. Otherwise, your device needs to know when it has seen the end of the command.
  • Set XON/XOFF: This, again, is device-specific. The example is there to show you how to do it if your device requires it.
  • Loop around the write and read - this is really trivial. All it does is sit there so you can continuously send commands and receive responses, like you do in HyperTerminal.


Just out of curiosity: you said that your microcontroller will be controlling some LEDs and some motors. Is there a reason you're using a microcontroller as opposed to a simple USB DAQ device?

 

0 Kudos
Message 14 of 24
(1,882 Views)
Im not familiar with the NI DAQ device. And i just recently knew about it. The reason where using a 8051 microcontroller is that, we already made that board as part of our project a year ago, also it was advised by our adviser and my groupmates are more familiar with this board since we used to study the functions and done some experiments regarding this board. 
0 Kudos
Message 15 of 24
(1,875 Views)
Btw, does anyone knows how to create a program that will make a specific pin (DTR) in 8051 microcontroller board always in active hi, so that the board will always be in run mode? coz my current problem is that, when i run labview and my board is connected to it, its always in loader mode and never go to run mode, which is the one i need for my program to work. thanks again.
0 Kudos
Message 16 of 24
(1,857 Views)

If you are referring to the DTR pin of a serial port you can set this using VISA Property nodes. See the "Troubleshooting Serial Line Monitor" example that ships with LabVIEW.

 

If you are referring to some other line then you need some hardware to set the line high.

0 Kudos
Message 17 of 24
(1,854 Views)
aahh..ok ok..if i set the said pin in serial port..does that mean it will be carried over to the specific DTR pin of my microcontroller? so there's no need to actually create a program to do it? thanks again.
0 Kudos
Message 18 of 24
(1,848 Views)

jmvrd wrote:
aahh..ok ok..if i set the said pin in serial port..does that mean it will be carried over to the specific DTR pin of my microcontroller? so there's no need to actually create a program to do it? thanks again.

Only if you have a physical wire connecting the pin on the computer to the pin on the microcontroller.

 

Sometimes you really do need physical wires.  Smiley Very Happy

0 Kudos
Message 19 of 24
(1,838 Views)

Hi,

 

I already successfully communicated with our 8051 board and i was able to send data from labview to our micro. Thanks for all the help! Greatly aprreciate it.

 

Btw, how can i change the picture(array) set at the strumming VI? im planning to change and modify the said pictures (the one with arrows, and arrows lighted up and down). thanks again.  

0 Kudos
Message 20 of 24
(1,800 Views)