05-18-2016 04:10 PM
I think my loop is running at 0.1 seconds.
05-18-2016 04:15 PM
Probing the value coming out of the subtraction after the feedback node will tell you the exact loop time. You can even plop down a waveform chart like I did to see how the value changes over time.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
05-18-2016 04:17 PM
The probe said it was alternating between 0,1, and 2, not neccesarily in that order.
05-18-2016 04:22 PM
Attahced is a screenshot of the probe. Number 11 was alternating between like 1000, 500 and Inf.
05-18-2016 04:48 PM - edited 05-18-2016 04:50 PM
Then that makes total sense and is exactly what RavensFan described. Your loop is running at 0ms, 1ms, or 2ms. Notice how your probe has E-3 that means 1 * 10^-3. 99% of the time you get 0 messages in 1ms which is dividing by 0 which is where INF comes from. Some times you get 1 message in 1ms. If you get one message in 1ms then you are getting 1000 messages in one second. You are going to need more logic to track the number of messages, over a longer period of time, or slow down your loop rate, which I'm guessing you don't want to do because it is used in a messenging scheme. Maybe this would be a good place for an action engine, or functional global which can add new messages as it sees them.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
05-18-2016 04:51 PM - edited 05-18-2016 04:52 PM
Ok, all this logic is in a case structure. Can you change the time for a case structure?
And I've never done anything with an action engine?
Thanks,
SM
05-18-2016 09:30 PM
See Ben's Action Engine Nugget
05-19-2016 10:18 AM
Here is an example using the other technique I mentioned. Basically we keep track of how many As we see as we go along, and then once a second we reset the number back to 0. There are still a couple of flaws with this design. In my case I'm just looking for A which is a single character. You might be looking for a series of characters, and if your message comes in, but cuts the message into two pieces, then this code detecting the start of the message might not be all there at once. More logic could be written fix this but it probably isn't an issue for a small message like "10". The action engine approach is a good one if you have time to learn about it.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
05-23-2016 08:39 AM
So yes I am in a time crunch and really don't have time to learn about the action engine stuff, although I certainly will read through it when I have the time.
Hooovahh, what would I need to change in the code you just posted to be able to check for a space at the beginning of the string. I can just have the robot send the strings with a space at the beginning so it'll be easier to detect an incoming string.
Thanks,
SM
05-23-2016 08:46 AM
Well does the string start with a return character and then a space? If so then that is what you would search for instead of "A". You can just use a space instead of A but then you'll find all spaces, and since I don't know the typical strings you will see I can't say for sure if that would find other spaces that aren't the start of your message.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord