Go to Post Just as you and your team will make hard decisions as you struggle to build a robot, FIRST has had to make hard decisions concerning maximizing safety while making the number of rules as small as possible. - Mike Betts [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 29-01-2011, 14:47
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
PID need someone to look it over.

I have PID programed in but I'm not sure if its going to work and I cannot test it right now. What its doing is when a button is pressed (and held) it will turn one motor until it hits the setpoint then run another motor until it hits its setpoint. then stop. I don't know if it will work at all even in theory.
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.

Last edited by j.cole : 30-01-2011 at 13:51.
Reply With Quote
  #2   Spotlight this post!  
Unread 30-01-2011, 11:37
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: PID need someone to look it over.

Whoa, that's complicated. Some notations in the code might help people to understand what it's doing. I can't follow it easily, so I can't give any helpful advice.

I'm sure there's an easier way to choose among constants than using those deeply nested case blocks, though.
Reply With Quote
  #3   Spotlight this post!  
Unread 30-01-2011, 13:51
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
Re: PID need someone to look it over.

It makes me sad that you cant understand it. I annotated it to make it easier to understand. My build adviser got a laugh out of it.
Attached Files
File Type: vi Teleop.vi (43.5 KB, 29 views)
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
Reply With Quote
  #4   Spotlight this post!  
Unread 30-01-2011, 14:00
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 7,011
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: PID need someone to look it over.

If Alan can't understand it - the guy understands Klingon for goodness' sake - then it can't be good.
__________________

I am N2IRZ - What's your callsign?
Reply With Quote
  #5   Spotlight this post!  
Unread 30-01-2011, 14:20
Acarid Acarid is offline
<3 Nested Clusters
FRC #2521
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Eugene, Oregon
Posts: 10
Acarid is an unknown quantity at this point
Re: PID need someone to look it over.

I think I have a basic understanding of what it's doing, although the details are beyond me. I think the code can be cleaned up a little, if nothing else.

Near the end, you are using case structures to decide which wire to use. Take a look at this block, it might be more suited for this.
http://zone.ni.com/reference/en-XX/h.../glang/select/

Also the giant case structure in the middle... I'd be tempted to put the buttons into a boolean array, then convert that array to a number, then put that number into a single case structure which can select the constant. This was used pretty elegantly in the example line following code.

Also it seems a little messy to run the process value into the setpoint as a method of making it not move. I'm not sure I understand the goal, but perhaps removing the first case and instead making one around that PID would be better.

Hope this helps... My confidence is a little shot by Alan's reply...
Reply With Quote
  #6   Spotlight this post!  
Unread 30-01-2011, 17:54
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: PID need someone to look it over.

Using the automatic diagram cleanup tool made some of it a lot clearer. You put input and output tunnels on the same edge of the case, and it wasn't at all obvious which way the data was flowing until they were rearranged to put things in a more traditional left-to-right order.

I am confused by your use of the dt input to the PID blocks. Can you explain what you intend it to do?
Reply With Quote
  #7   Spotlight this post!  
Unread 30-01-2011, 18:38
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
Re: PID need someone to look it over.

that part may be wrong because i do not know what that input does exactly but i was hoping that it would give me an exact time value instead of the vi calculating its own runtime
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
Reply With Quote
  #8   Spotlight this post!  
Unread 30-01-2011, 21:10
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: PID need someone to look it over.

If you want a few pointers on more readable diagrams -- so that you can read your code more easily and others can too, I'll throw some out there.

When you have a choice between a case structure and the ternary assignment, also called the Select node, use the Select.

When you have a positive and negative constant that you are just selecting between, consider using one constant and multiply by either one or negative one. When you need to change the constant, you are far less likely to wind up with a partial update.

Whenever possible, combine the Booleans into a number and switch on that to minimize duplication of constants and code.

My monitor is 1920x1200 and I still need to scroll quite a bit to see your diagram. White space is cool, but if you need to scroll, limit the scrolling to one dimension. Even better, use subVIs to avoid scrolling altogether.

I can't follow the logic enough to be able to answer your question about the PID.

Greg McKaskle
Reply With Quote
  #9   Spotlight this post!  
Unread 30-01-2011, 22:15
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
Re: PID need someone to look it over.

I think my problem is not knowing what i can use to simplify things more (also i find it easier to use stacked cases than use arrays). And what are ternary assignments?
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
Reply With Quote
  #10   Spotlight this post!  
Unread 31-01-2011, 06:45
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: PID need someone to look it over.

Ternary assignment in C/C++ looks like

y= a<0.3 ? 0 : a;

which is equivalent to

if(a < 0.3)
y= 0;
else
y= a;

In LV it looks like the attached image.

Greg McKaskle
Attached Images
 
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 21:20.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi