LabVIEW has serial VIs that communicate to the serial port on a PC. These serial VIs can be used to communicate with a 2-wire device using a DS3900 that accepts data and commands from the serial port and converts the information to 2-wire protocol. Serial Port Interfacing with LabVIEW. Details Cable Connectors Hardware Specification 1. Pin Identification 2. Communications Specifications LabVIEW Interfacing. Cable Connectors DB-9 Connector. Using a straight through serial cable. Typically, PC's are defined as a DTE and peripherals are defined as DCE.
I have a problem of synchronization between data sent from LabView interface to Arduino.This is my code. I am using a SHT31 sensor to send temperature and humidity from Arduino to LabView after receiving a character specified. This part doesn't work correctly.I am using also a heating resistors activated by a random number in the LabView interface
Can anyone help me in putting interrupts in every event? Hadoop winutils.exe download.
Edgar Bonetclosed as unclear what you're asking by Code Gorilla, gre_gor, jfpoilpret, Greenonline, Enric BlancoJun 28 '17 at 10:23
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1 Answer
I tried to make sense of your code, but I didn't quite understandeverything, for two reasons:
your question is not very clear, as you don't completely specify whatyou want your program to do
the code itself is not always clear about what it's doing: somevariable should have better names and some more comments are needed tomake things clear.
These are also the most likely reasons you got a closing vote.
Despite this limited understanding, I tried to clean up the program.Here are the improvements I suggest:
The first thing to do is get rid of the timer. You are trying to readthe serial port both from a timer event and from
serialEvent()
,which makes little sense. You should also remove all unusedfunctions, variables and #includes, they only make your programharder to read.Your
getDecimal()
function is a very misguided attempt to format anumber. If you callgetDecimal(23.008)
you get 8 (or maybe 7,depending on rounding), and you print it as23.8
. The simplest wayto get what you want is to letSerial.println()
do the formatting.You can pass a second argument to specify how many decimal places youwant.Guitar search by serial number. There is a bug in your usage of
stringVal1
andstringVal2
: youare always adding data to them, which will inevitably exhaust youravailable memory.You always store a single character in your
caract
string,therefore this string can never be'HU'
. The easiest fix is to usesingle-character commands (e.g. “H” for humidity), then you don'tneed a String and you remove the risk of running into memory issues.You should process input characters only as you read them. Readingthem in
serialEvent()
and processing them inloop()
will get youout of sync, so do both in the same function.Note that
Serial.read()
returns anint
, which is-1
if there isno data available. Thus, if you are going to compare to specificvalues, you don't need to test forSerial.available()
.If you set your heater index to a random number between 0 and 2, thenyou can use it as an index into an array of pins.
Apr 11, 2004 Heckler Koch Date of Manufacturer Date Codes. If you own a Heckler Koch product, you may be wondering what those numbers and letters stamped on the receiver mean. Well, the two letter code refers to the year the weapon was made. HK CODE LEGEND. Heckler & koch pistols.
And here is a version of your program implementing all of the above:
Note that EXTRA_PINS
is a very poorly named constant. You should findbetter constant names, but I couldn't figure out what you wanted to dowith those pins.