Reading in the data to control PWM ports from labVIEW

Hi

So i have a project and at this stage, i just want to control signals from labVIEW to arduino PWM ports
I am not so good with writing the code to establish a connection to the arduino hoping someone can give me guidance on how to do this.

i am using serial communication. So far i am reading in sensor values from the sketch provided.
Now i want to send back these PWM values which i can scale from 0-255 and control RGB lights or motor speed.

Please help i am stuck

Workingfile.ino (3.53 KB)

Arduino PWM VALS.PNG

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

The technique in the 3rd example will be the most reliable.

I am not familiar with Labview but I believe it can send data in the format used in that example.

...R

Cheers for the examples.

I feel its a bit over my head trying to get it working. Its a little much for me since i am a beginner.

I tried to embed example 3 in my code and get some of it working but compile doesn't accept because the
recvWithStartEndMarkers() is not recognized.

Could you assist me in getting me started?

JACKSONSPARROW:
Could you assist me in getting me started?

I will try. But first you have to post the complete program that you are having the problem with.

...R

This is the complete program

So far i am able to recieve the data from the sensors and the LUX sensor. Its just being able to get the PWM signals from LabVIEW data back into arduino so i can write them back to the PWM ports is where i am suffering

the PNG is how the data is sent back through serial to arduino.
thanks in advance

Workingfile.ino (3.53 KB)

labviewTOarduino.PNG

JACKSONSPARROW:
This is the complete program

That is not the program that caused you to write this comment in Reply #2

I tried to embed example 3 in my code and get some of it working but compile doesn't accept because the
recvWithStartEndMarkers() is not recognized.

...R

Sorry, my bad, that was the program i am going to embed this in once i see how it works.

basically, I want to send the values from from labVIEW to my PWM ports through serial which i can control 3 LED RGB lights, and 2 motors all on PWM 11,10,9,6,5 Arduino UNO
the PNG files shows the values 0-255

labviewTOarduino.PNG

sendPWMLABVIEW.ino (1.23 KB)

I know nothing about labview except there are add ins for controlling Arduino from lab view and lots of online tutorials - any use ?

Yes those addins are useful and work. Main problem is my lecturer doesnt allow it because he says adding extra software on uni computers causes alot of problems. from my experience it does not but he has the fina; say :confused:

Just copying an example (code in reply #6) is not an attempt to implement Robin's ideas in your own code.

Im trying to understand it so i can implement it.

I have never used arduino before neither have i written much code its hard for me to understand

So.... the main focus in simply to use labview to make the arduino output a pwm signal with a level ranging between 0 and 255 inclusive, right?

That's the main point, right?

If that's all you want to do, then it shouldn't be very hard to do in labview. The only barrier is the little bit of fiddling that's generally required --- usually involving configuration/setup parameters that allows labview to communicate properly with arduino.

Southpark:
So.... the main focus in simply to use labview to make the arduino output a pwm signal with a level ranging between 0 and 255 inclusive, right?

That's the main point, right?

If that's all you want to do, then it shouldn't be very hard to do in labview. The only barrier is the little bit of fiddling that's generally required --- usually involving configuration/setup parameters that allows labview to communicate properly with arduino.

I agree. I think the main part i am really struggling with is the Arduino part. Because I have already prepared the information in LabVIEW which is sent to the serial port in a string form of (255, 161, 255, 205, 255,). It is just getting Arduino to read this information and send it to the Digital ports that i am finding extremely difficult. Im not very strong with the Arduino side of things unfortunately and been working on this issue for last 10 hours. Just hoping someone can provide me with a solution

JACKSONSPARROW:
Sorry, my bad, that was the program i am going to embed this in once i see how it works.

In Reply #2 you mentioned that you got an error when you tried something. It will be much easier to help you if you post the program that gave rise to your comment in Reply #2 because that will show me how you tried to implement my code. That is why I asked you in Reply #3 to post that program. We are now at Reply #13 without any obvious progress.

...R

Hi Robin,

That is why I asked you in Reply #3 to post that program. We are now at Reply #13 without any obvious progress.

in reply#6 i posted the program including the array of data from labview in the form it is sent through serial.

JACKSONSPARROW:
I agree. I think the main part i am really struggling with is the Arduino part.

I'll take a look at it to see if I can out. The main issue is not because the users don't know how to use Labview properly. Instead, the issue is with the lack of documentation about how to configure the VI modules that are are in the labview libraries. Eventually, when enough time is spent (or wasted) ..... it all works at the end.

This example here certainly works ..... you just have to know which communications port your arduino is using... eg. com port 5 (or whatever your arduino is assigned to by the computer)...... and you choose the PWM pin (channel) .... eg choose pwm pin (channel) '13' for arduino MEGA or maybe arduino UNO, which also happens to be the on-board arduino LED pin..... which allows us to see some LED activity.

The third setting is 'duty cycle'..... but...for this example only, the duty cycle setting seems to be expressed as a value in the range zero to one..... ie. 0 to 1. So if you want 10 percent duty cycle.... you have to type '0.1' into the box.

If you want 5 percent duty cycle..... you have to type 0.05 into the box. If you want 50 percent duty cycle..... type 0.5.

I only checked to see if this VI works on my mega 2560. It is working.

I'm using the "LINX" libraries for labview. You installed the LINX libraries right?

example pwm - Labview with LINX

That's for 1 channel. I'll later take a look at other examples -- using the other VI modules to set up multiple channels.

JACKSONSPARROW:
in reply#6 i posted the program including the array of data from labview in the form it is sent through serial.

I am finding this very confusing.

In your Original Post you included a program that did not have my recvWithStartEndMarkers(). In Reply #2 you said you had a program that gave an error when you tried to embed my code in your code. In Reply #6 you have a program that seems to be my code only, with none of yours.

I have been assuming when you said in Reply #2 that "I tried to embed example 3 in my code..." that you have a program that is a combination of the code from your Original Post and my code. And that is the program I offered to help with in Reply #3.

What part of all of this have I got wrong?

Can you reproduce the error that you mentioned in Reply #2 and then post the program that gives rise to the error?

...R

Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile: