Go to Post Stand up and cheer for yourselves and others. That is FIRST, don't change it. - Steve W [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-16-2016, 11:55 AM
ksanger's Avatar
ksanger ksanger is offline
Registered User
FRC #0211 (MaK)
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Rochester NY
Posts: 62
ksanger is on a distinguished road
Do we need to wait between CAN Bus commands?

Hi;

My question is that in 2016 do we still need to wait between sequential CAN Bus Commands? In the past if we wrote to a CANJaguar we needed to wait before issuing another command too fast. I've read that the devices are being queried and updated every 20 msec. But I have not found any information regarding a need to wait between CAN commands for the last command to finish. For instance if we read currents from the Power Distribution Panel do we need to wait between reading the first and the second channels? Would we have issues reading four channels in a row? Or do the new libraries take care of that for us?

Should we assume that a CAN command that returns a value will not continue until the value is read? And that a command that sets a value without returning a variable may take a while to actually execute? Therefor we do not need to wait after asking for a reading, but may need to wait after sending a command? Or do the libraries buffer all CAN commands?

We are programming in Java.

Thanks
  #2   Spotlight this post!  
Unread 02-17-2016, 12:31 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,112
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: Do we need to wait between CAN Bus commands?

You should probably go with the assumption that the actual CAN messages are happening constantly in the background, and your code won't need to wait. The status frames are read and cached by the communication code, so your program gets an immediate answer when it asks for a value.
  #3   Spotlight this post!  
Unread 02-17-2016, 09:36 PM
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Do we need to wait between CAN Bus commands?

In general, CAN (in general, not specific to FRC) is implemented as an isochronous network.

This means that real-time data on the network is continuously retransmitted at some interval, and only the latest frame with a given ID is needed.

With a network like this, all devices which produce data will transmit it on the bus at a regular, fixed interval, which is picked to not overload the bus but still provide data fast enough for it to be useful.

All of the new CTRE CAN products operate in this way. As status frames are received by the low-level CAN driver, they are buffered. A read call by the high level libraries simply returns the data from the last CAN frame received, it doesn't actively request it from the device. Outgoing messages are actively transmitted whenever you call the set functions, so your code determines the transmit rate of these on the bus.

The older CAN Jaguars operated much differently, they used a synchronous message passing system which required roughly 2x the CAN bandwidth (all packets had a request and response). This also required the user code to wait for the response message. In my understanding, this was done because the Jaguar had a poor CAN firmware implementation and too many messages addressed to a single Jaguar too quickly could cause a CAN buffer overrun, so the user code had to wait for an ACK from that Jaguar before sending another message to it. This is not normal for CAN design.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
  #4   Spotlight this post!  
Unread 02-18-2016, 08:24 AM
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 986
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Do we need to wait between CAN Bus commands?

Quote:
Originally Posted by apalrd View Post
The older CAN Jaguars operated much differently, they used a synchronous message passing system which required roughly 2x the CAN bandwidth (all packets had a request and response). This also required the user code to wait for the response message. In my understanding, this was done because the Jaguar had a poor CAN firmware implementation and too many messages addressed to a single Jaguar too quickly could cause a CAN buffer overrun, so the user code had to wait for an ACK from that Jaguar before sending another message to it. This is not normal for CAN design.
This describes the original Jaguar protocol.

Asynch was added to the Jag firmware even before the switch to roboRIO. During the switch last year, the WPILib portions of CANJag (for sure for C++ and Java, and I think LV too) were rewritten to make them work like the CTRE hardware from a user perspective.
  #5   Spotlight this post!  
Unread 02-19-2016, 08:32 AM
ksanger's Avatar
ksanger ksanger is offline
Registered User
FRC #0211 (MaK)
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Rochester NY
Posts: 62
ksanger is on a distinguished road
Re: Do we need to wait between CAN Bus commands?

Thanks guys; I didn't realize everything that was going on in the background. Explains how the DriverStation SW has a record of all of the reading of the PDP after an Enable/Disable session.

Thanks again.
Closed Thread


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:57 PM.

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