Serial Port Complete - Latest Microcontroller projects

(lily) #1
An RS-485 Network

' Uncomment one of these lines.

' delay_before_responding = 0 ' No delay before responding.
delay_before_responding = 1 ' Delay before responding

' Uncomment one of these lines:

' firmware_driver_enable = 0 ' Circuits have automatic driver-enable control.
firmware_driver_enable = 1 ' Firmware controls the driver-enable line.

if (firmware_driver_enable = 1) then

' Define the driver-enable line and disable the driver.

TRISB.3 = 0
driver_enable = 0
endif

 // Comment out this line if using automatic hardware control of the
// RS-485 driver-enable line.


#define firmware_driver_enable

// Comment out this line if the remote computer requires no extra time to disable
// its RS-485 driver before the microcontroller responds to a received command.

#define delay_before_responding

#if defined(firmware_driver_enable)
#define driver_enable PORTBbits.RB3
#endif

#define COMMAND_START 58

const byte MAX_COMMAND_LENGTH = 5;

// The microcontroller's network address:

const char MY_ADDRESS = 'h';
Free download pdf