PCAN-Explorer 6: Synchronization between sensors is achieved using a single CAN bus

Professional Windows® software to communicate with CAN and CAN FD busses and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
ASMAReb
Posts: 9
Joined: Thu 4. Apr 2024, 13:37

Re: PCAN-Explorer 6: Synchronization between sensors is achieved using a single CAN bus

Post by ASMAReb » Fri 5. Apr 2024, 11:37

Hello ,
yes I changed the program but nothing happens when I run the program, the sensor continues to work at the same time

Code: Select all

call Sub 
Repeat
// First Sensor: Send request and receive
Sub:
    //Send 1 521h 1 RequestFromFirstSensor
    WaitId 0 1 521h // Wait for response from first sensor
    Wait 2000 // Wait for 2000ms before proceeding to the second sensor
    
    // Second Sensor: Send request and receive
    Send 1 522h 2 AAh
    //WaitId 2000 1 522h // Wait for response from second sensor
    Wait 2000 // Wait for 2000ms before repeating the loop
    Return 
Added code-tags for readability

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: PCAN-Explorer 6: Synchronization between sensors is achieved using a single CAN bus

Post by M.Heidemann » Fri 5. Apr 2024, 12:46

Hello,

I tested this and it works:

Code: Select all

// PCAN-Explorer Macro File
// First edited: 05.04.2024 12:30:22
FormatVersion=6.0
//Initial message

Send 1 521h 1 BBh
Call Sub


Sub:	WaitId 2 0 521h
		Wait 2000
		Send 2 522h 1 AAh


		WaitId 1 1 522h
		Wait 2000
		Send 1 521h 1 BBh
		Repeat
this Macro will run until stopped.

If you want both Bus to have a cycle time of 2000ms, remove one of the wait statements (i did comment it out):

Code: Select all

// PCAN-Explorer Macro File
// First edited: 05.04.2024 12:30:22
FormatVersion=6.0
//Initial message

Send 1 521h 1 BBh
Call Sub


Sub:	WaitId 2 0 521h
		Wait 2000
		Send 2 522h 1 AAh


		WaitId 1 1 522h
		//Wait 2000
		Send 1 521h 1 BBh
		Repeat
	
Let me know if this worked for you
---
Marvin Heidemann
PEAK-Support Team

ASMAReb
Posts: 9
Joined: Thu 4. Apr 2024, 13:37

Re: PCAN-Explorer 6: Synchronization between sensors is achieved using a single CAN bus

Post by ASMAReb » Wed 10. Apr 2024, 14:54

Hello,
I appreciate your response, but I'm not familiar with macros standard, so I encountered a problem finding a solution, which is why I will use Python (pcan-python)

Best Regards

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: PCAN-Explorer 6: Synchronization between sensors is achieved using a single CAN bus

Post by M.Heidemann » Wed 10. Apr 2024, 14:57

Hello,

Okay, Python it is then.

If you need any help regarding this, just open a up a new thread
in the PCANBasic subsection of this forum.

Best Regards

Marvin

-closed-
---
Marvin Heidemann
PEAK-Support Team

Locked