Send a CAN message via a state machine

Discuss issues and ideas you have to configuring displays with PowerVision
nunoalves
Posts: 9
Joined: Fri Aug 31, 2012 10:36 am

Send a CAN message via a state machine

Post by nunoalves » Tue Mar 01, 2016 3:43 pm

Hi,
Im porting code from Powerview 2.3 to Powerview 2.8 so it works with the PV780 screens.
I need to send a free form CAN message whenever the user presses a button. Its a pretty straight forward thing,which worked just fine on Powerview 2.3 but i cant seem to get it to work on Powerview 2.8.

See the attached screenshots.... but the process is as follows:
1) I created a free form CAN message with two variables in two bytes
2) I created a state machine that does some computation on those variables, and then sends the CAN message via an event.
3) In a menu page, I assigned a "key press" to a transition on the state machine.

This is simple stuff... But whenever I press the button, I cant seem to get the CAN message event to process (I receive no message on the CAN bus from the LCD) The LCD CAN chip is good, since I am able to read external CAN messages.

Any ideas?
Attachments
Screen Shot 2016-03-01 at 4.32.22 PM.png
Screen Shot 2016-03-01 at 4.32.22 PM.png (98.38 KiB) Viewed 228 times
Screen Shot 2016-03-01 at 4.32.00 PM.png
Screen Shot 2016-03-01 at 4.32.00 PM.png (174.96 KiB) Viewed 228 times
Screen Shot 2016-03-01 at 4.29.18 PM.png
Screen Shot 2016-03-01 at 4.29.18 PM.png (100.98 KiB) Viewed 228 times
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Send a CAN message via a state machine

Post by stalley » Wed Mar 02, 2016 11:31 am

Hello nunoalves,

The only thing I see in your configuration is that you don't have the check box for Update Device Address on outbound messages checked. Otherwise you will be trying to send a message from source address x00 and in most systems, the engine ECU uses x00.

I am sending a demo config that shows how to send a free form extended frame message from a script or a state machine.

Something that I see in your configuration is that it appears that you are clearing your message data in the exit part of your state where you transmit. The transmit needs more time before you reset the message data. If you put a timed event (25-50ms) to another state and then reset, the transmit should be completed.

Hope this gets you going. I think you are very close!
Attachments
Send J1939Message.zip
(678.12 KiB) Downloaded 30 times
Sara Talley
Software Engineer
Enovation Controls
nunoalves
Posts: 9
Joined: Fri Aug 31, 2012 10:36 am

Re: Send a CAN message via a state machine

Post by nunoalves » Wed Mar 02, 2016 3:27 pm

Thank you for your code. Unfortunately it did not work and I think I know why.
Whenever the LCD first boots up many CAN messages are being sent from the LCD. Please see attached screenshot for a sample. I do not know what they are. By pressing the send CAN message button, no CAN messages get sent. It seems the CAN buffer for sending messages has overflown.

My questions...
1) What are all these CAN messages that are being generated at boot time, and how can I prevent them from being sent?
2) Is there any API function that forces the CAN buffer to be flushed?
Attachments
Screen Shot 2016-03-02 at 12.49.33 PM.png
Screen Shot 2016-03-02 at 12.49.33 PM.png (222.72 KiB) Viewed 193 times
nunoalves
Posts: 9
Joined: Fri Aug 31, 2012 10:36 am

Re: Send a CAN message via a state machine

Post by nunoalves » Wed Mar 02, 2016 3:47 pm

I am still trying to get your code which sends CAN messages work on the LCD. It loads and runs fine on my PV780, but i simply can't get CAN messages out.

Could the issue be with an older Loader version number? Please see attachment.

Thank you for your support.
Attachments
Screen Shot 2016-03-02 at 4.45.59 PM.png
Screen Shot 2016-03-02 at 4.45.59 PM.png (16.62 KiB) Viewed 192 times
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Send a CAN message via a state machine

Post by stalley » Wed Mar 02, 2016 4:17 pm

Hey nunoalves,

Are you using a CAN sniffer to determine that the display is not transmitting or your device?

If you transmit the Engine Speed SPN 190 to the display does it show up on the display in a text gauge? Are you using the config I sent to you or your own?

If you have a way to look at the CAN traffic, can you power cycle the display and see it arbitrate for a source address? Is it the address that you need?
Sara Talley
Software Engineer
Enovation Controls
nunoalves
Posts: 9
Joined: Fri Aug 31, 2012 10:36 am

Re: Send a CAN message via a state machine

Post by nunoalves » Wed Mar 02, 2016 4:28 pm

1) I am definitely using a CAN sniffer and nothing is coming out of the LCD whenever I press the buttons. Except for the initial CAN messages that I receive at boot time.

2) Using the code you sent me, by sending the appropriate RPM PGN (0x18F00400) / Engine Speed SPN 190 with my CAN device, the LCD displays the correct RPM. For example when I set Byte3=20 and Byte4=50 of a message with the identifier 0x18F00400, I get the expected 1603RPM on the LCD. See the attached screenshot of my CAN log whenever I am sending a engine RPM message (blue).

3) "If you have a way to look at the CAN traffic, can you power cycle the display and see it arbitrate for a source address? Is it the address that you need?" Maybe this is the problem? Can I just specify an address for all messages and get rid of any arbitration?
Attachments
Screen Shot 2016-03-02 at 5.23.02 PM.png
Screen Shot 2016-03-02 at 5.23.02 PM.png (94.65 KiB) Viewed 191 times
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Send a CAN message via a state machine

Post by stalley » Wed Mar 02, 2016 5:01 pm

If you are using the config I sent you, I would expect to see an address claim message x18EEFFF2.

What source address does your device expect the xFFAA to come from?

If you can configure your device to listen to all addresses for the xFFAA then it won't matter what address the display transmits from.

In your network data capture I don't know why you would have address claims 0x18EEFFxx from the same address 0xfe multiple times. Do you know what device is claiming xFE? Who is claiming xFD?
Sara Talley
Software Engineer
Enovation Controls
nunoalves
Posts: 9
Joined: Fri Aug 31, 2012 10:36 am

Re: Send a CAN message via a state machine

Post by nunoalves » Wed Mar 02, 2016 5:37 pm

Those messages are all being sent from the LCD. There are no other devices in the bus besides my can sniffer.

Why would the lcd send all those messages at boot?
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Send a CAN message via a state machine

Post by stalley » Wed Mar 02, 2016 5:44 pm

Were you using the config I sent? It should have been claiming xF2, not xFD or xFE
Sara Talley
Software Engineer
Enovation Controls
nunoalves
Posts: 9
Joined: Fri Aug 31, 2012 10:36 am

Re: Send a CAN message via a state machine

Post by nunoalves » Wed Mar 02, 2016 6:00 pm

I am definitely using your code and i am seeing lots of messages from 0xEEFF but with different source addresses (see the first screenshot on this thread). Can u explain what those CAN messages do?