LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Joystick Read + Serial Write to Arduino with LabVIEW

I simply just wanted you test the functionality of your LEDs. I think your best bet is to do what you have mentioned: Set the Digital outputs controlling the LED's to false when you don't need them on.

 

Jason L

Product Support Engineer
National Instruments
0 Kudos
Message 11 of 36
(1,456 Views)

I simplified the LED part to test their functionality. Currently the basic four NSEW work fine but that is because I introducted a trigger; when the trigger is pressed only W & E are possible while without the trigger it is only N & S. The reason for this is that otherwise the numbers overlap; 256 for say N plus 512 for S = 768 for which I do not have a switch case because they are reading the x & y and sending them added to eachother. My solution works for now and these combinations may help with regard to directions like NW but the trigger will  harm me in those cases because it will bring me back to single directions.

 

Can anyone recommend a way around this? I have an issue with directional combinations when I want to represent NSEW but need them for NW, NE etc. and the trigger alone cannot fix this.

 

Any advice is greatly appreciated,

Yusif

0 Kudos
Message 12 of 36
(1,451 Views)

Yusif,

 

I guess for clarification, what exactly are you sending the LED's for W & E (in terms of bits). Before I thought you said you were able to implement your code such that with the trigger you can get NW,NE,SW,SE, and withouth you were able to get NWSE.

 

Jason

Product Support Engineer
National Instruments
0 Kudos
Message 13 of 36
(1,435 Views)

I've rewritten the directional signal parameters so I don't know if the answer to the bit question will still be relevant. Thankfully I can now activate all directional LEDs without needing a trigger (still might use one) albeit I need to play around with the ranges since I am not in love with the device's sensitivity.

 

I was hoping to flush out the suggestion to but false constants for the other LEDs in each directional case (for the W1 LED True, the E1, S1, N1, etc would be False). I tried this within the case statement and the vi simply created duplicated of my LEDs instead of referencing the ones I already had in other case statements. Is there another way to approach this? Possibly placing them outside of the case structure with only constants inside?

 

Thanks,

Yusif

0 Kudos
Message 14 of 36
(1,423 Views)

Hey Akello,

I have looked through your code and the past few discussions. And before we get into how to deal with a trigger, I might suggest an easier programming route. I can say that although your joystick is being output in x & y, a conversion to polar might make life easier. You have positioned your LED's in such a way that polar coordinates would be more intuitive. Setting a range for the radius and the angle range would nicely map to each LED evenly. Doing that in X & Y clearly is causing a headache because technically there are 8 by 8 unique squares defined by your X & Y cut-offs.

 

All you need to do is use the following equations 

R=Sqrt(x2+y2); 3 radius ranges
Theta=ArcTan(Y/X); 8 angles ranges

 

No trigger required!

 

Give that a go and let me know if there are still problems with sensitivity.

 

Also, yes, move the LED's out of the case structure. When you connect all the LED's via a wires to the right edge of the case structure, then you technically only need to wire a single true constants to the LED corresponding to the specific case because false is the default value when nothing is specified.

 

 

 

Ben D.
Applications Engineer
National Instruments
0 Kudos
Message 15 of 36
(1,409 Views)

Not that it matters, but you actually defined portions of a 7 x 7 grid, not 8x8 as I had mentioned in the previous post. Sorry! Polar is still your best option.

Ben D.
Applications Engineer
National Instruments
0 Kudos
Message 16 of 36
(1,405 Views)

I'm trying to implement the radius/angle method but the angles will be the same for two of the hemispheres...is there an easier way to do this without adding a condition that divides them into two?

0 Kudos
Message 17 of 36
(1,385 Views)

For that matter won't the N touch the 45 degree line thus overlapping with the main path of the NE/NW?

 

I might not be getting something about your suggestion but it seems like there would be more overlap...

0 Kudos
Message 18 of 36
(1,384 Views)

I see the hemisphere overlap, sorry about that. You would still need to give it an additional input like the sign of x or something.

 

What do you mean by N touch the 45 degree?

 

Additionally, the arc tan of anything where x is zero would be an error. You would have to treat that line as a special case.

 

I can see this as also being a complicated solution. However, it's the best way in my opinion to give inuitive spacing to each LED's trigger region.

Ben D.
Applications Engineer
National Instruments
0 Kudos
Message 19 of 36
(1,371 Views)

Ben,

 

I think I got a little mixed up with the angles initially so let me withdraw my previous concern. I plotted it all out on a peice of paper and it looks like it should work very well indeed so I will be moving forward with it this weekend. So far I made one (NE1) LED light up and used a simple X, Y comparison with 1 to specify the sector which is pretty much what you suggested. I will post an update once I have the whole thing wired.

 

Also, I had the idea of making a hybrid; two paths for strictly N-S and E-W based on zones and radii in between them for NE, NW, etc. I want to make a strict radius version like you suggested first, however, and will make the hybrid if there are still any kinks.

 

Thanks for the help,

Yusif 

0 Kudos
Message 20 of 36
(1,364 Views)