OCCRA
Go to Post "prepare to take flight"! I see people taking off shoes and waiting in long lines. - 346CADmen [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-15-2018, 12:57 PM
xule xule is offline
Registered User
no team
 
Join Date: Mar 2008
Location: long beach
Posts: 11
xule is an unknown quantity at this point
configure encoder in can

our team is switching over to can with the talons srx, our drive system works well using master/follower. my question is how do i configure my cui encoder which is attached to my talon. I've read the manuals and perused through git hub but i'm looking for a begin example and an autonomous example. I would like to move 120" using 6" wheels. Thanks.
Attached Thumbnails
Click image for larger version

Name:	upload.png
Views:	30
Size:	233.8 KB
ID:	23423  

Last edited by xule : 05-16-2018 at 08:09 AM.
Reply With Quote
  #2   Spotlight this post!  
Unread 05-17-2018, 11:13 AM
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,164
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: configure encoder in can

The encoder config at the bottom right of your screenshot has an easily corrected error. You've used a RefNum Set function instead of a RefNum Get. Notice the direction of the arrow in the motor control (MC) icon? It's going into the refnum registry, where it needs to be coming out of it.

However, while that will correct the syntax error and let it run, it still won't work properly. The problem is that you're trying to read from the registry at the same time everything else in Begin is running, and the Left Drive Motor probably won't have had time to be opened and set yet. There's another easy fix for that, though. Instead of using a RefNum Get function to obtain the reference to the Talon, just wire the reference directly from the output of the Talon Open to the input of the Config Sensor function. Take it from the same place you're getting the wire to the Follow function.



Rule of thumb: RefNum Set functions go in Begin and nowhere else. RefNum Get functions go everywhere else and never in Begin.
Reply With Quote
  #3   Spotlight this post!  
Unread 05-17-2018, 03:11 PM
ngreen ngreen is offline
Mentor
AKA: Nelson Green
FRC #1108 (Panther Robotics)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Paola, KS
Posts: 1,039
ngreen has a reputation beyond reputengreen has a reputation beyond reputengreen has a reputation beyond reputengreen has a reputation beyond reputengreen has a reputation beyond reputengreen has a reputation beyond reputengreen has a reputation beyond reputengreen has a reputation beyond reputengreen has a reputation beyond reputengreen has a reputation beyond reputengreen has a reputation beyond repute
Re: configure encoder in can

I didn't find it worthwhile to setup the encoders for the Talon in Begin.vi. You can do it, I think connecting it directly is a better practice, like Alan mentions. But instead I prefer to setup the encoders in Periodic Task.vi, because you will want to get updated encoder readings. I write these to Robot Global Variable.vi, which allows them to easily be accessed either in TeleOp.vi or Autonomous Independent.vi.

Here is an example of that:


The math afterwards is converting (roughly) for 6" wheels from pulses to inches, but for a 4096 pulses per revolution. I'm not sure about the CUI AMT103-V, but think it might be 2048. You can see once you have code up and running.

For autonomous to go 120", you will need some code to drive for distance, by comparing your encoder value to your setpoint (120"). PID is a typical way to address this, and here is code I've used:



Just place it somewhere in your autonomous case, and you can use the error in/error out to control the sequence.

Notes: 1) The gyro code might need disabled. It is for helping drive straight by compensating with the gyro, but uses some additional code. 2) The loop speed on the first snippet is at 50 mS, which is possibly a little slow, especially when mismatched with the 5 mS speed for the PID loop. 3) You'll want to tune the PID gains.
Reply With Quote
  #4   Spotlight this post!  
Unread 05-17-2018, 07:28 PM
xule xule is offline
Registered User
no team
 
Join Date: Mar 2008
Location: long beach
Posts: 11
xule is an unknown quantity at this point
Re: configure encoder in can

Thank you
I will try it tomorrow.
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 06:00 AM.

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


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