LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arduino hex communication over serial


@letmetry wrote:

@Knight Of NI

 

Hi,

 

yes I have watched this but I cant find a way to apply it to my problem

 

Thanks

 


Then we need a better description of your exact problem and your actual LabVIEW code (not a picture) so we can debug it.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 11 of 18
(645 Views)

Attached is an example of what I am trying to do. However I have changed from reading a big load of strings to just sending one hex string depending on the various states 

0 Kudos
Message 12 of 18
(641 Views)

I did some cleaning up of your VI.  The main changes are the following:

1. Replace the VISA Open with VISA Configure Serial Port.  This makes sure we have the right baud rate and other settings.

 

2. According to the code you posted earlier, the Arduino will only send a status when it receives a command.  Therefore, do the read after your write.

 

I also redid the decoding of the status based on what you posted earlier.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 13 of 18
(626 Views)

@letmetry wrote:

Attached is an example of what I am trying to do. However I have changed from reading a big load of strings to just sending one hex string depending on the various states 


Go back and rewatch that video... Especially the first section about receiving ASCII data with a termination character.

 

At first glance I see a couple things here

  1. There's no Configure Serial Port 
    1. Use Configure Port instead of VISA Open
      1. Set it to use a Termination Character 
      2. CR+LF is an EOL character so you can use either 10 or 13 as your Term Char
  2. You need to send your a or b THEN wait for a reply
  3. I don't understand what the Boolean logic and feedback nodes are doing. 
    1. It looks rather "Rube Goldberg"
    2. What are you trying to do there?
========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 14 of 18
(620 Views)

The example I attached is my attempt LOL!

So the logic latch is to keep the status of each led on once the relay locks.

This prevents the need for the arduino to continually sending data as lab view was getting slow in that situation.

the command send "relay1on" the led would flash and that was it so I implemented a latch system,

 

Probably not the best idea for sure. 

0 Kudos
Message 15 of 18
(612 Views)

Just to add to the discussion, it is not necessary to use hex format for sending just a single byte. You have 6 relays, which can fit into a single byte. So you can send just a single byte as the response (you don't even need a termination character since you know you are reading exactly 1 byte).

 

    byte status = 0b00111111;

    Serial.write(status);

 

 

The labview code will look like this then:

Read 1 byte.png

0 Kudos
Message 16 of 18
(605 Views)

@crossrulz

 

Thank you for this woah!

Amazing how I can ask a question and somebody can decipher what im trying to say and then give a solid answer, well done.

 

I am going to go over this for a bit and will get back to you when I have a better understanding of what's going on.

 

As for now it is working much better 🙂

 

Thank you !  

0 Kudos
Message 17 of 18
(591 Views)

@crossrulz

 

Thanks for the help everything works very well and now I can use your example as a foundation to  build better Labview.

Is there any good places to search so I can get a better understanding of how the example you have made works ?

 

Regards,

0 Kudos
Message 18 of 18
(525 Views)